diff options
author | Timur Kristóf <timur.kristof@gmail.com> | 2021-10-11 20:41:35 +0200 |
---|---|---|
committer | Dylan Baker <dylan.c.baker@intel.com> | 2021-10-14 09:03:48 -0700 |
commit | c52e6a9463ea725d2c4d183ec02b095d49b1c812 (patch) | |
tree | b90574ee7299e33bcdf64b7259f94849bbc0615e | |
parent | e0ffead86420ac6a48da0d76ccc9ed25dba60944 (diff) |
ac/nir/cull: Accept NaN and +/- Inf in face culling.
When the determinant that we use for calculating triangle area
is NaN, it's not possible to decide the facing of the triangle.
This can happen when a coordinate of one of the triangle's vertices
is INFINITY. It's better to just accept these triangles in the shader
and let the PA deal with them.
Let's do the same for +/- Infinity too.
Though we haven't seen this yet, it may be troublesome as well.
Fixes: 651a3da1b59446a6e392321d1dbbc1891a0544a8
Closes: #5470
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13299>
(cherry picked from commit 783f8f728ce8e77885adbc7b2c12c39c3e3e5198)
-rw-r--r-- | .pick_status.json | 2 | ||||
-rw-r--r-- | src/amd/common/ac_nir_cull.c | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/.pick_status.json b/.pick_status.json index 09596b02bfe..7021a0cceba 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4,7 +4,7 @@ "description": "ac/nir/cull: Accept NaN and +/- Inf in face culling.", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "651a3da1b59446a6e392321d1dbbc1891a0544a8" }, diff --git a/src/amd/common/ac_nir_cull.c b/src/amd/common/ac_nir_cull.c index a5adf2a4614..26e1f6515f4 100644 --- a/src/amd/common/ac_nir_cull.c +++ b/src/amd/common/ac_nir_cull.c @@ -75,7 +75,14 @@ cull_face(nir_builder *b, nir_ssa_def *pos[3][4], const position_w_info *w_info) nir_ssa_def *cull_front = nir_build_load_cull_front_face_enabled_amd(b); nir_ssa_def *cull_back = nir_build_load_cull_back_face_enabled_amd(b); - return nir_inot(b, nir_bcsel(b, front_facing, cull_front, cull_back)); + nir_ssa_def *face_culled = nir_bcsel(b, front_facing, cull_front, cull_back); + + /* Don't reject NaN and +/-infinity, these are tricky. + * Just trust fixed-function HW to handle these cases correctly. + */ + face_culled = nir_iand(b, face_culled, nir_fisfinite(b, det)); + + return nir_inot(b, face_culled); } static nir_ssa_def * |