From: Eric Anholt Date: Thu, 25 Mar 2010 21:48:25 +0000 (-0700) Subject: Set up fragment shader builtin variables. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b3f743ab0badc0ca7cba16d7989ec7ba368f6b36;p=mesa.git Set up fragment shader builtin variables. --- diff --git a/builtin_variables.h b/builtin_variables.h index 9693217e990..5b18446a0da 100644 --- a/builtin_variables.h +++ b/builtin_variables.h @@ -32,6 +32,13 @@ static const builtin_variable builtin_core_vs_variables[] = { { ir_var_out, "float", "gl_PointSize" }, }; +static const builtin_variable builtin_core_fs_variables[] = { + { ir_var_out, "vec4", "gl_FragCoord" }, + { ir_var_out, "bool", "gl_FrontFacing" }, + { ir_var_out, "vec4", "gl_FragColor" }, + { ir_var_out, "float", "gl_FragDepth" }, +}; + static const builtin_variable builtin_110_deprecated_vs_variables[] = { { ir_var_in, "vec4", "gl_Vertex" }, { ir_var_in, "vec4", "gl_Normal" }, diff --git a/ir_variable.cpp b/ir_variable.cpp index 283842c54e0..9344170613d 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -127,6 +127,57 @@ initialize_vs_variables(exec_list *instructions, } } +static void +generate_110_fs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { + add_builtin_variable(& builtin_core_fs_variables[i], + instructions, symtab); + } + + /* FINISHME: Add support for gl_FragData[GL_MAX_DRAW_BUFFERS]. */ +} + +static void +generate_120_fs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + /* GLSL version 1.20 did not add any built-in variables in the fragment + * shader. + */ + generate_110_fs_variables(instructions, symtab); +} + +static void +generate_130_fs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + generate_120_fs_variables(instructions, symtab); + + /* FINISHME: Add support fo gl_ClipDistance. The size of this array is + * FINISHME: implementation dependent based on the value of + * FINISHME: GL_MAX_CLIP_DISTANCES. + */ +} + +static void +initialize_fs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + + switch (state->language_version) { + case 110: + generate_110_fs_variables(instructions, state->symbols); + break; + case 120: + generate_120_fs_variables(instructions, state->symbols); + break; + case 130: + generate_130_fs_variables(instructions, state->symbols); + break; + } +} void _mesa_glsl_initialize_variables(exec_list *instructions, @@ -137,7 +188,9 @@ _mesa_glsl_initialize_variables(exec_list *instructions, initialize_vs_variables(instructions, state); break; case geometry_shader: + break; case fragment_shader: + initialize_fs_variables(instructions, state); break; } }