From fe325e64230e01fa7f3044afb99f927bc594bef7 Mon Sep 17 00:00:00 2001 From: Tim Rowley Date: Thu, 16 Mar 2017 13:44:52 -0500 Subject: [PATCH] swr: [rasterizer] Cleanup naming of codegen files All template files and generated files are prefixed with gen_. Reviewed-by: Bruce Cherniak --- src/gallium/drivers/swr/.gitignore | 12 ++-- src/gallium/drivers/swr/Makefile.am | 62 +++++++++---------- src/gallium/drivers/swr/SConscript | 18 +++--- .../swr/rasterizer/archrast/archrast.cpp | 2 +- .../swr/rasterizer/archrast/archrast.h | 2 +- .../swr/rasterizer/archrast/eventmanager.h | 4 +- .../swr/rasterizer/codegen/gen_archrast.py | 60 +++++++++--------- .../swr/rasterizer/codegen/gen_backends.py | 8 +-- .../swr/rasterizer/codegen/gen_knobs.py | 2 +- .../rasterizer/codegen/gen_llvm_ir_macros.py | 2 +- ...ar_event_cpp.template => gen_ar_event.cpp} | 4 +- .../{ar_event_h.template => gen_ar_event.hpp} | 0 ...ler_h.template => gen_ar_eventhandler.hpp} | 0 ...h.template => gen_ar_eventhandlerfile.hpp} | 0 .../{backend_template.cpp => gen_backend.cpp} | 0 ...n_builder_template.hpp => gen_builder.hpp} | 0 .../{knobs_template.cpp => gen_knobs.cpp} | 57 +++++++++-------- .../rasterizer/codegen/templates/gen_llvm.hpp | 29 ++++----- .../drivers/swr/rasterizer/core/api.cpp | 1 - .../swr/rasterizer/jitter/JitManager.cpp | 2 +- .../swr/rasterizer/jitter/blend_jit.cpp | 2 +- .../swr/rasterizer/jitter/fetch_jit.cpp | 2 +- .../swr/rasterizer/jitter/streamout_jit.cpp | 2 +- src/gallium/drivers/swr/swr_shader.cpp | 4 +- src/gallium/drivers/swr/swr_state.cpp | 4 +- src/gallium/drivers/swr/swr_tex_sample.cpp | 4 +- 26 files changed, 145 insertions(+), 138 deletions(-) rename src/gallium/drivers/swr/rasterizer/codegen/templates/{ar_event_cpp.template => gen_ar_event.cpp} (96%) rename src/gallium/drivers/swr/rasterizer/codegen/templates/{ar_event_h.template => gen_ar_event.hpp} (100%) rename src/gallium/drivers/swr/rasterizer/codegen/templates/{ar_eventhandler_h.template => gen_ar_eventhandler.hpp} (100%) rename src/gallium/drivers/swr/rasterizer/codegen/templates/{ar_eventhandlerfile_h.template => gen_ar_eventhandlerfile.hpp} (100%) rename src/gallium/drivers/swr/rasterizer/codegen/templates/{backend_template.cpp => gen_backend.cpp} (100%) rename src/gallium/drivers/swr/rasterizer/codegen/templates/{gen_builder_template.hpp => gen_builder.hpp} (100%) rename src/gallium/drivers/swr/rasterizer/codegen/templates/{knobs_template.cpp => gen_knobs.cpp} (91%) diff --git a/src/gallium/drivers/swr/.gitignore b/src/gallium/drivers/swr/.gitignore index 33ee5fa1492..32b64006cd1 100644 --- a/src/gallium/drivers/swr/.gitignore +++ b/src/gallium/drivers/swr/.gitignore @@ -1,11 +1,11 @@ -swr_context_llvm.h +gen_swr_context_llvm.h rasterizer/archrast/gen_ar_event.cpp -rasterizer/archrast/gen_ar_event.h -rasterizer/archrast/gen_ar_eventhandler.h -rasterizer/archrast/gen_ar_eventhandlerfile.h +rasterizer/archrast/gen_ar_event.hpp +rasterizer/archrast/gen_ar_eventhandler.hpp +rasterizer/archrast/gen_ar_eventhandlerfile.hpp rasterizer/jitter/gen_builder.hpp rasterizer/jitter/gen_builder_x86.hpp -rasterizer/jitter/state_llvm.h +rasterizer/jitter/gen_state_llvm.h rasterizer/codegen/gen_knobs.cpp rasterizer/codegen/gen_knobs.h -rasterizer/core/BackendPixelRate0.cpp +rasterizer/core/gen_BackendPixelRate0.cpp diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am index 99a7df5f6c4..8ba9ac93da9 100644 --- a/src/gallium/drivers/swr/Makefile.am +++ b/src/gallium/drivers/swr/Makefile.am @@ -52,49 +52,49 @@ COMMON_SOURCES = \ $(BUILT_SOURCES) BUILT_SOURCES = \ - swr_context_llvm.h \ + gen_swr_context_llvm.h \ rasterizer/codegen/gen_knobs.cpp \ rasterizer/codegen/gen_knobs.h \ - rasterizer/jitter/state_llvm.h \ + rasterizer/jitter/gen_state_llvm.h \ rasterizer/jitter/gen_builder_x86.hpp \ - rasterizer/archrast/gen_ar_event.h \ + rasterizer/archrast/gen_ar_event.hpp \ rasterizer/archrast/gen_ar_event.cpp \ - rasterizer/archrast/gen_ar_eventhandler.h \ - rasterizer/archrast/gen_ar_eventhandlerfile.h \ - rasterizer/core/BackendPixelRate0.cpp + rasterizer/archrast/gen_ar_eventhandler.hpp \ + rasterizer/archrast/gen_ar_eventhandlerfile.hpp \ + rasterizer/core/gen_BackendPixelRate0.cpp MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D) PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS) -swr_context_llvm.h: rasterizer/codegen/gen_llvm_types.py rasterizer/codegen/templates/gen_llvm.hpp swr_context.h +gen_swr_context_llvm.h: rasterizer/codegen/gen_llvm_types.py rasterizer/codegen/templates/gen_llvm.hpp swr_context.h $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_llvm_types.py \ --input $(srcdir)/swr_context.h \ - --output ./swr_context_llvm.h + --output ./gen_swr_context_llvm.h -rasterizer/codegen/gen_knobs.cpp: rasterizer/codegen/gen_knobs.py rasterizer/codegen/knob_defs.py rasterizer/codegen/templates/knobs_template.cpp +rasterizer/codegen/gen_knobs.cpp: rasterizer/codegen/gen_knobs.py rasterizer/codegen/knob_defs.py rasterizer/codegen/templates/gen_knobs.cpp $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_knobs.py \ - --input $(srcdir)/rasterizer/codegen/templates/knobs_template.cpp \ + --input $(srcdir)/rasterizer/codegen/templates/gen_knobs.cpp \ --output rasterizer/codegen/gen_knobs.cpp \ --gen_cpp -rasterizer/codegen/gen_knobs.h: rasterizer/codegen/gen_knobs.py rasterizer/codegen/knob_defs.py rasterizer/codegen/templates/knobs_template.cpp +rasterizer/codegen/gen_knobs.h: rasterizer/codegen/gen_knobs.py rasterizer/codegen/knob_defs.py rasterizer/codegen/templates/gen_knobs.cpp $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_knobs.py \ - --input $(srcdir)/rasterizer/codegen/templates/knobs_template.cpp \ + --input $(srcdir)/rasterizer/codegen/templates/gen_knobs.cpp \ --output rasterizer/codegen/gen_knobs.h \ --gen_h -rasterizer/jitter/state_llvm.h: rasterizer/codegen/gen_llvm_types.py rasterizer/codegen/templates/gen_llvm.hpp rasterizer/core/state.h +rasterizer/jitter/gen_state_llvm.h: rasterizer/codegen/gen_llvm_types.py rasterizer/codegen/templates/gen_llvm.hpp rasterizer/core/state.h $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_llvm_types.py \ --input $(srcdir)/rasterizer/core/state.h \ - --output rasterizer/jitter/state_llvm.h + --output rasterizer/jitter/gen_state_llvm.h -rasterizer/jitter/gen_builder.hpp: rasterizer/codegen/gen_llvm_ir_macros.py rasterizer/codegen/templates/gen_builder_template.hpp +rasterizer/jitter/gen_builder.hpp: rasterizer/codegen/gen_llvm_ir_macros.py rasterizer/codegen/templates/gen_builder.hpp $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_llvm_ir_macros.py \ @@ -102,22 +102,22 @@ rasterizer/jitter/gen_builder.hpp: rasterizer/codegen/gen_llvm_ir_macros.py rast --output rasterizer/jitter \ --gen_h -rasterizer/jitter/gen_builder_x86.hpp: rasterizer/codegen/gen_llvm_ir_macros.py rasterizer/codegen/templates/gen_builder_template.hpp +rasterizer/jitter/gen_builder_x86.hpp: rasterizer/codegen/gen_llvm_ir_macros.py rasterizer/codegen/templates/gen_builder.hpp $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_llvm_ir_macros.py \ --output rasterizer/jitter \ --gen_x86_h -rasterizer/archrast/gen_ar_event.h: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/ar_event_h.template rasterizer/archrast/events.proto +rasterizer/archrast/gen_ar_event.hpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_event.hpp rasterizer/archrast/events.proto $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_archrast.py \ --proto $(srcdir)/rasterizer/archrast/events.proto \ - --output rasterizer/archrast/gen_ar_event.h \ + --output rasterizer/archrast/gen_ar_event.hpp \ --gen_event_h -rasterizer/archrast/gen_ar_event.cpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/ar_event_cpp.template rasterizer/archrast/events.proto +rasterizer/archrast/gen_ar_event.cpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_event.cpp rasterizer/archrast/events.proto $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_archrast.py \ @@ -125,20 +125,20 @@ rasterizer/archrast/gen_ar_event.cpp: rasterizer/codegen/gen_archrast.py rasteri --output rasterizer/archrast/gen_ar_event.cpp \ --gen_event_cpp -rasterizer/archrast/gen_ar_eventhandler.h: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/ar_eventhandler_h.template rasterizer/archrast/events.proto +rasterizer/archrast/gen_ar_eventhandler.hpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_eventhandler.hpp rasterizer/archrast/events.proto $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_archrast.py \ --proto $(srcdir)/rasterizer/archrast/events.proto \ - --output rasterizer/archrast/gen_ar_eventhandler.h \ + --output rasterizer/archrast/gen_ar_eventhandler.hpp \ --gen_eventhandler_h -rasterizer/archrast/gen_ar_eventhandlerfile.h: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/ar_eventhandlerfile_h.template rasterizer/archrast/events.proto +rasterizer/archrast/gen_ar_eventhandlerfile.hpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp rasterizer/archrast/events.proto $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_archrast.py \ --proto $(srcdir)/rasterizer/archrast/events.proto \ - --output rasterizer/archrast/gen_ar_eventhandlerfile.h \ + --output rasterizer/archrast/gen_ar_eventhandlerfile.hpp \ --gen_eventhandlerfile_h # 5 SWR_MULTISAMPLE_TYPE_COUNT @@ -147,7 +147,7 @@ rasterizer/archrast/gen_ar_eventhandlerfile.h: rasterizer/codegen/gen_archrast.p # 2 centroid # 2 forcedSampleCount # 2 canEarlyZ -rasterizer/core/BackendPixelRate0.cpp: rasterizer/codegen/gen_backends.py rasterizer/codegen/templates/backend_template.cpp +rasterizer/core/gen_BackendPixelRate0.cpp: rasterizer/codegen/gen_backends.py rasterizer/codegen/templates/gen_backend.cpp $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_backends.py \ @@ -258,11 +258,11 @@ EXTRA_DIST = \ rasterizer/codegen/mako/runtime.py \ rasterizer/codegen/mako/template.py \ rasterizer/codegen/mako/util.py \ - rasterizer/codegen/templates/knobs_template.cpp \ - rasterizer/codegen/templates/ar_event_h.template \ - rasterizer/codegen/templates/ar_event_cpp.template \ - rasterizer/codegen/templates/ar_eventhandler_h.template \ - rasterizer/codegen/templates/ar_eventhandlerfile_h.template \ - rasterizer/codegen/templates/backend_template.cpp \ - rasterizer/codegen/templates/gen_builder_template.hpp \ + rasterizer/codegen/templates/gen_ar_event.cpp \ + rasterizer/codegen/templates/gen_ar_event.hpp \ + rasterizer/codegen/templates/gen_ar_eventhandler.hpp \ + rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp \ + rasterizer/codegen/templates/gen_backend.cpp \ + rasterizer/codegen/templates/gen_builder.hpp \ + rasterizer/codegen/templates/gen_knobs.cpp \ rasterizer/codegen/templates/gen_llvm.hpp diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript index efcc686aaa7..ad16162c297 100644 --- a/src/gallium/drivers/swr/SConscript +++ b/src/gallium/drivers/swr/SConscript @@ -51,19 +51,19 @@ swrroot = '#src/gallium/drivers/swr/' env.CodeGenerate( target = 'rasterizer/codegen/gen_knobs.cpp', script = swrroot + 'rasterizer/codegen/gen_knobs.py', - source = 'rasterizer/codegen/templates/knobs_template.cpp', + source = 'rasterizer/codegen/templates/gen_knobs.cpp', command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp' ) env.CodeGenerate( target = 'rasterizer/codegen/gen_knobs.h', script = swrroot + 'rasterizer/codegen/gen_knobs.py', - source = 'rasterizer/codegen/templates/knobs_template.cpp', + source = 'rasterizer/codegen/templates/gen_knobs.cpp', command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h' ) env.CodeGenerate( - target = 'rasterizer/jitter/state_llvm.h', + target = 'rasterizer/jitter/gen_state_llvm.h', script = swrroot + 'rasterizer/codegen/gen_llvm_types.py', source = 'rasterizer/core/state.h', command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET' @@ -84,14 +84,14 @@ env.CodeGenerate( ) env.CodeGenerate( - target = './swr_context_llvm.h', + target = './gen_swr_context_llvm.h', script = swrroot + 'rasterizer/codegen/gen_llvm_types.py', source = 'swr_context.h', command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET' ) env.CodeGenerate( - target = 'rasterizer/archrast/gen_ar_event.h', + target = 'rasterizer/archrast/gen_ar_event.hpp', script = swrroot + 'rasterizer/codegen/gen_archrast.py', source = 'rasterizer/archrast/events.proto', command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_h' @@ -105,14 +105,14 @@ env.CodeGenerate( ) env.CodeGenerate( - target = 'rasterizer/archrast/gen_ar_eventhandler.h', + target = 'rasterizer/archrast/gen_ar_eventhandler.hpp', script = swrroot + 'rasterizer/codegen/gen_archrast.py', source = 'rasterizer/archrast/events.proto', command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandler_h' ) env.CodeGenerate( - target = 'rasterizer/archrast/gen_ar_eventhandlerfile.h', + target = 'rasterizer/archrast/gen_ar_eventhandlerfile.hpp', script = swrroot + 'rasterizer/codegen/gen_archrast.py', source = 'rasterizer/archrast/events.proto', command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandlerfile_h' @@ -125,7 +125,7 @@ env.CodeGenerate( # 2 forcedSampleCount # 2 canEarlyZ env.CodeGenerate( - target = 'rasterizer/core/BackendPixelRate0.cpp', + target = 'rasterizer/core/gen_BackendPixelRate0.cpp', script = swrroot + 'rasterizer/codegen/gen_backends.py', command = python_cmd + ' $SCRIPT --output rasterizer/core --dim 5 2 3 2 2 2 --split 0 --cpp' ) @@ -134,7 +134,7 @@ env.CodeGenerate( built_sources = [ 'rasterizer/codegen/gen_knobs.cpp', 'rasterizer/archrast/gen_ar_event.cpp', - 'rasterizer/core/BackendPixelRate0.cpp', + 'rasterizer/core/gen_BackendPixelRate0.cpp', ] source = built_sources diff --git a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp index 20b14a3a28c..a7d41e27c0d 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp +++ b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp @@ -30,7 +30,7 @@ #include "common/os.h" #include "archrast/archrast.h" #include "archrast/eventmanager.h" -#include "gen_ar_eventhandlerfile.h" +#include "gen_ar_eventhandlerfile.hpp" namespace ArchRast { diff --git a/src/gallium/drivers/swr/rasterizer/archrast/archrast.h b/src/gallium/drivers/swr/rasterizer/archrast/archrast.h index c0f9d6a8194..1b81e6e952b 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/archrast.h +++ b/src/gallium/drivers/swr/rasterizer/archrast/archrast.h @@ -28,7 +28,7 @@ #pragma once #include "common/os.h" -#include "gen_ar_event.h" +#include "gen_ar_event.hpp" namespace ArchRast { diff --git a/src/gallium/drivers/swr/rasterizer/archrast/eventmanager.h b/src/gallium/drivers/swr/rasterizer/archrast/eventmanager.h index b361188c3dd..44f75e44410 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/eventmanager.h +++ b/src/gallium/drivers/swr/rasterizer/archrast/eventmanager.h @@ -29,8 +29,8 @@ #include "common/os.h" -#include "gen_ar_event.h" -#include "gen_ar_eventhandler.h" +#include "gen_ar_event.hpp" +#include "gen_ar_eventhandler.hpp" #include diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py index 901d6d8d05b..cbaa1beddec 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py +++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py @@ -36,12 +36,12 @@ def write_template_to_string(template_filename, **kwargs): except: traceback = RichTraceback() for (filename, lineno, function, line) in traceback.traceback: - print("File %s, line %s, in %s" % (filename, lineno, function)) - print(line, "\n") - print("%s: %s" % (str(traceback.error.__class__.__name__), traceback.error)) + print('File %s, line %s, in %s' % (filename, lineno, function)) + print(line, '\n') + print('%s: %s' % (str(traceback.error.__class__.__name__), traceback.error)) def write_template_to_file(template_filename, output_filename, **kwargs): - with open(output_filename, "w") as outfile: + with open(output_filename, 'w') as outfile: print(write_template_to_string(template_filename, **kwargs), file=outfile) def parse_event_fields(lines, idx, event_dict): @@ -57,14 +57,14 @@ def parse_event_fields(lines, idx, event_dict): line = lines[idx].rstrip() idx += 1 - field = re.match(r"(\s*)(\w+)(\s*)(\w+)", line) + field = re.match(r'(\s*)(\w+)(\s*)(\w+)', line) if field: field_types.append(field.group(2)) field_names.append(field.group(4)) num_fields += 1 - end_of_event = re.match(r"(\s*)};", line) + end_of_event = re.match(r'(\s*)};', line) event_dict['field_types'] = field_types event_dict['field_names'] = field_names @@ -82,15 +82,15 @@ def parse_enums(lines, idx, event_dict): line = lines[idx].rstrip() idx += 1 - preprocessor = re.search(r"#if|#endif", line) + preprocessor = re.search(r'#if|#endif', line) if not preprocessor: - enum = re.match(r"(\s*)(\w+)(\s*)", line) + enum = re.match(r'(\s*)(\w+)(\s*)', line) if enum: enum_names.append(line) - end_of_enum = re.match(r"(\s*)};", line) + end_of_enum = re.match(r'(\s*)};', line) event_dict['names'] = enum_names return idx @@ -115,7 +115,7 @@ def parse_protos(filename): idx += 1 # search for event definitions. - match = re.match(r"(\s*)event(\s*)(\w+)", line) + match = re.match(r'(\s*)event(\s*)(\w+)', line) if match: eventId += 1 @@ -127,7 +127,7 @@ def parse_protos(filename): idx = parse_event_fields(lines, idx, protos['events'][event_name]) # search for enums. - match = re.match(r"(\s*)enum(\s*)(\w+)", line) + match = re.match(r'(\s*)enum(\s*)(\w+)', line) if match: enum_name = match.group(3) @@ -142,12 +142,12 @@ def main(): # Parse args... parser = argparse.ArgumentParser() - parser.add_argument("--proto", "-p", help="Path to proto file", required=True) - parser.add_argument("--output", "-o", help="Output filename (i.e. event.h)", required=True) - parser.add_argument("--gen_event_h", "-geh", help="Generate event header", action="store_true", default=False) - parser.add_argument("--gen_event_cpp", "-gec", help="Generate event cpp", action="store_true", default=False) - parser.add_argument("--gen_eventhandler_h", "-gehh", help="Generate eventhandler header", action="store_true", default=False) - parser.add_argument("--gen_eventhandlerfile_h", "-gehf", help="Generate eventhandler header for writing to files", action="store_true", default=False) + parser.add_argument('--proto', '-p', help='Path to proto file', required=True) + parser.add_argument('--output', '-o', help='Output filename (i.e. event.hpp)', required=True) + parser.add_argument('--gen_event_hpp', help='Generate event header', action='store_true', default=False) + parser.add_argument('--gen_event_cpp', help='Generate event cpp', action='store_true', default=False) + parser.add_argument('--gen_eventhandler_hpp', help='Generate eventhandler header', action='store_true', default=False) + parser.add_argument('--gen_eventhandlerfile_hpp', help='Generate eventhandler header for writing to files', action='store_true', default=False) args = parser.parse_args() proto_filename = args.proto @@ -155,21 +155,21 @@ def main(): (output_dir, output_filename) = os.path.split(args.output) if not output_dir: - output_dir = "." + output_dir = '.' - #print("output_dir = %s" % output_dir, file=sys.stderr) - #print("output_filename = %s" % output_filename, file=sys.stderr) + #print('output_dir = %s' % output_dir, file=sys.stderr) + #print('output_filename = %s' % output_filename, file=sys.stderr) if not os.path.exists(proto_filename): - print("Error: Could not find proto file %s" % proto_filename, file=sys.stderr) + print('Error: Could not find proto file %s' % proto_filename, file=sys.stderr) return 1 protos = parse_protos(proto_filename) # Generate event header - if args.gen_event_h: + if args.gen_event_hpp: curdir = os.path.dirname(os.path.abspath(__file__)) - template_file = os.sep.join([curdir, 'templates', 'ar_event_h.template']) + template_file = os.sep.join([curdir, 'templates', 'gen_ar_event.hpp']) output_fullpath = os.sep.join([output_dir, output_filename]) write_template_to_file(template_file, output_fullpath, @@ -179,7 +179,7 @@ def main(): # Generate event implementation if args.gen_event_cpp: curdir = os.path.dirname(os.path.abspath(__file__)) - template_file = os.sep.join([curdir, 'templates', 'ar_event_cpp.template']) + template_file = os.sep.join([curdir, 'templates', 'gen_ar_event.cpp']) output_fullpath = os.sep.join([output_dir, output_filename]) write_template_to_file(template_file, output_fullpath, @@ -187,25 +187,25 @@ def main(): protos=protos) # Generate event handler header - if args.gen_eventhandler_h: + if args.gen_eventhandler_hpp: curdir = os.path.dirname(os.path.abspath(__file__)) - template_file = os.sep.join([curdir, 'templates', 'ar_eventhandler_h.template']) + template_file = os.sep.join([curdir, 'templates', 'gen_ar_eventhandler.hpp']) output_fullpath = os.sep.join([output_dir, output_filename]) write_template_to_file(template_file, output_fullpath, filename=output_filename, - event_header="gen_ar_event.h", # todo: fix this! + event_header='gen_ar_event.hpp', protos=protos) # Generate event handler header - if args.gen_eventhandlerfile_h: + if args.gen_eventhandlerfile_hpp: curdir = os.path.dirname(os.path.abspath(__file__)) - template_file = os.sep.join([curdir, 'templates', 'ar_eventhandlerfile_h.template']) + template_file = os.sep.join([curdir, 'templates', 'gen_ar_eventhandlerfile.hpp']) output_fullpath = os.sep.join([output_dir, output_filename]) write_template_to_file(template_file, output_fullpath, filename=output_filename, - event_header="gen_ar_eventhandler.h", # todo: fix this! + event_header='gen_ar_eventhandler.hpp', protos=protos) return 0 diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py index c889ea5816e..f2a22729dc2 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py +++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py @@ -94,8 +94,8 @@ def main(args=sys.argv[1:]): # generate .cpp files if args.cpp: - baseCppName = os.path.join(args.outdir, 'BackendPixelRate%s.cpp') - templateCpp = os.path.join(thisDir, 'templates', 'backend_template.cpp') + baseCppName = os.path.join(args.outdir, 'gen_BackendPixelRate%s.cpp') + templateCpp = os.path.join(thisDir, 'templates', 'gen_backend.cpp') for fileNum in range(numFiles): filename = baseCppName % str(fileNum) @@ -109,7 +109,7 @@ def main(args=sys.argv[1:]): # generate gen_backend.cmake file if args.cmake: - templateCmake = os.path.join(thisDir, 'templates', 'backend_template.cmake') + templateCmake = os.path.join(thisDir, 'templates', 'gen_backend.cmake') cmakeFile = os.path.join(args.outdir, 'gen_backends.cmake') #print('Generating', cmakeFile) write_template_to_file( @@ -117,7 +117,7 @@ def main(args=sys.argv[1:]): cmakeFile, cmdline=sys.argv, numFiles=numFiles, - baseCppName=baseCppName.replace('\\','/')) + baseCppName='${RASTY_GEN_SRC_DIR}/backends/' + os.path.basename(baseCppName)) #print("Generated %d template instantiations in %d files" % (len(output_list), numFiles)) diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_knobs.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_knobs.py index 50afdcdd10c..e722b84a9f1 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/gen_knobs.py +++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_knobs.py @@ -51,7 +51,7 @@ def main(args=sys.argv[1:]): # parse args parser = argparse.ArgumentParser() - parser.add_argument("--input", "-i", help="Path to knobs.template", required=True) + parser.add_argument("--input", "-i", help="Path to gen_knobs.cpp template", required=True) parser.add_argument("--output", "-o", help="Path to output file", required=True) parser.add_argument("--gen_h", "-gen_h", help="Generate gen_knobs.h", action="store_true", default=False) parser.add_argument("--gen_cpp", "-gen_cpp", help="Generate gen_knobs.cpp", action="store_true", required=False) diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py index cfd63942dc1..bd8e48e4218 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py +++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py @@ -95,7 +95,7 @@ intrinsics = [ ] this_dir = os.path.dirname(os.path.abspath(__file__)) -template = os.path.join(this_dir, 'templates', 'gen_builder_template.hpp') +template = os.path.join(this_dir, 'templates', 'gen_builder.hpp') def convert_uppercamel(name): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_cpp.template b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.cpp similarity index 96% rename from src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_cpp.template rename to src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.cpp index 4b3dcd57dbc..b743b2f3d2d 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_cpp.template +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.cpp @@ -28,8 +28,8 @@ * ******************************************************************************/ #include "common/os.h" -#include "gen_ar_event.h" -#include "gen_ar_eventhandler.h" +#include "gen_ar_event.hpp" +#include "gen_ar_eventhandler.hpp" using namespace ArchRast; % for name in protos['event_names']: diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_h.template b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.hpp similarity index 100% rename from src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_h.template rename to src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.hpp diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandler_h.template b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandler.hpp similarity index 100% rename from src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandler_h.template rename to src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandler.hpp diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandlerfile_h.template b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp similarity index 100% rename from src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandlerfile_h.template rename to src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/backend_template.cpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_backend.cpp similarity index 100% rename from src/gallium/drivers/swr/rasterizer/codegen/templates/backend_template.cpp rename to src/gallium/drivers/swr/rasterizer/codegen/templates/gen_backend.cpp diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder_template.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder.hpp similarity index 100% rename from src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder_template.hpp rename to src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder.hpp diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/knobs_template.cpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp similarity index 91% rename from src/gallium/drivers/swr/rasterizer/codegen/templates/knobs_template.cpp rename to src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp index 99294d2290e..81e49da659c 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/knobs_template.cpp +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp @@ -1,28 +1,4 @@ -<% - max_len = 0 - for knob in knobs: - if len(knob[0]) > max_len: max_len = len(knob[0]) - max_len += len('KNOB_ ') - if max_len % 4: max_len += 4 - (max_len % 4) - - def space_knob(knob): - knob_len = len('KNOB_' + knob) - return ' '*(max_len - knob_len) - - def calc_max_name_len(choices_array): - _max_len = 0 - for choice in choices_array: - if len(choice['name']) > _max_len: _max_len = len(choice['name']) - - if _max_len % 4: _max_len += 4 - (_max_len % 4) - return _max_len - - def space_name(name, max_len): - name_len = len(name) - return ' '*(max_len - name_len) - - -%>/****************************************************************************** +/****************************************************************************** * * Copyright 2015-2017 * Intel Corporation @@ -53,6 +29,7 @@ * ${'\n* '.join(cmdline)} * ******************************************************************************/ +<% calc_max_knob_len(knobs) %> %if gen_header: #pragma once #include @@ -168,3 +145,33 @@ std::string GlobalKnobs::ToString(const char* optPerLinePrefix) } % endif + +<%! + # Globally available python + max_len = 0 + def calc_max_knob_len(knobs): + global max_len + max_len = 0 + for knob in knobs: + if len(knob[0]) > max_len: max_len = len(knob[0]) + max_len += len('KNOB_ ') + if max_len % 4: max_len += 4 - (max_len % 4) + + def space_knob(knob): + knob_len = len('KNOB_' + knob) + return ' '*(max_len - knob_len) + + def calc_max_name_len(choices_array): + _max_len = 0 + for choice in choices_array: + if len(choice['name']) > _max_len: _max_len = len(choice['name']) + + if _max_len % 4: _max_len += 4 - (_max_len % 4) + return _max_len + + def space_name(name, max_len): + name_len = len(name) + return ' '*(max_len - name_len) + + +%> \ No newline at end of file diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp index 40bc8a42cdc..18ea7817137 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp @@ -30,19 +30,6 @@ * ${'\n* '.join(cmdline)} * ******************************************************************************/ -<%! - def calc_max_len(fields): - max_type_len = 0 - max_name_len = 0 - for f in fields: - if len(f['type']) > max_type_len: max_type_len = len(f['type']) - if len(f['name']) > max_name_len: max_name_len = len(f['name']) - return (max_type_len, max_name_len) - - def pad(cur_len, max_len): - pad_amt = max_len - cur_len - return ' '*pad_amt -%> #pragma once namespace SwrJit @@ -58,7 +45,7 @@ namespace SwrJit (max_type_len, max_name_len) = calc_max_len(type['members']) %> %for member in type['members']: - /* ${member['name']} ${pad(len(member['name']), max_name_len)} */ members.push_back( ${member['type']} ); + /* ${member['name']} ${pad(len(member['name']), max_name_len)}*/ members.push_back( ${member['type']} ); %endfor return StructType::get(ctx, members, false); @@ -70,3 +57,17 @@ namespace SwrJit %endfor } // ns SwrJit + +<%! # Global function definitions + def calc_max_len(fields): + max_type_len = 0 + max_name_len = 0 + for f in fields: + if len(f['type']) > max_type_len: max_type_len = len(f['type']) + if len(f['name']) > max_name_len: max_name_len = len(f['name']) + return (max_type_len, max_name_len) + + def pad(cur_len, max_len): + pad_amt = max_len - cur_len + return ' '*pad_amt +%> diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp index ca5a6dd1a23..bd63796d138 100644 --- a/src/gallium/drivers/swr/rasterizer/core/api.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp @@ -43,7 +43,6 @@ #include "core/clip.h" #include "core/utils.h" -#include "common/simdintrin.h" #include "common/os.h" static const SWR_RECT g_MaxScissorRect = { 0, 0, KNOB_MAX_SCISSOR_X, KNOB_MAX_SCISSOR_Y }; diff --git a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp index ead52fe55f3..79118f5f65c 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp @@ -59,7 +59,7 @@ #include "core/state.h" -#include "state_llvm.h" +#include "gen_state_llvm.h" #include #if defined(_WIN32) diff --git a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp index 55961d19957..1c2c8df1977 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp @@ -30,7 +30,7 @@ #include "builder.h" #include "jit_api.h" #include "blend_jit.h" -#include "state_llvm.h" +#include "gen_state_llvm.h" #include diff --git a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp index 9bc63f31c6a..d8eb5309d7c 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp @@ -30,7 +30,7 @@ #include "builder.h" #include "jit_api.h" #include "fetch_jit.h" -#include "state_llvm.h" +#include "gen_state_llvm.h" #include #include diff --git a/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp index 3d393387bb0..494d8cfc89d 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp @@ -30,7 +30,7 @@ #include "builder.h" #include "jit_api.h" #include "streamout_jit.h" -#include "state_llvm.h" +#include "gen_state_llvm.h" #include "llvm/IR/DataLayout.h" #include diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp index a61ed9c3519..f75909efd01 100644 --- a/src/gallium/drivers/swr/swr_shader.cpp +++ b/src/gallium/drivers/swr/swr_shader.cpp @@ -30,7 +30,7 @@ #pragma pop_macro("DEBUG") #include "state.h" -#include "state_llvm.h" +#include "gen_state_llvm.h" #include "builder.h" #include "tgsi/tgsi_strings.h" @@ -42,7 +42,7 @@ #include "gallivm/lp_bld_tgsi.h" #include "swr_context.h" -#include "swr_context_llvm.h" +#include "gen_swr_context_llvm.h" #include "swr_resource.h" #include "swr_state.h" #include "swr_screen.h" diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 2fafabd80ee..efd2b4ae9a5 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -29,7 +29,7 @@ #include "common/os.h" #include "jit_api.h" -#include "state_llvm.h" +#include "gen_state_llvm.h" #include "gallivm/lp_bld_tgsi.h" #include "util/u_format.h" @@ -42,7 +42,7 @@ #include "swr_state.h" #include "swr_context.h" -#include "swr_context_llvm.h" +#include "gen_swr_context_llvm.h" #include "swr_screen.h" #include "swr_resource.h" #include "swr_tex_sample.h" diff --git a/src/gallium/drivers/swr/swr_tex_sample.cpp b/src/gallium/drivers/swr/swr_tex_sample.cpp index ec2fa154085..f1ac41b0895 100644 --- a/src/gallium/drivers/swr/swr_tex_sample.cpp +++ b/src/gallium/drivers/swr/swr_tex_sample.cpp @@ -46,7 +46,7 @@ #include "state.h" #include "JitManager.h" -#include "state_llvm.h" +#include "gen_state_llvm.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" @@ -58,7 +58,7 @@ #include "util/u_memory.h" #include "swr_tex_sample.h" -#include "swr_context_llvm.h" +#include "gen_swr_context_llvm.h" using namespace SwrJit; -- 2.30.2