From 01bad67a940c234e325e17a37afe076b47ac9ad1 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Tue, 25 Aug 2020 10:35:24 -0700 Subject: [PATCH] isl: Define isl_drm_modifier_get_score() [v3] Return the modifier's score, which indicates the driver's preference for the modifier relative to others. A higher score is better. Zero means unsupported. Intended to assist selection of a modifier from an externally provided list, such as VkImageDrmFormatModifierListCreateInfoEXT. v2: - Rename anv_drm_format_mod_score to isl_drm_modifier_get_score. - Squash all incremental changes to anv_drm_format_mod_score. v3: - Drop redundant 'unlikely'. (for nchery) Reviewed-by: Lionel Landwerlin (v2) Reviewed-by: Jason Ekstrand (v3) --- src/intel/isl/isl.h | 12 ++++++++++++ src/intel/isl/isl_drm.c | 27 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h index 4e805867d6a..378caa9fe8f 100644 --- a/src/intel/isl/isl.h +++ b/src/intel/isl/isl.h @@ -1892,6 +1892,18 @@ isl_drm_modifier_get_default_aux_state(uint64_t modifier) ISL_AUX_STATE_COMPRESSED_NO_CLEAR; } +/** + * Return the modifier's score, which indicates the driver's preference for the + * modifier relative to others. A higher score is better. Zero means + * unsupported. + * + * Intended to assist selection of a modifier from an externally provided list, + * such as VkImageDrmFormatModifierListCreateInfoEXT. + */ +uint32_t +isl_drm_modifier_get_score(const struct gen_device_info *devinfo, + uint64_t modifier); + 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 e1cae671ec6..04b50fc7912 100644 --- a/src/intel/isl/isl_drm.c +++ b/src/intel/isl/isl_drm.c @@ -29,6 +29,7 @@ #include "isl.h" #include "dev/gen_device_info.h" +#include "dev/gen_debug.h" uint32_t isl_tiling_to_i915_tiling(enum isl_tiling tiling) @@ -121,3 +122,29 @@ isl_drm_modifier_get_info(uint64_t modifier) return NULL; } + +uint32_t +isl_drm_modifier_get_score(const struct gen_device_info *devinfo, + uint64_t modifier) +{ + /* FINISHME: Add gen12 modifiers */ + switch (modifier) { + default: + return 0; + case DRM_FORMAT_MOD_LINEAR: + return 1; + case I915_FORMAT_MOD_X_TILED: + return 2; + case I915_FORMAT_MOD_Y_TILED: + return 3; + case I915_FORMAT_MOD_Y_TILED_CCS: + /* Gen12's CCS layout differs from Gen9-11. */ + if (devinfo->gen >= 12) + return 0; + + if (INTEL_DEBUG & DEBUG_NO_RBC) + return 0; + + return 4; + } +}