diff --git a/src/gallium/frontends/va/context.c b/src/gallium/frontends/va/context.c index 15cb2b70ae1..5c18019346c 100644 --- a/src/gallium/frontends/va/context.c +++ b/src/gallium/frontends/va/context.c @@ -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); diff --git a/src/gallium/frontends/va/surface.c b/src/gallium/frontends/va/surface.c index a5220049452..a56696e67bf 100644 --- a/src/gallium/frontends/va/surface.c +++ b/src/gallium/frontends/va/surface.c @@ -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; diff --git a/src/gallium/frontends/va/va_private.h b/src/gallium/frontends/va/va_private.h index b32b6c9177d..640af03747d 100644 --- a/src/gallium/frontends/va/va_private.h +++ b/src/gallium/frontends/va/va_private.h @@ -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;