[Mesa-dev] [PATCH v2 10/10] swr: [rasterizer codegen] Fix windows build

Kyriazis, George george.kyriazis at intel.com
Tue Mar 28 02:42:36 UTC 2017


Tried Depends(), but it doesn’t work all the time.  There are some cases where it works, and some others where it doesn’t.

I’ll need to investigate more.  Fix in a separate checkin later?

George

On Mar 27, 2017, at 8:38 PM, Rowley, Timothy O <timothy.o.rowley at intel.com<mailto:timothy.o.rowley at intel.com>> wrote:

On closer review of 10/10, I don’t like the approach taken here.

You’ve added a —template argument to gen_backends.py, making it different from the rest of the scripts and actually running it with different parameters on automake and scons.  Can’t you get scons to have the necessary dependency using its Depends() call?

http://scons.org/doc/production/HTML/scons-user/ch06s05.html

On Mar 27, 2017, at 7:39 PM, George Kyriazis <george.kyriazis at intel.com<mailto:george.kyriazis at intel.com>> wrote:

Fix codegen build break that was introduced earlier

v2: update rules for gen_knobs.cpp and gen_knobs.h

---
src/gallium/drivers/swr/Makefile.am                |  4 +--
src/gallium/drivers/swr/SConscript                 | 15 ++++++-----
.../drivers/swr/rasterizer/codegen/gen_backends.py | 30 ++++++++++++++--------
.../swr/rasterizer/codegen/gen_llvm_ir_macros.py   | 20 +++++++--------
4 files changed, 39 insertions(+), 30 deletions(-)

diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am
index 515a9089cc..cc37abf3e8 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -97,14 +97,14 @@ rasterizer/jitter/gen_builder.hpp: rasterizer/codegen/gen_llvm_ir_macros.py rast
$(PYTHON_GEN) \
$(srcdir)/rasterizer/codegen/gen_llvm_ir_macros.py \
--input $(LLVM_INCLUDEDIR)/llvm/IR/IRBuilder.h \
- --output rasterizer/jitter \
+ --output $@ \
--gen_h

rasterizer/jitter/gen_builder_x86.hpp: rasterizer/codegen/gen_llvm_ir_macros.py rasterizer/codegen/templates/gen_builder.hpp rasterizer/codegen/gen_common.py
$(MKDIR_GEN)
$(PYTHON_GEN) \
$(srcdir)/rasterizer/codegen/gen_llvm_ir_macros.py \
- --output rasterizer/jitter \
+ --output $@ \
--gen_x86_h

rasterizer/archrast/gen_ar_event.hpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_event.hpp rasterizer/archrast/events.proto rasterizer/codegen/gen_common.py
diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript
index ad16162c29..aa4a8e6d55 100644
--- a/src/gallium/drivers/swr/SConscript
+++ b/src/gallium/drivers/swr/SConscript
@@ -51,15 +51,15 @@ swrroot = '#src/gallium/drivers/swr/'
env.CodeGenerate(
    target = 'rasterizer/codegen/gen_knobs.cpp',
    script = swrroot + 'rasterizer/codegen/gen_knobs.py',
-    source = 'rasterizer/codegen/templates/gen_knobs.cpp',
-    command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp'
+    source = '',
+    command = python_cmd + ' $SCRIPT --output $TARGET --gen_cpp'
)

env.CodeGenerate(
    target = 'rasterizer/codegen/gen_knobs.h',
    script = swrroot + 'rasterizer/codegen/gen_knobs.py',
-    source = 'rasterizer/codegen/templates/gen_knobs.cpp',
-    command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h'
+    source = '',
+    command = python_cmd + ' $SCRIPT --output $TARGET --gen_h'
)

