mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 13:20:14 +01:00
nir/format_convert: Assert that UNORM formats are <= 16 bits
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28793>
This commit is contained in:
parent
5f5f4474f6
commit
22f1b04a99
1 changed files with 5 additions and 1 deletions
|
|
@ -199,7 +199,11 @@ _nir_format_norm_factor(nir_builder *b, const unsigned *bits,
|
|||
nir_const_value factor[NIR_MAX_VEC_COMPONENTS];
|
||||
memset(factor, 0, sizeof(factor));
|
||||
for (unsigned i = 0; i < num_components; i++) {
|
||||
assert(bits[i] <= 32);
|
||||
/* A 16-bit float only has 23 bits of mantissa. This isn't enough to
|
||||
* convert 24 or 32-bit UNORM/SNORM accurately. For that, we would need
|
||||
* fp64 or some sort of fixed-point math.
|
||||
*/
|
||||
assert(bits[i] <= 16);
|
||||
factor[i].f32 = (1ull << (bits[i] - is_signed)) - 1;
|
||||
}
|
||||
return nir_build_imm(b, num_components, 32, factor);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue