[Mesa-dev] [PATCH 23/23] mesa: Handle binding of uniforms to image units with glUniform*().
Francisco Jerez
currojerez at riseup.net
Tue Nov 26 00:08:34 PST 2013
---
src/mesa/main/uniform_query.cpp | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 88ad476..fec45be 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -686,6 +686,9 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
case GLSL_TYPE_SAMPLER:
match = (basicType == GLSL_TYPE_INT);
break;
+ case GLSL_TYPE_IMAGE:
+ match = (type == GL_INT);
+ break;
default:
match = (basicType == uni->type->base_type);
break;
@@ -735,6 +738,22 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
}
}
+ if (uni->type->is_image()) {
+ int i;
+
+ for (i = 0; i < count; i++) {
+ const int unit = ((GLint *) values)[i];
+
+ /* check that the image unit is legal */
+ if (unit < 0 || unit >= (int)ctx->Const.MaxImageUnits) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glUniform1i(invalid image unit index for uniform %d)",
+ location);
+ return;
+ }
+ }
+ }
+
/* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says:
*
* "When loading N elements starting at an arbitrary position k in a
@@ -830,6 +849,23 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
}
}
}
+
+ /* If the uniform is an image, update the mapping from image
+ * uniforms to image units present in the shader data structure.
+ */
+ if (uni->type->is_image()) {
+ int i, j;
+
+ for (i = 0; i < MESA_SHADER_TYPES; i++) {
+ if (uni->image[i].active) {
+ struct gl_shader *sh = shProg->_LinkedShaders[i];
+
+ for (j = 0; j < count; j++)
+ sh->ImageUnits[uni->image[i].index + offset + j] =
+ ((GLint *) values)[j];
+ }
+ }
+ }
}
/**
--
1.8.3.4
More information about the mesa-dev
mailing list