mesa: Rearrange legal_texobj_target to look more like _mesa_legal_get_tex_level_param...
[mesa.git] / src / mesa / main / uniforms.c
index a9308d09f69afbbcd3c011fc4c55535e1dece1aa..3921644892c33aaf8c6ea51b816b25ec035d51ef 100644 (file)
@@ -46,6 +46,7 @@
 #include "compiler/glsl/ir_uniform.h"
 #include "compiler/glsl_types.h"
 #include "program/program.h"
+#include "util/bitscan.h"
 
 /**
  * Update the vertex/fragment program's TexturesUsed array.
@@ -66,8 +67,8 @@ void
 _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
                                  struct gl_program *prog)
 {
-   GLuint s;
-   struct gl_shader *shader =
+   GLbitfield mask = prog->SamplersUsed;
+   struct gl_linked_shader *shader =
       shProg->_LinkedShaders[_mesa_program_enum_to_shader_stage(prog->Target)];
 
    assert(shader);
@@ -77,26 +78,25 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
 
    shProg->SamplersValidated = GL_TRUE;
 
-   for (s = 0; s < MAX_SAMPLERS; s++) {
-      if (prog->SamplersUsed & (1 << s)) {
-         GLuint unit = shader->SamplerUnits[s];
-         GLuint tgt = shader->SamplerTargets[s];
-         assert(unit < ARRAY_SIZE(prog->TexturesUsed));
-         assert(tgt < NUM_TEXTURE_TARGETS);
-
-         /* The types of the samplers associated with a particular texture
-          * unit must be an exact match.  Page 74 (page 89 of the PDF) of the
-          * OpenGL 3.3 core spec says:
-          *
-          *     "It is not allowed to have variables of different sampler
-          *     types pointing to the same texture image unit within a program
-          *     object."
-          */
-         if (prog->TexturesUsed[unit] & ~(1 << tgt))
-            shProg->SamplersValidated = GL_FALSE;
-
-         prog->TexturesUsed[unit] |= (1 << tgt);
-      }
+   while (mask) {
+      const int s = u_bit_scan(&mask);
+      GLuint unit = shader->SamplerUnits[s];
+      GLuint tgt = shader->SamplerTargets[s];
+      assert(unit < ARRAY_SIZE(prog->TexturesUsed));
+      assert(tgt < NUM_TEXTURE_TARGETS);
+
+      /* The types of the samplers associated with a particular texture
+       * unit must be an exact match.  Page 74 (page 89 of the PDF) of the
+       * OpenGL 3.3 core spec says:
+       *
+       *     "It is not allowed to have variables of different sampler
+       *     types pointing to the same texture image unit within a program
+       *     object."
+       */
+      if (prog->TexturesUsed[unit] & ~(1 << tgt))
+         shProg->SamplersValidated = GL_FALSE;
+
+      prog->TexturesUsed[unit] |= (1 << tgt);
    }
 }
 
@@ -1144,6 +1144,12 @@ mesa_bufferiv(struct gl_shader_program *shProg, GLenum type,
                                   GL_REFERENCED_BY_FRAGMENT_SHADER, params,
                                   caller);
       return;
+   case GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER:
+   case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER:
+      _mesa_program_resource_prop(shProg, res, index,
+                                  GL_REFERENCED_BY_COMPUTE_SHADER, params,
+                                  caller);
+      return;
    default:
       _mesa_error(ctx, GL_INVALID_ENUM,
                   "%s(pname 0x%x (%s))", caller, pname,