swr/rast: Separate event types to public and private
authorGeorge Kyriazis <george.kyriazis@intel.com>
Wed, 31 Jan 2018 07:09:53 +0000 (01:09 -0600)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 16 Feb 2018 16:53:59 +0000 (10:53 -0600)
Split into two proto files and modify appropriate build rules for
configure / scons / meson builds.

There are private internal events (proxy) that communicate information
from rasterizer to ArchRast. ArchRast can use these events to calculate
a final answer and then emit other public events which will be saved to
file. Users will use the public proto file and not the private one.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/Makefile.am
src/gallium/drivers/swr/SConscript
src/gallium/drivers/swr/meson.build
src/gallium/drivers/swr/rasterizer/archrast/events.proto
src/gallium/drivers/swr/rasterizer/archrast/events_private.proto [new file with mode: 0644]
src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py
src/gallium/drivers/swr/rasterizer/codegen/meson.build

index 2bc129429c695864bdd0cd0642cab0f1661f4359..869eec16d82cd0b2be7a335addc68cf084438a0d 100644 (file)
@@ -140,37 +140,41 @@ rasterizer/jitter/gen_builder_x86.hpp: rasterizer/codegen/gen_llvm_ir_macros.py
                --output rasterizer/jitter \
                --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
+rasterizer/archrast/gen_ar_event.hpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_event.hpp rasterizer/archrast/events.proto rasterizer/archrast/events_private.proto rasterizer/codegen/gen_common.py
        $(MKDIR_GEN)
        $(PYTHON_GEN) \
                $(srcdir)/rasterizer/codegen/gen_archrast.py \
                --proto $(srcdir)/rasterizer/archrast/events.proto \
+               --proto_private $(srcdir)/rasterizer/archrast/events_private.proto \
                --output rasterizer/archrast/gen_ar_event.hpp \
-               --gen_event_h
+               --gen_event_hpp
 
-rasterizer/archrast/gen_ar_event.cpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_event.cpp rasterizer/archrast/events.proto rasterizer/codegen/gen_common.py
+rasterizer/archrast/gen_ar_event.cpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_event.cpp rasterizer/archrast/events.proto rasterizer/archrast/events_private.proto rasterizer/codegen/gen_common.py
        $(MKDIR_GEN)
        $(PYTHON_GEN) \
                $(srcdir)/rasterizer/codegen/gen_archrast.py \
                --proto $(srcdir)/rasterizer/archrast/events.proto \
+               --proto_private $(srcdir)/rasterizer/archrast/events_private.proto \
                --output rasterizer/archrast/gen_ar_event.cpp \
                --gen_event_cpp
 
-rasterizer/archrast/gen_ar_eventhandler.hpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_eventhandler.hpp rasterizer/archrast/events.proto rasterizer/codegen/gen_common.py
+rasterizer/archrast/gen_ar_eventhandler.hpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_eventhandler.hpp rasterizer/archrast/events.proto rasterizer/archrast/events_private.proto rasterizer/codegen/gen_common.py
        $(MKDIR_GEN)
        $(PYTHON_GEN) \
                $(srcdir)/rasterizer/codegen/gen_archrast.py \
                --proto $(srcdir)/rasterizer/archrast/events.proto \
+               --proto_private $(srcdir)/rasterizer/archrast/events_private.proto \
                --output rasterizer/archrast/gen_ar_eventhandler.hpp \
-               --gen_eventhandler_h
+               --gen_eventhandler_hpp
 
-rasterizer/archrast/gen_ar_eventhandlerfile.hpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp rasterizer/archrast/events.proto rasterizer/codegen/gen_common.py
+rasterizer/archrast/gen_ar_eventhandlerfile.hpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp rasterizer/archrast/events.proto rasterizer/archrast/events_private.proto rasterizer/codegen/gen_common.py
        $(MKDIR_GEN)
        $(PYTHON_GEN) \
                $(srcdir)/rasterizer/codegen/gen_archrast.py \
                --proto $(srcdir)/rasterizer/archrast/events.proto \
+               --proto_private $(srcdir)/rasterizer/archrast/events_private.proto \
                --output rasterizer/archrast/gen_ar_eventhandlerfile.hpp \
