radeonsi: extract the VGT_GS_MODE calculation into its own function
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 22 Jan 2016 21:58:15 +0000 (16:58 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 25 Jan 2016 15:15:08 +0000 (10:15 -0500)
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_state_shaders.c

index 79f2335b9b52ec3643f82eff722531f782d48e43..096f1521a6152a241f88f857f7f7d41639f32bb8 100644 (file)
@@ -212,13 +212,37 @@ static void si_shader_es(struct si_shader *shader)
                si_set_tesseval_regs(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 *shader)
+{
+       unsigned gs_max_vert_out = shader->selector->gs_max_out_vertices;
+       unsigned cut_mode;
+
+       if (gs_max_vert_out <= 128) {
+               cut_mode = V_028A40_GS_CUT_128;
+       } else if (gs_max_vert_out <= 256) {
+               cut_mode = V_028A40_GS_CUT_256;
+       } else if (gs_max_vert_out <= 512) {
+               cut_mode = V_028A40_GS_CUT_512;
+       } else {
+               assert(gs_max_vert_out <= 1024);
+               cut_mode = V_028A40_GS_CUT_1024;
+       }
+
+       return S_028A40_MODE(V_028A40_GS_SCENARIO_G) |
+              S_028A40_CUT_MODE(cut_mode)|
+              S_028A40_ES_WRITE_OPTIMIZE(1) |
+              S_028A40_GS_WRITE_OPTIMIZE(1);
+}
+
 static void si_shader_gs(struct si_shader *shader)
 {
        unsigned gs_vert_itemsize = shader->selector->gsvs_vertex_size;
-       unsigned gs_max_vert_out = shader->selector->gs_max_out_vertices;
        unsigned gsvs_itemsize = shader->selector->max_gsvs_emit_size >> 2;
        unsigned gs_num_invocations = shader->selector->gs_num_invocations;
-       unsigned cut_mode;
        struct si_pm4_state *pm4;
        unsigned num_sgprs, num_user_sgprs;
        uint64_t va;
@@ -232,22 +256,7 @@ static void si_shader_gs(struct si_shader *shader)
        if (!pm4)
                return;
 
-       if (gs_max_vert_out <= 128) {
-               cut_mode = V_028A40_GS_CUT_128;
-       } else if (gs_max_vert_out <= 256) {
-               cut_mode = V_028A40_GS_CUT_256;
-       } else if (gs_max_vert_out <= 512) {
-               cut_mode = V_028A40_GS_CUT_512;
-       } else {
-               assert(gs_max_vert_out <= 1024);
-               cut_mode = V_028A40_GS_CUT_1024;
-       }
-
-       si_pm4_set_reg(pm4, R_028A40_VGT_GS_MODE,
-                      S_028A40_MODE(V_028A40_GS_SCENARIO_G) |
-                      S_028A40_CUT_MODE(cut_mode)|
-                      S_028A40_ES_WRITE_OPTIMIZE(1) |
-                      S_028A40_GS_WRITE_OPTIMIZE(1));
+       si_pm4_set_reg(pm4, R_028A40_VGT_GS_MODE, si_vgt_gs_mode(shader));
 
        si_pm4_set_reg(pm4, R_028A60_VGT_GSVS_RING_OFFSET_1, gsvs_itemsize);
        si_pm4_set_reg(pm4, R_028A64_VGT_GSVS_RING_OFFSET_2, gsvs_itemsize * ((max_stream >= 2) ? 2 : 1));
@@ -255,7 +264,7 @@ static void si_shader_gs(struct si_shader *shader)
 
        si_pm4_set_reg(pm4, R_028AB0_VGT_GSVS_RING_ITEMSIZE, gsvs_itemsize * (max_stream + 1));
 
-       si_pm4_set_reg(pm4, R_028B38_VGT_GS_MAX_VERT_OUT, gs_max_vert_out);
+       si_pm4_set_reg(pm4, R_028B38_VGT_GS_MAX_VERT_OUT, shader->selector->gs_max_out_vertices);
 
        si_pm4_set_reg(pm4, R_028B5C_VGT_GS_VERT_ITEMSIZE, gs_vert_itemsize >> 2);
        si_pm4_set_reg(pm4, R_028B60_VGT_GS_VERT_ITEMSIZE_1, (max_stream >= 1) ? gs_vert_itemsize >> 2 : 0);