From: Tim Rowley Date: Thu, 16 Mar 2017 18:44:52 +0000 (-0500) Subject: swr: [rasterizer] Cleanup naming of codegen files X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fe325e64230e01fa7f3044afb99f927bc594bef7;p=mesa.git swr: [rasterizer] Cleanup naming of codegen files All template files and generated files are prefixed with gen_. Reviewed-by: Bruce Cherniak --- 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/ar_event_cpp.template deleted file mode 100644 index 4b3dcd57dbc..00000000000 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_cpp.template +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -* Copyright (C) 2016 Intel Corporation. All Rights Reserved. -* -* 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. -* -* @file ${filename} -* -* @brief Implementation for events. auto-generated file -* -* DO NOT EDIT -* -******************************************************************************/ -#include "common/os.h" -#include "gen_ar_event.h" -#include "gen_ar_eventhandler.h" - -using namespace ArchRast; -% for name in protos['event_names']: - -void ${name}::Accept(EventHandler* pHandler) -{ - pHandler->Handle(*this); -} -% endfor diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_h.template b/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_h.template deleted file mode 100644 index 68926ea8053..00000000000 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_h.template +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -* Copyright (C) 2016 Intel Corporation. All Rights Reserved. -* -* 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. -* -* @file ${filename} -* -* @brief Definitions for events. auto-generated file -* -* DO NOT EDIT -* -******************************************************************************/ -#pragma once - -#include "common/os.h" -#include "core/state.h" - -namespace ArchRast -{ -% for name in protos['enum_names']: - enum ${name} - {<% names = protos['enums'][name]['names'] %> - % for i in range(len(names)): - ${names[i].lstrip()} - % endfor - }; -% endfor - - //Forward decl - class EventHandler; - - ////////////////////////////////////////////////////////////////////////// - /// Event - interface for handling events. - ////////////////////////////////////////////////////////////////////////// - struct Event - { - Event() {} - virtual ~Event() {} - - virtual void Accept(EventHandler* pHandler) = 0; - }; -% for name in protos['event_names']: - - ////////////////////////////////////////////////////////////////////////// - /// ${name}Data - ////////////////////////////////////////////////////////////////////////// -#pragma pack(push, 1) - struct ${name}Data - {<% - field_names = protos['events'][name]['field_names'] - field_types = protos['events'][name]['field_types'] %> - // Fields - % for i in range(len(field_names)): - ${field_types[i]} ${field_names[i]}; - % endfor - }; -#pragma pack(pop) - - ////////////////////////////////////////////////////////////////////////// - /// ${name} - ////////////////////////////////////////////////////////////////////////// - struct ${name} : Event - {<% - field_names = protos['events'][name]['field_names'] - field_types = protos['events'][name]['field_types'] %> - ${name}Data data; - - // Constructor - ${name}( - % for i in range(len(field_names)): - % if i < len(field_names)-1: - ${field_types[i]} ${field_names[i]}, - % endif - % if i == len(field_names)-1: - ${field_types[i]} ${field_names[i]} - % endif - % endfor - ) - { - % for i in range(len(field_names)): - data.${field_names[i]} = ${field_names[i]}; - % endfor - } - - virtual void Accept(EventHandler* pHandler); - }; -% endfor -} \ No newline at end of file diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandler_h.template b/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandler_h.template deleted file mode 100644 index cfed2aded0c..00000000000 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandler_h.template +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -* Copyright (C) 2016 Intel Corporation. All Rights Reserved. -* -* 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. -* -* @file ${filename} -* -* @brief Event handler interface. auto-generated file -* -* DO NOT EDIT -* -******************************************************************************/ -#pragma once - -#include "${event_header}" - -namespace ArchRast -{ - ////////////////////////////////////////////////////////////////////////// - /// EventHandler - interface for handling events. - ////////////////////////////////////////////////////////////////////////// - class EventHandler - { - public: - EventHandler() {} - virtual ~EventHandler() {} - - virtual void FlushDraw(uint32_t drawId) {} - -% for name in protos['event_names']: - virtual void Handle(const ${name}& event) {} -% endfor - }; -} diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandlerfile_h.template b/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandlerfile_h.template deleted file mode 100644 index 48ff0b0a958..00000000000 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandlerfile_h.template +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -* Copyright (C) 2016 Intel Corporation. All Rights Reserved. -* -* 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. -* -* @file ${filename} -* -* @brief Event handler interface. auto-generated file -* -* DO NOT EDIT -* -******************************************************************************/ -#pragma once - -#include "common/os.h" -#include "${event_header}" -#include -#include - -namespace ArchRast -{ - ////////////////////////////////////////////////////////////////////////// - /// EventHandlerFile - interface for handling events. - ////////////////////////////////////////////////////////////////////////// - class EventHandlerFile : public EventHandler - { - public: - EventHandlerFile(uint32_t id) - : mBufOffset(0) - { -#if defined(_WIN32) - DWORD pid = GetCurrentProcessId(); - TCHAR procname[MAX_PATH]; - GetModuleFileName(NULL, procname, MAX_PATH); - const char* pBaseName = strrchr(procname, '\\'); - std::stringstream outDir; - outDir << KNOB_DEBUG_OUTPUT_DIR << pBaseName << "_" << pid << std::ends; - CreateDirectory(outDir.str().c_str(), NULL); - - char buf[255]; - // There could be multiple threads creating thread pools. We - // want to make sure they are uniquly identified by adding in - // the creator's thread id into the filename. - sprintf(buf, "%s\\ar_event%d_%d.bin", outDir.str().c_str(), GetCurrentThreadId(), id); - mFilename = std::string(buf); -#else - char buf[255]; - // There could be multiple threads creating thread pools. We - // want to make sure they are uniquly identified by adding in - // the creator's thread id into the filename. - sprintf(buf, "%s/ar_event%d_%d.bin", "/tmp", GetCurrentThreadId(), id); - mFilename = std::string(buf); -#endif - } - - virtual ~EventHandlerFile() - { - FlushBuffer(); - } - - ////////////////////////////////////////////////////////////////////////// - /// @brief Flush buffer to file. - bool FlushBuffer() - { - if (mBufOffset > 0) - { - if (mBufOffset == mHeaderBufOffset) - { - // Nothing to flush. Only header has been generated. - return false; - } - - std::ofstream file; - file.open(mFilename, std::ios::out | std::ios::app | std::ios::binary); - - if (!file.is_open()) - { - SWR_INVALID("ArchRast: Could not open event file!"); - return false; - } - - file.write((char*)mBuffer, mBufOffset); - file.close(); - - mBufOffset = 0; - mHeaderBufOffset = 0; // Reset header offset so its no longer considered. - } - return true; - } - - ////////////////////////////////////////////////////////////////////////// - /// @brief Write event and its payload to the memory buffer. - void Write(uint32_t eventId, const char* pBlock, uint32_t size) - { - if ((mBufOffset + size + sizeof(eventId)) > mBufferSize) - { - if (!FlushBuffer()) - { - // Don't corrupt what's already in the buffer? - /// @todo Maybe add corrupt marker to buffer here in case we can open file in future? - return; - } - } - - memcpy(&mBuffer[mBufOffset], (char*)&eventId, sizeof(eventId)); - mBufOffset += sizeof(eventId); - memcpy(&mBuffer[mBufOffset], pBlock, size); - mBufOffset += size; - } - -% for name in protos['event_names']: - ////////////////////////////////////////////////////////////////////////// - /// @brief Handle ${name} event - virtual void Handle(const ${name}& event) - { -% if protos['events'][name]['num_fields'] == 0: - Write(${protos['events'][name]['event_id']}, (char*)&event.data, 0); -% else: - Write(${protos['events'][name]['event_id']}, (char*)&event.data, sizeof(event.data)); -%endif - } -% endfor - - ////////////////////////////////////////////////////////////////////////// - /// @brief Everything written to buffer this point is the header. - virtual void MarkHeader() - { - mHeaderBufOffset = mBufOffset; - } - - std::string mFilename; - - static const uint32_t mBufferSize = 1024; - uint8_t mBuffer[mBufferSize]; - uint32_t mBufOffset{0}; - uint32_t mHeaderBufOffset{0}; - }; -} diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/backend_template.cpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/backend_template.cpp deleted file mode 100644 index 4eb4ad4f2b3..00000000000 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/backend_template.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//============================================================================ -// Copyright (C) 2017 Intel Corporation. All Rights Reserved. -// -// 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. -// -// @file BackendPixelRate${fileNum}.cpp -// -// @brief auto-generated file -// -// DO NOT EDIT -// -// Generation Command Line: -// ${'\n// '.join(cmdline)} -// -//============================================================================ - -#include "core/backend.h" - -void InitBackendPixelRate${fileNum}() -{ - %for func in funcList: - ${func} - %endfor -} diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.cpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.cpp new file mode 100644 index 00000000000..b743b2f3d2d --- /dev/null +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +* Copyright (C) 2016 Intel Corporation. All Rights Reserved. +* +* 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. +* +* @file ${filename} +* +* @brief Implementation for events. auto-generated file +* +* DO NOT EDIT +* +******************************************************************************/ +#include "common/os.h" +#include "gen_ar_event.hpp" +#include "gen_ar_eventhandler.hpp" + +using namespace ArchRast; +% for name in protos['event_names']: + +void ${name}::Accept(EventHandler* pHandler) +{ + pHandler->Handle(*this); +} +% endfor diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.hpp new file mode 100644 index 00000000000..68926ea8053 --- /dev/null +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.hpp @@ -0,0 +1,105 @@ +/**************************************************************************** +* Copyright (C) 2016 Intel Corporation. All Rights Reserved. +* +* 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. +* +* @file ${filename} +* +* @brief Definitions for events. auto-generated file +* +* DO NOT EDIT +* +******************************************************************************/ +#pragma once + +#include "common/os.h" +#include "core/state.h" + +namespace ArchRast +{ +% for name in protos['enum_names']: + enum ${name} + {<% names = protos['enums'][name]['names'] %> + % for i in range(len(names)): + ${names[i].lstrip()} + % endfor + }; +% endfor + + //Forward decl + class EventHandler; + + ////////////////////////////////////////////////////////////////////////// + /// Event - interface for handling events. + ////////////////////////////////////////////////////////////////////////// + struct Event + { + Event() {} + virtual ~Event() {} + + virtual void Accept(EventHandler* pHandler) = 0; + }; +% for name in protos['event_names']: + + ////////////////////////////////////////////////////////////////////////// + /// ${name}Data + ////////////////////////////////////////////////////////////////////////// +#pragma pack(push, 1) + struct ${name}Data + {<% + field_names = protos['events'][name]['field_names'] + field_types = protos['events'][name]['field_types'] %> + // Fields + % for i in range(len(field_names)): + ${field_types[i]} ${field_names[i]}; + % endfor + }; +#pragma pack(pop) + + ////////////////////////////////////////////////////////////////////////// + /// ${name} + ////////////////////////////////////////////////////////////////////////// + struct ${name} : Event + {<% + field_names = protos['events'][name]['field_names'] + field_types = protos['events'][name]['field_types'] %> + ${name}Data data; + + // Constructor + ${name}( + % for i in range(len(field_names)): + % if i < len(field_names)-1: + ${field_types[i]} ${field_names[i]}, + % endif + % if i == len(field_names)-1: + ${field_types[i]} ${field_names[i]} + % endif + % endfor + ) + { + % for i in range(len(field_names)): + data.${field_names[i]} = ${field_names[i]}; + % endfor + } + + virtual void Accept(EventHandler* pHandler); + }; +% endfor +} \ No newline at end of file diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandler.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandler.hpp new file mode 100644 index 00000000000..cfed2aded0c --- /dev/null +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandler.hpp @@ -0,0 +1,51 @@ +/**************************************************************************** +* Copyright (C) 2016 Intel Corporation. All Rights Reserved. +* +* 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. +* +* @file ${filename} +* +* @brief Event handler interface. auto-generated file +* +* DO NOT EDIT +* +******************************************************************************/ +#pragma once + +#include "${event_header}" + +namespace ArchRast +{ + ////////////////////////////////////////////////////////////////////////// + /// EventHandler - interface for handling events. + ////////////////////////////////////////////////////////////////////////// + class EventHandler + { + public: + EventHandler() {} + virtual ~EventHandler() {} + + virtual void FlushDraw(uint32_t drawId) {} + +% for name in protos['event_names']: + virtual void Handle(const ${name}& event) {} +% endfor + }; +} diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp new file mode 100644 index 00000000000..48ff0b0a958 --- /dev/null +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp @@ -0,0 +1,155 @@ +/**************************************************************************** +* Copyright (C) 2016 Intel Corporation. All Rights Reserved. +* +* 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. +* +* @file ${filename} +* +* @brief Event handler interface. auto-generated file +* +* DO NOT EDIT +* +******************************************************************************/ +#pragma once + +#include "common/os.h" +#include "${event_header}" +#include +#include + +namespace ArchRast +{ + ////////////////////////////////////////////////////////////////////////// + /// EventHandlerFile - interface for handling events. + ////////////////////////////////////////////////////////////////////////// + class EventHandlerFile : public EventHandler + { + public: + EventHandlerFile(uint32_t id) + : mBufOffset(0) + { +#if defined(_WIN32) + DWORD pid = GetCurrentProcessId(); + TCHAR procname[MAX_PATH]; + GetModuleFileName(NULL, procname, MAX_PATH); + const char* pBaseName = strrchr(procname, '\\'); + std::stringstream outDir; + outDir << KNOB_DEBUG_OUTPUT_DIR << pBaseName << "_" << pid << std::ends; + CreateDirectory(outDir.str().c_str(), NULL); + + char buf[255]; + // There could be multiple threads creating thread pools. We + // want to make sure they are uniquly identified by adding in + // the creator's thread id into the filename. + sprintf(buf, "%s\\ar_event%d_%d.bin", outDir.str().c_str(), GetCurrentThreadId(), id); + mFilename = std::string(buf); +#else + char buf[255]; + // There could be multiple threads creating thread pools. We + // want to make sure they are uniquly identified by adding in + // the creator's thread id into the filename. + sprintf(buf, "%s/ar_event%d_%d.bin", "/tmp", GetCurrentThreadId(), id); + mFilename = std::string(buf); +#endif + } + + virtual ~EventHandlerFile() + { + FlushBuffer(); + } + + ////////////////////////////////////////////////////////////////////////// + /// @brief Flush buffer to file. + bool FlushBuffer() + { + if (mBufOffset > 0) + { + if (mBufOffset == mHeaderBufOffset) + { + // Nothing to flush. Only header has been generated. + return false; + } + + std::ofstream file; + file.open(mFilename, std::ios::out | std::ios::app | std::ios::binary); + + if (!file.is_open()) + { + SWR_INVALID("ArchRast: Could not open event file!"); + return false; + } + + file.write((char*)mBuffer, mBufOffset); + file.close(); + + mBufOffset = 0; + mHeaderBufOffset = 0; // Reset header offset so its no longer considered. + } + return true; + } + + ////////////////////////////////////////////////////////////////////////// + /// @brief Write event and its payload to the memory buffer. + void Write(uint32_t eventId, const char* pBlock, uint32_t size) + { + if ((mBufOffset + size + sizeof(eventId)) > mBufferSize) + { + if (!FlushBuffer()) + { + // Don't corrupt what's already in the buffer? + /// @todo Maybe add corrupt marker to buffer here in case we can open file in future? + return; + } + } + + memcpy(&mBuffer[mBufOffset], (char*)&eventId, sizeof(eventId)); + mBufOffset += sizeof(eventId); + memcpy(&mBuffer[mBufOffset], pBlock, size); + mBufOffset += size; + } + +% for name in protos['event_names']: + ////////////////////////////////////////////////////////////////////////// + /// @brief Handle ${name} event + virtual void Handle(const ${name}& event) + { +% if protos['events'][name]['num_fields'] == 0: + Write(${protos['events'][name]['event_id']}, (char*)&event.data, 0); +% else: + Write(${protos['events'][name]['event_id']}, (char*)&event.data, sizeof(event.data)); +%endif + } +% endfor + + ////////////////////////////////////////////////////////////////////////// + /// @brief Everything written to buffer this point is the header. + virtual void MarkHeader() + { + mHeaderBufOffset = mBufOffset; + } + + std::string mFilename; + + static const uint32_t mBufferSize = 1024; + uint8_t mBuffer[mBufferSize]; + uint32_t mBufOffset{0}; + uint32_t mHeaderBufOffset{0}; + }; +} diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_backend.cpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_backend.cpp new file mode 100644 index 00000000000..4eb4ad4f2b3 --- /dev/null +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_backend.cpp @@ -0,0 +1,41 @@ +//============================================================================ +// Copyright (C) 2017 Intel Corporation. All Rights Reserved. +// +// 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. +// +// @file BackendPixelRate${fileNum}.cpp +// +// @brief auto-generated file +// +// DO NOT EDIT +// +// Generation Command Line: +// ${'\n// '.join(cmdline)} +// +//============================================================================ + +#include "core/backend.h" + +void InitBackendPixelRate${fileNum}() +{ + %for func in funcList: + ${func} + %endfor +} diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder.hpp new file mode 100644 index 00000000000..2e957581ac4 --- /dev/null +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder.hpp @@ -0,0 +1,50 @@ +//============================================================================ +// Copyright (C) 2014-2017 Intel Corporation. All Rights Reserved. +// +// 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. +// +// @file ${filename} +// +// @brief auto-generated file +// +// DO NOT EDIT +// +// Generation Command Line: +// ${'\n// '.join(cmdline)} +// +//============================================================================ +#pragma once + +//============================================================================ +// Auto-generated ${comment} +//============================================================================ + +%for func in functions: +${func['decl']} +{ +%if isX86: + Function *pFunc = Intrinsic::getDeclaration(JM()->mpCurrentModule, Intrinsic::${func['intrin']}); + return CALL(pFunc, std::initializer_list{${func['args']}}); +%else: + return IRB()->${func['intrin']}(${func['args']}); +%endif +} + +%endfor diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder_template.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder_template.hpp deleted file mode 100644 index 2e957581ac4..00000000000 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder_template.hpp +++ /dev/null @@ -1,50 +0,0 @@ -//============================================================================ -// Copyright (C) 2014-2017 Intel Corporation. All Rights Reserved. -// -// 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. -// -// @file ${filename} -// -// @brief auto-generated file -// -// DO NOT EDIT -// -// Generation Command Line: -// ${'\n// '.join(cmdline)} -// -//============================================================================ -#pragma once - -//============================================================================ -// Auto-generated ${comment} -//============================================================================ - -%for func in functions: -${func['decl']} -{ -%if isX86: - Function *pFunc = Intrinsic::getDeclaration(JM()->mpCurrentModule, Intrinsic::${func['intrin']}); - return CALL(pFunc, std::initializer_list{${func['args']}}); -%else: - return IRB()->${func['intrin']}(${func['args']}); -%endif -} - -%endfor diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp new file mode 100644 index 00000000000..81e49da659c --- /dev/null +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp @@ -0,0 +1,177 @@ +/****************************************************************************** +* +* Copyright 2015-2017 +* Intel Corporation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http ://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +% if gen_header: +* @file ${filename}.h +% else: +* @file ${filename}.cpp +% endif +* +* @brief Dynamic Knobs for Core. +* +* ======================= AUTO GENERATED: DO NOT EDIT !!! ==================== +* +* Generation Command Line: +* ${'\n* '.join(cmdline)} +* +******************************************************************************/ +<% calc_max_knob_len(knobs) %> +%if gen_header: +#pragma once +#include + +template +struct Knob +{ + const T& Value() const { return m_Value; } + const T& Value(const T& newValue) { m_Value = newValue; return Value(); } + +protected: + Knob(const T& defaultValue) : m_Value(defaultValue) {} + +private: + T m_Value; +}; + +#define DEFINE_KNOB(_name, _type, _default) \\ + + struct Knob_##_name : Knob<_type> \\ + + { \\ + + Knob_##_name() : Knob<_type>(_default) { } \\ + + static const char* Name() { return "KNOB_" #_name; } \\ + + } _name; + +#define GET_KNOB(_name) g_GlobalKnobs._name.Value() +#define SET_KNOB(_name, _newValue) g_GlobalKnobs._name.Value(_newValue) + +struct GlobalKnobs +{ + % for knob in knobs: + //----------------------------------------------------------- + // KNOB_${knob[0]} + // + % for line in knob[1]['desc']: + // ${line} + % endfor + % if knob[1].get('choices'): + <% + choices = knob[1].get('choices') + _max_len = calc_max_name_len(choices) %>// + % for i in range(len(choices)): + // ${choices[i]['name']}${space_name(choices[i]['name'], _max_len)} = ${format(choices[i]['value'], '#010x')} + % endfor + % endif + // + % if knob[1]['type'] == 'std::string': + DEFINE_KNOB(${knob[0]}, ${knob[1]['type']}, "${repr(knob[1]['default'])[1:-1]}"); + % else: + DEFINE_KNOB(${knob[0]}, ${knob[1]['type']}, ${knob[1]['default']}); + % endif + + % endfor + GlobalKnobs(); + std::string ToString(const char* optPerLinePrefix=""); +}; +extern GlobalKnobs g_GlobalKnobs; + +#undef DEFINE_KNOB + +% for knob in knobs: +#define KNOB_${knob[0]}${space_knob(knob[0])} GET_KNOB(${knob[0]}) +% endfor + +% else: +% for inc in includes: +#include <${inc}> +% endfor + +//======================================================== +// Static Data Members +//======================================================== +GlobalKnobs g_GlobalKnobs; + +//======================================================== +// Knob Initialization +//======================================================== +GlobalKnobs::GlobalKnobs() +{ + % for knob in knobs: + InitKnob(${knob[0]}); + % endfor +} + +//======================================================== +// Knob Display (Convert to String) +//======================================================== +std::string GlobalKnobs::ToString(const char* optPerLinePrefix) +{ + std::basic_stringstream str; + str << std::showbase << std::setprecision(1) << std::fixed; + + if (optPerLinePrefix == nullptr) { optPerLinePrefix = ""; } + + % for knob in knobs: + str << optPerLinePrefix << "KNOB_${knob[0]}:${space_knob(knob[0])}"; + % if knob[1]['type'] == 'bool': + str << (KNOB_${knob[0]} ? "+\n" : "-\n"); + % elif knob[1]['type'] != 'float' and knob[1]['type'] != 'std::string': + str << std::hex << std::setw(11) << std::left << KNOB_${knob[0]}; + str << std::dec << KNOB_${knob[0]} << "\n"; + % else: + str << KNOB_${knob[0]} << "\n"; + % endif + % endfor + str << std::ends; + + return str.str(); +} + +% 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/codegen/templates/knobs_template.cpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/knobs_template.cpp deleted file mode 100644 index 99294d2290e..00000000000 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/knobs_template.cpp +++ /dev/null @@ -1,170 +0,0 @@ -<% - 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 -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http ://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -% if gen_header: -* @file ${filename}.h -% else: -* @file ${filename}.cpp -% endif -* -* @brief Dynamic Knobs for Core. -* -* ======================= AUTO GENERATED: DO NOT EDIT !!! ==================== -* -* Generation Command Line: -* ${'\n* '.join(cmdline)} -* -******************************************************************************/ -%if gen_header: -#pragma once -#include - -template -struct Knob -{ - const T& Value() const { return m_Value; } - const T& Value(const T& newValue) { m_Value = newValue; return Value(); } - -protected: - Knob(const T& defaultValue) : m_Value(defaultValue) {} - -private: - T m_Value; -}; - -#define DEFINE_KNOB(_name, _type, _default) \\ - - struct Knob_##_name : Knob<_type> \\ - - { \\ - - Knob_##_name() : Knob<_type>(_default) { } \\ - - static const char* Name() { return "KNOB_" #_name; } \\ - - } _name; - -#define GET_KNOB(_name) g_GlobalKnobs._name.Value() -#define SET_KNOB(_name, _newValue) g_GlobalKnobs._name.Value(_newValue) - -struct GlobalKnobs -{ - % for knob in knobs: - //----------------------------------------------------------- - // KNOB_${knob[0]} - // - % for line in knob[1]['desc']: - // ${line} - % endfor - % if knob[1].get('choices'): - <% - choices = knob[1].get('choices') - _max_len = calc_max_name_len(choices) %>// - % for i in range(len(choices)): - // ${choices[i]['name']}${space_name(choices[i]['name'], _max_len)} = ${format(choices[i]['value'], '#010x')} - % endfor - % endif - // - % if knob[1]['type'] == 'std::string': - DEFINE_KNOB(${knob[0]}, ${knob[1]['type']}, "${repr(knob[1]['default'])[1:-1]}"); - % else: - DEFINE_KNOB(${knob[0]}, ${knob[1]['type']}, ${knob[1]['default']}); - % endif - - % endfor - GlobalKnobs(); - std::string ToString(const char* optPerLinePrefix=""); -}; -extern GlobalKnobs g_GlobalKnobs; - -#undef DEFINE_KNOB - -% for knob in knobs: -#define KNOB_${knob[0]}${space_knob(knob[0])} GET_KNOB(${knob[0]}) -% endfor - -% else: -% for inc in includes: -#include <${inc}> -% endfor - -//======================================================== -// Static Data Members -//======================================================== -GlobalKnobs g_GlobalKnobs; - -//======================================================== -// Knob Initialization -//======================================================== -GlobalKnobs::GlobalKnobs() -{ - % for knob in knobs: - InitKnob(${knob[0]}); - % endfor -} - -//======================================================== -// Knob Display (Convert to String) -//======================================================== -std::string GlobalKnobs::ToString(const char* optPerLinePrefix) -{ - std::basic_stringstream str; - str << std::showbase << std::setprecision(1) << std::fixed; - - if (optPerLinePrefix == nullptr) { optPerLinePrefix = ""; } - - % for knob in knobs: - str << optPerLinePrefix << "KNOB_${knob[0]}:${space_knob(knob[0])}"; - % if knob[1]['type'] == 'bool': - str << (KNOB_${knob[0]} ? "+\n" : "-\n"); - % elif knob[1]['type'] != 'float' and knob[1]['type'] != 'std::string': - str << std::hex << std::setw(11) << std::left << KNOB_${knob[0]}; - str << std::dec << KNOB_${knob[0]} << "\n"; - % else: - str << KNOB_${knob[0]} << "\n"; - % endif - % endfor - str << std::ends; - - return str.str(); -} - -% endif 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;