* DEALINGS IN THE SOFTWARE.
*/
+#include "main/mtypes.h"
+
struct builtin_variable {
enum ir_variable_mode mode;
+ int slot;
const char *type;
const char *name;
};
static const builtin_variable builtin_core_vs_variables[] = {
- { ir_var_out, "vec4", "gl_Position" },
- { ir_var_out, "float", "gl_PointSize" },
+ { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_Position" },
+ { ir_var_out, VERT_RESULT_PSIZ, "float", "gl_PointSize" },
};
static const builtin_variable builtin_core_fs_variables[] = {
- { ir_var_in, "vec4", "gl_FragCoord" },
- { ir_var_in, "bool", "gl_FrontFacing" },
- { ir_var_out, "vec4", "gl_FragColor" },
- { ir_var_out, "float", "gl_FragDepth" },
+ { ir_var_in, FRAG_ATTRIB_WPOS, "vec4", "gl_FragCoord" },
+ { ir_var_in, FRAG_ATTRIB_FACE, "bool", "gl_FrontFacing" },
+ { ir_var_out, FRAG_RESULT_COLOR, "vec4", "gl_FragColor" },
+ { ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" },
};
static const builtin_variable builtin_110_deprecated_fs_variables[] = {
- { ir_var_in, "vec4", "gl_Color" },
- { ir_var_in, "vec4", "gl_SecondaryColor" },
- { ir_var_in, "float", "gl_FogFragCoord" },
+ { ir_var_in, FRAG_ATTRIB_COL0, "vec4", "gl_Color" },
+ { ir_var_in, FRAG_ATTRIB_COL1, "vec4", "gl_SecondaryColor" },
+ { ir_var_in, FRAG_ATTRIB_FOGC, "float", "gl_FogFragCoord" },
};
static const builtin_variable builtin_110_deprecated_vs_variables[] = {
- { ir_var_in, "vec4", "gl_Vertex" },
- { ir_var_in, "vec3", "gl_Normal" },
- { ir_var_in, "vec4", "gl_Color" },
- { ir_var_in, "vec4", "gl_SecondaryColor" },
- { ir_var_in, "vec4", "gl_MultiTexCoord0" },
- { ir_var_in, "vec4", "gl_MultiTexCoord1" },
- { ir_var_in, "vec4", "gl_MultiTexCoord2" },
- { ir_var_in, "vec4", "gl_MultiTexCoord3" },
- { ir_var_in, "vec4", "gl_MultiTexCoord4" },
- { ir_var_in, "vec4", "gl_MultiTexCoord5" },
- { ir_var_in, "vec4", "gl_MultiTexCoord6" },
- { ir_var_in, "vec4", "gl_MultiTexCoord7" },
- { ir_var_in, "float", "gl_FogCoord" },
- { ir_var_out, "vec4", "gl_ClipVertex" },
- { ir_var_out, "vec4", "gl_FrontColor" },
- { ir_var_out, "vec4", "gl_BackColor" },
- { ir_var_out, "vec4", "gl_FrontSecondaryColor" },
- { ir_var_out, "vec4", "gl_BackSecondaryColor" },
- { ir_var_out, "float", "gl_FogFragCoord" },
+ { ir_var_in, VERT_ATTRIB_POS, "vec4", "gl_Vertex" },
+ { ir_var_in, VERT_ATTRIB_NORMAL, "vec3", "gl_Normal" },
+ { ir_var_in, VERT_ATTRIB_COLOR0, "vec4", "gl_Color" },
+ { ir_var_in, VERT_ATTRIB_COLOR1, "vec4", "gl_SecondaryColor" },
+ { ir_var_in, VERT_ATTRIB_TEX0, "vec4", "gl_MultiTexCoord0" },
+ { ir_var_in, VERT_ATTRIB_TEX1, "vec4", "gl_MultiTexCoord1" },
+ { ir_var_in, VERT_ATTRIB_TEX2, "vec4", "gl_MultiTexCoord2" },
+ { ir_var_in, VERT_ATTRIB_TEX3, "vec4", "gl_MultiTexCoord3" },
+ { ir_var_in, VERT_ATTRIB_TEX4, "vec4", "gl_MultiTexCoord4" },
+ { ir_var_in, VERT_ATTRIB_TEX5, "vec4", "gl_MultiTexCoord5" },
+ { ir_var_in, VERT_ATTRIB_TEX6, "vec4", "gl_MultiTexCoord6" },
+ { ir_var_in, VERT_ATTRIB_TEX7, "vec4", "gl_MultiTexCoord7" },
+ { ir_var_in, VERT_ATTRIB_FOG, "float", "gl_FogCoord" },
+ { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_ClipVertex" },
+ { ir_var_out, VERT_RESULT_COL0, "vec4", "gl_FrontColor" },
+ { ir_var_out, VERT_RESULT_BFC0, "vec4", "gl_BackColor" },
+ { ir_var_out, VERT_RESULT_COL1, "vec4", "gl_FrontSecondaryColor" },
+ { ir_var_out, VERT_RESULT_BFC1, "vec4", "gl_BackSecondaryColor" },
+ { ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" },
};
static const builtin_variable builtin_130_vs_variables[] = {
- { ir_var_in, "int", "gl_VertexID" },
+ { ir_var_in, -1, "int", "gl_VertexID" },
};
static const builtin_variable builtin_110_deprecated_uniforms[] = {
- { ir_var_uniform, "mat4", "gl_ModelViewMatrix" },
- { ir_var_uniform, "mat4", "gl_ProjectionMatrix" },
- { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrix" },
- { ir_var_uniform, "mat3", "gl_NormalMatrix" },
- { ir_var_uniform, "mat4", "gl_ModelViewMatrixInverse" },
- { ir_var_uniform, "mat4", "gl_ProjectionMatrixInverse" },
- { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrixInverse" },
- { ir_var_uniform, "mat4", "gl_ModelViewMatrixTranspose" },
- { ir_var_uniform, "mat4", "gl_ProjectionMatrixTranspose" },
- { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrixTranspose" },
- { ir_var_uniform, "mat4", "gl_ModelViewMatrixInverseTranspose" },
- { ir_var_uniform, "mat4", "gl_ProjectionMatrixInverseTranspose" },
- { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" },
- { ir_var_uniform, "float", "gl_NormalScale" },
+ { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrix" },
+ { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrix" },
+ { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrix" },
+ { ir_var_uniform, -1, "mat3", "gl_NormalMatrix" },
+ { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverse" },
+ { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverse" },
+ { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverse" },
+ { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixTranspose" },
+ { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixTranspose" },
+ { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixTranspose" },
+ { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverseTranspose" },
+ { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" },
+ { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" },
+ { ir_var_uniform, -1, "float", "gl_NormalScale" },
};
#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);
}
const glsl_type *const mat4_array_type =
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 */
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, light_source_array_type,
+ add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type,
instructions, symtab);
/* FINISHME: Add support for gl_LightModel */
const glsl_type *const vec4_array_type =
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);
}
const glsl_type *const vec4_array_type =
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);
}