aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_variable.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2010-08-07 02:45:33 -0700
committerKenneth Graunke <[email protected]>2010-09-07 17:30:38 -0700
commitb4fe4d52b6c642e2a30162c0e27f81622235d861 (patch)
tree917b91f3fae06d887b1d3381b8c5d9caf6bca405 /src/glsl/ir_variable.cpp
parent76deef138ee25ab57b4716aef41ce0c94081f20a (diff)
glsl: Add built-in variables for GLSL ES 1.00.
Diffstat (limited to 'src/glsl/ir_variable.cpp')
-rw-r--r--src/glsl/ir_variable.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
index e638c9602f0..3fed4d9e6ed 100644
--- a/src/glsl/ir_variable.cpp
+++ b/src/glsl/ir_variable.cpp
@@ -97,6 +97,32 @@ add_builtin_constant(exec_list *instructions,
var->constant_value = new(var) ir_constant(value);
}
+/* Several constants in GLSL ES have different names than normal desktop GLSL.
+ * Therefore, this function should only be called on the ES path.
+ */
+static void
+generate_100ES_uniforms(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ add_builtin_constant(instructions, state, "gl_MaxVertexAttribs",
+ state->Const.MaxVertexAttribs);
+ add_builtin_constant(instructions, state, "gl_MaxVertexUniformVectors",
+ state->Const.MaxVertexUniformComponents);
+ add_builtin_constant(instructions, state, "gl_MaxVaryingVectors",
+ state->Const.MaxVaryingFloats / 4);
+ add_builtin_constant(instructions, state, "gl_MaxVertexTextureImageUnits",
+ state->Const.MaxVertexTextureImageUnits);
+ add_builtin_constant(instructions, state, "gl_MaxCombinedTextureImageUnits",
+ state->Const.MaxCombinedTextureImageUnits);
+ add_builtin_constant(instructions, state, "gl_MaxTextureImageUnits",
+ state->Const.MaxTextureImageUnits);
+ add_builtin_constant(instructions, state, "gl_MaxFragmentUniformVectors",
+ state->Const.MaxFragmentUniformComponents);
+
+ add_uniform(instructions, state, "gl_DepthRange",
+ state->symbols->get_type("gl_DepthRangeParameters"));
+}
+
static void
generate_110_uniforms(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
@@ -189,6 +215,23 @@ generate_110_uniforms(exec_list *instructions,
state->symbols->get_type("gl_FogParameters"));
}
+/* This function should only be called for ES, not desktop GL. */
+static void
+generate_100ES_vs_variables(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) {
+ add_builtin_variable(& builtin_core_vs_variables[i],
+ instructions, state->symbols);
+ }
+
+ generate_100ES_uniforms(instructions, state);
+
+ generate_ARB_draw_buffers_variables(instructions, state, false,
+ vertex_shader);
+}
+
+
static void
generate_110_vs_variables(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
@@ -264,6 +307,9 @@ initialize_vs_variables(exec_list *instructions,
{
switch (state->language_version) {
+ case 100:
+ generate_100ES_vs_variables(instructions, state);
+ break;
case 110:
generate_110_vs_variables(instructions, state);
break;
@@ -276,6 +322,27 @@ initialize_vs_variables(exec_list *instructions,
}
}
+/* This function should only be called for ES, not desktop GL. */
+static void
+generate_100ES_fs_variables(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) {
+ add_builtin_variable(& builtin_core_fs_variables[i],
+ instructions, state->symbols);
+ }
+
+ for (unsigned i = 0; i < Elements(builtin_100ES_fs_variables); i++) {
+ add_builtin_variable(& builtin_100ES_fs_variables[i],
+ instructions, state->symbols);
+ }
+
+ generate_100ES_uniforms(instructions, state);
+
+ generate_ARB_draw_buffers_variables(instructions, state, false,
+ fragment_shader);
+}
+
static void
generate_110_fs_variables(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
@@ -285,6 +352,11 @@ generate_110_fs_variables(exec_list *instructions,
instructions, state->symbols);
}
+ for (unsigned i = 0; i < Elements(builtin_110_fs_variables); i++) {
+ add_builtin_variable(& builtin_110_fs_variables[i],
+ instructions, state->symbols);
+ }
+
for (unsigned i = 0
; i < Elements(builtin_110_deprecated_fs_variables)
; i++) {
@@ -382,6 +454,9 @@ initialize_fs_variables(exec_list *instructions,
{
switch (state->language_version) {
+ case 100:
+ generate_100ES_fs_variables(instructions, state);
+ break;
case 110:
generate_110_fs_variables(instructions, state);
break;