mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-04 10:40:36 +01:00
nir: Prepare nir_lower_io_vars_to_temporaries() for optional PLS lowering
Rather than adding another boolean to optionally lower PLS vars, pass the types we want to lowers through a nir_variable_mode bitmask. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Eric R. Smith <eric.smith@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37110>
This commit is contained in:
parent
ab867cc3cd
commit
ea4d4d2a77
21 changed files with 50 additions and 38 deletions
|
|
@ -678,9 +678,10 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
|||
|
||||
if (nir->info.stage == MESA_SHADER_VERTEX || nir->info.stage == MESA_SHADER_GEOMETRY ||
|
||||
nir->info.stage == MESA_SHADER_FRAGMENT) {
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(nir), true, true);
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(nir),
|
||||
nir_var_shader_in | nir_var_shader_out);
|
||||
} else if (nir->info.stage == MESA_SHADER_TESS_EVAL) {
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(nir), true, false);
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(nir), nir_var_shader_out);
|
||||
}
|
||||
|
||||
NIR_PASS(_, nir, nir_split_var_copies);
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ hk_preprocess_nir_internal(struct vk_physical_device *vk_pdev, nir_shader *nir)
|
|||
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir), true, false);
|
||||
nir_shader_get_entrypoint(nir), nir_var_shader_out);
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_global_vars_to_local);
|
||||
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ preprocess_nir(nir_shader *nir)
|
|||
}
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir), true, false);
|
||||
nir_shader_get_entrypoint(nir), nir_var_shader_out);
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_system_values);
|
||||
|
||||
|
|
|
|||
|
|
@ -5171,7 +5171,7 @@ bool nir_lower_locals_to_regs(nir_shader *shader, uint8_t bool_bitsize);
|
|||
|
||||
bool nir_lower_io_vars_to_temporaries(nir_shader *shader,
|
||||
nir_function_impl *entrypoint,
|
||||
bool outputs, bool inputs);
|
||||
nir_variable_mode modes);
|
||||
|
||||
bool nir_lower_vars_to_scratch(nir_shader *shader,
|
||||
nir_variable_mode modes,
|
||||
|
|
|
|||
|
|
@ -1248,7 +1248,7 @@ nir_lower_io_passes(nir_shader *nir, bool renumber_vs_inputs)
|
|||
|
||||
if (lower_indirect_outputs) {
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir), true, false);
|
||||
nir_shader_get_entrypoint(nir), nir_var_shader_out);
|
||||
|
||||
/* We need to lower all the copy_deref's introduced by lower_io_to-
|
||||
* _temporaries before calling nir_lower_io.
|
||||
|
|
|
|||
|
|
@ -332,10 +332,14 @@ move_variables_to_list(nir_shader *shader, nir_variable_mode mode,
|
|||
|
||||
bool
|
||||
nir_lower_io_vars_to_temporaries(nir_shader *shader, nir_function_impl *entrypoint,
|
||||
bool outputs, bool inputs)
|
||||
nir_variable_mode modes)
|
||||
{
|
||||
ASSERTED const nir_variable_mode supported_modes =
|
||||
nir_var_shader_in | nir_var_shader_out;
|
||||
struct lower_io_state state;
|
||||
|
||||
assert(!(modes & ~supported_modes));
|
||||
|
||||
if (shader->info.stage != MESA_SHADER_VERTEX &&
|
||||
shader->info.stage != MESA_SHADER_TESS_EVAL &&
|
||||
shader->info.stage != MESA_SHADER_GEOMETRY &&
|
||||
|
|
@ -348,11 +352,11 @@ nir_lower_io_vars_to_temporaries(nir_shader *shader, nir_function_impl *entrypoi
|
|||
state.input_map = _mesa_pointer_hash_table_create(NULL);
|
||||
|
||||
exec_list_make_empty(&state.old_inputs);
|
||||
if (inputs)
|
||||
if (modes & nir_var_shader_in)
|
||||
move_variables_to_list(shader, nir_var_shader_in, &state.old_inputs);
|
||||
|
||||
exec_list_make_empty(&state.old_outputs);
|
||||
if (outputs)
|
||||
if (modes & nir_var_shader_out)
|
||||
move_variables_to_list(shader, nir_var_shader_out, &state.old_outputs);
|
||||
|
||||
exec_list_make_empty(&state.new_inputs);
|
||||
|
|
@ -374,10 +378,10 @@ nir_lower_io_vars_to_temporaries(nir_shader *shader, nir_function_impl *entrypoi
|
|||
}
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (inputs)
|
||||
if (modes & nir_var_shader_in)
|
||||
emit_input_copies_impl(&state, impl);
|
||||
|
||||
if (outputs)
|
||||
if (modes & nir_var_shader_out)
|
||||
emit_output_copies_impl(&state, impl);
|
||||
|
||||
nir_progress(true, impl, nir_metadata_control_flow);
|
||||
|
|
|
|||
|
|
@ -489,13 +489,19 @@ ir3_nir_lower_io_vars_to_temporaries(nir_shader *s)
|
|||
* stop doing that once we're sure all drivers are doing their own
|
||||
* indirect i/o lowering.
|
||||
*/
|
||||
bool lower_input = s->info.stage == MESA_SHADER_VERTEX ||
|
||||
s->info.stage == MESA_SHADER_FRAGMENT;
|
||||
bool lower_output = s->info.stage != MESA_SHADER_TESS_CTRL &&
|
||||
s->info.stage != MESA_SHADER_GEOMETRY;
|
||||
if (lower_input || lower_output) {
|
||||
nir_variable_mode lower_modes = 0;
|
||||
|
||||
if (s->info.stage == MESA_SHADER_VERTEX ||
|
||||
s->info.stage == MESA_SHADER_FRAGMENT)
|
||||
lower_modes |= nir_var_shader_in;
|
||||
|
||||
if (s->info.stage != MESA_SHADER_TESS_CTRL &&
|
||||
s->info.stage != MESA_SHADER_GEOMETRY)
|
||||
lower_modes |= nir_var_shader_out;
|
||||
|
||||
if (lower_modes) {
|
||||
NIR_PASS(_, s, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(s),
|
||||
lower_output, lower_input);
|
||||
lower_modes);
|
||||
|
||||
/* nir_lower_io_vars_to_temporaries() creates global variables and copy
|
||||
* instructions which need to be cleaned up.
|
||||
|
|
|
|||
|
|
@ -1181,7 +1181,7 @@ crocus_compile_vs(struct crocus_context *ice,
|
|||
/* Check if variables were found. */
|
||||
if (nir_lower_clip_vs(nir, (1 << key->nr_userclip_plane_consts) - 1,
|
||||
true, false, NULL)) {
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, true, false);
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, nir_var_shader_out);
|
||||
nir_lower_global_vars_to_local(nir);
|
||||
nir_lower_vars_to_ssa(nir);
|
||||
nir_shader_gather_info(nir, impl);
|
||||
|
|
@ -1541,7 +1541,7 @@ crocus_compile_tes(struct crocus_context *ice,
|
|||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
nir_lower_clip_vs(nir, (1 << key->nr_userclip_plane_consts) - 1, true,
|
||||
false, NULL);
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, true, false);
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, nir_var_shader_out);
|
||||
nir_lower_global_vars_to_local(nir);
|
||||
nir_lower_vars_to_ssa(nir);
|
||||
nir_shader_gather_info(nir, impl);
|
||||
|
|
@ -1684,7 +1684,7 @@ crocus_compile_gs(struct crocus_context *ice,
|
|||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
nir_lower_clip_gs(nir, (1 << key->nr_userclip_plane_consts) - 1, false,
|
||||
NULL);
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, true, false);
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, nir_var_shader_out);
|
||||
nir_lower_global_vars_to_local(nir);
|
||||
nir_lower_vars_to_ssa(nir);
|
||||
nir_shader_gather_info(nir, impl);
|
||||
|
|
|
|||
|
|
@ -1898,7 +1898,7 @@ iris_compile_vs(struct iris_screen *screen,
|
|||
/* Check if variables were found. */
|
||||
if (nir_lower_clip_vs(nir, (1 << key->vue.nr_userclip_plane_consts) - 1,
|
||||
true, false, NULL)) {
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, true, false);
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, nir_var_shader_out);
|
||||
nir_lower_global_vars_to_local(nir);
|
||||
nir_lower_vars_to_ssa(nir);
|
||||
nir_shader_gather_info(nir, impl);
|
||||
|
|
@ -2345,7 +2345,7 @@ iris_compile_tes(struct iris_screen *screen,
|
|||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
nir_lower_clip_vs(nir, (1 << key->vue.nr_userclip_plane_consts) - 1,
|
||||
true, false, NULL);
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, true, false);
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, nir_var_shader_out);
|
||||
nir_lower_global_vars_to_local(nir);
|
||||
nir_lower_vars_to_ssa(nir);
|
||||
nir_shader_gather_info(nir, impl);
|
||||
|
|
@ -2540,7 +2540,7 @@ iris_compile_gs(struct iris_screen *screen,
|
|||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
nir_lower_clip_gs(nir, (1 << key->vue.nr_userclip_plane_consts) - 1,
|
||||
false, NULL);
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, true, false);
|
||||
nir_lower_io_vars_to_temporaries(nir, impl, nir_var_shader_out);
|
||||
nir_lower_global_vars_to_local(nir);
|
||||
nir_lower_vars_to_ssa(nir);
|
||||
nir_shader_gather_info(nir, impl);
|
||||
|
|
|
|||
|
|
@ -3418,7 +3418,7 @@ Converter::run()
|
|||
|
||||
if (lowered) {
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, impl, true, false);
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, impl, nir_var_shader_out);
|
||||
NIR_PASS(_, nir, nir_lower_global_vars_to_local);
|
||||
NIR_PASS(_, nir, nv50_nir_lower_load_user_clip_plane, info);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -359,7 +359,8 @@ lvp_shader_lower(struct lvp_device *pdevice, nir_shader *nir, struct lvp_pipelin
|
|||
optimize(nir);
|
||||
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(nir), true, true);
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(nir),
|
||||
nir_var_shader_out | nir_var_shader_in);
|
||||
NIR_PASS(_, nir, nir_split_var_copies);
|
||||
NIR_PASS(_, nir, nir_lower_global_vars_to_local);
|
||||
|
||||
|
|
|
|||
|
|
@ -567,8 +567,7 @@ void pco_preprocess_nir(pco_ctx *ctx, nir_shader *nir)
|
|||
nir,
|
||||
nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir),
|
||||
true,
|
||||
true);
|
||||
nir_var_shader_out | nir_var_shader_in);
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_global_vars_to_local);
|
||||
NIR_PASS(_, nir, nir_split_var_copies);
|
||||
|
|
|
|||
|
|
@ -1660,7 +1660,7 @@ brw_nir_link_shaders(const struct brw_compiler *compiler,
|
|||
* those write-mask in output is handled by I/O lowering.
|
||||
*/
|
||||
NIR_PASS(_, producer, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(producer), true, false);
|
||||
nir_shader_get_entrypoint(producer), nir_var_shader_out);
|
||||
NIR_PASS(_, producer, nir_lower_global_vars_to_local);
|
||||
NIR_PASS(_, producer, nir_split_var_copies);
|
||||
NIR_PASS(_, producer, nir_lower_var_copies);
|
||||
|
|
|
|||
|
|
@ -1236,7 +1236,7 @@ elk_nir_link_shaders(const struct elk_compiler *compiler,
|
|||
* that we need to clean up.
|
||||
*/
|
||||
NIR_PASS(_, producer, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(producer), true, false);
|
||||
nir_shader_get_entrypoint(producer), nir_var_shader_out);
|
||||
NIR_PASS(_, producer, nir_lower_global_vars_to_local);
|
||||
NIR_PASS(_, producer, nir_split_var_copies);
|
||||
NIR_PASS(_, producer, nir_lower_var_copies);
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ anv_shader_preprocess_nir(struct vk_physical_device *device,
|
|||
const struct brw_compiler *compiler = pdevice->compiler;
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir), true, false);
|
||||
nir_shader_get_entrypoint(nir), nir_var_shader_out);
|
||||
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.point_coord = true,
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ anv_shader_stage_to_nir(struct anv_device *device,
|
|||
}
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir), true, false);
|
||||
nir_shader_get_entrypoint(nir), nir_var_shader_out);
|
||||
|
||||
const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = {
|
||||
.point_coord = true,
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ optimize(nir_shader *nir)
|
|||
nir_var_shader_in | nir_var_shader_out | nir_var_system_value,
|
||||
NULL);
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir), true, false);
|
||||
nir_shader_get_entrypoint(nir), nir_var_shader_out);
|
||||
nir_lower_compute_system_values_options options = {
|
||||
.has_base_global_invocation_id = 0,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ kk_preprocess_nir(UNUSED struct vk_physical_device *vk_pdev, nir_shader *nir,
|
|||
* jump, which is illegal.
|
||||
*/
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir), true, false);
|
||||
nir_shader_get_entrypoint(nir), nir_var_shader_out);
|
||||
|
||||
msl_preprocess_nir(nir);
|
||||
}
|
||||
|
|
@ -1279,4 +1279,4 @@ const struct vk_device_shader_ops kk_device_shader_ops = {
|
|||
.deserialize = kk_deserialize_shader,
|
||||
.cmd_set_dynamic_graphics_state = vk_cmd_set_dynamic_graphics_state,
|
||||
.cmd_bind_shaders = kk_cmd_bind_shaders,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1027,7 +1027,8 @@ dxil_spirv_nir_passes(nir_shader *nir,
|
|||
NIR_PASS(_, nir, dxil_nir_lower_int_cubemaps, false);
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_clip_cull_distance_array_vars);
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(nir), true, true);
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(nir),
|
||||
nir_var_shader_out | nir_var_shader_in);
|
||||
NIR_PASS(_, nir, nir_lower_global_vars_to_local);
|
||||
NIR_PASS(_, nir, nir_split_var_copies);
|
||||
NIR_PASS(_, nir, nir_lower_var_copies);
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ nak_preprocess_nir(nir_shader *nir, const struct nak_compiler *nak)
|
|||
|
||||
OPT(nir, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir),
|
||||
true /* outputs */, false /* inputs */);
|
||||
nir_var_shader_out);
|
||||
|
||||
const nir_lower_tex_options tex_options = {
|
||||
.lower_txd_3d = true,
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ panvk_preprocess_nir(struct vk_physical_device *vk_pdev,
|
|||
NIR_PASS(_, nir, nir_opt_vectorize_io_vars, nir_var_shader_out);
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir), true, false);
|
||||
nir_shader_get_entrypoint(nir), nir_var_shader_out);
|
||||
|
||||
#if PAN_ARCH < 9
|
||||
/* This needs to be done just after the io_to_temporaries pass, because we
|
||||
|
|
@ -798,7 +798,7 @@ panvk_lower_nir(struct panvk_device *dev, nir_shader *nir,
|
|||
/* Pull output writes out of the loop and give them constant offsets for
|
||||
* pan_lower_store_components */
|
||||
NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries,
|
||||
nir_shader_get_entrypoint(nir), true, false);
|
||||
nir_shader_get_entrypoint(nir), nir_var_shader_out);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue