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 <jordan.l.justen@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
2db9470d88
commit
b1d1b7222a
|
@ -75,7 +75,7 @@ COMPILER_FILES = \
|
||||||
compiler/brw_nir_analyze_boolean_resolves.c \
|
compiler/brw_nir_analyze_boolean_resolves.c \
|
||||||
compiler/brw_nir_analyze_ubo_ranges.c \
|
compiler/brw_nir_analyze_ubo_ranges.c \
|
||||||
compiler/brw_nir_attribute_workarounds.c \
|
compiler/brw_nir_attribute_workarounds.c \
|
||||||
compiler/brw_nir_intrinsics.c \
|
compiler/brw_nir_lower_cs_intrinsics.c \
|
||||||
compiler/brw_nir_opt_peephole_ffma.c \
|
compiler/brw_nir_opt_peephole_ffma.c \
|
||||||
compiler/brw_nir_tcs_workarounds.c \
|
compiler/brw_nir_tcs_workarounds.c \
|
||||||
compiler/brw_packed_float.c \
|
compiler/brw_packed_float.c \
|
||||||
|
|
|
@ -6766,7 +6766,7 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data,
|
||||||
MAX2(shader->num_uniforms,
|
MAX2(shader->num_uniforms,
|
||||||
(unsigned)4 * (prog_data->thread_local_id_index + 1));
|
(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);
|
shader = brw_postprocess_nir(shader, compiler, true);
|
||||||
|
|
||||||
prog_data->local_size[0] = shader->info.cs.local_size[0];
|
prog_data->local_size[0] = shader->info.cs.local_size[0];
|
||||||
|
|
|
@ -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 *brw_preprocess_nir(const struct brw_compiler *compiler,
|
||||||
nir_shader *nir);
|
nir_shader *nir);
|
||||||
|
|
||||||
bool brw_nir_lower_intrinsics(nir_shader *nir,
|
bool brw_nir_lower_cs_intrinsics(nir_shader *nir,
|
||||||
struct brw_stage_prog_data *prog_data);
|
struct brw_cs_prog_data *prog_data);
|
||||||
void brw_nir_lower_vs_inputs(nir_shader *nir,
|
void brw_nir_lower_vs_inputs(nir_shader *nir,
|
||||||
bool use_legacy_snorm_formula,
|
bool use_legacy_snorm_formula,
|
||||||
const uint8_t *vs_attrib_wa_flags);
|
const uint8_t *vs_attrib_wa_flags);
|
||||||
|
|
|
@ -26,10 +26,7 @@
|
||||||
|
|
||||||
struct lower_intrinsics_state {
|
struct lower_intrinsics_state {
|
||||||
nir_shader *nir;
|
nir_shader *nir;
|
||||||
union {
|
struct brw_cs_prog_data *prog_data;
|
||||||
struct brw_stage_prog_data *prog_data;
|
|
||||||
struct brw_cs_prog_data *cs_prog_data;
|
|
||||||
};
|
|
||||||
nir_function_impl *impl;
|
nir_function_impl *impl;
|
||||||
bool progress;
|
bool progress;
|
||||||
nir_builder builder;
|
nir_builder builder;
|
||||||
|
@ -50,9 +47,9 @@ read_thread_local_id(struct lower_intrinsics_state *state)
|
||||||
if (group_size <= 8)
|
if (group_size <= 8)
|
||||||
return nir_imm_int(b, 0);
|
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;
|
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 *load =
|
||||||
nir_intrinsic_instr_create(nir, nir_intrinsic_load_uniform);
|
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;
|
nir_ssa_def *sysval;
|
||||||
switch (intrinsic->intrinsic) {
|
switch (intrinsic->intrinsic) {
|
||||||
case nir_intrinsic_load_local_invocation_index: {
|
case nir_intrinsic_load_local_invocation_index: {
|
||||||
assert(nir->stage == MESA_SHADER_COMPUTE);
|
|
||||||
/* We construct the local invocation index from:
|
/* We construct the local invocation index from:
|
||||||
*
|
*
|
||||||
* gl_LocalInvocationIndex =
|
* gl_LocalInvocationIndex =
|
||||||
|
@ -97,7 +93,6 @@ lower_cs_intrinsics_convert_block(struct lower_intrinsics_state *state,
|
||||||
}
|
}
|
||||||
|
|
||||||
case nir_intrinsic_load_local_invocation_id: {
|
case nir_intrinsic_load_local_invocation_id: {
|
||||||
assert(nir->stage == MESA_SHADER_COMPUTE);
|
|
||||||
/* We lower gl_LocalInvocationID from gl_LocalInvocationIndex based
|
/* We lower gl_LocalInvocationID from gl_LocalInvocationIndex based
|
||||||
* on this formula:
|
* on this formula:
|
||||||
*
|
*
|
||||||
|
@ -156,11 +151,10 @@ lower_cs_intrinsics_convert_impl(struct lower_intrinsics_state *state)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
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 */
|
assert(nir->stage == MESA_SHADER_COMPUTE);
|
||||||
if (nir->stage != MESA_SHADER_COMPUTE)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
bool progress = false;
|
bool progress = false;
|
||||||
struct lower_intrinsics_state state;
|
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;
|
progress |= state.progress;
|
||||||
} while (state.progress);
|
} while (state.progress);
|
||||||
|
|
||||||
if (nir->stage == MESA_SHADER_COMPUTE && !state.cs_thread_id_used)
|
if (!state.cs_thread_id_used)
|
||||||
state.cs_prog_data->thread_local_id_index = -1;
|
state.prog_data->thread_local_id_index = -1;
|
||||||
|
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
|
@ -73,7 +73,7 @@ libintel_compiler_files = files(
|
||||||
'brw_nir_analyze_boolean_resolves.c',
|
'brw_nir_analyze_boolean_resolves.c',
|
||||||
'brw_nir_analyze_ubo_ranges.c',
|
'brw_nir_analyze_ubo_ranges.c',
|
||||||
'brw_nir_attribute_workarounds.c',
|
'brw_nir_attribute_workarounds.c',
|
||||||
'brw_nir_intrinsics.c',
|
'brw_nir_lower_cs_intrinsics.c',
|
||||||
'brw_nir_opt_peephole_ffma.c',
|
'brw_nir_opt_peephole_ffma.c',
|
||||||
'brw_nir_tcs_workarounds.c',
|
'brw_nir_tcs_workarounds.c',
|
||||||
'brw_packed_float.c',
|
'brw_packed_float.c',
|
||||||
|
|
Loading…
Reference in New Issue