radeonsi: generate GS prolog to (partially) fix triangle strip adjacency rotation
[mesa.git] / src / gallium / drivers / radeonsi / si_state_draw.c
index c0e2642ba3d2fb67857afeaeca137cfca2b9869f..affc156a3d1e8a087b47a9274246fd4c528cbd01 100644 (file)
@@ -982,6 +982,24 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
                sctx->do_update_shaders = true;
        }
 
+       if (sctx->gs_shader.cso) {
+               /* Determine whether the GS triangle strip adjacency fix should
+                * be applied. Rotate every other triangle if
+                * - triangle strips with adjacency are fed to the GS and
+                * - primitive restart is disabled (the rotation doesn't help
+                *   when the restart occurs after an odd number of triangles).
+                */
+               bool gs_tri_strip_adj_fix =
+                       !sctx->tes_shader.cso &&
+                       info->mode == PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY &&
+                       !info->primitive_restart;
+
+               if (gs_tri_strip_adj_fix != sctx->gs_tri_strip_adj_fix) {
+                       sctx->gs_tri_strip_adj_fix = gs_tri_strip_adj_fix;
+                       sctx->do_update_shaders = true;
+               }
+       }
+
        if (sctx->do_update_shaders && !si_update_shaders(sctx))
                return;