radeonsi: unify the logic that sets rast_prim
authorMarek Olšák <marek.olsak@amd.com>
Sun, 14 Aug 2022 10:46:09 +0000 (06:46 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 30 Aug 2022 04:57:43 +0000 (04:57 +0000)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18195>

src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state_draw.cpp
src/gallium/drivers/radeonsi/si_state_shaders.cpp

index 8f83a9c..46ff86b 100644 (file)
@@ -2101,6 +2101,19 @@ void si_check_dirty_buffers_textures(struct si_context *sctx)
    }
 }
 
+/* Set the primitive type seen by the rasterizer. GS and tessellation affect this. */
+static inline void
+si_set_rasterized_prim(struct si_context *sctx, enum pipe_prim_type rast_prim)
+{
+   if (rast_prim != sctx->current_rast_prim) {
+      if (util_prim_is_points_or_lines(sctx->current_rast_prim) !=
+          util_prim_is_points_or_lines(rast_prim))
+         si_mark_atom_dirty(sctx, &sctx->atoms.s.guardband);
+
+      sctx->current_rast_prim = rast_prim;
+      sctx->do_update_shaders = true;
+   }
+}
 
 #define PRINT_ERR(fmt, args...)                                                                    \
    fprintf(stderr, "EE %s:%d %s - " fmt, __FILE__, __LINE__, __func__, ##args)
index 055f591..73b71c9 100644 (file)
@@ -2362,14 +2362,7 @@ static void si_draw(struct pipe_context *ctx,
          rast_prim = prim;
       }
 
-      if (rast_prim != sctx->current_rast_prim) {
-         if (util_prim_is_points_or_lines(sctx->current_rast_prim) !=
-             util_prim_is_points_or_lines(rast_prim))
-            si_mark_atom_dirty(sctx, &sctx->atoms.s.guardband);
-
-         sctx->current_rast_prim = rast_prim;
-         sctx->do_update_shaders = true;
-      }
+      si_set_rasterized_prim(sctx, rast_prim);
    }
 
    if (IS_DRAW_VERTEX_STATE) {
index ffad77f..415d9cf 100644 (file)
@@ -3313,25 +3313,14 @@ static void si_update_clip_regs(struct si_context *sctx, struct si_shader_select
 
 static void si_update_rasterized_prim(struct si_context *sctx)
 {
-   enum pipe_prim_type rast_prim;
-
    if (sctx->shader.gs.cso) {
       /* Only possibilities: POINTS, LINE_STRIP, TRIANGLES */
-      rast_prim = sctx->shader.gs.cso->rast_prim;
+      si_set_rasterized_prim(sctx, sctx->shader.gs.cso->rast_prim);
    } else if (sctx->shader.tes.cso) {
       /* Only possibilities: POINTS, LINE_STRIP, TRIANGLES */
-      rast_prim = sctx->shader.tes.cso->rast_prim;
+      si_set_rasterized_prim(sctx, sctx->shader.tes.cso->rast_prim);
    } else {
-      /* Determined by draw calls. */
-      return;
-   }
-
-   if (rast_prim != sctx->current_rast_prim) {
-      if (util_prim_is_points_or_lines(sctx->current_rast_prim) !=
-          util_prim_is_points_or_lines(rast_prim))
-         si_mark_atom_dirty(sctx, &sctx->atoms.s.guardband);
-
-      sctx->current_rast_prim = rast_prim;
+      /* The rasterized prim is determined by draw calls. */
    }
 }