radeonsi: clean up passing the is_monolithic flag for compilation
authorMarek Olšák <marek.olsak@amd.com>
Thu, 21 Jun 2018 05:36:22 +0000 (01:36 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 25 Jun 2018 22:33:58 +0000 (18:33 -0400)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_shader_internal.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index d2b9b73e0398fb7ce7475491207555837ecd46c5..af52558efe14f8bfc49ecbed66d4e590e9faa4f4 100644 (file)
@@ -5053,8 +5053,7 @@ static void create_function(struct si_shader_context *ctx)
                           si_get_max_workgroup_size(shader));
 
        /* Reserve register locations for VGPR inputs the PS prolog may need. */
-       if (ctx->type == PIPE_SHADER_FRAGMENT &&
-           ctx->separate_prolog) {
+       if (ctx->type == PIPE_SHADER_FRAGMENT && !ctx->shader->is_monolithic) {
                ac_llvm_add_target_dep_function_attr(ctx->main_fn,
                                                     "InitialPSInputAddr",
                                                     S_0286D0_PERSP_SAMPLE_ENA(1) |
@@ -6055,8 +6054,7 @@ static bool si_vs_needs_prolog(const struct si_shader_selector *sel,
        return sel->vs_needs_prolog || key->ls_vgpr_fix;
 }
 
-static bool si_compile_tgsi_main(struct si_shader_context *ctx,
-                                bool is_monolithic)
+static bool si_compile_tgsi_main(struct si_shader_context *ctx)
 {
        struct si_shader *shader = ctx->shader;
        struct si_shader_selector *sel = shader->selector;
@@ -6141,7 +6139,7 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx,
         * if-block together with its prolog in si_build_wrapper_function.
         */
        if (ctx->screen->info.chip_class >= GFX9) {
-               if (!is_monolithic &&
+               if (!shader->is_monolithic &&
                    sel->info.num_instructions > 1 && /* not empty shader */
                    (shader->key.as_es || shader->key.as_ls) &&
                    (ctx->type == PIPE_SHADER_TESS_EVAL ||
@@ -6151,7 +6149,7 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx,
                                                ctx->param_merged_wave_info, 0);
                } else if (ctx->type == PIPE_SHADER_TESS_CTRL ||
                           ctx->type == PIPE_SHADER_GEOMETRY) {
-                       if (!is_monolithic)
+                       if (!shader->is_monolithic)
                                ac_init_exec_full_mask(&ctx->ac);
 
                        /* The barrier must execute for all shaders in a
@@ -6764,7 +6762,6 @@ static void si_build_wrapper_function(struct si_shader_context *ctx,
 int si_compile_tgsi_shader(struct si_screen *sscreen,
                           struct si_compiler *compiler,
                           struct si_shader *shader,
-                          bool is_monolithic,
                           struct pipe_debug_callback *debug)
 {
        struct si_shader_selector *sel = shader->selector;
@@ -6784,19 +6781,18 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
 
        si_init_shader_ctx(&ctx, sscreen, compiler);
        si_llvm_context_set_tgsi(&ctx, shader);
-       ctx.separate_prolog = !is_monolithic;
 
        memset(shader->info.vs_output_param_offset, AC_EXP_PARAM_UNDEFINED,
               sizeof(shader->info.vs_output_param_offset));
 
        shader->info.uses_instanceid = sel->info.uses_instanceid;
 
-       if (!si_compile_tgsi_main(&ctx, is_monolithic)) {
+       if (!si_compile_tgsi_main(&ctx)) {
                si_llvm_dispose(&ctx);
                return -1;
        }
 
-       if (is_monolithic && ctx.type == PIPE_SHADER_VERTEX) {
+       if (shader->is_monolithic && ctx.type == PIPE_SHADER_VERTEX) {
                LLVMValueRef parts[2];
                bool need_prolog = sel->vs_needs_prolog;
 
@@ -6814,7 +6810,7 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
 
                si_build_wrapper_function(&ctx, parts + !need_prolog,
                                          1 + need_prolog, need_prolog, 0);
-       } else if (is_monolithic && ctx.type == PIPE_SHADER_TESS_CTRL) {
+       } else if (shader->is_monolithic && ctx.type == PIPE_SHADER_TESS_CTRL) {
                if (sscreen->info.chip_class >= GFX9) {
                        struct si_shader_selector *ls = shader->key.part.tcs.ls;
                        LLVMValueRef parts[4];
@@ -6837,9 +6833,10 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
                        shader_ls.key.as_ls = 1;
                        shader_ls.key.mono = shader->key.mono;
                        shader_ls.key.opt = shader->key.opt;
+                       shader_ls.is_monolithic = true;
                        si_llvm_context_set_tgsi(&ctx, &shader_ls);
 
-                       if (!si_compile_tgsi_main(&ctx, true)) {
+                       if (!si_compile_tgsi_main(&ctx)) {
                                si_llvm_dispose(&ctx);
                                return -1;
                        }
@@ -6879,7 +6876,7 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
 
                        si_build_wrapper_function(&ctx, parts, 2, 0, 0);
                }
-       } else if (is_monolithic && ctx.type == PIPE_SHADER_GEOMETRY) {
+       } else if (shader->is_monolithic && ctx.type == PIPE_SHADER_GEOMETRY) {
                if (ctx.screen->info.chip_class >= GFX9) {
                        struct si_shader_selector *es = shader->key.part.gs.es;
                        LLVMValueRef es_prolog = NULL;
@@ -6901,9 +6898,10 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
                        shader_es.key.as_es = 1;
                        shader_es.key.mono = shader->key.mono;
                        shader_es.key.opt = shader->key.opt;
+                       shader_es.is_monolithic = true;
                        si_llvm_context_set_tgsi(&ctx, &shader_es);
 
-                       if (!si_compile_tgsi_main(&ctx, true)) {
+                       if (!si_compile_tgsi_main(&ctx)) {
                                si_llvm_dispose(&ctx);
                                return -1;
                        }
@@ -6952,7 +6950,7 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
 
                        si_build_wrapper_function(&ctx, parts, 2, 1, 0);
                }
-       } else if (is_monolithic && ctx.type == PIPE_SHADER_FRAGMENT) {
+       } else if (shader->is_monolithic && ctx.type == PIPE_SHADER_FRAGMENT) {
                LLVMValueRef parts[3];
                union si_shader_part_key prolog_key;
                union si_shader_part_key epilog_key;
@@ -8060,7 +8058,7 @@ int si_shader_create(struct si_screen *sscreen, struct si_compiler *compiler,
                /* Monolithic shader (compiled as a whole, has many variants,
                 * may take a long time to compile).
                 */
-               r = si_compile_tgsi_shader(sscreen, compiler, shader, true, debug);
+               r = si_compile_tgsi_shader(sscreen, compiler, shader, debug);
                if (r)
                        return r;
        } else {
index 9e8d5736259d2b53da6e4c4be2bff1ca0a24e60c..0ca0a6b9679279d1b3c8c1122fd8399075e7c03b 100644 (file)
@@ -662,7 +662,6 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
 int si_compile_tgsi_shader(struct si_screen *sscreen,
                           struct si_compiler *compiler,
                           struct si_shader *shader,
-                          bool is_monolithic,
                           struct pipe_debug_callback *debug);
 int si_shader_create(struct si_screen *sscreen, struct si_compiler *compiler,
                     struct si_shader *shader,
index 0a347172d626016fd9fe3fce34556cee325a932c..e528a56023feb2de93a2162498a4c631a6055280 100644 (file)
@@ -62,9 +62,6 @@ struct si_shader_context {
        unsigned num_images;
        unsigned num_samplers;
 
-       /* Whether the prolog will be compiled separately. */
-       bool separate_prolog;
-
        struct ac_shader_abi abi;
 
        /** This function is responsible for initilizing the inputs array and will be
index bedd10e784f8710dc01341dfcb06678f528f93bb..f2569a53be3f9978a7e9073ed7417b2748aefc34 100644 (file)
@@ -1582,10 +1582,10 @@ static bool si_check_missing_main_part(struct si_screen *sscreen,
                main_part->selector = sel;
                main_part->key.as_es = key->as_es;
                main_part->key.as_ls = key->as_ls;
+               main_part->is_monolithic = false;
 
                if (si_compile_tgsi_shader(sscreen, compiler_state->compiler,
-                                          main_part, false,
-                                          &compiler_state->debug) != 0) {
+                                          main_part, &compiler_state->debug) != 0) {
                        FREE(main_part);
                        return false;
                }
@@ -1884,6 +1884,7 @@ static void si_init_shader_selector_async(void *job, int thread_index)
                util_queue_fence_init(&shader->ready);
 
                shader->selector = sel;
+               shader->is_monolithic = false;
                si_parse_next_shader_property(&sel->info,
                                              sel->so.num_outputs != 0,
                                              &shader->key);
@@ -1902,7 +1903,7 @@ static void si_init_shader_selector_async(void *job, int thread_index)
                        mtx_unlock(&sscreen->shader_cache_mutex);
 
                        /* Compile the shader if it hasn't been loaded from the cache. */
-                       if (si_compile_tgsi_shader(sscreen, compiler, shader, false,
+                       if (si_compile_tgsi_shader(sscreen, compiler, shader,
                                                   debug) != 0) {
                                FREE(shader);
                                FREE(ir_binary);