-               --gen_eventhandlerfile_h
+               --gen_eventhandlerfile_hpp
 
 rasterizer/core/backends/gen_BackendPixelRate0.cpp \
 rasterizer/core/backends/gen_BackendPixelRate1.cpp \
index eca4830c24930b181b96cc59a6d34fb69efb4fe3..cc9c9e9a02416138b1983d633c4588796452d15b 100644 (file)
@@ -36,6 +36,7 @@ if not env['msvc'] :
     ])
 
 swrroot = '#src/gallium/drivers/swr/'
+srcroot = Dir(swrroot).abspath
 bldroot = Dir('.').abspath
 
 env.CodeGenerate(
@@ -96,8 +97,10 @@ env.CodeGenerate(
     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'
+    command = python_cmd + ' $SCRIPT --proto $SOURCE --proto_private ' + srcroot + '/rasterizer/archrast/events_private.proto --output $TARGET --gen_event_hpp'
 )
+Depends('rasterizer/archrast/gen_ar_event.hpp',
+        swrroot + 'rasterizer/archrast/events_private.proto')
 Depends('rasterizer/jitter/gen_state_llvm.h',
         swrroot + 'rasterizer/codegen/templates/gen_ar_event.hpp')
 
@@ -105,8 +108,10 @@ env.CodeGenerate(
     target = 'rasterizer/archrast/gen_ar_event.cpp',
     script = swrroot + 'rasterizer/codegen/gen_archrast.py',
     source = 'rasterizer/archrast/events.proto',
-    command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_cpp'
+    command = python_cmd + ' $SCRIPT --proto $SOURCE --proto_private ' + srcroot + '/rasterizer/archrast/events_private.proto --output $TARGET --gen_event_cpp'
 )
+Depends('rasterizer/archrast/gen_ar_event.cpp',
+        swrroot + 'rasterizer/archrast/events_private.proto')
 Depends('rasterizer/jitter/gen_state_llvm.h',
         swrroot + 'rasterizer/codegen/templates/gen_ar_event.cpp')
 
@@ -114,8 +119,10 @@ env.CodeGenerate(
     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'
+    command = python_cmd + ' $SCRIPT --proto $SOURCE --proto_private ' + srcroot + '/rasterizer/archrast/events_private.proto --output $TARGET --gen_eventhandler_hpp'
 )
+Depends('rasterizer/archrast/gen_ar_eventhandler.hpp',
+        swrroot + 'rasterizer/archrast/events_private.proto')
 Depends('rasterizer/jitter/gen_state_llvm.h',
         swrroot + 'rasterizer/codegen/templates/gen_ar_eventhandler.hpp')
 
@@ -123,8 +130,10 @@ env.CodeGenerate(
     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'
+    command = python_cmd + ' $SCRIPT --proto $SOURCE --proto_private ' + srcroot + '/rasterizer/archrast/events_private.proto --output $TARGET --gen_eventhandlerfile_hpp'
 )
+Depends('rasterizer/archrast/gen_ar_eventhandlerfile.hpp',
+        swrroot + 'rasterizer/archrast/events_private.proto')
 Depends('rasterizer/jitter/gen_state_llvm.h',
         swrroot + 'rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp')
 
index a527d5ced19ecaa1a85ddbe97d634f19792e930c..4bcd4f4e388bb1f988fb05a1fb1f590aba054cf3 100644 (file)
@@ -151,6 +151,7 @@ files_swr_arch = files(
 swr_context_files = files('swr_context.h')
 swr_state_files = files('rasterizer/core/state.h')
 swr_event_proto_files = files('rasterizer/archrast/events.proto')
+swr_event_pproto_files = files('rasterizer/archrast/events_private.proto')
 swr_gen_backend_files = files('rasterizer/codegen/templates/gen_backend.cpp')
 swr_gen_rasterizer_files = files('rasterizer/codegen/templates/gen_rasterizer.cpp')
 swr_gen_header_init_files = files('rasterizer/codegen/templates/gen_header_init.hpp')
index 68773270f3034ff8f6fe26df1e829ad881863372..f9be5844333379cbdb674e604a5f3a9ea255b9a8 100644 (file)
@@ -131,72 +131,6 @@ event BackendStatsEvent
 
 };
 
-event EarlyDepthStencilInfoSingleSample
-{
-    uint64_t depthPassMask;
-    uint64_t stencilPassMask;
-    uint64_t coverageMask;
-};
-
-event EarlyDepthStencilInfoSampleRate
-{
-    uint64_t depthPassMask;
-    uint64_t stencilPassMask;
-    uint64_t coverageMask;
-};
-
-event EarlyDepthStencilInfoNullPS
-{
-    uint64_t depthPassMask;
-    uint64_t stencilPassMask;
-    uint64_t coverageMask;
-};
-
-event LateDepthStencilInfoSingleSample
-{
-    uint64_t depthPassMask;
-    uint64_t stencilPassMask;
-    uint64_t coverageMask;
-};
-
-event LateDepthStencilInfoSampleRate
-{
-    uint64_t depthPassMask;
-    uint64_t stencilPassMask;
-    uint64_t coverageMask;
-};
-
-event LateDepthStencilInfoNullPS
-{
-    uint64_t depthPassMask;
-    uint64_t stencilPassMask;
-    uint64_t coverageMask;
-};
-
-event EarlyDepthInfoPixelRate
-{
-    uint64_t depthPassCount;
-    uint64_t activeLanes;
-};
-
-
-event LateDepthInfoPixelRate
-{
-    uint64_t depthPassCount;
-    uint64_t activeLanes;
-};
-
-
-event BackendDrawEndEvent
-{
-    uint32_t drawId;
-};
-
-event FrontendDrawEndEvent
-{
-    uint32_t drawId;
-};
-
 event EarlyZSingleSample
 {
     uint32_t drawId;
@@ -310,13 +244,6 @@ event LateOmStencil
     uint64_t failCount;
 };
 
-event GSPrimInfo
-{
-    uint64_t inputPrimCount;
-    uint64_t primGeneratedCount;
-    uint64_t vertsInput;
-};
-
 event GSInputPrims
 {
     uint32_t drawId;
@@ -335,35 +262,12 @@ event GSVertsInput
     uint64_t vertsInput;
 };
 
-event ClipVertexCount
-{
-    uint64_t vertsPerPrim;
-    uint64_t primMask;
-};
-
-//REMOVE AND REPLACE
-event FlushVertClip
-{
-    uint32_t drawId;
-};
-
 event VertsClipped
 {
     uint32_t drawId;
     uint64_t clipCount;
 };
 
-event TessPrimCount
-{
-    uint64_t primCount;
-};
-
-//REMOVE AND REPLACE
-event TessPrimFlush
-{
-    uint32_t drawId;
-};
-
 event TessPrims
 {
     uint32_t drawId;
diff --git a/src/gallium/drivers/swr/rasterizer/archrast/events_private.proto b/src/gallium/drivers/swr/rasterizer/archrast/events_private.proto
new file mode 100644 (file)
index 0000000..e0fe9b9
--- /dev/null
@@ -0,0 +1,109 @@
+# Copyright (C) 2018 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.
+#
+# Provides definitions for private internal events that are only used internally
+# to rasty for communicating information between Rasty and Archrast. One goal for
+# ArchRast is to not pollute the Rasty code with lots of calculations, etc. that
+# are needed to compute per draw statistics, etc.
+
+event EarlyDepthStencilInfoSingleSample
+{
+    uint64_t depthPassMask;
+    uint64_t stencilPassMask;
+    uint64_t coverageMask;
+};
+
+event EarlyDepthStencilInfoSampleRate
+{
+    uint64_t depthPassMask;
+    uint64_t stencilPassMask;
+    uint64_t coverageMask;
+};
+
+event EarlyDepthStencilInfoNullPS
+{
+    uint64_t depthPassMask;
+    uint64_t stencilPassMask;
+    uint64_t coverageMask;
+};
+
+event LateDepthStencilInfoSingleSample
+{
+    uint64_t depthPassMask;
+    uint64_t stencilPassMask;
+    uint64_t coverageMask;
+};
+
+event LateDepthStencilInfoSampleRate
+{
+    uint64_t depthPassMask;
+    uint64_t stencilPassMask;
+    uint64_t coverageMask;
+};
+
+event LateDepthStencilInfoNullPS
+{
+    uint64_t depthPassMask;
+    uint64_t stencilPassMask;
+    uint64_t coverageMask;
+};
+
+event EarlyDepthInfoPixelRate
+{
+    uint64_t depthPassCount;
+    uint64_t activeLanes;
+};
+
+
+event LateDepthInfoPixelRate
+{
+    uint64_t depthPassCount;
+    uint64_t activeLanes;
+};
+
+
+event BackendDrawEndEvent
+{
+    uint32_t drawId;
+};
+
+event FrontendDrawEndEvent
+{
+    uint32_t drawId;
+};
+
+event ClipVertexCount
+{
+    uint64_t vertsPerPrim;
+    uint64_t primMask;
+};
+
+event TessPrimCount
+{
+    uint64_t primCount;
+};
+
+event GSPrimInfo
+{
+    uint64_t inputPrimCount;
+    uint64_t primGeneratedCount;
+    uint64_t vertsInput;
+};
index 06a3dea4ad95bb99bddc96bb086dfbe2d89781b0..aa09f220c3f56f231309aeb0ce1186efa53dd5ec 100644 (file)
@@ -77,19 +77,13 @@ def parse_enums(lines, idx, event_dict):
     event_dict['names'] = enum_names
     return idx
 
-def parse_protos(filename):
-    protos = {}
+def parse_protos(protos, filename):
 
     with open(filename, 'r') as f:
         lines=f.readlines()
 
         idx = 0
 
-        protos['events'] = {}       # event dictionary containing events with their fields
-        protos['event_names'] = []  # needed to keep events in order parsed. dict is not ordered.
-        protos['enums'] = {}
-        protos['enum_names'] = []
-
         eventId = 0
         raw_text = []
         while idx < len(lines):
@@ -118,13 +112,12 @@ def parse_protos(filename):
                 protos['enums'][enum_name] = {}
                 idx = parse_enums(lines, idx, protos['enums'][enum_name])
 
-    return protos
-
 def main():
 
     # Parse args...
     parser = ArgumentParser()
     parser.add_argument('--proto', '-p', help='Path to proto file', required=True)
+    parser.add_argument('--proto_private', '-pp', help='Path to private 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)
@@ -133,6 +126,7 @@ def main():
     args = parser.parse_args()
 
     proto_filename = args.proto
+    proto_private_filename = args.proto_private
 
     (output_dir, output_filename) = os.path.split(args.output)
 
@@ -146,7 +140,18 @@ def main():
         print('Error: Could not find proto file %s' % proto_filename, file=sys.stderr)
         return 1
 
-    protos = parse_protos(proto_filename)
+    if not os.path.exists(proto_private_filename):
+        print('Error: Could not find private proto file %s' % proto_private_filename, file=sys.stderr)
+        return 1
+
+    protos = {}
+    protos['events'] = {}       # event dictionary containing events with their fields
+    protos['event_names'] = []  # needed to keep events in order parsed. dict is not ordered.
+    protos['enums'] = {}
+    protos['enum_names'] = []
+
+    parse_protos(protos, proto_filename)
+    parse_protos(protos, proto_private_filename)
 
     # Generate event header
     if args.gen_event_hpp:
index a6e127b8c5f3aba7c73518c1d7dee73fa00e7db3..bbe6efff01a044f86c0c508cb9d41b743d333ec9 100644 (file)
@@ -67,10 +67,14 @@ foreach x : [['gen_ar_event.hpp', '--gen_event_hpp'],
              ['gen_ar_eventhandlerfile.hpp', '--gen_eventhandlerfile_h']]
   files_swr_common += custom_target(
     x[0],
-    input : ['gen_archrast.py', swr_event_proto_files],
+    input : ['gen_archrast.py', swr_event_proto_files, swr_event_pproto_files],
     output : x[0],
     command : [
-      prog_python2, '@INPUT0@', '--proto', '@INPUT1@', '--output', '@OUTPUT@',
+      prog_python2,
+      '@INPUT0@',
+      '--proto', '@INPUT1@',
+      '--proto_private', '@INPUT2@',
+      '--output', '@OUTPUT@',
       x[1],
     ],
     depend_files : files(