From 7876a2f68532a2bc5ab044cab726eae7fba328fa Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Fri, 1 Sep 2023 18:26:43 -0400 Subject: [PATCH] radeonsi/vcn: fix the incorrect dt_size Issue: For texture with multiple planes, the planes will point to the same BO with the total size, so current vcn dt_size is incorrect. (gdb) p/x *((struct si_resource *)(((struct vl_video_buffer *)out_surf)->resources[0])) ... buf = 0x5555558daa30, gpu_address = 0xffff800101000000, bo_size = 0xa2000, ... } (gdb) p/x *((struct si_resource *)(((struct vl_video_buffer *)out_surf)->resources[1])) ... buf = 0x5555558daa30, gpu_address = 0xffff800101000000, bo_size = 0xa2000, ... } This is because: in function static struct si_texture *si_texture_create_object(), if (plane0) { /* The buffer is shared with the first plane. */ resource->bo_size = plane0->buffer.bo_size; ... radeon_bo_reference(sscreen->ws, &resource->buf, plane0->buffer.buf); resource->gpu_address = plane0->buffer.gpu_address; } Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9728 Cc: mesa-stable Signed-off-by: Leo Liu Reviewed-by: Ruijing Dong Part-of: --- src/gallium/drivers/radeonsi/radeon_vcn_dec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/radeonsi/radeon_vcn_dec.c b/src/gallium/drivers/radeonsi/radeon_vcn_dec.c index 5c14f394ab0..5612cccf360 100644 --- a/src/gallium/drivers/radeonsi/radeon_vcn_dec.c +++ b/src/gallium/drivers/radeonsi/radeon_vcn_dec.c @@ -2130,8 +2130,13 @@ static struct pb_buffer *rvcn_dec_message_decode(struct radeon_decoder *dec, chroma = (struct si_texture *)((struct vl_video_buffer *)out_surf)->resources[1]; decode->dpb_size = (dec->dpb_type != DPB_DYNAMIC_TIER_2) ? dec->dpb.res->buf->size : 0; - decode->dt_size = si_resource(((struct vl_video_buffer *)out_surf)->resources[0])->buf->size + - si_resource(((struct vl_video_buffer *)out_surf)->resources[1])->buf->size; + + /* When texture being created, the bo will be created with total size of planes, + * and all planes point to the same buffer */ + assert(si_resource(((struct vl_video_buffer *)out_surf)->resources[0])->buf->size == + si_resource(((struct vl_video_buffer *)out_surf)->resources[1])->buf->size); + + decode->dt_size = si_resource(((struct vl_video_buffer *)out_surf)->resources[0])->buf->size; decode->sct_size = 0; decode->sc_coeff_size = 0;