with open(filename) as f:
fs[function_name] = f.read()
+def read_glsl_files(fs):
+ for filename in glob(path.join(path.join(builtins_dir, 'glsl'), '*.glsl')):
+ function_name = path.basename(filename).split('.')[0]
+ (output, returncode) = run_compiler([filename])
+ if (returncode):
+ sys.stderr.write("Failed to compile builtin: " + filename + "\n")
+ sys.stderr.write("Result:\n")
+ sys.stderr.write(output)
+ else:
+ fs[function_name] = output;
+
# Return a dictionary containing all builtin definitions (even generated)
def get_builtin_definitions():
fs = {}
generate_texture_functions(fs)
read_ir_files(fs)
+ read_glsl_files(fs)
return fs
def stringify(s):
# Also toss any duplicate newlines
output = output.replace('\n\n', '\n')
+ # Kill any global variable declarations. We don't want them.
+ kill_globals = re.compile(r'^\(declare.*\n', re.MULTILINE)
+ output = kill_globals.sub('', output)
+
return (output, p.returncode)
def write_profile(filename, profile):
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), ';'