* DEALINGS IN THE SOFTWARE.
*/
+#include "ir.h"
#include "glsl_parser_extras.h"
#include "glsl_symbol_table.h"
-#include "ir.h"
#include "builtin_variables.h"
#ifndef Elements
#endif
static ir_variable *
-add_variable(const char *name, enum ir_variable_mode mode,
+add_variable(const char *name, enum ir_variable_mode mode, int slot,
const glsl_type *type, exec_list *instructions,
glsl_symbol_table *symtab)
{
break;
}
+ var->location = slot;
+
/* Once the variable is created an initialized, add it to the symbol table
* and add the declaration to the IR stream.
*/
assert(type != NULL);
- add_variable(proto->name, proto->mode, type, instructions, symtab);
+ add_variable(proto->name, proto->mode, proto->slot, type, instructions,
+ symtab);
}
}
/* 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.
+ * 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.
*/
const glsl_type *const mat4_array_type =
- glsl_type::get_array_instance(glsl_type::mat4_type, 2);
+ glsl_type::get_array_instance(glsl_type::mat4_type, 4);
- add_variable("gl_TextureMatrix", ir_var_uniform, mat4_array_type,
+ add_variable("gl_TextureMatrix", ir_var_uniform, -1, mat4_array_type,
instructions, symtab);
/* FINISHME: Add support for gl_DepthRangeParameters */
* FINISHME: (glFrontMaterial, glBackMaterial)
*/
- /* FINISHME: Add support for gl_LightSource[] */
+ /* FINISHME: The size of this array is implementation dependent based on the
+ * FINISHME: value of GL_MAX_TEXTURE_LIGHTS. GL_MAX_TEXTURE_LIGHTS must be
+ * FINISHME: at least 8, so hard-code 8 for now.
+ */
+ const glsl_type *const light_source_array_type =
+ glsl_type::get_array_instance(symtab->get_type("gl_LightSourceParameters"), 8);
+
+ add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type,
+ instructions, symtab);
+
/* FINISHME: Add support for gl_LightModel */
/* FINISHME: Add support for gl_FrontLightProduct[], gl_BackLightProduct[] */
/* FINISHME: Add support for gl_TextureEnvColor[] */
generate_110_uniforms(instructions, symtab);
/* 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.
+ * 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.
*/
const glsl_type *const vec4_array_type =
- glsl_type::get_array_instance(glsl_type::vec4_type, 2);
+ glsl_type::get_array_instance(glsl_type::vec4_type, 4);
- add_variable("gl_TexCoord", ir_var_out, vec4_array_type, instructions,
- symtab);
+ add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type,
+ instructions, symtab);
}
*/
const glsl_type *const clip_distance_array_type =
glsl_type::get_array_instance(glsl_type::float_type, 8);
- add_variable("gl_ClipDistance", ir_var_out, clip_distance_array_type,
+
+ /* FINISHME: gl_ClipDistance needs a real location assigned. */
+ add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type,
instructions, symtab);
}
generate_110_uniforms(instructions, symtab);
/* 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.
+ * 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.
*/
const glsl_type *const vec4_array_type =
- glsl_type::get_array_instance(glsl_type::vec4_type, 2);
+ glsl_type::get_array_instance(glsl_type::vec4_type, 4);
- add_variable("gl_TexCoord", ir_var_in, vec4_array_type, instructions,
- symtab);
+ add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type,
+ instructions, symtab);
}
glsl_type::get_array_instance(glsl_type::vec4_type, 1);
ir_variable *const fd =
- add_variable("gl_FragData", ir_var_out, vec4_array_type, instructions,
- symtab);
+ add_variable("gl_FragData", ir_var_out, FRAG_RESULT_DATA0,
+ vec4_array_type, instructions, symtab);
if (warn)
fd->warn_extension = "GL_ARB_draw_buffers";
*/
const glsl_type *const clip_distance_array_type =
glsl_type::get_array_instance(glsl_type::float_type, 8);
- add_variable("gl_ClipDistance", ir_var_in, clip_distance_array_type,
+
+ /* FINISHME: gl_ClipDistance needs a real location assigned. */
+ add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type,
instructions, symtab);
}
case fragment_shader:
initialize_fs_variables(instructions, state);
break;
+ case ir_shader:
+ fprintf(stderr, "ir reader has no builtin variables");
+ exit(1);
+ break;
}
}