radeonsi/gfx10: merge main and pos/param export IF blocks into one if possible
[mesa.git] / src / gallium / drivers / radeonsi / si_compute.c
index 4cadf3e808d21986fd6ee799389a1214217f8edd..25e08c6f428c30f591c3e5f96db5854ca1c40711 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include "nir/tgsi_to_nir.h"
-#include "tgsi/tgsi_parse.h"
 #include "util/u_async_debug.h"
 #include "util/u_memory.h"
 #include "util/u_upload_mgr.h"
@@ -124,15 +123,10 @@ static void si_create_compute_state_async(void *job, int thread_index)
        if (!compiler->passes)
                si_init_compiler(sscreen, compiler);
 
-       if (program->ir_type == PIPE_SHADER_IR_TGSI) {
-               tgsi_scan_shader(sel->tokens, &sel->info);
-       } else {
-               assert(program->ir_type == PIPE_SHADER_IR_NIR);
-
-               si_nir_scan_shader(sel->nir, &sel->info);
-       }
+       assert(program->ir_type == PIPE_SHADER_IR_NIR);
+       si_nir_scan_shader(sel->nir, &sel->info);
 
-       /* Store the declared LDS size into tgsi_shader_info for the shader
+       /* Store the declared LDS size into si_shader_info for the shader
         * cache to include it.
         */
        sel->info.properties[TGSI_PROPERTY_CS_LOCAL_SIZE] = program->local_size;
@@ -165,11 +159,8 @@ static void si_create_compute_state_async(void *job, int thread_index)
        } else {
                simple_mtx_unlock(&sscreen->shader_cache_mutex);
 
-               if (!si_shader_create(sscreen, compiler, &program->shader, debug)) {
+               if (!si_create_shader_variant(sscreen, compiler, &program->shader, debug)) {
                        program->shader.compilation_failed = true;
-
-                       if (program->ir_type == PIPE_SHADER_IR_TGSI)
-                               FREE(sel->tokens);
                        return;
                }
 
@@ -198,6 +189,7 @@ static void si_create_compute_state_async(void *job, int thread_index)
                        S_00B84C_TGID_X_EN(sel->info.uses_block_id[0]) |
                        S_00B84C_TGID_Y_EN(sel->info.uses_block_id[1]) |
                        S_00B84C_TGID_Z_EN(sel->info.uses_block_id[2]) |
+                       S_00B84C_TG_SIZE_EN(sel->info.uses_subgroup_info) |
                        S_00B84C_TIDIG_COMP_CNT(sel->info.uses_thread_id[2] ? 2 :
                                                sel->info.uses_thread_id[1] ? 1 : 0) |
                        S_00B84C_LDS_SIZE(shader->config.lds_size);
@@ -208,8 +200,6 @@ static void si_create_compute_state_async(void *job, int thread_index)
                simple_mtx_unlock(&sscreen->shader_cache_mutex);
        }
 
-       FREE(sel->tokens);
-       sel->tokens = NULL;
        ralloc_free(sel->nir);
        sel->nir = NULL;
 }
@@ -233,16 +223,9 @@ static void *si_create_compute_state(
        program->input_size = cso->req_input_mem;
 
        if (cso->ir_type != PIPE_SHADER_IR_NATIVE) {
-               if (sscreen->options.enable_nir &&
-                   cso->ir_type == PIPE_SHADER_IR_TGSI) {
+               if (cso->ir_type == PIPE_SHADER_IR_TGSI) {
                        program->ir_type = PIPE_SHADER_IR_NIR;
                        sel->nir = tgsi_to_nir(cso->prog, ctx->screen);
-               } else if (cso->ir_type == PIPE_SHADER_IR_TGSI) {
-                       sel->tokens = tgsi_dup_tokens(cso->prog);
-                       if (!sel->tokens) {
-                               FREE(program);
-                               return NULL;
-                       }
                } else {
                        assert(cso->ir_type == PIPE_SHADER_IR_NIR);
                        sel->nir = (struct nir_shader *) cso->prog;
@@ -718,8 +701,8 @@ static bool si_upload_compute_input(struct si_context *sctx,
        return true;
 }
 
-static void si_setup_tgsi_user_data(struct si_context *sctx,
-                                const struct pipe_grid_info *info)
+static void si_setup_nir_user_data(struct si_context *sctx,
+                                  const struct pipe_grid_info *info)
 {
        struct si_compute *program = sctx->cs_shader_state.program;
        struct si_shader_selector *sel = &program->sel;
@@ -943,7 +926,7 @@ static void si_launch_grid(
        }
 
        if (program->ir_type != PIPE_SHADER_IR_NATIVE)
-               si_setup_tgsi_user_data(sctx, info);
+               si_setup_nir_user_data(sctx, info);
 
        si_emit_dispatch_packets(sctx, info);
 
@@ -976,7 +959,6 @@ void si_destroy_compute(struct si_compute *program)
        FREE(program->global_buffers);
 
        si_shader_destroy(&program->shader);
-       FREE(program->sel.tokens);
        ralloc_free(program->sel.nir);
        FREE(program);
 }