From 0df7e80179bf7f7785af12b3953895f99fe1ebf1 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Thu, 24 Oct 2024 15:46:33 +0200 Subject: [PATCH] frontends/va: Stop reallocating buffers for protected playback Instead set the protected flag on allocation and return error when the protected state of surface doesn't match context. Reviewed-by: Leo Liu Part-of: --- src/gallium/frontends/va/picture.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/gallium/frontends/va/picture.c b/src/gallium/frontends/va/picture.c index 477e8a911d0..f3eed05e82d 100644 --- a/src/gallium/frontends/va/picture.c +++ b/src/gallium/frontends/va/picture.c @@ -1168,6 +1168,8 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) apply_av1_fg = vlVaQueryApplyFilmGrainAV1(context, &output_id, &out_target); surf = handle_table_get(drv->htab, output_id); + if (surf && !surf->buffer && context->desc.base.protected_playback) + surf->templat.bind |= PIPE_BIND_PROTECTED; vlVaGetSurfaceBuffer(drv, surf); if (!surf || !surf->buffer) { mtx_unlock(&drv->mutex); @@ -1219,12 +1221,8 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) } if ((bool)(surf->templat.bind & PIPE_BIND_PROTECTED) != context->desc.base.protected_playback) { - if (context->desc.base.protected_playback) { - surf->templat.bind |= PIPE_BIND_PROTECTED; - } - else - surf->templat.bind &= ~PIPE_BIND_PROTECTED; - realloc = true; + mtx_unlock(&drv->mutex); + return VA_STATUS_ERROR_INVALID_SURFACE; } if (realloc) {