radv/video: Align each layer of encode DPB to 256

VCN requires the luma/chroma VAs to be 256 aligned. On VCN5, the
collocated buffer was not 256 aligned which can cause these VAs to be
unaligned.

This fixes VVL PositiveVideoEncodeH264.Basic on VCN5.

Fixes: 37e71a5cb2 ("radv/video: add support for AV1 encoding")
Reviewed-by: David Rosca <david.rosca@amd.com>
(cherry picked from commit 8848495875)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38803>
This commit is contained in:
Benjamin Cheng 2025-11-12 13:49:57 -05:00 committed by Dylan Baker
parent 7e61052f7b
commit 4bd93089a7
2 changed files with 11 additions and 7 deletions

View file

@ -1094,7 +1094,7 @@
"description": "radv/video: Align each layer of encode DPB to 256",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "37e71a5cb24cd6053603ca64b67352e0c8e2fce8",
"notes": null

View file

@ -1543,6 +1543,7 @@ radv_enc_ctx2(struct radv_cmd_buffer *cmd_buffer, const VkVideoEncodeInfoKHR *in
metadata_size += RENCODE_AV1_FRAME_CONTEXT_CDF_TABLE_SIZE;
metadata_size += RENCODE_AV1_CDEF_ALGORITHM_FRAME_CONTEXT_SIZE;
}
metadata_size = align(metadata_size, ENC_ALIGNMENT);
uint32_t dpb_array_idx = res->baseArrayLayer + dpb_iv->vk.base_array_layer;
uint64_t luma_va = dpb_img->bindings[0].addr + dpb_array_idx * (luma_size + chroma_size + metadata_size);
@ -3401,17 +3402,20 @@ radv_video_get_enc_dpb_image(struct radv_device *device, const struct VkVideoPro
}
for (unsigned i = 0; i < num_reconstructed_pictures; i++) {
image->size += luma_size;
image->size += chroma_size;
unsigned metadata_size = 0;
if (is_av1) {
image->size += RENCODE_AV1_FRAME_CONTEXT_CDF_TABLE_SIZE;
image->size += RENCODE_AV1_CDEF_ALGORITHM_FRAME_CONTEXT_SIZE;
metadata_size += RENCODE_AV1_FRAME_CONTEXT_CDF_TABLE_SIZE;
metadata_size += RENCODE_AV1_CDEF_ALGORITHM_FRAME_CONTEXT_SIZE;
}
if (pdev->enc_hw_ver >= RADV_VIDEO_ENC_HW_5) {
image->size += RENCODE_MAX_METADATA_BUFFER_SIZE_PER_FRAME;
metadata_size += RENCODE_MAX_METADATA_BUFFER_SIZE_PER_FRAME;
if (has_h264_b_support)
image->size += colloc_bytes;
metadata_size += colloc_bytes;
}
image->size += luma_size;
image->size += chroma_size;
image->size += align(metadata_size, ENC_ALIGNMENT);
}
image->alignment = ENC_ALIGNMENT;
}