nir_shader *shader = nir_shader_clone(mem_ctx, src_shader);
shader = brw_nir_apply_sampler_key(shader, compiler, &key->tex, true);
- /* Now that we cloned the nir_shader, we can update num_uniforms based on
- * the thread_local_id_index.
- */
- assert(prog_data->thread_local_id_index >= 0);
- shader->num_uniforms =
- MAX2(shader->num_uniforms,
- (unsigned)4 * (prog_data->thread_local_id_index + 1));
-
brw_nir_lower_cs_intrinsics(shader, prog_data);
shader = brw_postprocess_nir(shader, compiler, true);
nir_function_impl *impl;
bool progress;
nir_builder builder;
- bool cs_thread_id_used;
};
static nir_ssa_def *
read_thread_local_id(struct lower_intrinsics_state *state)
{
+ struct brw_cs_prog_data *prog_data = state->prog_data;
nir_builder *b = &state->builder;
nir_shader *nir = state->nir;
const unsigned *sizes = nir->info.cs.local_size;
if (group_size <= 8)
return nir_imm_int(b, 0);
- assert(state->prog_data->thread_local_id_index >= 0);
- state->cs_thread_id_used = true;
- const int id_index = state->prog_data->thread_local_id_index;
+ if (prog_data->thread_local_id_index == -1) {
+ prog_data->thread_local_id_index = prog_data->base.nr_params;
+ brw_stage_prog_data_add_params(&prog_data->base, 1);
+ nir->num_uniforms += 4;
+ }
+ unsigned id_index = prog_data->thread_local_id_index;
nir_intrinsic_instr *load =
nir_intrinsic_instr_create(nir, nir_intrinsic_load_uniform);
state.nir = nir;
state.prog_data = prog_data;
+ state.prog_data->thread_local_id_index = -1;
+
do {
state.progress = false;
nir_foreach_function(function, nir) {
progress |= state.progress;
} while (state.progress);
- if (!state.cs_thread_id_used)
- state.prog_data->thread_local_id_index = -1;
-
return progress;
}
pipeline->needs_data_cache = true;
}
- if (stage == MESA_SHADER_COMPUTE)
- ((struct brw_cs_prog_data *)prog_data)->thread_local_id_index =
- prog_data->nr_params++; /* The CS Thread ID uniform */
-
if (nir->info.num_ssbos > 0)
pipeline->needs_data_cache = true;
*/
int param_count = cp->program.nir->num_uniforms / 4;
- /* The backend also sometimes add a param for the thread local id. */
- prog_data.thread_local_id_index = param_count++;
-
prog_data.base.param = rzalloc_array(NULL, uint32_t, param_count);
prog_data.base.pull_param = rzalloc_array(NULL, uint32_t, param_count);
prog_data.base.nr_params = param_count;