Mesa (master): isl: round format alignment to nearest power of 2
Lionel Landwerlin
llandwerlin at kemper.freedesktop.org
Thu Sep 1 10:36:32 UTC 2016
Module: Mesa
Branch: master
Commit: 2dc6930a5a54c0f586ba09437123c380f3eae456
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2dc6930a5a54c0f586ba09437123c380f3eae456
Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date: Sat Aug 20 00:38:05 2016 +0100
isl: round format alignment to nearest power of 2
A few inline asserts in anv assume alignments are power of 2, but with
formats like R8G8B8 we have odd alignments.
v2: round up to power of 2 (Ilia)
v3: reuse util_next_power_of_two() from gallium/aux/util/u_math.h (Ilia)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
---
src/intel/isl/isl.c | 1 +
src/intel/isl/isl_priv.h | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
index c4989dd..0487515 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -1201,6 +1201,7 @@ isl_surf_init_s(const struct isl_device *dev,
base_alignment = MAX(base_alignment, fmtl->bpb / 8);
}
}
+ base_alignment = isl_round_up_to_power_of_two(base_alignment);
} else {
assert(phys_slice0_sa.w % fmtl->bw == 0);
const uint32_t total_w_el = phys_slice0_sa.width / fmtl->bw;
diff --git a/src/intel/isl/isl_priv.h b/src/intel/isl/isl_priv.h
index 3a7af1a..9867e22 100644
--- a/src/intel/isl/isl_priv.h
+++ b/src/intel/isl/isl_priv.h
@@ -99,6 +99,15 @@ isl_log2u(uint32_t n)
}
static inline uint32_t
+isl_round_up_to_power_of_two(uint32_t value)
+{
+ if (value <= 1)
+ return value;
+
+ return 1 << (32 - __builtin_clz(value - 1));
+}
+
+static inline uint32_t
isl_minify(uint32_t n, uint32_t levels)
{
if (unlikely(n == 0))
More information about the mesa-commit
mailing list