}
/* CS textures may not have return_size reflecting the shadow state. */
- nir_foreach_variable(var, &c->s->uniforms) {
+ nir_foreach_uniform_variable(var, c->s) {
const struct glsl_type *type = glsl_without_array(var->type);
unsigned array_len = MAX2(glsl_get_length(var->type), 1);
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;
#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)
{
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.
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);
return;
int binding = 0;
- nir_foreach_variable(var, &shader->uniforms) {
+ nir_foreach_uniform_variable(var, shader) {
if (glsl_type_is_sampler(var->type)) {
if (var->data.binding >= binding)
binding = var->data.binding + 1;
std::vector<bool> lower_sampler(shader->uniforms.length(), false);
auto is = lower_sampler.begin();
- nir_foreach_variable(var, &shader->uniforms) {
+ nir_foreach_uniform_variable(var, shader) {
if (var->type->is_sampler()) {
if (glsl_base_type_is_integer(var->type->sampled_type)) {
need_lowering = *is = true;
}
}
- nir_foreach_variable(var, &shader->uniforms) {
+ nir_foreach_uniform_variable(var, shader) {
const struct glsl_type *glsl_type = glsl_without_array(var->type);
if (!glsl_type_is_image(glsl_type))
* too late. At that point, the values for the built-in uniforms won't
* get sent to the shader.
*/
- nir_foreach_variable(var, &prog->nir->uniforms) {
+ nir_foreach_uniform_variable(var, prog->nir) {
const nir_state_slot *const slots = var->state_slots;
for (unsigned int i = 0; i < var->num_state_slots; i++) {
assert(slots != NULL);
stage_prog_data->nr_params = nr_params;
stage_prog_data->param = rzalloc_array(mem_ctx, uint32_t, nr_params);
- nir_foreach_variable(var, &shader->uniforms) {
+ nir_foreach_uniform_variable(var, shader) {
/* UBO's, atomics and samplers don't take up space in the
uniform file */
if (var->interface_type != NULL || var->type->contains_atomic())
const struct gl_program *prog)
{
/* We put image uniforms at the end */
- nir_foreach_variable(var, &shader->uniforms) {
+ nir_foreach_uniform_variable(var, shader) {
if (!var->type->contains_image())
continue;
static void
st_nir_assign_uniform_locations(struct gl_context *ctx,
struct gl_program *prog,
- struct exec_list *uniform_list)
+ nir_shader *nir)
{
int shaderidx = 0;
int imageidx = 0;
- nir_foreach_variable(uniform, uniform_list) {
+ nir_foreach_uniform_variable(uniform, nir) {
int loc;
- /*
- * UBO's have their own address spaces, so don't count them towards the
- * number of global uniforms
- */
- if (uniform->data.mode == nir_var_mem_ubo || uniform->data.mode == nir_var_mem_ssbo)
- continue;
-
const struct glsl_type *type = glsl_without_array(uniform->type);
if (!uniform->data.bindless && (type->is_sampler() || type->is_image())) {
if (type->is_sampler()) {
* too late. At that point, the values for the built-in uniforms won't
* get sent to the shader.
*/
- nir_foreach_variable(var, &nir->uniforms) {
+ nir_foreach_uniform_variable(var, nir) {
const nir_state_slot *const slots = var->state_slots;
if (slots != NULL) {
const struct glsl_type *type = glsl_without_array(var->type);
NIR_PASS_V(nir, nir_lower_var_copies);
st_nir_assign_varying_locations(st, nir);
- st_nir_assign_uniform_locations(st->ctx, prog,
- &nir->uniforms);
+ st_nir_assign_uniform_locations(st->ctx, prog, nir);
/* Set num_uniforms in number of attribute slots (vec4s) */
nir->num_uniforms = DIV_ROUND_UP(prog->Parameters->NumParameterValues, 4);
char *name = _mesa_program_state_string(tokens);
- nir_foreach_variable(var, &shader->uniforms) {
+ nir_foreach_uniform_variable(var, shader) {
if (strcmp(var->name, name) == 0) {
free(name);
return var;
find_sampler(lower_tex_src_state *state, unsigned samp)
{
/* NOTE: arrays of samplerExternalOES do not appear to be allowed: */
- nir_foreach_variable(var, &state->shader->uniforms)
+ nir_foreach_uniform_variable(var, state->shader)
if (var->data.binding == samp)
return var;
return NULL;