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
|
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)
|
nir_foreach_variable(var, list)
|
||||||
var->index = next_index++;
|
var->index = (*count)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
unsigned
|
||||||
nir_index_vars(nir_shader *shader, nir_function_impl *impl, nir_variable_mode modes)
|
nir_shader_index_vars(nir_shader *shader, nir_variable_mode modes)
|
||||||
{
|
{
|
||||||
if ((modes & nir_var_function_temp) && impl)
|
unsigned count = 0;
|
||||||
index_var_list(&impl->locals);
|
|
||||||
|
|
||||||
if (modes & nir_var_shader_temp)
|
if (modes & nir_var_shader_temp)
|
||||||
index_var_list(&shader->globals);
|
index_var_list(&shader->globals, &count);
|
||||||
|
|
||||||
if (modes & nir_var_shader_in)
|
if (modes & nir_var_shader_in)
|
||||||
index_var_list(&shader->inputs);
|
index_var_list(&shader->inputs, &count);
|
||||||
|
|
||||||
if (modes & nir_var_shader_out)
|
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))
|
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)
|
if (modes & nir_var_mem_shared)
|
||||||
index_var_list(&shader->shared);
|
index_var_list(&shader->shared, &count);
|
||||||
|
|
||||||
if (modes & nir_var_system_value)
|
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 *
|
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_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(nir_shader *shader, FILE *fp);
|
||||||
void nir_print_shader_annotated(nir_shader *shader, FILE *fp, struct hash_table *errors);
|
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 */
|
/* This pass can only be run once */
|
||||||
assert(shader->constant_data == NULL && shader->constant_data_size == 0);
|
assert(shader->constant_data == NULL && shader->constant_data_size == 0);
|
||||||
|
|
||||||
unsigned num_locals = exec_list_length(&impl->locals);
|
unsigned num_locals = nir_function_impl_index_vars(impl);
|
||||||
nir_index_vars(shader, impl, nir_var_function_temp);
|
|
||||||
|
|
||||||
if (num_locals == 0) {
|
if (num_locals == 0) {
|
||||||
nir_shader_preserve_all_metadata(shader);
|
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->callback = callback;
|
||||||
ctx->robust_modes = robust_modes;
|
ctx->robust_modes = robust_modes;
|
||||||
|
|
||||||
nir_index_vars(shader, NULL, modes);
|
nir_shader_index_vars(shader, modes);
|
||||||
|
|
||||||
nir_foreach_function(function, shader) {
|
nir_foreach_function(function, shader) {
|
||||||
if (function->impl) {
|
if (function->impl) {
|
||||||
if (modes & nir_var_function_temp)
|
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)
|
nir_foreach_block(block, function->impl)
|
||||||
progress |= process_block(function->impl, ctx, block);
|
progress |= process_block(function->impl, ctx, block);
|
||||||
|
Reference in New Issue
Block a user