diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 4926c58fd36..d66d71ca27b 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -808,6 +808,30 @@ add_aux_surface_if_supported(struct anv_device *device, return VK_SUCCESS; } +static VkResult +add_video_buffers(struct anv_device *device, + struct anv_image *image, + const struct VkVideoProfileListInfoKHR *profile_list) +{ + 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) { + 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; + } + } + + if (size == 0) + return VK_SUCCESS; + + ok = image_binding_grow(device, image, ANV_IMAGE_MEMORY_BINDING_PRIVATE, + ANV_OFFSET_IMPLICIT, size, 65536, &image->vid_dmv_top_surface); + return ok; +} + /** * Initialize the anv_image::*_surface selected by \a aspect. Then update the * image's memory requirements (that is, the image's size and alignment). @@ -1383,6 +1407,15 @@ anv_image_init(struct anv_device *device, struct anv_image *image, if (r != VK_SUCCESS) goto fail; + 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); + if (r != VK_SUCCESS) + goto fail; + } + r = alloc_private_binding(device, image, pCreateInfo); if (r != VK_SUCCESS) goto fail; diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 2ee62ea0cef..f45f8adeb7c 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -3546,6 +3546,8 @@ struct anv_image { */ bool can_non_zero_fast_clear; } planes[3]; + + struct anv_image_memory_range vid_dmv_top_surface; }; static inline bool @@ -4087,6 +4089,9 @@ struct anv_acceleration_structure { struct anv_address address; }; +#define ANV_MB_WIDTH 16 +#define ANV_MB_HEIGHT 16 + void anv_dump_pipe_bits(enum anv_pipe_bits bits);