From: Kenneth Graunke Date: Sat, 7 Aug 2010 09:45:33 +0000 (-0700) Subject: glsl: Add built-in variables for GLSL ES 1.00. X-Git-Tag: 062012170305~9778 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b4fe4d52b6c642e2a30162c0e27f81622235d861;p=profile%2Fivi%2Fmesa.git glsl: Add built-in variables for GLSL ES 1.00. --- diff --git a/src/glsl/builtin_variables.h b/src/glsl/builtin_variables.h index a7dbe48..a34c67e 100644 --- a/src/glsl/builtin_variables.h +++ b/src/glsl/builtin_variables.h @@ -39,6 +39,13 @@ static const builtin_variable builtin_core_fs_variables[] = { { 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" }, +}; + +static const builtin_variable builtin_100ES_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" }, +}; + +static const builtin_variable builtin_110_fs_variables[] = { { ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" }, }; diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index e638c96..3fed4d9 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;