From 1d7a988ec2442feab1f2e3b3bc88ddf72456d311 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Wed, 30 Apr 2025 17:38:21 +0100 Subject: [PATCH] vtn: use nir_const_value_for_raw_uint for bfloat SpecConstantOp/FConvert I'm not sure how this was supposed to ensure padding was zero, and it doesn't seem to work for me (GCC 15.0.1). Fixes a NIR validation failure with dEQP-VK.glsl.bfloat16.constant.compute and RADV. Signed-off-by: Rhys Perry Fixes: 90e1b128903c ("spirv: Add bfloat16 support to SpecConstantOp") Reviewed-by: Georg Lehmann Reviewed-by: Caio Oliveira Part-of: --- src/compiler/spirv/spirv_to_nir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 9d2ffebcb2f..96b929dbfa9 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -2789,10 +2789,9 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode, if (bfloat_dst) { for (int i = 0; i < num_components; i++) { - /* Ensure the pad bits are zeroed by fully assigning the value. */ const uint16_t b = _mesa_float_to_bfloat16_bits_rte(val->constant->values[i].f32); - val->constant->values[i] = (nir_const_value){ .u16 = b }; + val->constant->values[i] = nir_const_value_for_raw_uint(b, 16); } }