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@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Lionel Landwerlin 2016-08-20 00:38:05 +01:00
parent fc6be40011
commit 2dc6930a5a
2 changed files with 10 additions and 0 deletions

View File

@ -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;

View File

@ -98,6 +98,15 @@ isl_log2u(uint32_t n)
return 31 - __builtin_clz(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)
{