radeonsi: move maximum gs stream calculation into create_shader
authorMarek Olšák <marek.olsak@amd.com>
Sun, 8 Nov 2015 11:05:39 +0000 (12:05 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 13 Nov 2015 18:54:42 +0000 (19:54 +0100)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index bffffad9573806858f1f097f375523e6dd871ec2..1dd25227e9d509bddcb3ca95317a2364917f47c3 100644 (file)
@@ -205,6 +205,7 @@ struct si_shader_selector {
        unsigned        gs_output_prim;
        unsigned        gs_max_out_vertices;
        unsigned        gs_num_invocations;
+       unsigned        max_gs_stream; /* count - 1 */
        unsigned        gsvs_vertex_size;
        unsigned        max_gsvs_emit_size;
 
index 7a2cafeb9dc8af0150b3ee1bfcbd63d0b04515a3..0e403c492f527abc1002adcba99fa2e0ddc9e27e 100644 (file)
@@ -209,21 +209,6 @@ static void si_shader_es(struct si_shader *shader)
                si_set_tesseval_regs(shader, pm4);
 }
 
-static unsigned si_gs_get_max_stream(struct si_shader *shader)
-{
-       struct pipe_stream_output_info *so = &shader->selector->so;
-       unsigned max_stream = 0, i;
-
-       if (so->num_outputs == 0)
-               return 0;
-
-       for (i = 0; i < so->num_outputs; i++) {
-               if (so->output[i].stream > max_stream)
-                       max_stream = so->output[i].stream;
-       }
-       return max_stream;
-}
-
 static void si_shader_gs(struct si_shader *shader)
 {
        unsigned gs_vert_itemsize = shader->selector->gsvs_vertex_size;
@@ -234,7 +219,7 @@ static void si_shader_gs(struct si_shader *shader)
        struct si_pm4_state *pm4;
        unsigned num_sgprs, num_user_sgprs;
        uint64_t va;
-       unsigned max_stream = si_gs_get_max_stream(shader);
+       unsigned max_stream = shader->selector->max_gs_stream;
 
        /* The GSVS_RING_ITEMSIZE register takes 15 bits */
        assert(gsvs_itemsize < (1 << 15));
@@ -717,6 +702,11 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
                sel->max_gsvs_emit_size = sel->gsvs_vertex_size *
                                          sel->gs_max_out_vertices;
 
+               sel->max_gs_stream = 0;
+               for (i = 0; i < sel->so.num_outputs; i++)
+                       sel->max_gs_stream = MAX2(sel->max_gs_stream,
+                                                 sel->so.output[i].stream);
+
                for (i = 0; i < sel->info.num_inputs; i++) {
                        unsigned name = sel->info.input_semantic_name[i];
                        unsigned index = sel->info.input_semantic_index[i];