From 535823682dd44c8c3c7c3b75bbe0577cb76fa90a Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 20 Jun 2024 12:47:04 -0400 Subject: [PATCH] nir/format_convert: remove unorm bit size assert Yes, we're losing precision if this assert fails and it's wrong. It's also necessary to implement GL in a reasonable way on Asahi. Remove the assert that was recently added and add more comment context on the mess. Fixes debug build regression on asahi: dEQP-GLES3.functional.vertex_arrays.single_attribute.normalize.int.components4_quads1 Fixes: 22f1b04a99a ("nir/format_convert: Assert that UNORM formats are <= 16 bits") Signed-off-by: Alyssa Rosenzweig Suggested-by: Faith Ekstrand Acked-by: Boris Brezillon Part-of: --- src/compiler/nir/nir_format_convert.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_format_convert.c b/src/compiler/nir/nir_format_convert.c index 8bd25ff5005..76461b78835 100644 --- a/src/compiler/nir/nir_format_convert.c +++ b/src/compiler/nir/nir_format_convert.c @@ -202,8 +202,14 @@ _nir_format_norm_factor(nir_builder *b, const unsigned *bits, /* 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. + * + * Unfortunately, GL is silly and includes 32-bit normalized vertex + * formats even though you're guaranteed to lose precision. Those formats + * are broken by design, but we do need to support them with the + * bugginess, and the loss of precision here is acceptable for GL. This + * helper is used for the vertex format conversion on Asahi, so we can't + * assert(bits[i] <= 16). But if it's not, you get to pick up the pieces. */ - assert(bits[i] <= 16); factor[i].f32 = (1ull << (bits[i] - is_signed)) - 1; } return nir_build_imm(b, num_components, 32, factor);