From feba91d39053532135fcb115e89ef00530b3e7d3 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 2 Jul 2024 14:46:42 +0200 Subject: [PATCH] frontends/va: Rename slice_idx to have_slice_params and move to context Add explanation what it does. Reviewed-by: Ruijing Dong Reviewed-by: Boyuan Zhang Part-of: --- src/gallium/frontends/va/picture.c | 8 +++++--- src/gallium/frontends/va/va_private.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gallium/frontends/va/picture.c b/src/gallium/frontends/va/picture.c index c3b7c6731a5..a67a49b3527 100644 --- a/src/gallium/frontends/va/picture.c +++ b/src/gallium/frontends/va/picture.c @@ -137,6 +137,7 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende context->needs_begin_frame = true; context->slice_data_offset = 0; + context->have_slice_params = false; mtx_unlock(&drv->mutex); return VA_STATUS_SUCCESS; @@ -973,7 +974,6 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff VAStatus vaStatus = VA_STATUS_SUCCESS; unsigned i; - unsigned slice_idx = 0; vlVaBuffer *seq_param_buf = NULL; if (!ctx) @@ -1024,12 +1024,14 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff case VASliceParameterBufferType: handleSliceParameterBuffer(context, buf); - slice_idx += buf->num_elements; + context->have_slice_params = true; break; case VASliceDataBufferType: vaStatus = handleVASliceDataBufferType(context, buf); - if (slice_idx) + /* Workaround for apps sending single slice data buffer followed + * by multiple slice parameter buffers. */ + if (context->have_slice_params) context->slice_data_offset += buf->size; break; diff --git a/src/gallium/frontends/va/va_private.h b/src/gallium/frontends/va/va_private.h index 44ca21cc085..ffb9d6f8fc1 100644 --- a/src/gallium/frontends/va/va_private.h +++ b/src/gallium/frontends/va/va_private.h @@ -387,6 +387,7 @@ typedef struct { bool packed_header_emulation_bytes; struct set *surfaces; unsigned slice_data_offset; + bool have_slice_params; struct { void **buffers;