radeonsi/gfx11: fix a regression with PAIRS packets due to shader changes
authorMarek Olšák <marek.olsak@amd.com>
Tue, 11 Jul 2023 09:04:09 +0000 (05:04 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 11 Jul 2023 13:25:35 +0000 (13:25 +0000)
When the vertex shader switches from hw GS to hw HS and vice versa, we need
to re-emit all draw user SGPRs.

Fixes: 1753b321f876 - radeonsi/gfx11: use SET_SH_REG_PAIRS_PACKED for gfx by buffering reg writes

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

src/gallium/drivers/radeonsi/si_state_draw.cpp

index c547d28..e5f595c 100644 (file)
@@ -1765,26 +1765,33 @@ static void si_emit_draw_packets(struct si_context *sctx, const struct pipe_draw
       if (!is_blit) {
          /* Prefer SET_SH_REG_PAIRS_PACKED* on Gfx11+. */
          if (HAS_PAIRS) {
-            if (base_vertex != sctx->last_base_vertex ||
+            bool shader_switch = sh_base_reg != sctx->last_sh_base_reg;
+
+            if (shader_switch ||
+                base_vertex != sctx->last_base_vertex ||
                 sctx->last_base_vertex == SI_BASE_VERTEX_UNKNOWN) {
                radeon_push_gfx_sh_reg(sh_base_reg + SI_SGPR_BASE_VERTEX * 4, base_vertex);
                sctx->last_base_vertex = base_vertex;
             }
 
             if (set_draw_id &&
-                (drawid_base != sctx->last_drawid ||
+                (shader_switch ||
+                 drawid_base != sctx->last_drawid ||
                  sctx->last_drawid == SI_DRAW_ID_UNKNOWN)) {
                radeon_push_gfx_sh_reg(sh_base_reg + SI_SGPR_DRAWID * 4, drawid_base);
                sctx->last_drawid = drawid_base;
             }
 
             if (set_base_instance &&
-                (info->start_instance != sctx->last_start_instance ||
+                (shader_switch ||
+                 info->start_instance != sctx->last_start_instance ||
                  sctx->last_start_instance == SI_START_INSTANCE_UNKNOWN)) {
                radeon_push_gfx_sh_reg(sh_base_reg + SI_SGPR_START_INSTANCE * 4,
                                       info->start_instance);
                sctx->last_start_instance = info->start_instance;
             }
+
+            sctx->last_sh_base_reg = sh_base_reg;
          } else if (base_vertex != sctx->last_base_vertex ||
                     sctx->last_base_vertex == SI_BASE_VERTEX_UNKNOWN ||
                     (set_base_instance &&