Mesa (main): radeonsi: don't compile TES and GS draw_vbo variants for the prim discard CS

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 21 19:17:04 UTC 2021


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Mon May 24 15:43:54 2021 -0400

radeonsi: don't compile TES and GS draw_vbo variants for the prim discard CS

This also fixes the incorrect emit_draw_packets template argument.
The condition should be inverted.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11102>

---

 src/gallium/drivers/radeonsi/si_pipe.h         | 12 +++++++++++-
 src/gallium/drivers/radeonsi/si_state_draw.cpp | 13 ++++++-------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index 2af9365a656..127b6944ff9 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -2021,15 +2021,25 @@ static inline unsigned si_get_shader_wave_size(struct si_shader *shader)
 
 static inline void si_select_draw_vbo(struct si_context *sctx)
 {
+   bool has_prim_discard_cs = si_compute_prim_discard_enabled(sctx) &&
+                              !sctx->shader.tes.cso && !sctx->shader.gs.cso;
    pipe_draw_vbo_func draw_vbo = sctx->draw_vbo[!!sctx->shader.tes.cso]
                                                [!!sctx->shader.gs.cso]
                                                [sctx->ngg]
-                                               [si_compute_prim_discard_enabled(sctx)];
+                                               [has_prim_discard_cs];
    assert(draw_vbo);
    if (unlikely(sctx->real_draw_vbo))
       sctx->real_draw_vbo = draw_vbo;
    else
       sctx->b.draw_vbo = draw_vbo;
+
+   if (!has_prim_discard_cs) {
+      /* Reset this to false if prim discard CS is disabled because draw_vbo doesn't reset it. */
+      if (sctx->prim_discard_cs_instancing) {
+         sctx->do_update_shaders = true;
+         sctx->prim_discard_cs_instancing = false;
+      }
+   }
 }
 
 /* Return the number of samples that the rasterizer uses. */
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.cpp b/src/gallium/drivers/radeonsi/si_state_draw.cpp
index 9ad7fc0a691..f43fd5afb0a 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.cpp
+++ b/src/gallium/drivers/radeonsi/si_state_draw.cpp
@@ -1920,7 +1920,7 @@ static void si_draw_vbo(struct pipe_context *ctx,
    unsigned original_index_size = index_size;
 
    /* Determine if we can use the primitive discard compute shader. */
-   if (ALLOW_PRIM_DISCARD_CS && !HAS_TESS && !HAS_GS &&
+   if (ALLOW_PRIM_DISCARD_CS &&
        (total_direct_count > sctx->prim_discard_vertex_count_threshold
            ? (sctx->compute_num_verts_rejected += total_direct_count, true)
            : /* Add, then return true. */
@@ -1949,8 +1949,6 @@ static void si_draw_vbo(struct pipe_context *ctx,
         (!sctx->num_pipeline_stat_queries && !sctx->streamout.prims_gen_query_enabled) ||
         pd_msg("pipestat or primgen query")) &&
        (!sctx->vertex_elements->instance_divisor_is_fetched || pd_msg("loads instance divisors")) &&
-       (!HAS_TESS || pd_msg("uses tess")) &&
-       (!HAS_GS || pd_msg("uses GS")) &&
        (!sctx->shader.ps.cso->info.uses_primid || pd_msg("PS uses PrimID")) &&
        !rs->polygon_mode_enabled &&
 #if SI_PRIM_DISCARD_DEBUG /* same as cso->prim_discard_cs_allowed */
@@ -2180,8 +2178,7 @@ static void si_draw_vbo(struct pipe_context *ctx,
       }
       assert(sctx->dirty_atoms == 0);
 
-      si_emit_draw_packets<GFX_VERSION, NGG,
-                           !HAS_TESS && !HAS_GS ? PRIM_DISCARD_CS_OFF : ALLOW_PRIM_DISCARD_CS>
+      si_emit_draw_packets<GFX_VERSION, NGG, ALLOW_PRIM_DISCARD_CS>
             (sctx, info, drawid_offset, indirect, draws, num_draws, indexbuf, index_size,
              index_offset, instance_count, dispatch_prim_discard_cs,
              original_index_size);
@@ -2220,8 +2217,7 @@ static void si_draw_vbo(struct pipe_context *ctx,
       }
       assert(sctx->dirty_atoms == 0);
 
-      si_emit_draw_packets<GFX_VERSION, NGG,
-                           !HAS_TESS && !HAS_GS ? PRIM_DISCARD_CS_OFF : ALLOW_PRIM_DISCARD_CS>
+      si_emit_draw_packets<GFX_VERSION, NGG, ALLOW_PRIM_DISCARD_CS>
             (sctx, info, drawid_offset, indirect, draws, num_draws, indexbuf, index_size,
              index_offset, instance_count,
              dispatch_prim_discard_cs, original_index_size);
@@ -2319,6 +2315,9 @@ static void si_init_draw_vbo(struct si_context *sctx)
    if (ALLOW_PRIM_DISCARD_CS && GFX_VERSION < GFX7)
       return;
 
+   if (ALLOW_PRIM_DISCARD_CS && (HAS_TESS || HAS_GS))
+      return;
+
    if (NGG && GFX_VERSION < GFX10)
       return;
 



More information about the mesa-commit mailing list