From: Ian Romanick Date: Fri, 2 Apr 2010 18:59:57 +0000 (-0700) Subject: Make built-in gl_TexCoord available in vertex and fragment shaders X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3f9a73d121e7cf160b268b2c5d16e8584eea94db;p=mesa.git Make built-in gl_TexCoord available in vertex and fragment shaders --- diff --git a/ir_variable.cpp b/ir_variable.cpp index 1b4b742ac4c..0edb19e28fb 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -31,19 +31,13 @@ #endif static void -add_builtin_variable(const builtin_variable *proto, exec_list *instructions, +add_variable(const char *name, enum ir_variable_mode mode, + const glsl_type *type, exec_list *instructions, glsl_symbol_table *symtab) { - /* Create a new variable declaration from the description supplied by - * the caller. - */ - const glsl_type *const type = symtab->get_type(proto->type); - - assert(type != NULL); - - ir_variable *var = new ir_variable(type, proto->name); + ir_variable *var = new ir_variable(type, name); - var->mode = proto->mode; + var->mode = mode; if (var->mode != ir_var_out) var->read_only = true; @@ -56,6 +50,22 @@ add_builtin_variable(const builtin_variable *proto, exec_list *instructions, symtab->add_variable(var->name, var); } + +static void +add_builtin_variable(const builtin_variable *proto, exec_list *instructions, + glsl_symbol_table *symtab) +{ + /* Create a new variable declaration from the description supplied by + * the caller. + */ + const glsl_type *const type = symtab->get_type(proto->type); + + assert(type != NULL); + + add_variable(proto->name, proto->mode, type, instructions, symtab); +} + + static void generate_110_uniforms(exec_list *instructions, glsl_symbol_table *symtab) @@ -105,10 +115,17 @@ generate_110_vs_variables(exec_list *instructions, } generate_110_uniforms(instructions, symtab); - /* FINISHME: Add support fo gl_TexCoord. The size of this array is - * FINISHME: implementation dependent based on the value of - * FINISHME: GL_MAX_TEXTURE_COORDS. + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_TEXTURE_COORDS. GL_MAX_TEXTURE_COORDS must be + * FINISHME: at least 2, so hard-code 2 for now. */ + const glsl_type *const vec4_type = + glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 0); + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(vec4_type, 2); + + add_variable("gl_TexCoord", ir_var_out, vec4_array_type, instructions, + symtab); } @@ -168,7 +185,6 @@ generate_110_fs_variables(exec_list *instructions, instructions, symtab); } - /* FINISHME: Add support for gl_TexCoord[] */ for (unsigned i = 0 ; i < Elements(builtin_110_deprecated_fs_variables) ; i++) { @@ -178,6 +194,18 @@ generate_110_fs_variables(exec_list *instructions, generate_110_uniforms(instructions, symtab); /* FINISHME: Add support for gl_FragData[GL_MAX_DRAW_BUFFERS]. */ + + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_TEXTURE_COORDS. GL_MAX_TEXTURE_COORDS must be + * FINISHME: at least 2, so hard-code 2 for now. + */ + const glsl_type *const vec4_type = + glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 0); + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(vec4_type, 2); + + add_variable("gl_TexCoord", ir_var_in, vec4_array_type, instructions, + symtab); } static void