nir/lower_mediump: don't use fp16 for constants if the result is denormal

Image stores are not required to preserve denorms.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21622>
This commit is contained in:
Georg Lehmann
2023-03-01 13:24:30 +01:00
committed by Marge Bot
parent ede0630f9e
commit 0a3387a190

View File

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