From ac2fd8ae6609f50db8acbcfb8562bc23f93f2e92 Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Mon, 30 Sep 2024 15:24:34 +0900 Subject: [PATCH] anv: support VK_IMAGE_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR Signed-off-by: Hyunjun Ko Acked-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_image.c | 41 +++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 84b0afff0b7..0e263662411 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -895,23 +895,30 @@ add_aux_surface_if_supported(struct anv_device *device, static VkResult add_video_buffers(struct anv_device *device, struct anv_image *image, - const struct VkVideoProfileListInfoKHR *profile_list) + const struct VkVideoProfileListInfoKHR *profile_list, + bool independent_profile) { ASSERTED bool ok; unsigned size = 0; - for (unsigned i = 0; i < profile_list->profileCount; i++) { - if (profile_list->pProfiles[i].videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR || - profile_list->pProfiles[i].videoCodecOperation == VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR) { - unsigned w_mb = DIV_ROUND_UP(image->vk.extent.width, ANV_MB_WIDTH); - unsigned h_mb = DIV_ROUND_UP(image->vk.extent.height, ANV_MB_HEIGHT); - size = w_mb * h_mb * 128; - } - else if (profile_list->pProfiles[i].videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR || - profile_list->pProfiles[i].videoCodecOperation == VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR) { - unsigned w_mb = DIV_ROUND_UP(image->vk.extent.width, 32); - unsigned h_mb = DIV_ROUND_UP(image->vk.extent.height, 32); - size = ALIGN(w_mb * h_mb, 2) << 6; + if (independent_profile) { + /* Takes the worst case */ + unsigned w_mb = DIV_ROUND_UP(image->vk.extent.width, ANV_MB_WIDTH); + unsigned h_mb = DIV_ROUND_UP(image->vk.extent.height, ANV_MB_HEIGHT); + size = w_mb * h_mb * 128; + } else { + for (unsigned i = 0; i < profile_list->profileCount; i++) { + if (profile_list->pProfiles[i].videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR || + profile_list->pProfiles[i].videoCodecOperation == VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR) { + unsigned w_mb = DIV_ROUND_UP(image->vk.extent.width, ANV_MB_WIDTH); + unsigned h_mb = DIV_ROUND_UP(image->vk.extent.height, ANV_MB_HEIGHT); + size = w_mb * h_mb * 128; + } else if (profile_list->pProfiles[i].videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR || + profile_list->pProfiles[i].videoCodecOperation == VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR) { + unsigned w_mb = DIV_ROUND_UP(image->vk.extent.width, 32); + unsigned h_mb = DIV_ROUND_UP(image->vk.extent.height, 32); + size = ALIGN(w_mb * h_mb, 2) << 6; + } } } @@ -1781,8 +1788,12 @@ anv_image_init(struct anv_device *device, struct anv_image *image, const VkVideoProfileListInfoKHR *video_profile = vk_find_struct_const(pCreateInfo->pNext, VIDEO_PROFILE_LIST_INFO_KHR); - if (video_profile) { - r = add_video_buffers(device, image, video_profile); + + bool independent_video_profile = + pCreateInfo->flags & VK_IMAGE_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR; + + if (video_profile || independent_video_profile) { + r = add_video_buffers(device, image, video_profile, independent_video_profile); if (r != VK_SUCCESS) goto fail; }