aboutsummaryrefslogtreecommitdiffstats
path: root/src/intel/compiler/brw_nir_lower_cs_intrinsics.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-09-29 10:37:40 -0700
committerJason Ekstrand <[email protected]>2017-10-12 22:39:30 -0700
commit6bcc5c0c75226bb89f35d7529de11182051c729e (patch)
tree0236a1b24eed496b62121dd597dd0d53ce1cfb82 /src/intel/compiler/brw_nir_lower_cs_intrinsics.c
parentb1d1b7222acfe45e447d1708d60b3ff98ca5a9a7 (diff)
intel/cs: Grow prog_data::param on-demand for thread_local_id_index
Instead of making the caller of brw_compile_cs add something to the param array for thread_local_id_index, just add it on-demand in brw_nir_intrinsics and grow the array. This is now safe to do because everyone is now using ralloc for prog_data::param. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/intel/compiler/brw_nir_lower_cs_intrinsics.c')
-rw-r--r--src/intel/compiler/brw_nir_lower_cs_intrinsics.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/intel/compiler/brw_nir_lower_cs_intrinsics.c b/src/intel/compiler/brw_nir_lower_cs_intrinsics.c
index 602ef2e1749..01718eb5dd1 100644
--- a/src/intel/compiler/brw_nir_lower_cs_intrinsics.c
+++ b/src/intel/compiler/brw_nir_lower_cs_intrinsics.c
@@ -30,12 +30,12 @@ struct lower_intrinsics_state {
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;
@@ -47,9 +47,12 @@ read_thread_local_id(struct lower_intrinsics_state *state)
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);
@@ -162,6 +165,8 @@ brw_nir_lower_cs_intrinsics(nir_shader *nir,
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) {
@@ -173,8 +178,5 @@ brw_nir_lower_cs_intrinsics(nir_shader *nir,
progress |= state.progress;
} while (state.progress);
- if (!state.cs_thread_id_used)
- state.prog_data->thread_local_id_index = -1;
-
return progress;
}