From da46e5f5345ed2fa9c74d135267f3d5729c04ed1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 13:57:01 -0700 Subject: [PATCH] builtins: Add ftransform(). Fixes glsl-orangebook-ch06-bump.vert. --- builtin_function.cpp | 20 ++++++++++++++++++++ builtins/110_vs/ftransform | 7 +++++++ builtins/tools/generate_builtins.pl | 11 +++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 builtins/110_vs/ftransform diff --git a/builtin_function.cpp b/builtin_function.cpp index b7719ab4749..4203502e45b 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1778,6 +1778,22 @@ static const char *functions_for_110 [] = { builtins_110_tan, }; +/* Version 110_vs builtins */ + +static const char *builtins_110_vs_ftransform = { + "((function ftransform\n" + " (signature vec4\n" + " (parameters)\n" + " ((return (expression vec4 *\n" + " (var_ref gl_ModelViewProjectionMatrix)\n" + " (var_ref gl_Vertex)))))\n" + "))\n" +}; + +static const char *functions_for_110_vs [] = { + builtins_110_vs_ftransform, +}; + /* Version 130 builtins */ static const char *builtins_130_equal = { @@ -2039,6 +2055,10 @@ _mesa_glsl_initialize_functions(exec_list *instructions, read_builtins(state, instructions, functions_for_110, sizeof(functions_for_110) / sizeof(const char *)); + if (state->language_version >= 110 && state->target == vertex_shader) + read_builtins(state, instructions, functions_for_110_vs, + sizeof(functions_for_110_vs) / sizeof(const char *)); + if (state->language_version >= 130) read_builtins(state, instructions, functions_for_130, sizeof(functions_for_130) / sizeof(const char *)); diff --git a/builtins/110_vs/ftransform b/builtins/110_vs/ftransform new file mode 100644 index 00000000000..3a5e8ccecfc --- /dev/null +++ b/builtins/110_vs/ftransform @@ -0,0 +1,7 @@ +((function ftransform + (signature vec4 + (parameters) + ((return (expression vec4 * + (var_ref gl_ModelViewProjectionMatrix) + (var_ref gl_Vertex))))) +)) diff --git a/builtins/tools/generate_builtins.pl b/builtins/tools/generate_builtins.pl index e7ec8ef56ff..9ce0ce3a608 100755 --- a/builtins/tools/generate_builtins.pl +++ b/builtins/tools/generate_builtins.pl @@ -85,7 +85,7 @@ read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, EOF -@versions = sort(); +@versions = sort(); foreach $version (@versions) { $version =~ s!builtins/!!g; process_version($version); @@ -99,7 +99,14 @@ _mesa_glsl_initialize_functions(exec_list *instructions, EOF foreach $version (@versions) { - print " if (state->language_version >= $version)\n"; + $version_number = $version; + if ($version =~ m/_vs/) { + $version_check = " && state->target == vertex_shader"; + $version_number =~ s/_vs//; + } else { + $version_check = ""; + } + print " if (state->language_version >= $version_number$version_check)\n"; print " read_builtins(state, instructions, functions_for_$version,\n"; print " sizeof(functions_for_$version) / "; print "sizeof(const char *));\n\n" -- 2.30.2