radeonsi: get tgsi_shader_info only once before compilation
authorMarek Olšák <marek.olsak@amd.com>
Tue, 30 Sep 2014 13:12:09 +0000 (15:12 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 4 Oct 2014 13:16:14 +0000 (15:16 +0200)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state.c

index 9d2cc803c2d0410a6473f83d4cd72f5c1ecd62e6..276ba814d1d95927db6fc72b14f7fdf3e044c7dc 100644 (file)
@@ -2805,7 +2805,6 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader)
 {
        struct si_shader_selector *sel = shader->selector;
        struct si_shader_context si_shader_ctx;
-       struct tgsi_shader_info shader_info;
        struct lp_build_tgsi_context * bld_base;
        LLVMModuleRef mod;
        int r = 0;
@@ -2826,13 +2825,11 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader)
        radeon_llvm_context_init(&si_shader_ctx.radeon_bld);
        bld_base = &si_shader_ctx.radeon_bld.soa.bld_base;
 
-       tgsi_scan_shader(sel->tokens, &shader_info);
-
-       if (shader_info.uses_kill)
+       if (sel->info.uses_kill)
                shader->db_shader_control |= S_02880C_KILL_ENABLE(1);
 
-       shader->uses_instanceid = shader_info.uses_instanceid;
-       bld_base->info = &shader_info;
+       shader->uses_instanceid = sel->info.uses_instanceid;
+       bld_base->info = &sel->info;
        bld_base->emit_fetch_funcs[TGSI_FILE_CONSTANT] = fetch_constant;
 
        bld_base->op_actions[TGSI_OPCODE_TEX] = tex_action;
@@ -2876,16 +2873,16 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader)
                bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_gs;
                bld_base->emit_epilogue = si_llvm_emit_gs_epilogue;
 
-               for (i = 0; i < shader_info.num_properties; i++) {
-                       switch (shader_info.properties[i].name) {
+               for (i = 0; i < sel->info.num_properties; i++) {
+                       switch (sel->info.properties[i].name) {
                        case TGSI_PROPERTY_GS_INPUT_PRIM:
-                               shader->gs_input_prim = shader_info.properties[i].data[0];
+                               shader->gs_input_prim = sel->info.properties[i].data[0];
                                break;
                        case TGSI_PROPERTY_GS_OUTPUT_PRIM:
-                               shader->gs_output_prim = shader_info.properties[i].data[0];
+                               shader->gs_output_prim = sel->info.properties[i].data[0];
                                break;
                        case TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES:
-                               shader->gs_max_out_vertices = shader_info.properties[i].data[0];
+                               shader->gs_max_out_vertices = sel->info.properties[i].data[0];
                                break;
                        }
                }
@@ -2897,10 +2894,10 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader)
                si_shader_ctx.radeon_bld.load_input = declare_input_fs;
                bld_base->emit_epilogue = si_llvm_emit_fs_epilogue;
 
-               for (i = 0; i < shader_info.num_properties; i++) {
-                       switch (shader_info.properties[i].name) {
+               for (i = 0; i < sel->info.num_properties; i++) {
+                       switch (sel->info.properties[i].name) {
                        case TGSI_PROPERTY_FS_DEPTH_LAYOUT:
-                               switch (shader_info.properties[i].data[0]) {
+                               switch (sel->info.properties[i].data[0]) {
                                case TGSI_FS_DEPTH_LAYOUT_GREATER:
                                        shader->db_shader_control |=
                                                S_02880C_CONSERVATIVE_Z_EXPORT(V_02880C_EXPORT_GREATER_THAN_Z);
index d8a63df62755b46372a9f0dfc6f7799e1df8e671..8f5b4316cd6efa80b3a1ee809d499c015a52ec17 100644 (file)
@@ -30,6 +30,7 @@
 #define SI_SHADER_H
 
 #include <llvm-c/Core.h> /* LLVMModuleRef */
+#include "tgsi/tgsi_scan.h"
 
 #define SI_SGPR_CONST          0
 #define SI_SGPR_SAMPLER                2
@@ -117,6 +118,7 @@ struct si_shader_selector {
 
        struct tgsi_token       *tokens;
        struct pipe_stream_output_info  so;
+       struct tgsi_shader_info         info;
 
        unsigned        num_shaders;
 
index ed90f13a074b6b885d08daf00ef369d1ad2a83f9..0e2d6c4e6b5ead6077f706e30b3c15de65cc5b71 100644 (file)
@@ -30,7 +30,6 @@
 #include "radeon/r600_cs.h"
 
 #include "tgsi/tgsi_parse.h"
-#include "tgsi/tgsi_scan.h"
 #include "util/u_format.h"
 #include "util/u_format_s3tc.h"
 #include "util/u_framebuffer.h"
@@ -2311,13 +2310,10 @@ static void *si_create_shader_state(struct pipe_context *ctx,
        sel->type = pipe_shader_type;
        sel->tokens = tgsi_dup_tokens(state->tokens);
        sel->so = state->stream_output;
+       tgsi_scan_shader(state->tokens, &sel->info);
 
-       if (pipe_shader_type == PIPE_SHADER_FRAGMENT) {
-               struct tgsi_shader_info info;
-
-               tgsi_scan_shader(state->tokens, &info);
-               sel->fs_write_all = info.color0_writes_all_cbufs;
-       }
+       if (pipe_shader_type == PIPE_SHADER_FRAGMENT)
+               sel->fs_write_all = sel->info.color0_writes_all_cbufs;
 
        r = si_shader_select(ctx, sel);
        if (r) {