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

Author: Alyssa Rosenzweig <[email protected]>
Date:   Sat Jan 15 09:48:02 2022 -0500

panfrost: Only cull polygons

The spec says only polygons, not points/lines, should be culled when
culling is enabled. The hardware does not make this distinction, so we
have to.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
Reported-by: Icecream95 <[email protected]>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14575>

---

 src/gallium/drivers/panfrost/pan_cmdstream.c | 14 ++++++++++++--
 src/panfrost/ci/panfrost-g52-fails.txt       |  1 -
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c 
b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 1112f4fa617..f59146e87e1 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -2739,6 +2739,7 @@ panfrost_draw_emit_tiler(struct panfrost_batch *batch,
         }
 
         enum pipe_prim_type prim = u_reduced_prim(info->mode);
+        bool polygon = (prim == PIPE_PRIM_TRIANGLES);
         void *prim_size = pan_section_ptr(job, TILER_JOB, PRIMITIVE_SIZE);
 
 #if PAN_ARCH >= 6
@@ -2754,8 +2755,17 @@ panfrost_draw_emit_tiler(struct panfrost_batch *batch,
                 cfg.four_components_per_vertex = true;
                 cfg.draw_descriptor_is_64b = true;
                 cfg.front_face_ccw = rast->front_ccw;
-                cfg.cull_front_face = rast->cull_face & PIPE_FACE_FRONT;
-                cfg.cull_back_face = rast->cull_face & PIPE_FACE_BACK;
+
+                /*
+                 * From the Gallium documentation,
+                 * pipe_rasterizer_state::cull_face "indicates which faces of
+                 * polygons to cull". Points and lines are not considered
+                 * polygons and should be drawn even if all faces are culled.
+                 * The hardware does not take primitive type into account when
+                 * culling, so we need to do that check ourselves.
+                 */
+                cfg.cull_front_face = polygon && (rast->cull_face & 
PIPE_FACE_FRONT);
+                cfg.cull_back_face = polygon && (rast->cull_face & 
PIPE_FACE_BACK);
                 cfg.position = pos;
                 cfg.state = batch->rsd[PIPE_SHADER_FRAGMENT];
                 cfg.attributes = batch->attribs[PIPE_SHADER_FRAGMENT];
diff --git a/src/panfrost/ci/panfrost-g52-fails.txt 
b/src/panfrost/ci/panfrost-g52-fails.txt
index f7a89b72380..e3dd9fb5fbe 100644
--- a/src/panfrost/ci/panfrost-g52-fails.txt
+++ b/src/panfrost/ci/panfrost-g52-fails.txt
@@ -1129,7 +1129,6 @@ spec@!opengl 1.1@linestipple,Fail
 spec@!opengl 1.1@linestipple@Line loop,Fail
 spec@!opengl 1.1@linestipple@Line strip,Fail
 spec@!opengl 1.1@linestipple@Restarting lines within a single Begin-End 
block,Fail
-spec@!opengl 1.1@point-line-no-cull,Fail
 spec@!opengl 1.1@polygon-mode-facing,Fail
 spec@!opengl 1.1@polygon-mode,Fail
 spec@!opengl 1.1@polygon-mode-offset@config 0: Expected white pixel on bottom 
edge,Fail

Reply via email to