Mesa (master): glsl: Make gl_ClipDistance[] implicitly sized.
Paul Berry
stereotype441 at kemper.freedesktop.org
Thu Sep 8 16:46:49 UTC 2011
Module: Mesa
Branch: master
Commit: af243b55ac346f39acda1ad20d90e7c8cc1a33c7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=af243b55ac346f39acda1ad20d90e7c8cc1a33c7
Author: Paul Berry <stereotype441 at gmail.com>
Date: Thu Aug 11 15:03:19 2011 -0700
glsl: Make gl_ClipDistance[] implicitly sized.
>From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special Variables):
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.
Fixes piglit tests clip-distance-implicit-length.vert,
clip-distance-implicit-nonconst-access.vert, and
{vs,fs}-clip-distance-explicitly-sized.shader_test.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/glsl/ir_variable.cpp | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
index b848769..3809456 100644
--- a/src/glsl/ir_variable.cpp
+++ b/src/glsl/ir_variable.cpp
@@ -595,9 +595,18 @@ generate_130_vs_variables(exec_list *instructions,
& builtin_130_vs_variables[i]);
}
+ /* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special
+ * Variables):
+ *
+ * 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.
+ *
+ * We represent this in Mesa by initially declaring the array as
+ * size 0.
+ */
const glsl_type *const clip_distance_array_type =
- glsl_type::get_array_instance(glsl_type::float_type,
- state->Const.MaxClipPlanes);
+ glsl_type::get_array_instance(glsl_type::float_type, 0);
/* FINISHME: gl_ClipDistance needs a real location assigned. */
add_variable(instructions, state->symbols,
@@ -802,9 +811,20 @@ generate_130_fs_variables(exec_list *instructions,
{
generate_120_fs_variables(instructions, state);
+ /* From the GLSL 1.30 spec, section 7.2 (Fragment Shader Special
+ * Variables):
+ *
+ * The built-in input variable gl_ClipDistance array contains linearly
+ * interpolated values for the vertex values written by the vertex shader
+ * to the gl_ClipDistance vertex output variable. This array must be
+ * sized in the fragment shader either implicitly or explicitly to be the
+ * same size as it was sized in the vertex shader.
+ *
+ * In other words, the array must be pre-declared as implicitly sized. We
+ * represent this in Mesa by initially declaring the array as size 0.
+ */
const glsl_type *const clip_distance_array_type =
- glsl_type::get_array_instance(glsl_type::float_type,
- state->Const.MaxClipPlanes);
+ glsl_type::get_array_instance(glsl_type::float_type, 0);
/* FINISHME: gl_ClipDistance needs a real location assigned. */
add_variable(instructions, state->symbols,
More information about the mesa-commit
mailing list