nir: Split nir_index_vars into two functions
We also very slightly change the semantics. It no longer is one index per list for global variables and is a single index over-all. Reviewed-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
This commit is contained in:

committed by
Marge Bot

parent
86c9303814
commit
3be0be7d54
@@ -1821,36 +1821,43 @@ nir_index_instrs(nir_function_impl *impl)
|
||||
}
|
||||
|
||||
static void
|
||||
index_var_list(struct exec_list *list)
|
||||
index_var_list(struct exec_list *list, unsigned *count)
|
||||
{
|
||||
unsigned next_index = 0;
|
||||
nir_foreach_variable(var, list)
|
||||
var->index = next_index++;
|
||||
var->index = (*count)++;
|
||||
}
|
||||
|
||||
void
|
||||
nir_index_vars(nir_shader *shader, nir_function_impl *impl, nir_variable_mode modes)
|
||||
unsigned
|
||||
nir_shader_index_vars(nir_shader *shader, nir_variable_mode modes)
|
||||
{
|
||||
if ((modes & nir_var_function_temp) && impl)
|
||||
index_var_list(&impl->locals);
|
||||
|
||||
unsigned count = 0;
|
||||
if (modes & nir_var_shader_temp)
|
||||
index_var_list(&shader->globals);
|
||||
index_var_list(&shader->globals, &count);
|
||||
|
||||
if (modes & nir_var_shader_in)
|
||||
index_var_list(&shader->inputs);
|
||||
index_var_list(&shader->inputs, &count);
|
||||
|
||||
if (modes & nir_var_shader_out)
|
||||
index_var_list(&shader->outputs);
|
||||
index_var_list(&shader->outputs, &count);
|
||||
|
||||
if (modes & (nir_var_uniform | nir_var_mem_ubo | nir_var_mem_ssbo))
|
||||
index_var_list(&shader->uniforms);
|
||||
index_var_list(&shader->uniforms, &count);
|
||||
|
||||
if (modes & nir_var_mem_shared)
|
||||
index_var_list(&shader->shared);
|
||||
index_var_list(&shader->shared, &count);
|
||||
|
||||
if (modes & nir_var_system_value)
|
||||
index_var_list(&shader->system_values);
|
||||
index_var_list(&shader->system_values, &count);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
unsigned
|
||||
nir_function_impl_index_vars(nir_function_impl *impl)
|
||||
{
|
||||
unsigned count = 0;
|
||||
index_var_list(&impl->locals, &count);
|
||||
return count;
|
||||
}
|
||||
|
||||
static nir_instr *
|
||||
|
@@ -3737,7 +3737,8 @@ unsigned nir_index_instrs(nir_function_impl *impl);
|
||||
|
||||
void nir_index_blocks(nir_function_impl *impl);
|
||||
|
||||
void nir_index_vars(nir_shader *shader, nir_function_impl *impl, nir_variable_mode modes);
|
||||
unsigned nir_shader_index_vars(nir_shader *shader, nir_variable_mode modes);
|
||||
unsigned nir_function_impl_index_vars(nir_function_impl *impl);
|
||||
|
||||
void nir_print_shader(nir_shader *shader, FILE *fp);
|
||||
void nir_print_shader_annotated(nir_shader *shader, FILE *fp, struct hash_table *errors);
|
||||
|
@@ -176,8 +176,7 @@ nir_opt_large_constants(nir_shader *shader,
|
||||
/* This pass can only be run once */
|
||||
assert(shader->constant_data == NULL && shader->constant_data_size == 0);
|
||||
|
||||
unsigned num_locals = exec_list_length(&impl->locals);
|
||||
nir_index_vars(shader, impl, nir_var_function_temp);
|
||||
unsigned num_locals = nir_function_impl_index_vars(impl);
|
||||
|
||||
if (num_locals == 0) {
|
||||
nir_shader_preserve_all_metadata(shader);
|
||||
|
@@ -1359,12 +1359,12 @@ nir_opt_load_store_vectorize(nir_shader *shader, nir_variable_mode modes,
|
||||
ctx->callback = callback;
|
||||
ctx->robust_modes = robust_modes;
|
||||
|
||||
nir_index_vars(shader, NULL, modes);
|
||||
nir_shader_index_vars(shader, modes);
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
if (modes & nir_var_function_temp)
|
||||
nir_index_vars(shader, function->impl, nir_var_function_temp);
|
||||
nir_function_impl_index_vars(function->impl);
|
||||
|
||||
nir_foreach_block(block, function->impl)
|
||||
progress |= process_block(function->impl, ctx, block);
|
||||
|
Reference in New Issue
Block a user