diff options
author | Jason Ekstrand <[email protected]> | 2017-10-06 10:08:11 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-10-12 22:39:30 -0700 |
commit | b1d1b7222acfe45e447d1708d60b3ff98ca5a9a7 (patch) | |
tree | c6ecf720d2fb8a15238bb8f1e02596b5d2df1762 /src/intel/compiler | |
parent | 2db9470d88bb4856152465f44fa090f1a1bbf039 (diff) |
intel/compiler: Make brw_nir_lower_intrinsics compute-specific
It's already only ever called from brw_compile_cs and only handles
compute intrinsics. Let's just make it CS-specific. We can always
make it handle other stages again later if we want.
Reviewed-by: Jordan Justen <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/intel/compiler')
-rw-r--r-- | src/intel/compiler/brw_fs.cpp | 2 | ||||
-rw-r--r-- | src/intel/compiler/brw_nir.h | 4 | ||||
-rw-r--r-- | src/intel/compiler/brw_nir_lower_cs_intrinsics.c (renamed from src/intel/compiler/brw_nir_intrinsics.c) | 22 | ||||
-rw-r--r-- | src/intel/compiler/meson.build | 2 |
4 files changed, 12 insertions, 18 deletions
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 6f5f21ddcdf..371df710554 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -6766,7 +6766,7 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data, MAX2(shader->num_uniforms, (unsigned)4 * (prog_data->thread_local_id_index + 1)); - brw_nir_lower_intrinsics(shader, &prog_data->base); + brw_nir_lower_cs_intrinsics(shader, prog_data); shader = brw_postprocess_nir(shader, compiler, true); prog_data->local_size[0] = shader->info.cs.local_size[0]; diff --git a/src/intel/compiler/brw_nir.h b/src/intel/compiler/brw_nir.h index f4b13b18c34..6f64a731cac 100644 --- a/src/intel/compiler/brw_nir.h +++ b/src/intel/compiler/brw_nir.h @@ -95,8 +95,8 @@ void brw_nir_analyze_boolean_resolves(nir_shader *nir); nir_shader *brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir); -bool brw_nir_lower_intrinsics(nir_shader *nir, - struct brw_stage_prog_data *prog_data); +bool brw_nir_lower_cs_intrinsics(nir_shader *nir, + struct brw_cs_prog_data *prog_data); void brw_nir_lower_vs_inputs(nir_shader *nir, bool use_legacy_snorm_formula, const uint8_t *vs_attrib_wa_flags); diff --git a/src/intel/compiler/brw_nir_intrinsics.c b/src/intel/compiler/brw_nir_lower_cs_intrinsics.c index abbbc6f93ec..602ef2e1749 100644 --- a/src/intel/compiler/brw_nir_intrinsics.c +++ b/src/intel/compiler/brw_nir_lower_cs_intrinsics.c @@ -26,10 +26,7 @@ struct lower_intrinsics_state { nir_shader *nir; - union { - struct brw_stage_prog_data *prog_data; - struct brw_cs_prog_data *cs_prog_data; - }; + struct brw_cs_prog_data *prog_data; nir_function_impl *impl; bool progress; nir_builder builder; @@ -50,9 +47,9 @@ read_thread_local_id(struct lower_intrinsics_state *state) if (group_size <= 8) return nir_imm_int(b, 0); - assert(state->cs_prog_data->thread_local_id_index >= 0); + assert(state->prog_data->thread_local_id_index >= 0); state->cs_thread_id_used = true; - const int id_index = state->cs_prog_data->thread_local_id_index; + const int id_index = state->prog_data->thread_local_id_index; nir_intrinsic_instr *load = nir_intrinsic_instr_create(nir, nir_intrinsic_load_uniform); @@ -84,7 +81,6 @@ lower_cs_intrinsics_convert_block(struct lower_intrinsics_state *state, nir_ssa_def *sysval; switch (intrinsic->intrinsic) { case nir_intrinsic_load_local_invocation_index: { - assert(nir->stage == MESA_SHADER_COMPUTE); /* We construct the local invocation index from: * * gl_LocalInvocationIndex = @@ -97,7 +93,6 @@ lower_cs_intrinsics_convert_block(struct lower_intrinsics_state *state, } case nir_intrinsic_load_local_invocation_id: { - assert(nir->stage == MESA_SHADER_COMPUTE); /* We lower gl_LocalInvocationID from gl_LocalInvocationIndex based * on this formula: * @@ -156,11 +151,10 @@ lower_cs_intrinsics_convert_impl(struct lower_intrinsics_state *state) } bool -brw_nir_lower_intrinsics(nir_shader *nir, struct brw_stage_prog_data *prog_data) +brw_nir_lower_cs_intrinsics(nir_shader *nir, + struct brw_cs_prog_data *prog_data) { - /* Currently we only lower intrinsics for compute shaders */ - if (nir->stage != MESA_SHADER_COMPUTE) - return false; + assert(nir->stage == MESA_SHADER_COMPUTE); bool progress = false; struct lower_intrinsics_state state; @@ -179,8 +173,8 @@ brw_nir_lower_intrinsics(nir_shader *nir, struct brw_stage_prog_data *prog_data) progress |= state.progress; } while (state.progress); - if (nir->stage == MESA_SHADER_COMPUTE && !state.cs_thread_id_used) - state.cs_prog_data->thread_local_id_index = -1; + if (!state.cs_thread_id_used) + state.prog_data->thread_local_id_index = -1; return progress; } diff --git a/src/intel/compiler/meson.build b/src/intel/compiler/meson.build index 41c2f6ef1db..e29e1d39e2a 100644 --- a/src/intel/compiler/meson.build +++ b/src/intel/compiler/meson.build @@ -73,7 +73,7 @@ libintel_compiler_files = files( 'brw_nir_analyze_boolean_resolves.c', 'brw_nir_analyze_ubo_ranges.c', 'brw_nir_attribute_workarounds.c', - 'brw_nir_intrinsics.c', + 'brw_nir_lower_cs_intrinsics.c', 'brw_nir_opt_peephole_ffma.c', 'brw_nir_tcs_workarounds.c', 'brw_packed_float.c', |