mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
glsl2: Add gl_MaxTextureCoords
This commit is contained in:
parent
cd00d5b88c
commit
127308b4be
5 changed files with 24 additions and 22 deletions
|
|
@ -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 "
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ struct _mesa_glsl_parse_state {
|
|||
*/
|
||||
struct {
|
||||
unsigned MaxDrawBuffers;
|
||||
unsigned MaxTextureCoords;
|
||||
} Const;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue