builtins: Add ftransform().
authorEric Anholt <eric@anholt.net>
Wed, 19 May 2010 20:57:01 +0000 (13:57 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 1 Jun 2010 22:15:05 +0000 (15:15 -0700)
Fixes glsl-orangebook-ch06-bump.vert.

builtin_function.cpp
builtins/110_vs/ftransform [new file with mode: 0644]
builtins/tools/generate_builtins.pl

index b7719ab4749b4705ce6ca58c57bbb99f1b75b516..4203502e45bed6532c2d7f16c5d995e60046297c 100644 (file)
@@ -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 (file)
index 0000000..3a5e8cc
--- /dev/null
@@ -0,0 +1,7 @@
+((function ftransform
+   (signature vec4
+     (parameters)
+    ((return (expression vec4 *
+             (var_ref gl_ModelViewProjectionMatrix)
+             (var_ref gl_Vertex)))))
+))
index e7ec8ef56ff7ddc8e8cad8d8400018b67bdfaee2..9ce0ce3a608a4a05845d8a0fbf669732d38ffd23 100755 (executable)
@@ -85,7 +85,7 @@ read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions,
 
 EOF
 
-@versions = sort(<builtins/[1-9][0-9][0-9]>);
+@versions = sort(<builtins/[1-9][0-9][0-9]*>);
 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"