nir: Add a nir_foreach_uniform_variable helper
This one's a bit more complex because it filters off only those variables with mode == nir_var_uniform. As such, it's not exactly a drop-in replacement for nir_foreach_variable(var, &nir->uniforms). 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
92dcda5ce9
commit
feb32f898c
@@ -148,7 +148,7 @@ find_active_atomic_counters(struct gl_context *ctx,
|
||||
|
||||
nir_shader *nir = sh->Program->nir;
|
||||
|
||||
nir_foreach_variable(var, &nir->uniforms) {
|
||||
nir_foreach_uniform_variable(var, nir) {
|
||||
if (!glsl_contains_atomic(var->type))
|
||||
continue;
|
||||
|
||||
|
@@ -636,6 +636,14 @@ typedef struct nir_variable {
|
||||
#define nir_foreach_shader_out_variable_safe(var, shader) \
|
||||
nir_foreach_variable_safe(var, &(shader)->outputs)
|
||||
|
||||
#define nir_foreach_uniform_variable(var, shader) \
|
||||
nir_foreach_variable(var, &(shader)->uniforms) \
|
||||
if (var->data.mode == nir_var_uniform)
|
||||
|
||||
#define nir_foreach_uniform_variable_safe(var, shader) \
|
||||
nir_foreach_variable_safe(var, &(shader)->uniforms) \
|
||||
if (var->data.mode == nir_var_uniform)
|
||||
|
||||
static inline bool
|
||||
nir_variable_is_global(const nir_variable *var)
|
||||
{
|
||||
|
@@ -601,7 +601,7 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
|
||||
shader->info.image_buffers = 0;
|
||||
shader->info.msaa_images = 0;
|
||||
|
||||
nir_foreach_variable(var, &shader->uniforms) {
|
||||
nir_foreach_uniform_variable(var, shader) {
|
||||
/* Bindless textures and images don't use non-bindless slots.
|
||||
* Interface blocks imply inputs, outputs, UBO, or SSBO, which can only
|
||||
* mean bindless.
|
||||
|
@@ -188,7 +188,7 @@ nir_lower_atomics_to_ssbo(nir_shader *shader)
|
||||
if (progress) {
|
||||
/* replace atomic_uint uniforms with ssbo's: */
|
||||
unsigned replaced = 0;
|
||||
nir_foreach_variable_safe(var, &shader->uniforms) {
|
||||
nir_foreach_uniform_variable_safe(var, shader) {
|
||||
if (is_atomic_uint(var->type)) {
|
||||
exec_node_remove(&var->node);
|
||||
|
||||
|
Reference in New Issue
Block a user