diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2021-03-25 10:12:00 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2021-04-06 12:53:47 -0700 |
commit | 3da2d7b1aad084b14ab5ee4952f128ccaba5b943 (patch) | |
tree | c6e89ad8b24656cdc006f864404fc502622ac460 | |
parent | 3d709fc26e14c987f0490860689dd4fabb3624d6 (diff) |
anv: Use same primary surface memory range for both "planes" of subsampled formats
The Y plane and the UV plane of Y210, Y212, and Y216 formats occupy the
same memory. Ensure that the memory range for the two planes is the
same.
-rw-r--r-- | src/intel/vulkan/anv_image.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index c672451473b..95934801e3b 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -317,6 +317,24 @@ anv_formats_ccs_e_compatible(const struct gen_device_info *devinfo, } /** + * Do Y plane and UV planes have the same storage? + * + * Some packed, subsampled YUV formats are handled by the driver as if they + * were planar. For these formats, the Y plane and the UV plane is the same + * memory, but the surface formats for each view a different. + */ +static bool +is_y_plane_and_uv_plane_same_memory(VkFormat vk_format) +{ + return vk_format == VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 || + vk_format == VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 || + vk_format == VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 || + vk_format == VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 || + vk_format == VK_FORMAT_G16B16G16R16_422_UNORM || + vk_format == VK_FORMAT_B16G16R16G16_422_UNORM; +} + +/** * For color images that have an auxiliary surface, request allocation for an * additional buffer that mainly stores fast-clear values. Use of this buffer * allows us to access the image's subresources while being aware of their @@ -668,7 +686,10 @@ add_primary_surface(struct anv_device *device, image->planes[plane].aux_usage = ISL_AUX_USAGE_NONE; - add_surface(image, ANV_IMAGE_MEMORY_BINDING_PLANE_0 + plane, anv_surf); + if (plane == 1 && is_y_plane_and_uv_plane_same_memory(image->vk_format)) + anv_surf->memory_range = image->planes[0].primary_surface.memory_range; + else + add_surface(image, ANV_IMAGE_MEMORY_BINDING_PLANE_0 + plane, anv_surf); return VK_SUCCESS; } @@ -2380,6 +2401,12 @@ anv_CreateImageView(VkDevice _device, anv_foreach_image_aspect_bit(iaspect_bit, image, expanded_aspects) { uint32_t iplane = anv_image_aspect_to_plane(image->aspects, 1UL << iaspect_bit); + + if (conv_format != NULL && + is_y_plane_and_uv_plane_same_memory(conv_format->vk_format)) { + iplane = 0; + } + VkImageAspectFlags vplane_aspect = anv_plane_to_aspect(iview->aspect_mask, vplane); struct anv_format_plane format = |