radeonsi: move VGT_VERTEX_REUSE_BLOCK_CNTL into shader states for Polaris
authorMarek Olšák <marek.olsak@amd.com>
Wed, 25 Jan 2017 02:27:34 +0000 (03:27 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 30 Jan 2017 12:27:14 +0000 (13:27 +0100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_hw_context.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state_draw.c
src/gallium/drivers/radeonsi/si_state_shaders.c

index d862e26342d7131c0a278ea80bfbc720c405083e..e5da730458a76cb693368a3fe7ba00d53d811007 100644 (file)
@@ -251,7 +251,6 @@ void si_begin_new_cs(struct si_context *ctx)
        ctx->last_multi_vgt_param = -1;
        ctx->last_rast_prim = -1;
        ctx->last_sc_line_stipple = ~0;
-       ctx->last_vtx_reuse_depth = -1;
        ctx->emit_scratch_reloc = true;
        ctx->last_ls = NULL;
        ctx->last_tcs = NULL;
index 13b1e34d722c800aa80682a74fdd74690a9dea7b..18cd25c60c1fccc10ed5cba1b3eb4748937a957c 100644 (file)
@@ -326,7 +326,6 @@ struct si_context {
        int                     last_multi_vgt_param;
        int                     last_rast_prim;
        unsigned                last_sc_line_stipple;
-       int                     last_vtx_reuse_depth;
        int                     current_rast_prim; /* primitive type after TES, GS */
        bool                    gs_tri_strip_adj_fix;
 
index f0bd9304ea036cf9f0286c0f112818ba8ae0bb4e..5313a4d6db4cc602b91f3277c9270c4273687bb8 100644 (file)
@@ -468,25 +468,6 @@ static void si_emit_draw_registers(struct si_context *sctx,
        unsigned gs_out_prim = si_conv_prim_to_gs_out(sctx->current_rast_prim);
        unsigned ia_multi_vgt_param, num_patches = 0;
 
-       /* Polaris needs different VTX_REUSE_DEPTH settings depending on
-        * whether the "fractional odd" tessellation spacing is used.
-        */
-       if (sctx->b.family >= CHIP_POLARIS10) {
-               struct si_shader_selector *tes = sctx->tes_shader.cso;
-               unsigned vtx_reuse_depth = 30;
-
-               if (tes &&
-                   tes->info.properties[TGSI_PROPERTY_TES_SPACING] ==
-                   PIPE_TESS_SPACING_FRACTIONAL_ODD)
-                       vtx_reuse_depth = 14;
-
-               if (vtx_reuse_depth != sctx->last_vtx_reuse_depth) {
-                       radeon_set_context_reg(cs, R_028C58_VGT_VERTEX_REUSE_BLOCK_CNTL,
-                                              vtx_reuse_depth);
-                       sctx->last_vtx_reuse_depth = vtx_reuse_depth;
-               }
-       }
-
        if (sctx->tes_shader.cso)
                si_emit_derived_tess_state(sctx, info, &num_patches);
 
index 02f8d6c06be75218d73508aaeb4c6583f2cbc202..94fffdb4263c5b97ddb5b9b1474cfd83cf69349e 100644 (file)
@@ -331,6 +331,45 @@ static void si_set_tesseval_regs(struct si_screen *sscreen,
                       S_028B6C_DISTRIBUTION_MODE(distribution_mode));
 }
 
+/* Polaris needs different VTX_REUSE_DEPTH settings depending on
+ * whether the "fractional odd" tessellation spacing is used.
+ *
+ * Possible VGT configurations and which state should set the register:
+ *
+ *   Reg set in | VGT shader configuration   | Value
+ * ------------------------------------------------------
+ *     VS as VS | VS                         | 30
+ *     VS as ES | ES -> GS -> VS             | 30
+ *    TES as VS | LS -> HS -> VS             | 14 or 30
+ *    TES as ES | LS -> HS -> ES -> GS -> VS | 14 or 30
+ */
+static void polaris_set_vgt_vertex_reuse(struct si_screen *sscreen,
+                                        struct si_shader *shader,
+                                        struct si_pm4_state *pm4)
+{
+       unsigned type = shader->selector->type;
+
+       if (sscreen->b.family < CHIP_POLARIS10)
+               return;
+
+       /* VS as VS, or VS as ES: */
+       if ((type == PIPE_SHADER_VERTEX &&
+            !shader->key.as_ls &&
+            !shader->is_gs_copy_shader) ||
+           /* TES as VS, or TES as ES: */
+           type == PIPE_SHADER_TESS_EVAL) {
+               unsigned vtx_reuse_depth = 30;
+
+               if (type == PIPE_SHADER_TESS_EVAL &&
+                   shader->selector->info.properties[TGSI_PROPERTY_TES_SPACING] ==
+                   PIPE_TESS_SPACING_FRACTIONAL_ODD)
+                       vtx_reuse_depth = 14;
+
+               si_pm4_set_reg(pm4, R_028C58_VGT_VERTEX_REUSE_BLOCK_CNTL,
+                              vtx_reuse_depth);
+       }
+}
+
 static struct si_pm4_state *si_get_shader_pm4_state(struct si_shader *shader)
 {
        if (shader->pm4)
@@ -438,6 +477,8 @@ static void si_shader_es(struct si_screen *sscreen, struct si_shader *shader)
 
        if (shader->selector->type == PIPE_SHADER_TESS_EVAL)
                si_set_tesseval_regs(sscreen, shader, pm4);
+
+       polaris_set_vgt_vertex_reuse(sscreen, shader, pm4);
 }
 
 /**
@@ -625,6 +666,8 @@ static void si_shader_vs(struct si_screen *sscreen, struct si_shader *shader,
 
        if (shader->selector->type == PIPE_SHADER_TESS_EVAL)
                si_set_tesseval_regs(sscreen, shader, pm4);
+
+       polaris_set_vgt_vertex_reuse(sscreen, shader, pm4);
 }
 
 static unsigned si_get_ps_num_interp(struct si_shader *ps)