mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
mesa/st: Use lower_indirect_var_derefs in st_nir_lower_builtin
Instead of having a special NIR helper for GL stuff, we can now use the more generic helper and do so directly. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16482>
This commit is contained in:
parent
46a49df7b6
commit
5410f4ee89
4 changed files with 25 additions and 38 deletions
|
|
@ -4469,8 +4469,6 @@ bool nir_lower_indirect_derefs(nir_shader *shader, nir_variable_mode modes,
|
|||
bool nir_lower_indirect_var_derefs(nir_shader *shader,
|
||||
const struct set *vars);
|
||||
|
||||
bool nir_lower_indirect_builtin_uniform_derefs(nir_shader *shader);
|
||||
|
||||
bool nir_lower_locals_to_regs(nir_shader *shader);
|
||||
|
||||
void nir_lower_io_to_temporaries(nir_shader *shader,
|
||||
|
|
|
|||
|
|
@ -244,27 +244,3 @@ nir_lower_indirect_var_derefs(nir_shader *shader, const struct set *vars)
|
|||
|
||||
return progress;
|
||||
}
|
||||
|
||||
/** Lowers indirect variable loads/stores to direct loads/stores.
|
||||
*
|
||||
* The pass works by replacing any indirect load or store with an if-ladder
|
||||
* that does a binary search on the array index. It only changes uniform variable builtins,
|
||||
* e.g., gl_LightSource
|
||||
*/
|
||||
bool
|
||||
nir_lower_indirect_builtin_uniform_derefs(nir_shader *shader)
|
||||
{
|
||||
struct set *vars = _mesa_pointer_set_create(NULL);
|
||||
|
||||
nir_foreach_uniform_variable(var, shader) {
|
||||
/* built-in's will always start with "gl_" */
|
||||
if (strncmp(var->name, "gl_", 3) == 0)
|
||||
_mesa_set_add(vars, var);
|
||||
}
|
||||
|
||||
bool progress = nir_lower_indirect_var_derefs(shader, vars);
|
||||
|
||||
_mesa_set_destroy(vars, NULL);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -481,15 +481,8 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
|
|||
* storage don't need to lower builtins.
|
||||
*/
|
||||
if (!shader_program->data->spirv &&
|
||||
!st->ctx->Const.PackedDriverUniformStorage) {
|
||||
/* at this point, array uniforms have been split into separate
|
||||
* nir_variable structs where possible. this codepath can't handle dynamic
|
||||
* array indexing, however, so all indirect uniform derefs
|
||||
* must be eliminated beforehand to avoid trying to lower one of those builtins
|
||||
*/
|
||||
NIR_PASS_V(nir, nir_lower_indirect_builtin_uniform_derefs);
|
||||
!st->ctx->Const.PackedDriverUniformStorage)
|
||||
NIR_PASS_V(nir, st_nir_lower_builtin);
|
||||
}
|
||||
|
||||
if (!screen->get_param(screen, PIPE_CAP_NIR_ATOMICS_AS_DEREF))
|
||||
NIR_PASS_V(nir, gl_nir_lower_atomics, shader_program, true);
|
||||
|
|
|
|||
|
|
@ -232,8 +232,28 @@ lower_builtin_instr(nir_builder *b, nir_instr *instr, UNUSED void *_data)
|
|||
void
|
||||
st_nir_lower_builtin(nir_shader *shader)
|
||||
{
|
||||
if (nir_shader_instructions_pass(shader, lower_builtin_instr,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance, NULL))
|
||||
nir_remove_dead_derefs(shader);
|
||||
struct set *vars = _mesa_pointer_set_create(NULL);
|
||||
|
||||
nir_foreach_uniform_variable(var, shader) {
|
||||
/* built-in's will always start with "gl_" */
|
||||
if (strncmp(var->name, "gl_", 3) == 0)
|
||||
_mesa_set_add(vars, var);
|
||||
}
|
||||
|
||||
if (vars->entries > 0) {
|
||||
/* at this point, array uniforms have been split into separate
|
||||
* nir_variable structs where possible. this codepath can't handle
|
||||
* dynamic array indexing, however, so all indirect uniform derefs must
|
||||
* be eliminated beforehand to avoid trying to lower one of those
|
||||
* builtins
|
||||
*/
|
||||
nir_lower_indirect_var_derefs(shader, vars);
|
||||
|
||||
if (nir_shader_instructions_pass(shader, lower_builtin_instr,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance, NULL))
|
||||
nir_remove_dead_derefs(shader);
|
||||
}
|
||||
|
||||
_mesa_set_destroy(vars, NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue