From 18f0807408425da11cb1d8cd1d73de369317440d Mon Sep 17 00:00:00 2001 From: David Rosca Date: Thu, 23 Jan 2025 09:42:03 +0100 Subject: [PATCH] radeonsi/video: Fix creating video buffers with AMD_DEBUG=tmz Reviewed-by: David (Ming Qiang) Wu Part-of: --- src/gallium/drivers/radeonsi/si_uvd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_uvd.c b/src/gallium/drivers/radeonsi/si_uvd.c index b2eb323403d..0c4f10ad919 100644 --- a/src/gallium/drivers/radeonsi/si_uvd.c +++ b/src/gallium/drivers/radeonsi/si_uvd.c @@ -23,6 +23,7 @@ struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe, const struct pipe_video_buffer *tmpl) { + struct si_context *ctx = (struct si_context *)pipe; struct pipe_video_buffer vidbuf = *tmpl; uint64_t *modifiers = NULL; int modifiers_count = 0; @@ -31,6 +32,14 @@ struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe, if (tmpl->bind & (PIPE_BIND_VIDEO_DECODE_DPB | PIPE_BIND_VIDEO_ENCODE_DPB)) return vl_video_buffer_create_as_resource(pipe, &vidbuf, NULL, 0); + /* Ensure resource_get_handle doesn't need to reallocate the texture + * which would fail with compute-only context. + * This is only needed with AMD_DEBUG=tmz because in this case the frontend + * is not aware of the buffer being created as protected. + */ + if (ctx->screen->debug_flags & DBG(TMZ) && !(vidbuf.bind & PIPE_BIND_PROTECTED)) + vidbuf.bind |= PIPE_BIND_SHARED; + /* To get tiled buffers, users need to explicitly provide a list of * modifiers. */ vidbuf.bind |= PIPE_BIND_LINEAR;