mesa: unify _mesa_uniform() for image uniforms
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 15 May 2017 10:55:05 +0000 (12:55 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 16 May 2017 07:33:04 +0000 (09:33 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/main/uniform_query.cpp

index 979bd0dc461cd347be2669c67ba1fc16b649e991..16e3fe3d527b7d705f3e50f7029fdf26b89f1f2b 100644 (file)
@@ -1018,13 +1018,15 @@ _mesa_uniform(GLint location, GLsizei count, const GLvoid *values,
     */
    if (uni->type->is_image()) {
       for (int i = 0; i < MESA_SHADER_STAGES; i++) {
-         if (uni->opaque[i].active) {
-            struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
+         struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
 
-            for (int j = 0; j < count; j++)
-               sh->Program->sh.ImageUnits[uni->opaque[i].index + offset + j] =
-                  ((GLint *) values)[j];
-         }
+         /* If the shader stage doesn't use the image uniform, skip this. */
+         if (!uni->opaque[i].active)
+            continue;
+
+         for (int j = 0; j < count; j++)
+            sh->Program->sh.ImageUnits[uni->opaque[i].index + offset + j] =
+               ((GLint *) values)[j];
       }
 
       ctx->NewDriverState |= ctx->DriverFlags.NewImageUnits;