mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 17:20:10 +01:00
i965: Make add_const_offset_to_base() work at the shader level.
This makes it a pass, hiding the parameter structs and block callbacks so it's simpler to work with. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
824d82025d
commit
a3500f943e
1 changed files with 21 additions and 17 deletions
|
|
@ -60,7 +60,7 @@ struct add_const_offset_to_base_params {
|
|||
};
|
||||
|
||||
static bool
|
||||
add_const_offset_to_base(nir_block *block, void *closure)
|
||||
add_const_offset_to_base_block(nir_block *block, void *closure)
|
||||
{
|
||||
struct add_const_offset_to_base_params *params = closure;
|
||||
nir_builder *b = ¶ms->b;
|
||||
|
|
@ -85,7 +85,19 @@ add_const_offset_to_base(nir_block *block, void *closure)
|
|||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
add_const_offset_to_base(nir_shader *nir, nir_variable_mode mode)
|
||||
{
|
||||
struct add_const_offset_to_base_params params = { .mode = mode };
|
||||
|
||||
nir_foreach_function(nir, f) {
|
||||
if (f->impl) {
|
||||
nir_builder_init(¶ms.b, f->impl);
|
||||
nir_foreach_block(f->impl, add_const_offset_to_base_block, ¶ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -195,10 +207,6 @@ brw_nir_lower_inputs(nir_shader *nir,
|
|||
const struct brw_device_info *devinfo,
|
||||
bool is_scalar)
|
||||
{
|
||||
struct add_const_offset_to_base_params params = {
|
||||
.mode = nir_var_shader_in
|
||||
};
|
||||
|
||||
switch (nir->stage) {
|
||||
case MESA_SHADER_VERTEX:
|
||||
/* Start with the location of the variable's base. */
|
||||
|
|
@ -224,10 +232,10 @@ brw_nir_lower_inputs(nir_shader *nir,
|
|||
/* This pass needs actual constants */
|
||||
nir_opt_constant_folding(nir);
|
||||
|
||||
add_const_offset_to_base(nir, nir_var_shader_in);
|
||||
|
||||
nir_foreach_function(nir, function) {
|
||||
if (function->impl) {
|
||||
nir_builder_init(¶ms.b, function->impl);
|
||||
nir_foreach_block(function->impl, add_const_offset_to_base, ¶ms);
|
||||
nir_foreach_block(function->impl, remap_vs_attrs, &inputs_read);
|
||||
}
|
||||
}
|
||||
|
|
@ -270,10 +278,10 @@ brw_nir_lower_inputs(nir_shader *nir,
|
|||
/* This pass needs actual constants */
|
||||
nir_opt_constant_folding(nir);
|
||||
|
||||
add_const_offset_to_base(nir, nir_var_shader_in);
|
||||
|
||||
nir_foreach_function(nir, function) {
|
||||
if (function->impl) {
|
||||
nir_builder_init(¶ms.b, function->impl);
|
||||
nir_foreach_block(function->impl, add_const_offset_to_base, ¶ms);
|
||||
nir_foreach_block(function->impl, remap_inputs_with_vue_map,
|
||||
&input_vue_map);
|
||||
}
|
||||
|
|
@ -296,10 +304,10 @@ brw_nir_lower_inputs(nir_shader *nir,
|
|||
/* This pass needs actual constants */
|
||||
nir_opt_constant_folding(nir);
|
||||
|
||||
add_const_offset_to_base(nir, nir_var_shader_in);
|
||||
|
||||
nir_foreach_function(nir, function) {
|
||||
if (function->impl) {
|
||||
nir_builder_init(¶ms.b, function->impl);
|
||||
nir_foreach_block(function->impl, add_const_offset_to_base, ¶ms);
|
||||
nir_builder_init(&state.b, function->impl);
|
||||
nir_foreach_block(function->impl, remap_patch_urb_offsets, &state);
|
||||
}
|
||||
|
|
@ -339,10 +347,6 @@ brw_nir_lower_outputs(nir_shader *nir,
|
|||
}
|
||||
break;
|
||||
case MESA_SHADER_TESS_CTRL: {
|
||||
struct add_const_offset_to_base_params params = {
|
||||
.mode = nir_var_shader_out
|
||||
};
|
||||
|
||||
struct remap_patch_urb_offsets_state state;
|
||||
brw_compute_tess_vue_map(&state.vue_map, nir->info.outputs_written,
|
||||
nir->info.patch_outputs_written);
|
||||
|
|
@ -356,10 +360,10 @@ brw_nir_lower_outputs(nir_shader *nir,
|
|||
/* This pass needs actual constants */
|
||||
nir_opt_constant_folding(nir);
|
||||
|
||||
add_const_offset_to_base(nir, nir_var_shader_out);
|
||||
|
||||
nir_foreach_function(nir, function) {
|
||||
if (function->impl) {
|
||||
nir_builder_init(¶ms.b, function->impl);
|
||||
nir_foreach_block(function->impl, add_const_offset_to_base, ¶ms);
|
||||
nir_builder_init(&state.b, function->impl);
|
||||
nir_foreach_block(function->impl, remap_patch_urb_offsets, &state);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue