frontends/va: Switch to graphics context when creating protected surface

Reviewed-by: David (Ming Qiang) Wu <David.Wu3@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33136>
This commit is contained in:
David Rosca
2025-01-23 09:34:09 +01:00
committed by Marge Bot
parent 62919ef9d0
commit fcec81363e
3 changed files with 28 additions and 0 deletions
+2
View File
@@ -584,6 +584,8 @@ vlVaTerminate(VADriverContextP ctx)
drv = ctx->pDriverData;
vl_compositor_cleanup_state(&drv->cstate);
vl_compositor_cleanup(&drv->compositor);
if (drv->pipe2)
drv->pipe2->destroy(drv->pipe2);
drv->pipe->destroy(drv->pipe);
drv->vscreen->destroy(drv->vscreen);
handle_table_destroy(drv->htab);
+25
View File
@@ -1022,6 +1022,28 @@ vlVaSurfaceFlush(vlVaDriver *drv, vlVaSurface *surf)
drv->has_external_handles ? 0 : PIPE_FLUSH_ASYNC);
}
static void
vlVaSwitchToProtectedContext(vlVaDriver *drv)
{
if (drv->pipe2)
return;
/* For now the context only needs to have graphics */
struct pipe_context *ctx = pipe_create_multimedia_context(drv->pipe->screen, false);
if (!ctx)
return;
drv->pipe2 = drv->pipe;
drv->pipe = ctx;
if (drv->cstate.pipe) {
vl_compositor_cleanup_state(&drv->cstate);
vl_compositor_cleanup(&drv->compositor);
vl_compositor_init(&drv->compositor, drv->pipe, false);
vl_compositor_init_state(&drv->cstate, drv->pipe);
}
}
static int
rt_format_to_fourcc(uint32_t format)
{
@@ -1102,6 +1124,9 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
protected = format & VA_RT_FORMAT_PROTECTED;
format &= ~VA_RT_FORMAT_PROTECTED;
if (protected)
vlVaSwitchToProtectedContext(drv);
expected_fourcc = rt_format_to_fourcc(format);
if (!expected_fourcc)
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
+1
View File
@@ -346,6 +346,7 @@ ProfileToPipe(VAProfile profile)
typedef struct {
struct vl_screen *vscreen;
struct pipe_context *pipe;
struct pipe_context *pipe2;
struct handle_table *htab;
struct vl_compositor compositor;
struct vl_compositor_state cstate;