aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2010-07-01 13:30:50 -0700
committerIan Romanick <[email protected]>2010-07-01 13:30:50 -0700
commit127308b4be077e5bdf60f76320307550921e86bb (patch)
tree582191198d46cd3161dd35769448afaca868dbaa
parentcd00d5b88caa41ebf4b407126f314832f9fdae54 (diff)
glsl2: Add gl_MaxTextureCoords
-rw-r--r--src/glsl/ast_to_hir.cpp12
-rw-r--r--src/glsl/glsl_parser_extras.h1
-rw-r--r--src/glsl/ir_variable.cpp31
-rw-r--r--src/glsl/main.cpp1
-rw-r--r--src/mesa/shader/ir_to_mesa.cpp1
5 files changed, 24 insertions, 22 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 22d9f7ad532..fc5a652f25d 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1817,20 +1817,16 @@ ast_declarator_list::hir(exec_list *instructions,
*
* "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.
*/
+ const unsigned size = unsigned(var->type->array_size());
if ((strcmp("gl_TexCoord", var->name) == 0)
- && (var->type->array_size() > 4)) {
+ && (size > state->Const.MaxTextureCoords)) {
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) {
+ state->Const.MaxTextureCoords);
+ } else if (size <= 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/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index f957a926be3..3aeba83cc52 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -50,6 +50,7 @@ struct _mesa_glsl_parse_state {
*/
struct {
unsigned MaxDrawBuffers;
+ unsigned MaxTextureCoords;
} Const;
/**
diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
index d43809ef9c2..9daad803e96 100644
--- a/src/glsl/ir_variable.cpp
+++ b/src/glsl/ir_variable.cpp
@@ -96,25 +96,28 @@ add_builtin_variable(const builtin_variable *proto, exec_list *instructions,
static void
generate_110_uniforms(exec_list *instructions,
- glsl_symbol_table *symtab)
+ struct _mesa_glsl_parse_state *state)
{
for (unsigned i = 0
; i < Elements(builtin_110_deprecated_uniforms)
; i++) {
add_builtin_variable(& builtin_110_deprecated_uniforms[i],
- instructions, symtab);
+ 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.
- */
+ ir_variable *const mtc = add_variable("gl_MaxTextureCoords", ir_var_auto,
+ -1, glsl_type::int_type,
+ instructions, state->symbols);
+ mtc->constant_value = new(mtc)
+ ir_constant(int(state->Const.MaxTextureCoords));
+
+
const glsl_type *const mat4_array_type =
- glsl_type::get_array_instance(symtab, glsl_type::mat4_type, 4);
+ glsl_type::get_array_instance(state->symbols, glsl_type::mat4_type,
+ state->Const.MaxTextureCoords);
add_variable("gl_TextureMatrix", ir_var_uniform, -1, mat4_array_type,
- instructions, symtab);
+ instructions, state->symbols);
/* FINISHME: Add support for gl_DepthRangeParameters */
/* FINISHME: Add support for gl_ClipPlane[] */
@@ -129,11 +132,11 @@ generate_110_uniforms(exec_list *instructions,
* FINISHME: at least 8, so hard-code 8 for now.
*/
const glsl_type *const light_source_array_type =
- glsl_type::get_array_instance(symtab,
- symtab->get_type("gl_LightSourceParameters"), 8);
+ glsl_type::get_array_instance(state->symbols,
+ state->symbols->get_type("gl_LightSourceParameters"), 8);
add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type,
- instructions, symtab);
+ instructions, state->symbols);
/* FINISHME: Add support for gl_LightModel */
/* FINISHME: Add support for gl_FrontLightProduct[], gl_BackLightProduct[] */
@@ -157,7 +160,7 @@ generate_110_vs_variables(exec_list *instructions,
add_builtin_variable(& builtin_110_deprecated_vs_variables[i],
instructions, state->symbols);
}
- generate_110_uniforms(instructions, state->symbols);
+ generate_110_uniforms(instructions, state);
/* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
*
@@ -247,7 +250,7 @@ generate_110_fs_variables(exec_list *instructions,
add_builtin_variable(& builtin_110_deprecated_fs_variables[i],
instructions, state->symbols);
}
- generate_110_uniforms(instructions, state->symbols);
+ generate_110_uniforms(instructions, state);
/* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
*
diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index fa63853b476..c833c9cde6d 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -128,6 +128,7 @@ compile_shader(struct gl_shader *shader)
state->ARB_texture_rectangle_enable = true;
state->Const.MaxDrawBuffers = 2;
+ state->Const.MaxTextureCoords = 4;
const char *source = shader->Source;
state->error = preprocess(state, &source, &state->info_log);
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index 1e186354c58..14abf602af2 100644
--- a/src/mesa/shader/ir_to_mesa.cpp
+++ b/src/mesa/shader/ir_to_mesa.cpp
@@ -1710,6 +1710,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
state->ARB_texture_rectangle_enable = true;
state->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers;
+ state->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits;
const char *source = shader->Source;
state->error = preprocess(state, &source, &state->info_log);