mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-02 13:50:09 +01:00
tgsi_exec: Fix NaN behavior of saturate
Modern shader APIs, like DX10 and GLSL 1.30, want saturate or
clamp(..., 0.0, 1.0) to "cleanse" NaN. If the source is NaN, the
result should be zero.
There are many cases where TGSI is generate from NIR, and many
optimizations in NIR expect this behavior. Not meeting these
expectations can lead to unexpected results.
Reviewed-by: Eric Anholt <eric@anholt.net>
Fixes: 56c30bf17b ("tgsi: Saturate modifier obeys ExecMask. Implement NVIDIA [-1;+1] saturate mode.")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10419>
This commit is contained in:
parent
c6ef4047d0
commit
d1c0f62b42
1 changed files with 2 additions and 2 deletions
|
|
@ -1938,7 +1938,7 @@ store_dest(struct tgsi_exec_machine *mach,
|
|||
else {
|
||||
for (i = 0; i < TGSI_QUAD_SIZE; i++)
|
||||
if (execmask & (1 << i)) {
|
||||
if (chan->f[i] < 0.0f)
|
||||
if (chan->f[i] < 0.0f || isnan(chan->f[i]))
|
||||
dst->f[i] = 0.0f;
|
||||
else if (chan->f[i] > 1.0f)
|
||||
dst->f[i] = 1.0f;
|
||||
|
|
@ -3621,7 +3621,7 @@ store_double_channel(struct tgsi_exec_machine *mach,
|
|||
else {
|
||||
for (i = 0; i < TGSI_QUAD_SIZE; i++)
|
||||
if (execmask & (1 << i)) {
|
||||
if (chan->d[i] < 0.0)
|
||||
if (chan->d[i] < 0.0 || isnan(chan->d[i]))
|
||||
temp.d[i] = 0.0;
|
||||
else if (chan->d[i] > 1.0)
|
||||
temp.d[i] = 1.0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue