aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/linker.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-11-17 16:46:41 +0100
committermarha <marha@users.sourceforge.net>2011-11-17 16:46:41 +0100
commit97fb1dadc6c52adeba0ac0684129520288ab794f (patch)
tree6a3b54bec00abec5b571087dd001a33d62bf488c /mesalib/src/glsl/linker.cpp
parentb99cdb7509cad0b99761d19fe99637177913412b (diff)
parentd41bc08d1ae8c4784c09d8977816c0fadab1ba52 (diff)
downloadvcxsrv-97fb1dadc6c52adeba0ac0684129520288ab794f.tar.gz
vcxsrv-97fb1dadc6c52adeba0ac0684129520288ab794f.tar.bz2
vcxsrv-97fb1dadc6c52adeba0ac0684129520288ab794f.zip
Merge remote-tracking branch 'origin/released'
Conflicts: mesalib/src/mesa/swrast/s_readpix.c
Diffstat (limited to 'mesalib/src/glsl/linker.cpp')
-rw-r--r--mesalib/src/glsl/linker.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 351680d43..0ec773d6c 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -1875,6 +1875,47 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
return true;
}
+/**
+ * Validate the resources used by a program versus the implementation limits
+ */
+static bool
+check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
+{
+ static const char *const shader_names[MESA_SHADER_TYPES] = {
+ "vertex", "fragment", "geometry"
+ };
+
+ const unsigned max_samplers[MESA_SHADER_TYPES] = {
+ ctx->Const.MaxVertexTextureImageUnits,
+ ctx->Const.MaxTextureImageUnits,
+ ctx->Const.MaxGeometryTextureImageUnits
+ };
+
+ const unsigned max_uniform_components[MESA_SHADER_TYPES] = {
+ ctx->Const.VertexProgram.MaxUniformComponents,
+ ctx->Const.FragmentProgram.MaxUniformComponents,
+ 0 /* FINISHME: Geometry shaders. */
+ };
+
+ for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+ struct gl_shader *sh = prog->_LinkedShaders[i];
+
+ if (sh == NULL)
+ continue;
+
+ if (sh->num_samplers > max_samplers[i]) {
+ linker_error(prog, "Too many %s shader texture samplers",
+ shader_names[i]);
+ }
+
+ if (sh->num_uniform_components > max_uniform_components[i]) {
+ linker_error(prog, "Too many %s shader uniform components",
+ shader_names[i]);
+ }
+ }
+
+ return prog->LinkStatus;
+}
void
link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
@@ -2137,6 +2178,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
update_array_sizes(prog);
link_assign_uniform_locations(prog);
+ if (!check_resources(ctx, prog))
+ goto done;
+
/* OpenGL ES requires that a vertex shader and a fragment shader both be
* present in a linked program. By checking for use of shading language
* version 1.00, we also catch the GL_ARB_ES2_compatibility case.