env.CodeGenerate(
@@ -73,14 +73,14 @@ env.CodeGenerate(
    target = 'rasterizer/jitter/gen_builder.hpp',
    script = swrroot + 'rasterizer/codegen/gen_llvm_ir_macros.py',
    source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'),
-    command = python_cmd + ' $SCRIPT --input $SOURCE --output rasterizer/jitter --gen_h'
+    command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h'
)

env.CodeGenerate(
    target = 'rasterizer/jitter/gen_builder_x86.hpp',
    script = swrroot + 'rasterizer/codegen/gen_llvm_ir_macros.py',
    source = '',
-    command = python_cmd + ' $SCRIPT --output rasterizer/jitter --gen_x86_h'
+    command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_h'
)

env.CodeGenerate(
@@ -127,7 +127,8 @@ env.CodeGenerate(
env.CodeGenerate(
    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'
+    source = swrroot + 'rasterizer/codegen/templates/gen_backend.cpp',
+    command = python_cmd + ' $SCRIPT --output $TARGET --template $SOURCE --dim 5 2 3 2 2 2 --split 0 --cpp'
)

# Auto-generated .cpp files (that need to generate object files)
diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py
index 242ab7a73e..8f7ba94ba1 100644
--- a/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py
+++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py
@@ -34,7 +34,10 @@ def main(args=sys.argv[1:]):
    parser = ArgumentParser("Generate files and initialization functions for all permutuations of BackendPixelRate.")
    parser.add_argument('--dim', help="gBackendPixelRateTable array dimensions", nargs='+', type=int, required=True)
    parser.add_argument('--outdir', help="output directory", nargs='?', type=str, default=thisDir)
+    parser.add_argument('--output', help="output filename", nargs='?', type=str)
+    parser.add_argument('--template', help="input template", nargs='?', type=str)
    parser.add_argument('--split', help="how many lines of initialization per file [0=no split]", nargs='?', type=int, default='512')
+    parser.add_argument('--index', help="file to output", nargs='?', type=int, default=0)
    parser.add_argument('--cpp', help="Generate cpp file(s)", action='store_true', default=False)
    parser.add_argument('--cmake', help="Generate cmake file", action='store_true', default=False)

@@ -72,18 +75,25 @@ def main(args=sys.argv[1:]):

    # generate .cpp files
    if args.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)
-            #print('Generating', filename)
+        if not args.output:
+            baseCppName = os.path.join(args.outdir, 'gen_BackendPixelRate%s.cpp')
+            templateCpp = os.path.join(thisDir, 'templates', 'gen_backend.cpp')
+
+            for fileNum in range(numFiles):
+                MakoTemplateWriter.to_file(
+                    templateCpp,
+                    baseCppName % str(fileNum),
+                    cmdline=sys.argv,
+                    fileNum=fileNum,
+                    funcList=chunkedList[fileNum])
+
+        else:
            MakoTemplateWriter.to_file(
-                templateCpp,
-                baseCppName % str(fileNum),
+                args.template,
+                args.output,
                cmdline=sys.argv,
-                fileNum=fileNum,
-                funcList=chunkedList[fileNum])
+                fileNum=args.index,
+                funcList=chunkedList[args.index])

    # generate gen_backend.cmake file
    if args.cmake:
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 dbf56471ee..4cd9b6fbb6 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
@@ -178,9 +178,8 @@ def parse_ir_builder(input_file):
'''
    Auto-generates macros for LLVM IR
'''
-def generate_gen_h(functions, output_dir):
-    filename = 'gen_builder.hpp'
-    output_filename = os.path.join(output_dir, filename)
+def generate_gen_h(functions, output):
+    output_filename = output

    templfuncs = []
    for func in functions:
@@ -197,16 +196,15 @@ def generate_gen_h(functions, output_dir):
        output_filename,
        cmdline=sys.argv,
        comment='Builder IR Wrappers',
-        filename=filename,
+        filename=os.path.basename(output_filename),
        functions=templfuncs,
        isX86=False)

'''
    Auto-generates macros for LLVM IR
'''
-def generate_x86_h(output_dir):
-    filename = 'gen_builder_x86.hpp'
-    output_filename = os.path.join(output_dir, filename)
+def generate_x86_h(output):
+    output_filename = output

    functions = []
    for inst in intrinsics:
@@ -224,7 +222,7 @@ def generate_x86_h(output_dir):
        output_filename,
        cmdline=sys.argv,
        comment='x86 intrinsics',
-        filename=filename,
+        filename=os.path.basename(output_filename),
        functions=functions,
        isX86=True)

@@ -238,13 +236,13 @@ def main():
    # Parse args...
    parser = ArgumentParser()
    parser.add_argument('--input', '-i', type=FileType('r'), help='Path to IRBuilder.h', required=False)
-    parser.add_argument('--output-dir', '-o', action='store', dest='output', help='Path to output directory', required=True)
+    parser.add_argument('--output', '-o', action='store', dest='output', help='Output filename', required=True)
    parser.add_argument('--gen_h', help='Generate builder_gen.h', action='store_true', default=False)
    parser.add_argument('--gen_x86_h', help='Generate x86 intrinsics. No input is needed.', action='store_true', default=False)
    args = parser.parse_args()

-    if not os.path.exists(args.output):
-        os.makedirs(args.output)
+    if not os.path.exists(os.path.dirname(args.output)):
+        os.makedirs(os.path.dirname(args.output))

    if args.input:
        functions = parse_ir_builder(args.input)
--
2.11.1.windows.1

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org<mailto:mesa-dev at lists.freedesktop.org>
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170328/2e34c11d/attachment-0001.html>


More information about the mesa-dev mailing list