Module: Mesa Branch: main Commit: 47565d31e1446ba872f4d6473feea2caa406db84 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=47565d31e1446ba872f4d6473feea2caa406db84
Author: Nanley Chery <[email protected]> Date: Wed Jun 21 13:59:50 2023 -0400 intel: Add and use isl_drm_modifier_get_plane_count We're going to enable the DG2_RC_CCS modifier in anv. Add and use this function to prepare for the new plane count that comes with that modifier. iris is left alone for now because it supports more modifiers than isl_drm_modifier_get_score is aware of. Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24120> --- src/intel/isl/isl.h | 6 ++++++ src/intel/isl/isl_drm.c | 29 +++++++++++++++++++++++++++++ src/intel/vulkan/anv_formats.c | 14 ++++++++------ 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h index a104d906923..64819fc1f22 100644 --- a/src/intel/isl/isl.h +++ b/src/intel/isl/isl.h @@ -2305,6 +2305,12 @@ uint32_t isl_drm_modifier_get_score(const struct intel_device_info *devinfo, uint64_t modifier); +/* Return the number of planes used by an image with the given parameters. */ +uint32_t +isl_drm_modifier_get_plane_count(const struct intel_device_info *devinfo, + uint64_t modifier, + uint32_t fmt_planes); + struct isl_extent2d ATTRIBUTE_CONST isl_get_interleaved_msaa_px_size_sa(uint32_t samples); diff --git a/src/intel/isl/isl_drm.c b/src/intel/isl/isl_drm.c index eb00c62c197..01afc361199 100644 --- a/src/intel/isl/isl_drm.c +++ b/src/intel/isl/isl_drm.c @@ -221,3 +221,32 @@ isl_drm_modifier_get_score(const struct intel_device_info *devinfo, return 4; } } + +uint32_t +isl_drm_modifier_get_plane_count(const struct intel_device_info *devinfo, + uint64_t modifier, + uint32_t fmt_planes) +{ + /* This function could return the wrong value if the modifier is not + * supported by the device. + */ + assert(isl_drm_modifier_get_score(devinfo, modifier) > 0); + + /* Planar images don't support clear color. */ + if (isl_drm_modifier_get_info(modifier)->supports_clear_color) + assert(fmt_planes == 1); + + if (devinfo->has_flat_ccs) { + if (isl_drm_modifier_get_info(modifier)->supports_clear_color) + return 2 * fmt_planes; + else + return 1 * fmt_planes; + } else { + if (isl_drm_modifier_get_info(modifier)->supports_clear_color) + return 3 * fmt_planes; + else if (isl_drm_modifier_has_aux(modifier)) + return 2 * fmt_planes; + else + return 1 * fmt_planes; + } +} diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index 4ad6c0963a5..40b4f1110bd 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -895,9 +895,10 @@ get_drm_format_modifier_properties_list(const struct anv_physical_device *physic if (!features) continue; - uint32_t planes = anv_format->n_planes; - if (isl_mod_info->aux_usage != ISL_AUX_USAGE_NONE) - ++planes; + const uint32_t planes = + isl_drm_modifier_get_plane_count(&physical_device->info, + isl_mod_info->modifier, + anv_format->n_planes); vk_outarray_append_typed(VkDrmFormatModifierPropertiesEXT, &out, out_props) { *out_props = (VkDrmFormatModifierPropertiesEXT) { @@ -928,9 +929,10 @@ get_drm_format_modifier_properties_list_2(const struct anv_physical_device *phys if (!features2) continue; - uint32_t planes = anv_format->n_planes; - if (isl_mod_info->aux_usage != ISL_AUX_USAGE_NONE) - ++planes; + const uint32_t planes = + isl_drm_modifier_get_plane_count(&physical_device->info, + isl_mod_info->modifier, + anv_format->n_planes); vk_outarray_append_typed(VkDrmFormatModifierProperties2EXT, &out, out_props) { *out_props = (VkDrmFormatModifierProperties2EXT) {
