summaryrefslogtreecommitdiff
path: root/src/glsl/builtins/tools
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-08-11 16:53:52 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-08-13 19:09:36 -0700
commit43ff8f1a4b90554eae489cebb7e05f983dd9ad66 (patch)
treed9a63bb1ce1257b45aea4bbcae450959b75cc64c /src/glsl/builtins/tools
parentd802ba110f78c3eee9541867cde819ada1b2c449 (diff)
glsl2: Rework builtin function generation.
Each language version/extension and target now has a "profile" containing all of the available builtin function prototypes. These are written in GLSL, and come directly out of the GLSL spec (except for expanding genType). A new builtins/ir/ folder contains the hand-written IR for each builtin, regardless of what version includes it. Only those definitions that have prototypes in the profile will be included. The autogenerated IR for texture builtins is no longer written to disk, so there's no longer any confusion as to what's hand-written or generated. All scripts are now in python instead of perl.
Diffstat (limited to 'src/glsl/builtins/tools')
-rw-r--r--src/glsl/builtins/tools/builtin_function.cpp39
-rwxr-xr-xsrc/glsl/builtins/tools/generate_builtins.pl164
-rwxr-xr-xsrc/glsl/builtins/tools/generate_builtins.py207
-rwxr-xr-xsrc/glsl/builtins/tools/texture_builtins.py261
4 files changed, 402 insertions, 269 deletions
diff --git a/src/glsl/builtins/tools/builtin_function.cpp b/src/glsl/builtins/tools/builtin_function.cpp
new file mode 100644
index 0000000000..c44804f2ef
--- /dev/null
+++ b/src/glsl/builtins/tools/builtin_function.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdio.h>
+#include "glsl_parser_extras.h"
+
+/* A dummy file. When compiling prototypes, we don't care about builtins.
+ * We really don't want to half-compile builtin_functions.cpp and fail, though.
+ */
+void
+_mesa_glsl_release_functions(void)
+{
+}
+
+void
+_mesa_glsl_initialize_functions(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+}
diff --git a/src/glsl/builtins/tools/generate_builtins.pl b/src/glsl/builtins/tools/generate_builtins.pl
deleted file mode 100755
index 91ef8917b0..0000000000
--- a/src/glsl/builtins/tools/generate_builtins.pl
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/env perl
-
-sub process_version {
- my ($version) = @_;
- my @vars;
- print "/* $version builtins */\n\n";
-
- my @files = <builtins/$version/*>;
- foreach $file (@files) {
- push(@vars, process_file($file));
- }
-
- print "static const char *functions_for_$version [] = {\n";
- foreach $var (@vars) {
- print " $var,\n";
- }
- print "};\n\n"
-}
-
-sub process_file {
- my ($file) = @_;
-
- # Change from builtins/110/foo to builtins_110_foo
- my $var = $file; $var =~ s!/!_!g;
-
- print "static const char *$var = {\n";
- open SRC, "<", "$file" or die $!;
- while (<SRC>) {
- s/\\/\\\\/g;
- s/\"/\\\"/g;
- s/\n/\\n/g;
- print " \"$_\"\n";
- }
- print "};\n\n";
- close SRC or die $!;
- return $var;
-}
-
-print << 'EOF';
-/* DO NOT MODIFY - automatically generated by generate_builtins.pl */
-/*
- * Copyright © 2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include <stdio.h>
-#include "main/compiler.h"
-#include "glsl_parser_extras.h"
-#include "ir_reader.h"
-#include "program.h"
-
-extern "C" struct gl_shader *
-_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type);
-
-gl_shader *
-read_builtins(GLenum target, const char **functions, unsigned count)
-{
- gl_shader *sh = _mesa_new_shader(NULL, 0, target);
- struct _mesa_glsl_parse_state *st =
- new(sh) _mesa_glsl_parse_state(NULL, target, sh);
-
- st->language_version = 130;
- st->ARB_texture_rectangle_enable = true;
- st->EXT_texture_array_enable = true;
- _mesa_glsl_initialize_types(st);
-
- sh->ir = new(sh) exec_list;
- sh->symbols = st->symbols;
-
- for (unsigned i = 0; i < count; i++) {
- _mesa_glsl_read_ir(st, sh->ir, functions[i]);
-
- if (st->error) {
- printf("error reading builtin: %.35s ...\n", functions[i]);
- delete st;
- talloc_free(sh);
- return NULL;
- }
- }
-
- reparent_ir(sh->ir, sh);
- delete st;
-
- return sh;
-}
-
-EOF
-
-@versions = sort(<builtins/[1-9A-Z]*>);
-foreach $version (@versions) {
- $version =~ s!builtins/!!g;
- process_version($version);
-}
-
-print << 'EOF';
-void *builtin_mem_ctx = NULL;
-
-void
-_mesa_glsl_release_functions(void)
-{
- talloc_free(builtin_mem_ctx);
-}
-
-void
-_mesa_glsl_initialize_functions(exec_list *instructions,
- struct _mesa_glsl_parse_state *state)
-{
- if (builtin_mem_ctx == NULL)
- builtin_mem_ctx = talloc_init("GLSL built-in functions");
-
- state->num_builtins_to_link = 0;
-EOF
-
-foreach $version_xs (@versions) {
- $check = "";
- if ($version_xs =~ /_vs/) {
- $check = "state->target == vertex_shader && ";
- } elsif ($version_xs =~ /_fs/) {
- $check = "state->target == fragment_shader && ";
- }
- $version = $version_xs;
- $version =~ s/_[vf]s//g;
-
- if ($version =~ /^[1-9][0-9][0-9]/) {
- $check = "${check}state->language_version >= $version";
- } else {
- # Not a version...an extension name
- $check = "${check}state->${version}_enable";
- }
- print " if ($check) {\n";
- print " static gl_shader *sh = NULL;\n";
- print "\n";
- print " if (sh == NULL) {\n";
- print " sh = read_builtins(GL_VERTEX_SHADER, functions_for_$version_xs,\n";
- print " Elements(functions_for_$version_xs));\n";
- print " talloc_steal(builtin_mem_ctx, sh);\n";
- print " }\n";
- print "\n";
- print " import_prototypes(sh->ir, instructions, state->symbols, state);\n";
- print " state->builtins_to_link[state->num_builtins_to_link] = sh;\n";
- print " state->num_builtins_to_link++;\n";
- print " }\n";
- print "\n";
-}
-
-print "}\n";
diff --git a/src/glsl/builtins/tools/generate_builtins.py b/src/glsl/builtins/tools/generate_builtins.py
new file mode 100755
index 0000000000..2eb67e398a
--- /dev/null
+++ b/src/glsl/builtins/tools/generate_builtins.py
@@ -0,0 +1,207 @@
+#!/usr/bin/python
+# -*- coding: UTF-8 -*-
+
+import re, glob, sys
+from os import path
+from subprocess import Popen, PIPE
+
+# Local module: generator for texture lookup builtins
+from texture_builtins import generate_texture_functions
+
+builtins_dir = path.join(path.dirname(path.abspath(__file__)), "..")
+
+# Read the files in builtins/ir/*...add them to the supplied dictionary.
+def read_ir_files(fs):
+ for filename in glob.glob(path.join(path.join(builtins_dir, 'ir'), '*')):
+ with open(filename) as f:
+ fs[path.basename(filename)] = f.read()
+
+# Return a dictionary containing all builtin definitions (even generated)
+def get_builtin_definitions():
+ fs = {}
+ generate_texture_functions(fs)
+ read_ir_files(fs)
+ return fs
+
+def stringify(s):
+ t = s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n"\n "')
+ return ' "' + t + '"\n'
+
+def write_function_definitions():
+ fs = get_builtin_definitions()
+ for k, v in fs.iteritems():
+ print 'static const char *builtin_' + k + ' ='
+ print stringify(v), ';'
+
+def run_compiler(args):
+ compiler_path = path.join(path.join(builtins_dir, '..'), 'glsl_compiler')
+ command = [compiler_path, '--dump-lir'] + args
+ p = Popen(command, 1, stdout=PIPE, shell=False)
+ output = p.communicate()[0]
+ return (output, p.returncode)
+
+def write_profile(filename, profile):
+ (proto_ir, returncode) = run_compiler([filename])
+
+ if returncode != 0:
+ print '#error builtins profile', profile, 'failed to compile'
+ return
+
+ # Kill any global variable declarations. We don't want them.
+ kill_globals = re.compile(r'^\(declare.*\n', re.MULTILINE);
+ proto_ir = kill_globals.sub('', proto_ir)
+
+ print 'static const char *prototypes_for_' + profile + ' ='
+ print stringify(proto_ir), ';'
+
+ # Print a table of all the functions (not signatures) referenced.
+ # This is done so we can avoid bothering with a hash table in the C++ code.
+
+ function_names = set()
+ for func in re.finditer(r'\(function (.+)\n', proto_ir):
+ function_names.add(func.group(1))
+
+ print 'static const char *functions_for_' + profile + ' [] = {'
+ for func in function_names:
+ print ' builtin_' + func + ','
+ print '};'
+
+def write_profiles():
+ profiles = get_profile_list()
+ for (filename, profile) in profiles:
+ write_profile(filename, profile)
+
+def get_profile_list():
+ profiles = []
+ for pfile in glob.glob(path.join(path.join(builtins_dir, 'profiles'), '*')):
+ profiles.append((pfile, path.basename(pfile).replace('.', '_')))
+ return profiles
+
+if __name__ == "__main__":
+ print """/* DO NOT MODIFY - automatically generated by generate_builtins.py */
+/*
+ * Copyright © 2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdio.h>
+#include "main/compiler.h"
+#include "glsl_parser_extras.h"
+#include "ir_reader.h"
+#include "program.h"
+#include "ast.h"
+
+extern "C" struct gl_shader *
+_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type);
+
+gl_shader *
+read_builtins(GLenum target, const char *protos, const char **functions, unsigned count)
+{
+ gl_shader *sh = _mesa_new_shader(NULL, 0, target);
+ struct _mesa_glsl_parse_state *st =
+ new(sh) _mesa_glsl_parse_state(NULL, target, sh);
+
+ st->language_version = 130;
+ st->ARB_texture_rectangle_enable = true;
+ st->EXT_texture_array_enable = true;
+ _mesa_glsl_initialize_types(st);
+
+ sh->ir = new(sh) exec_list;
+ sh->symbols = st->symbols;
+
+ /* Read the IR containing the prototypes */
+ _mesa_glsl_read_ir(st, sh->ir, protos, true);
+
+ /* Read ALL the function bodies, telling the IR reader not to scan for
+ * prototypes (we've already created them). The IR reader will skip any
+ * signature that does not already exist as a prototype.
+ */
+ for (unsigned i = 0; i < count; i++) {
+ _mesa_glsl_read_ir(st, sh->ir, functions[i], false);
+
+ if (st->error) {
+ printf("error reading builtin: %.35s ...\\n", functions[i]);
+ talloc_free(sh);
+ return NULL;
+ }
+ }
+
+ reparent_ir(sh->ir, sh);
+ delete st;
+
+ return sh;
+}
+"""
+
+ write_function_definitions()
+ write_profiles()
+
+ print """
+void *builtin_mem_ctx = NULL;
+
+void
+_mesa_glsl_release_functions(void)
+{
+ talloc_free(builtin_mem_ctx);
+}
+
+void
+_mesa_glsl_initialize_functions(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ if (builtin_mem_ctx == NULL)
+ builtin_mem_ctx = talloc_init("GLSL built-in functions");
+
+ state->num_builtins_to_link = 0;
+"""
+
+ profiles = get_profile_list()
+ for (filename, profile) in profiles:
+ if profile.endswith('_vert'):
+ check = 'state->target == vertex_shader && '
+ elif profile.endswith('_frag'):
+ check = 'state->target == fragment_shader && '
+
+ version = re.sub(r'_(vert|frag)$', '', profile)
+ if version.isdigit():
+ check += 'state->language_version == ' + version
+ else: # an extension name
+ check += 'state->' + version + '_enable'
+
+ print ' if (' + check + ') {'
+ print ' static gl_shader *sh = NULL;'
+ print ' if (sh == NULL) {'
+ print ' sh = read_builtins(GL_VERTEX_SHADER,'
+ print ' prototypes_for_' + profile + ','
+ print ' functions_for_' + profile + ','
+ print ' Elements(functions_for_' + profile,
+ print '));'
+ print ' talloc_steal(builtin_mem_ctx, sh);'
+ print ' }'
+ print
+ print ' import_prototypes(sh->ir, instructions, state->symbols,'
+ print ' state);'
+ print ' state->builtins_to_link[state->num_builtins_to_link] = sh;'
+ print ' state->num_builtins_to_link++;'
+ print ' }'
+ print
+ print '}'
+
diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py
index 33d9642ef7..8bf708b5aa 100755
--- a/src/glsl/builtins/tools/texture_builtins.py
+++ b/src/glsl/builtins/tools/texture_builtins.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
-from os import path
import sys
+import StringIO
def vec_type(g, size):
if size == 1:
@@ -95,204 +95,255 @@ def generate_fiu_sigs(tex_inst, sampler_type, use_proj = False, unused_fields =
generate_sigs("i", tex_inst, sampler_type, use_proj, unused_fields)
generate_sigs("u", tex_inst, sampler_type, use_proj, unused_fields)
-builtins_dir = path.join(path.dirname(path.abspath(__file__)), "..")
+def start_function(name):
+ sys.stdout = StringIO.StringIO()
+ print "((function " + name
-with open(path.join(builtins_dir, "130", "texture"), 'w') as sys.stdout:
- print "((function texture"
+def end_function(fs, name):
+ print "))"
+ fs[name] = sys.stdout.getvalue();
+ sys.stdout.close()
+
+# Generate all the functions and store them in the supplied dictionary.
+# This is better than writing them to actual files since they should never be
+# edited; it'd also be easy to confuse them with the many hand-generated files.
+#
+# Takes a dictionary as an argument.
+def generate_texture_functions(fs):
+ start_function("texture")
generate_fiu_sigs("tex", "1D")
generate_fiu_sigs("tex", "2D")
generate_fiu_sigs("tex", "3D")
generate_fiu_sigs("tex", "Cube")
generate_fiu_sigs("tex", "1DArray")
generate_fiu_sigs("tex", "2DArray")
- print "))"
-# txb variants are only allowed within a fragment shader (GLSL 1.30 p. 86)
-with open(path.join(builtins_dir, "130_fs", "texture"), 'w') as sys.stdout:
- print "((function texture"
generate_fiu_sigs("txb", "1D")
generate_fiu_sigs("txb", "2D")
generate_fiu_sigs("txb", "3D")
generate_fiu_sigs("txb", "Cube")
generate_fiu_sigs("txb", "1DArray")
generate_fiu_sigs("txb", "2DArray")
- print "))"
+ end_function(fs, "texture")
-with open(path.join(builtins_dir, "130", "textureProj"), 'w') as sys.stdout:
- print "((function textureProj"
+ start_function("textureProj")
generate_fiu_sigs("tex", "1D", True)
generate_fiu_sigs("tex", "1D", True, 2)
generate_fiu_sigs("tex", "2D", True)
generate_fiu_sigs("tex", "2D", True, 1)
generate_fiu_sigs("tex", "3D", True)
- print "))"
-with open(path.join(builtins_dir, "130_fs", "textureProj"), 'w') as sys.stdout:
- print "((function textureProj"
generate_fiu_sigs("txb", "1D", True)
generate_fiu_sigs("txb", "1D", True, 2)
generate_fiu_sigs("txb", "2D", True)
generate_fiu_sigs("txb", "2D", True, 1)
generate_fiu_sigs("txb", "3D", True)
- print "))"
+ end_function(fs, "textureProj")
-with open(path.join(builtins_dir, "130", "textureLod"), 'w') as sys.stdout:
- print "((function textureLod"
+ start_function("textureLod")
generate_fiu_sigs("txl", "1D")
generate_fiu_sigs("txl", "2D")
generate_fiu_sigs("txl", "3D")
generate_fiu_sigs("txl", "Cube")
generate_fiu_sigs("txl", "1DArray")
generate_fiu_sigs("txl", "2DArray")
- print "))"
+ end_function(fs, "textureLod")
-with open(path.join(builtins_dir, "130", "texelFetch"), 'w') as sys.stdout:
- print "((function texelFetch"
+ start_function("texelFetch")
generate_fiu_sigs("txf", "1D")
generate_fiu_sigs("txf", "2D")
generate_fiu_sigs("txf", "3D")
generate_fiu_sigs("txf", "1DArray")
generate_fiu_sigs("txf", "2DArray")
- print "))"
+ end_function(fs, "texelFetch")
-with open(path.join(builtins_dir, "130", "textureProjLod"), 'w') as sys.stdout:
- print "((function textureProjLod"
+ start_function("textureProjLod")
generate_fiu_sigs("txl", "1D", True)
generate_fiu_sigs("txl", "1D", True, 2)
generate_fiu_sigs("txl", "2D", True)
generate_fiu_sigs("txl", "2D", True, 1)
generate_fiu_sigs("txl", "3D", True)
- print "))"
+ end_function(fs, "textureProjLod")
-with open(path.join(builtins_dir, "130", "textureGrad"), 'w') as sys.stdout:
- print "((function textureGrad"
+ start_function("textureGrad")
generate_fiu_sigs("txd", "1D")
generate_fiu_sigs("txd", "2D")
generate_fiu_sigs("txd", "3D")
generate_fiu_sigs("txd", "Cube")
generate_fiu_sigs("txd", "1DArray")
generate_fiu_sigs("txd", "2DArray")
- print ")\n)"
+ end_function(fs, "textureGrad")
-with open(path.join(builtins_dir, "130", "textureProjGrad"), 'w') as sys.stdout:
- print "((function textureProjGrad"
+ start_function("textureProjGrad")
generate_fiu_sigs("txd", "1D", True)
generate_fiu_sigs("txd", "1D", True, 2)
generate_fiu_sigs("txd", "2D", True)
generate_fiu_sigs("txd", "2D", True, 1)
generate_fiu_sigs("txd", "3D", True)
- print "))"
+ end_function(fs, "textureProjGrad")
-# ARB_texture_rectangle extension
-with open(path.join(builtins_dir, "ARB_texture_rectangle", "textures"), 'w') as sys.stdout:
- print "((function texture2DRect"
+ # ARB_texture_rectangle extension
+ start_function("texture2DRect")
generate_sigs("", "tex", "2DRect")
- print ")\n (function shadow2DRect"
+ end_function(fs, "texture2DRect")
+
+ start_function("texture2DRectProj")
+ generate_sigs("", "tex", "2DRect", True)
+ generate_sigs("", "tex", "2DRect", True, 1)
+ end_function(fs, "texture2DRectProj")
+
+ start_function("shadow2DRect")
generate_sigs("", "tex", "2DRectShadow")
- print "))"
+ end_function(fs, "shadow2DRect")
-# EXT_texture_array extension
-with open(path.join(builtins_dir, "EXT_texture_array", "textures"), 'w') as sys.stdout:
- print "((function texture1DArray"
+ start_function("shadow2DRectProj")
+ generate_sigs("", "tex", "2DRectShadow", True)
+ end_function(fs, "shadow2DRectProj")
+
+ # EXT_texture_array extension
+ start_function("texture1DArray")
generate_sigs("", "tex", "1DArray")
- print ")\n (function texture1DArrayLod"
+ generate_sigs("", "txb", "1DArray")
+ end_function(fs, "texture1DArray")
+
+ start_function("texture1DArrayLod")
generate_sigs("", "txl", "1DArray")
- print ")\n (function texture2DArray"
+ end_function(fs, "texture1DArrayLod")
+
+ start_function("texture2DArray")
generate_sigs("", "tex", "2DArray")
- print ")\n (function texture2DArrayLod"
+ generate_sigs("", "txb", "2DArray")
+ end_function(fs, "texture2DArray")
+
+ start_function("texture2DArrayLod")
generate_sigs("", "txl", "2DArray")
- print ")\n (function shadow1DArray"
+ end_function(fs, "texture2DArrayLod")
+
+ start_function("shadow1DArray")
generate_sigs("", "tex", "1DArrayShadow")
- print ")\n (function shadow1DArrayLod"
+ generate_sigs("", "txb", "1DArrayShadow")
+ end_function(fs, "shadow1DArray")
+
+ start_function("shadow1DArrayLod")
generate_sigs("", "txl", "1DArrayShadow")
- print ")\n (function shadow2DArray"
- generate_sigs("", "tex", "2DArrayShadow")
- print "))"
+ end_function(fs, "shadow1DArrayLod")
-with open(path.join(builtins_dir, "EXT_texture_array_fs", "textures"), 'w') as sys.stdout:
- print "((function texture1DArray"
- generate_sigs("", "txb", "1DArray")
- print ")\n (function texture2DArray"
- generate_sigs("", "txb", "2DArray")
- print ")\n (function shadow1DArray"
- generate_sigs("", "txb", "1DArrayShadow")
- print "))"
+ start_function("shadow2DArray")
+ generate_sigs("", "tex", "2DArrayShadow")
+ end_function(fs, "shadow2DArray")
-# Deprecated (110/120 style) functions with silly names:
-with open(path.join(builtins_dir, "110", "textures"), 'w') as sys.stdout:
- print "((function texture1D"
+ # Deprecated (110/120 style) functions with silly names:
+ start_function("texture1D")
generate_sigs("", "tex", "1D")
- print ")\n (function texture1DLod"
+ generate_sigs("", "txb", "1D")
+ end_function(fs, "texture1D")
+
+ start_function("texture1DLod")
generate_sigs("", "txl", "1D")
- print ")\n (function texture1DProj"
+ end_function(fs, "texture1DLod")
+
+ start_function("texture1DProj")
generate_sigs("", "tex", "1D", True)
generate_sigs("", "tex", "1D", True, 2)
- print ")\n (function texture1DProjLod"
+ generate_sigs("", "txb", "1D", True)
+ generate_sigs("", "txb", "1D", True, 2)
+ end_function(fs, "texture1DProj")
+
+ start_function("texture1DProjLod")
generate_sigs("", "txl", "1D", True)
generate_sigs("", "txl", "1D", True, 2)
- print ")\n (function texture2D"
+ end_function(fs, "texture1DProjLod")
+
+ start_function("texture2D")
generate_sigs("", "tex", "2D")
- print ")\n(function texture2DLod"
+ generate_sigs("", "txb", "2D")
+ end_function(fs, "texture2D")
+
+ start_function("texture2DLod")
generate_sigs("", "txl", "2D")
- print ")\n (function texture2DProj"
+ end_function(fs, "texture2DLod")
+
+ start_function("texture2DProj")
generate_sigs("", "tex", "2D", True)
generate_sigs("", "tex", "2D", True, 1)
- print ")\n (function texture2DProjLod"
+ generate_sigs("", "txb", "2D", True)
+ generate_sigs("", "txb", "2D", True, 1)
+ end_function(fs, "texture2DProj")
+
+ start_function("texture2DProjLod")
generate_sigs("", "txl", "2D", True)
generate_sigs("", "txl", "2D", True, 1)
- print ")\n (function texture3D"
+ end_function(fs, "texture2DProjLod")
+
+ start_function("texture3D")
generate_sigs("", "tex", "3D")
- print ")\n (function texture3DLod"
+ generate_sigs("", "txb", "3D")
+ end_function(fs, "texture3D")
+
+ start_function("texture3DLod")
generate_sigs("", "txl", "3D")
- print ")\n (function texture3DProj"
+ end_function(fs, "texture3DLod")
+
+ start_function("texture3DProj")
generate_sigs("", "tex", "3D", True)
- print ")\n (function texture3DProjLod"
+ generate_sigs("", "txb", "3D", True)
+ end_function(fs, "texture3DProj")
+
+ start_function("texture3DProjLod")
generate_sigs("", "txl", "3D", True)
- print ")\n (function textureCube"
+ end_function(fs, "texture3DProjLod")
+
+ start_function("textureCube")
generate_sigs("", "tex", "Cube")
- print ")\n (function textureCubeLod"
+ generate_sigs("", "txb", "Cube")
+ end_function(fs, "textureCube")
+
+ start_function("textureCubeLod")
generate_sigs("", "txl", "Cube")
- print ")\n (function shadow1D"
+ end_function(fs, "textureCubeLod")
+
+ start_function("shadow1D")
generate_sigs("", "tex", "1DShadow", False, 1)
- print ")\n (function shadow1DLod"
+ generate_sigs("", "txb", "1DShadow", False, 1)
+ end_function(fs, "shadow1D")
+
+ start_function("shadow1DLod")
generate_sigs("", "txl", "1DShadow", False, 1)
- print ")\n (function shadow1DProj"
+ end_function(fs, "shadow1DLod")
+
+ start_function("shadow1DProj")
generate_sigs("", "tex", "1DShadow", True, 1)
- print ")\n (function shadow1DProjLod"
+ generate_sigs("", "txb", "1DShadow", True, 1)
+ end_function(fs, "shadow1DProj")
+
+ start_function("shadow1DProjLod")
generate_sigs("", "txl", "1DShadow", True, 1)
- print ")\n (function shadow2D"
+ end_function(fs, "shadow1DProjLod")
+
+ start_function("shadow2D")
generate_sigs("", "tex", "2DShadow")
- print ")\n (function shadow2DLod"
+ generate_sigs("", "txb", "2DShadow")
+ end_function(fs, "shadow2D")
+
+ start_function("shadow2DLod")
generate_sigs("", "txl", "2DShadow")
- print ")\n (function shadow2DProj"
+ end_function(fs, "shadow2DLod")
+
+ start_function("shadow2DProj")
generate_sigs("", "tex", "2DShadow", True)
- print ")\n (function shadow2DProjLod"
+ generate_sigs("", "txb", "2DShadow", True)
+ end_function(fs, "shadow2DProj")
+
+ start_function("shadow2DProjLod")
generate_sigs("", "txl", "2DShadow", True)
- print "))"
+ end_function(fs, "shadow2DProjLod")
-with open(path.join(builtins_dir, "110_fs", "textures"), 'w') as sys.stdout:
- print "((function texture1D"
- generate_sigs("", "txb", "1D")
- print ")\n (function texture1DProj"
- generate_sigs("", "txb", "1D", True)
- generate_sigs("", "txb", "1D", True, 2)
- print ")\n (function texture2D"
- generate_sigs("", "txb", "2D")
- print ")\n (function texture2DProj"
- generate_sigs("", "txb", "2D", True)
- generate_sigs("", "txb", "2D", True, 1)
- print ")\n (function texture3D"
- generate_sigs("", "txb", "3D")
- print ")\n (function texture3DProj"
- generate_sigs("", "txb", "3D", True)
- print ")\n (function textureCube"
- generate_sigs("", "txb", "Cube")
- print ")\n (function shadow1D"
- generate_sigs("", "txb", "1DShadow", False, 1)
- print ")\n (function shadow1DProj"
- generate_sigs("", "txb", "1DShadow", True, 1)
- print ")\n (function shadow2D"
- generate_sigs("", "txb", "2DShadow")
- print ")\n (function shadow2DProj"
- generate_sigs("", "txb", "2DShadow", True)
- print "))"
+ sys.stdout = sys.__stdout__
+ return fs
+
+# If you actually run this script, it'll print out all the functions.
+if __name__ == "__main__":
+ fs = {}
+ generate_texture_functions(fs);
+ for k, v in fs.iteritems():
+ print v