From: Marek Olšák <[email protected]>

---
 src/gallium/drivers/radeonsi/si_hw_context.c    |  1 -
 src/gallium/drivers/radeonsi/si_pipe.h          |  1 -
 src/gallium/drivers/radeonsi/si_state_draw.c    | 19 -----------
 src/gallium/drivers/radeonsi/si_state_shaders.c | 43 +++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 21 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c 
b/src/gallium/drivers/radeonsi/si_hw_context.c
index d862e26..e5da730 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -244,19 +244,18 @@ void si_begin_new_cs(struct si_context *ctx)
         * the first draw call. */
        si_invalidate_draw_sh_constants(ctx);
        ctx->last_index_size = -1;
        ctx->last_primitive_restart_en = -1;
        ctx->last_restart_index = SI_RESTART_INDEX_UNKNOWN;
        ctx->last_gs_out_prim = -1;
        ctx->last_prim = -1;
        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;
        ctx->last_tes_sh_base = -1;
        ctx->last_num_tcs_input_cp = -1;
 
        ctx->cs_shader_state.initialized = false;
 }
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index 13b1e34..18cd25c 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -319,21 +319,20 @@ struct si_context {
        int                     last_start_instance;
        int                     last_drawid;
        int                     last_sh_base_reg;
        int                     last_primitive_restart_en;
        int                     last_restart_index;
        int                     last_gs_out_prim;
        int                     last_prim;
        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;
 
        /* Scratch buffer */
        struct r600_resource    *scratch_buffer;
        bool                    emit_scratch_reloc;
        unsigned                scratch_waves;
        unsigned                spi_tmpring_size;
 
        struct r600_resource    *compute_scratch_buffer;
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c 
b/src/gallium/drivers/radeonsi/si_state_draw.c
index cce5f30..3ce19aa 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -461,39 +461,20 @@ static void si_emit_rasterizer_prim_state(struct 
si_context *sctx)
 }
 
 static void si_emit_draw_registers(struct si_context *sctx,
                                   const struct pipe_draw_info *info)
 {
        struct radeon_winsys_cs *cs = sctx->b.gfx.cs;
        unsigned prim = si_conv_pipe_prim(info->mode);
        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);
 
        ia_multi_vgt_param = si_get_ia_multi_vgt_param(sctx, info, num_patches);
 
        /* Draw state. */
        if (ia_multi_vgt_param != sctx->last_multi_vgt_param) {
                if (sctx->b.chip_class >= CIK)
                        radeon_set_context_reg_idx(cs, 
R_028AA8_IA_MULTI_VGT_PARAM, 1, ia_multi_vgt_param);
                else
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 02f8d6c..94fffdb 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -324,20 +324,59 @@ static void si_set_tesseval_regs(struct si_screen 
*sscreen,
        } else
                distribution_mode = V_028B6C_DISTRIBUTION_MODE_NO_DIST;
 
        si_pm4_set_reg(pm4, R_028B6C_VGT_TF_PARAM,
                       S_028B6C_TYPE(type) |
                       S_028B6C_PARTITIONING(partitioning) |
                       S_028B6C_TOPOLOGY(topology) |
                       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)
                si_pm4_clear_state(shader->pm4);
        else
                shader->pm4 = CALLOC_STRUCT(si_pm4_state);
 
        return shader->pm4;
 }
 
@@ -431,20 +470,22 @@ static void si_shader_es(struct si_screen *sscreen, 
struct si_shader *shader)
                       S_00B328_VGPR_COMP_CNT(vgpr_comp_cnt) |
                       S_00B328_DX10_CLAMP(1) |
                       S_00B328_FLOAT_MODE(shader->config.float_mode));
        si_pm4_set_reg(pm4, R_00B32C_SPI_SHADER_PGM_RSRC2_ES,
                       S_00B32C_USER_SGPR(num_user_sgprs) |
                       S_00B32C_OC_LDS_EN(oc_lds_en) |
                       
S_00B32C_SCRATCH_EN(shader->config.scratch_bytes_per_wave > 0));
 
        if (shader->selector->type == PIPE_SHADER_TESS_EVAL)
                si_set_tesseval_regs(sscreen, shader, pm4);
+
+       polaris_set_vgt_vertex_reuse(sscreen, shader, pm4);
 }
 
 /**
  * Calculate the appropriate setting of VGT_GS_MODE when \p shader is a
  * geometry shader.
  */
 static uint32_t si_vgt_gs_mode(struct si_shader_selector *sel)
 {
        unsigned gs_max_vert_out = sel->gs_max_out_vertices;
        unsigned cut_mode;
@@ -618,20 +659,22 @@ static void si_shader_vs(struct si_screen *sscreen, 
struct si_shader *shader,
                               S_028818_VTX_XY_FMT(1) | S_028818_VTX_Z_FMT(1));
        else
                si_pm4_set_reg(pm4, R_028818_PA_CL_VTE_CNTL,
                               S_028818_VTX_W0_FMT(1) |
                               S_028818_VPORT_X_SCALE_ENA(1) | 
S_028818_VPORT_X_OFFSET_ENA(1) |
                               S_028818_VPORT_Y_SCALE_ENA(1) | 
S_028818_VPORT_Y_OFFSET_ENA(1) |
                               S_028818_VPORT_Z_SCALE_ENA(1) | 
S_028818_VPORT_Z_OFFSET_ENA(1));
 
        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)
 {
        struct tgsi_shader_info *info = &ps->selector->info;
        unsigned num_colors = !!(info->colors_read & 0x0f) +
                              !!(info->colors_read & 0xf0);
        unsigned num_interp = ps->selector->info.num_inputs +
                              (ps->key.part.ps.prolog.color_two_side ? 
num_colors : 0);
 
-- 
2.7.4

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to