summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/glsl/ast_to_hir.cpp19
-rw-r--r--src/glsl/ir_variable.cpp26
2 files changed, 34 insertions, 11 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 9d642c1a64..22d9f7ad53 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1813,7 +1813,24 @@ ast_declarator_list::hir(exec_list *instructions,
* FINISHME: required or not.
*/
- if (var->type->array_size() <= (int)earlier->max_array_access) {
+ /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
+ *
+ * "The size [of gl_TexCoord] can be at most
+ * gl_MaxTextureCoords."
+ *
+ * FINISHME: Every platform that supports GLSL sets
+ * FINISHME: gl_MaxTextureCoords to at least 4, so hard-code 4
+ * FINISHME: for now.
+ */
+ if ((strcmp("gl_TexCoord", var->name) == 0)
+ && (var->type->array_size() > 4)) {
+ YYLTYPE loc = this->get_location();
+
+ _mesa_glsl_error(& loc, state, "`gl_TexCoord' array size cannot "
+ "be larger than gl_MaxTextureCoords (%u)\n",
+ 4);
+ } else if (var->type->array_size() <=
+ (int)earlier->max_array_access) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(& loc, state, "array size must be > %u due to "
diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
index ac168142dc..d43809ef9c 100644
--- a/src/glsl/ir_variable.cpp
+++ b/src/glsl/ir_variable.cpp
@@ -159,13 +159,16 @@ generate_110_vs_variables(exec_list *instructions,
}
generate_110_uniforms(instructions, state->symbols);
- /* FINISHME: The size of this array is implementation dependent based on the
- * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports
- * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4
- * FINISHME: for now.
+ /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
+ *
+ * "As with all arrays, indices used to subscript gl_TexCoord must
+ * either be an integral constant expressions, or this array must be
+ * re-declared by the shader with a size. The size can be at most
+ * gl_MaxTextureCoords. Using indexes close to 0 may aid the
+ * implementation in preserving varying resources."
*/
const glsl_type *const vec4_array_type =
- glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 4);
+ glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 0);
add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type,
instructions, state->symbols);
@@ -246,13 +249,16 @@ generate_110_fs_variables(exec_list *instructions,
}
generate_110_uniforms(instructions, state->symbols);
- /* FINISHME: The size of this array is implementation dependent based on the
- * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports
- * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4
- * FINISHME: for now.
+ /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
+ *
+ * "As with all arrays, indices used to subscript gl_TexCoord must
+ * either be an integral constant expressions, or this array must be
+ * re-declared by the shader with a size. The size can be at most
+ * gl_MaxTextureCoords. Using indexes close to 0 may aid the
+ * implementation in preserving varying resources."
*/
const glsl_type *const vec4_array_type =
- glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 4);
+ glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 0);
add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type,
instructions, state->symbols);