Module: Mesa
Branch: main
Commit: 9af3a31744db8140ccb17e8e9131c5dc4dc186df
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9af3a31744db8140ccb17e8e9131c5dc4dc186df

Author: Timur Kristóf <[email protected]>
Date:   Mon Jan 30 15:34:40 2023 +0100

ac/nir/cull: Alway remove zero-area triangles in face culling.

The face culling algorithm should have been disabled for
conservative overestimation because it already
(mistakenly) removed some close-to-zero area triangles.

Now that the driver disables it in that case,
let's always remove zero-area triangles.
This only costs +2 SALU instructions.

Signed-off-by: Timur Kristóf <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20987>

---

 src/amd/common/ac_nir_cull.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/amd/common/ac_nir_cull.c b/src/amd/common/ac_nir_cull.c
index 2d4cf2fb51e..1994c73c565 100644
--- a/src/amd/common/ac_nir_cull.c
+++ b/src/amd/common/ac_nir_cull.c
@@ -64,14 +64,15 @@ cull_face_triangle(nir_builder *b, nir_ssa_def *pos[3][4], 
const position_w_info
 
    det = nir_bcsel(b, w_info->w_reflection, nir_fneg(b, det), det);
 
-   nir_ssa_def *front_facing_cw = nir_flt(b, det, nir_imm_float(b, 0.0f));
    nir_ssa_def *front_facing_ccw = nir_flt(b, nir_imm_float(b, 0.0f), det);
+   nir_ssa_def *zero_area = nir_feq(b, nir_imm_float(b, 0.0f), det);
    nir_ssa_def *ccw = nir_load_cull_ccw_amd(b);
-   nir_ssa_def *front_facing = nir_bcsel(b, ccw, front_facing_ccw, 
front_facing_cw);
+   nir_ssa_def *front_facing = nir_ieq(b, front_facing_ccw, ccw);
    nir_ssa_def *cull_front = nir_load_cull_front_face_enabled_amd(b);
    nir_ssa_def *cull_back = nir_load_cull_back_face_enabled_amd(b);
 
    nir_ssa_def *face_culled = nir_bcsel(b, front_facing, cull_front, 
cull_back);
+   face_culled = nir_ior(b, face_culled, zero_area);
 
    /* Don't reject NaN and +/-infinity, these are tricky.
     * Just trust fixed-function HW to handle these cases correctly.

Reply via email to