From 1e91280242d266758a0c59b5c2575d7d78ebfb91 Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Mon, 14 Jan 2019 11:32:21 -0800 Subject: [PATCH] isl: Add and use isl_tiling_flag_to_enum() Use a helper that will automatically handle Gen12's CCS tiling when creating a CCS isl_surf. Reviewed-by: Kenneth Graunke Reviewed-by: Jordan Justen --- src/intel/isl/isl.c | 4 ++-- src/intel/isl/isl.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c index 39e5dca5307..a91c7204f66 100644 --- a/src/intel/isl/isl.c +++ b/src/intel/isl/isl.c @@ -384,7 +384,7 @@ isl_surf_choose_tiling(const struct isl_device *dev, if (info->usage & ISL_SURF_USAGE_HIZ_BIT) { assert(info->format == ISL_FORMAT_HIZ); assert(tiling_flags == ISL_TILING_HIZ_BIT); - *tiling = ISL_TILING_HIZ; + *tiling = isl_tiling_flag_to_enum(tiling_flags); return true; } @@ -392,7 +392,7 @@ isl_surf_choose_tiling(const struct isl_device *dev, if (info->usage & ISL_SURF_USAGE_CCS_BIT) { assert(isl_format_get_layout(info->format)->txc == ISL_TXC_CCS); assert(tiling_flags == ISL_TILING_CCS_BIT); - *tiling = ISL_TILING_CCS; + *tiling = isl_tiling_flag_to_enum(tiling_flags); return true; } diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h index 757d5fb0ae8..5b7458a2285 100644 --- a/src/intel/isl/isl.h +++ b/src/intel/isl/isl.h @@ -1636,6 +1636,13 @@ bool isl_has_matching_typed_storage_image_format(const struct gen_device_info *devinfo, enum isl_format fmt); +static inline enum isl_tiling +isl_tiling_flag_to_enum(isl_tiling_flags_t flag) +{ + assert(__builtin_popcount(flag) == 1); + return (enum isl_tiling) (__builtin_ffs(flag) - 1); +} + static inline bool isl_tiling_is_any_y(enum isl_tiling tiling) { -- 2.30.2