anv: Add a get_format_plane helper and use it in image setup
Unlike anv_get_format_aspect, this takes a plane number which is relative to the set of aspects on the format. There are a number of cases where we already have the plane and so re-fetching it is useless. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12141>
This commit is contained in:

committed by
Marge Bot

parent
dc6794ec24
commit
4df2078e72
@@ -468,9 +468,9 @@ anv_format_has_npot_plane(const struct anv_format *anv_format) {
|
||||
* _cannot_ check for compatibility).
|
||||
*/
|
||||
struct anv_format_plane
|
||||
anv_get_format_aspect(const struct intel_device_info *devinfo,
|
||||
VkFormat vk_format,
|
||||
VkImageAspectFlagBits aspect, VkImageTiling tiling)
|
||||
anv_get_format_plane(const struct intel_device_info *devinfo,
|
||||
VkFormat vk_format, uint32_t plane,
|
||||
VkImageTiling tiling)
|
||||
{
|
||||
const struct anv_format *format = anv_get_format(vk_format);
|
||||
const struct anv_format_plane unsupported = {
|
||||
@@ -480,7 +480,7 @@ anv_get_format_aspect(const struct intel_device_info *devinfo,
|
||||
if (format == NULL)
|
||||
return unsupported;
|
||||
|
||||
uint32_t plane = anv_image_aspect_to_plane(vk_format_aspects(vk_format), aspect);
|
||||
assert(plane < format->n_planes);
|
||||
struct anv_format_plane plane_format = format->planes[plane];
|
||||
if (plane_format.isl_format == ISL_FORMAT_UNSUPPORTED)
|
||||
return unsupported;
|
||||
@@ -491,8 +491,6 @@ anv_get_format_aspect(const struct intel_device_info *devinfo,
|
||||
if (vk_format_is_depth_or_stencil(vk_format))
|
||||
return plane_format;
|
||||
|
||||
assert((aspect & ~VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) == 0);
|
||||
|
||||
const struct isl_format_layout *isl_layout =
|
||||
isl_format_get_layout(plane_format.isl_format);
|
||||
|
||||
@@ -533,6 +531,16 @@ anv_get_format_aspect(const struct intel_device_info *devinfo,
|
||||
return plane_format;
|
||||
}
|
||||
|
||||
struct anv_format_plane
|
||||
anv_get_format_aspect(const struct intel_device_info *devinfo,
|
||||
VkFormat vk_format,
|
||||
VkImageAspectFlagBits aspect, VkImageTiling tiling)
|
||||
{
|
||||
const uint32_t plane =
|
||||
anv_image_aspect_to_plane(vk_format_aspects(vk_format), aspect);
|
||||
return anv_get_format_plane(devinfo, vk_format, plane, tiling);
|
||||
}
|
||||
|
||||
// Format capabilities
|
||||
|
||||
VkFormatFeatureFlags
|
||||
|
@@ -1035,7 +1035,7 @@ add_all_surfaces_implicit_layout(
|
||||
VkImageAspectFlagBits aspect = 1 << b;
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const struct anv_format_plane plane_format =
|
||||
anv_get_format_aspect(devinfo, image->vk_format, aspect, image->tiling);
|
||||
anv_get_format_plane(devinfo, image->vk_format, plane, image->tiling);
|
||||
|
||||
VkImageUsageFlags vk_usage = image->usage;
|
||||
if (aspect == VK_IMAGE_ASPECT_STENCIL_BIT)
|
||||
@@ -1156,7 +1156,7 @@ add_all_surfaces_explicit_layout(
|
||||
const VkImageAspectFlagBits aspect = 1 << b;
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const struct anv_format_plane format_plane =
|
||||
anv_get_format_aspect(devinfo, image->vk_format, aspect, image->tiling);
|
||||
anv_get_format_plane(devinfo, image->vk_format, plane, image->tiling);
|
||||
const VkSubresourceLayout *primary_layout = &drm_info->pPlaneLayouts[plane];
|
||||
|
||||
result = add_primary_surface(device, image, plane,
|
||||
|
@@ -3838,6 +3838,11 @@ anv_get_format_planes(VkFormat vk_format)
|
||||
return format != NULL ? format->n_planes : 0;
|
||||
}
|
||||
|
||||
struct anv_format_plane
|
||||
anv_get_format_plane(const struct intel_device_info *devinfo,
|
||||
VkFormat vk_format, uint32_t plane,
|
||||
VkImageTiling tiling);
|
||||
|
||||
struct anv_format_plane
|
||||
anv_get_format_aspect(const struct intel_device_info *devinfo,
|
||||
VkFormat vk_format,
|
||||
|
Reference in New Issue
Block a user