Mesa (master): glsl: Check that gl_ClipDistance[] is not sized too large.
Paul Berry
stereotype441 at kemper.freedesktop.org
Thu Sep 8 16:46:50 UTC 2011
Module: Mesa
Branch: master
Commit: 37bb1c4de2eb2fa80d09b6e8dc8f39814d790e09
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=37bb1c4de2eb2fa80d09b6e8dc8f39814d790e09
Author: Paul Berry <stereotype441 at gmail.com>
Date: Thu Aug 11 15:23:33 2011 -0700
glsl: Check that gl_ClipDistance[] is not sized too large.
Fixes piglit tests
clip-distance-explicit-too-large-with-access.{frag,vert} and
clip-distance-explicit-too-large.{frag,vert}.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/glsl/ast_to_hir.cpp | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index fbb2c14..a4eaf85 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -912,6 +912,21 @@ check_builtin_array_max_size(const char *name, unsigned size,
"be larger than gl_MaxTextureCoords (%u)\n",
state->Const.MaxTextureCoords);
return true;
+ } else if (strcmp("gl_ClipDistance", name) == 0
+ && size > state->Const.MaxClipPlanes) {
+ /* From section 7.1 (Vertex Shader Special Variables) of the
+ * GLSL 1.30 spec:
+ *
+ * "The gl_ClipDistance array is predeclared as unsized and
+ * must be sized by the shader either redeclaring it with a
+ * size or indexing it only with integral constant
+ * expressions. ... The size can be at most
+ * gl_MaxClipDistances."
+ */
+ _mesa_glsl_error(&loc, state, "`gl_ClipDistance' array size cannot "
+ "be larger than gl_MaxClipDistances (%u)\n",
+ state->Const.MaxClipPlanes);
+ return true;
}
return false;
}
More information about the mesa-commit
mailing list