nir_builder builder;
void *mem_ctx;
int (*type_size)(const struct glsl_type *type);
- nir_variable_mode mode;
+ nir_variable_mode modes;
};
void
}
static bool
-nir_lower_io_block(nir_block *block, void *void_state)
+nir_lower_io_block(nir_block *block,
+ struct lower_io_state *state)
{
- struct lower_io_state *state = void_state;
-
nir_builder *b = &state->builder;
nir_foreach_instr_safe(block, instr) {
nir_variable_mode mode = intrin->variables[0]->var->data.mode;
- if (state->mode != nir_var_all && state->mode != mode)
+ if ((state->modes & mode) == 0)
continue;
if (mode != nir_var_shader_in &&
intrin->variables[0]->var->data.driver_location);
if (load->intrinsic == nir_intrinsic_load_uniform) {
- load->const_index[1] =
- state->type_size(intrin->variables[0]->var->type);
+ nir_intrinsic_set_range(load,
+ state->type_size(intrin->variables[0]->var->type));
}
if (per_vertex)
static void
nir_lower_io_impl(nir_function_impl *impl,
- nir_variable_mode mode,
+ nir_variable_mode modes,
int (*type_size)(const struct glsl_type *))
{
struct lower_io_state state;
nir_builder_init(&state.builder, impl);
state.mem_ctx = ralloc_parent(impl);
- state.mode = mode;
+ state.modes = modes;
state.type_size = type_size;
- nir_foreach_block(impl, nir_lower_io_block, &state);
+ nir_foreach_block(block, impl) {
+ nir_lower_io_block(block, &state);
+ }
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
}
void
-nir_lower_io(nir_shader *shader, nir_variable_mode mode,
+nir_lower_io(nir_shader *shader, nir_variable_mode modes,
int (*type_size)(const struct glsl_type *))
{
nir_foreach_function(shader, function) {
if (function->impl)
- nir_lower_io_impl(function->impl, mode, type_size);
+ nir_lower_io_impl(function->impl, modes, type_size);
}
}