From 0a3387a190e9eef969ffc8a4f16ecde122e15c7e Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 1 Mar 2023 13:24:30 +0100 Subject: [PATCH] nir/lower_mediump: don't use fp16 for constants if the result is denormal MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Image stores are not required to preserve denorms. Reviewed-by: Marek Olšák Reviewed-by: Emma Anholt Part-of: --- src/compiler/nir/nir_lower_mediump.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_lower_mediump.c b/src/compiler/nir/nir_lower_mediump.c index c1baabf..2e7a40d 100644 --- a/src/compiler/nir/nir_lower_mediump.c +++ b/src/compiler/nir/nir_lower_mediump.c @@ -749,7 +749,9 @@ static bool const_is_f16(nir_ssa_scalar scalar) { double value = nir_ssa_scalar_as_float(scalar); - return value == _mesa_half_to_float(_mesa_float_to_half(value)); + uint16_t fp16_val = _mesa_float_to_half(value); + bool is_denorm = (fp16_val & 0x7fff) != 0 && (fp16_val & 0x7fff) <= 0x3ff; + return value == _mesa_half_to_float(fp16_val) && !is_denorm; } static bool -- 2.7.4