From a44420d9ccceaa113ab9db9f60d37621b10c733b Mon Sep 17 00:00:00 2001 From: Alok Hota Date: Mon, 17 Sep 2018 14:50:47 -0500 Subject: [PATCH] swr/rast: Add general SWTag statistics Update Archrast parser to use stats, used with an internal tool Reviewed-by: Bruce Cherniak --- .../drivers/swr/rasterizer/archrast/events.proto | 314 +++++++++++---------- .../drivers/swr/rasterizer/codegen/gen_archrast.py | 36 ++- .../rasterizer/codegen/templates/gen_ar_event.hpp | 2 +- 3 files changed, 191 insertions(+), 161 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/archrast/events.proto b/src/gallium/drivers/swr/rasterizer/archrast/events.proto index aedc37b..1057a94 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/events.proto +++ b/src/gallium/drivers/swr/rasterizer/archrast/events.proto @@ -96,355 +96,371 @@ event SwrStoreTilesEvent event FrontendStatsEvent { uint32_t drawId; - uint64_t IaVertices; - uint64_t IaPrimitives; - uint64_t VsInvocations; - uint64_t HsInvocations; - uint64_t DsInvocations; - uint64_t GsInvocations; - uint64_t GsPrimitives; - uint64_t CInvocations; - uint64_t CPrimitives; - uint64_t SoPrimStorageNeeded0; - uint64_t SoPrimStorageNeeded1; - uint64_t SoPrimStorageNeeded2; - uint64_t SoPrimStorageNeeded3; - uint64_t SoNumPrimsWritten0; - uint64_t SoNumPrimsWritten1; - uint64_t SoNumPrimsWritten2; - uint64_t SoNumPrimsWritten3; + uint64_t counter IaVertices; + uint64_t counter IaPrimitives; + uint64_t counter VsInvocations; + uint64_t counter HsInvocations; + uint64_t counter DsInvocations; + uint64_t counter GsInvocations; + uint64_t counter GsPrimitives; + uint64_t counter CInvocations; + uint64_t counter CPrimitives; + uint64_t counter SoPrimStorageNeeded0; + uint64_t counter SoPrimStorageNeeded1; + uint64_t counter SoPrimStorageNeeded2; + uint64_t counter SoPrimStorageNeeded3; + uint64_t counter SoNumPrimsWritten0; + uint64_t counter SoNumPrimsWritten1; + uint64_t counter SoNumPrimsWritten2; + uint64_t counter SoNumPrimsWritten3; }; event BackendStatsEvent { uint32_t drawId; - uint64_t DepthPassCount; - uint64_t PsInvocations; - uint64_t CsInvocations; + uint64_t counter DepthPassCount; + uint64_t counter PsInvocations; + uint64_t counter CsInvocations; }; event EarlyZSingleSample { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event LateZSingleSample { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event EarlyStencilSingleSample { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event LateStencilSingleSample { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event EarlyZSampleRate { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event LateZSampleRate { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event EarlyStencilSampleRate { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event LateStencilSampleRate { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; // Total Early-Z counts, SingleSample and SampleRate event EarlyZ { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; // Total LateZ counts, SingleSample and SampleRate event LateZ { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; // Total EarlyStencil counts, SingleSample and SampleRate event EarlyStencil { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; // Total LateStencil counts, SingleSample and SampleRate event LateStencil { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event EarlyZNullPS { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event EarlyStencilNullPS { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event EarlyZPixelRate { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event LateZPixelRate { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event EarlyOmZ { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event EarlyOmStencil { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event LateOmZ { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event LateOmStencil { uint32_t drawId; - uint64_t passCount; - uint64_t failCount; + uint64_t counter passCount; + uint64_t counter failCount; }; event GSInputPrims { uint32_t drawId; - uint64_t inputPrimCount; + uint64_t counter inputPrimCount; }; event GSPrimsGen { uint32_t drawId; - uint64_t primGeneratedCount; + uint64_t counter primGeneratedCount; }; event GSVertsInput { uint32_t drawId; - uint64_t vertsInput; + uint64_t counter vertsInput; }; event TessPrims { uint32_t drawId; - uint64_t primCount; + uint64_t counter primCount; }; event RasterTiles { uint32_t drawId; - uint32_t rastTileCount; + uint32_t counter rastTileCount; }; event ClipperEvent { uint32_t drawId; - uint32_t trivialRejectCount; - uint32_t trivialAcceptCount; - uint32_t mustClipCount; + uint32_t counter trivialRejectCount; + uint32_t counter trivialAcceptCount; + uint32_t counter mustClipCount; }; event CullEvent { uint32_t drawId; - uint64_t backfacePrimCount; - uint64_t degeneratePrimCount; + uint64_t counter backfacePrimCount; + uint64_t counter degeneratePrimCount; }; event AlphaEvent { uint32_t drawId; - uint32_t alphaTestCount; - uint32_t alphaBlendCount; + uint32_t counter alphaTestCount; + uint32_t counter alphaBlendCount; }; event VSInfo { uint32_t drawId; - uint32_t numInstExecuted; - uint32_t numSampleExecuted; - uint32_t numSampleLExecuted; - uint32_t numSampleBExecuted; - uint32_t numSampleCExecuted; - uint32_t numSampleCLZExecuted; - uint32_t numSampleCDExecuted; - uint32_t numGather4Executed; - uint32_t numGather4CExecuted; - uint32_t numGather4CPOExecuted; - uint32_t numGather4CPOCExecuted; - uint32_t numLodExecuted; + uint32_t counter numInstExecuted; + uint32_t counter numSampleExecuted; + uint32_t counter numSampleLExecuted; + uint32_t counter numSampleBExecuted; + uint32_t counter numSampleCExecuted; + uint32_t counter numSampleCLZExecuted; + uint32_t counter numSampleCDExecuted; + uint32_t counter numGather4Executed; + uint32_t counter numGather4CExecuted; + uint32_t counter numGather4CPOExecuted; + uint32_t counter numGather4CPOCExecuted; + uint32_t counter numLodExecuted; }; event HSInfo { uint32_t drawId; - uint32_t numInstExecuted; - uint32_t numSampleExecuted; - uint32_t numSampleLExecuted; - uint32_t numSampleBExecuted; - uint32_t numSampleCExecuted; - uint32_t numSampleCLZExecuted; - uint32_t numSampleCDExecuted; - uint32_t numGather4Executed; - uint32_t numGather4CExecuted; - uint32_t numGather4CPOExecuted; - uint32_t numGather4CPOCExecuted; - uint32_t numLodExecuted; + uint32_t counter numInstExecuted; + uint32_t counter numSampleExecuted; + uint32_t counter numSampleLExecuted; + uint32_t counter numSampleBExecuted; + uint32_t counter numSampleCExecuted; + uint32_t counter numSampleCLZExecuted; + uint32_t counter numSampleCDExecuted; + uint32_t counter numGather4Executed; + uint32_t counter numGather4CExecuted; + uint32_t counter numGather4CPOExecuted; + uint32_t counter numGather4CPOCExecuted; + uint32_t counter numLodExecuted; }; event DSInfo { uint32_t drawId; - uint32_t numInstExecuted; - uint32_t numSampleExecuted; - uint32_t numSampleLExecuted; - uint32_t numSampleBExecuted; - uint32_t numSampleCExecuted; - uint32_t numSampleCLZExecuted; - uint32_t numSampleCDExecuted; - uint32_t numGather4Executed; - uint32_t numGather4CExecuted; - uint32_t numGather4CPOExecuted; - uint32_t numGather4CPOCExecuted; - uint32_t numLodExecuted; + uint32_t counter numInstExecuted; + uint32_t counter numSampleExecuted; + uint32_t counter numSampleLExecuted; + uint32_t counter numSampleBExecuted; + uint32_t counter numSampleCExecuted; + uint32_t counter numSampleCLZExecuted; + uint32_t counter numSampleCDExecuted; + uint32_t counter numGather4Executed; + uint32_t counter numGather4CExecuted; + uint32_t counter numGather4CPOExecuted; + uint32_t counter numGather4CPOCExecuted; + uint32_t counter numLodExecuted; }; event GSInfo { uint32_t drawId; - uint32_t numInstExecuted; - uint32_t numSampleExecuted; - uint32_t numSampleLExecuted; - uint32_t numSampleBExecuted; - uint32_t numSampleCExecuted; - uint32_t numSampleCLZExecuted; - uint32_t numSampleCDExecuted; - uint32_t numGather4Executed; - uint32_t numGather4CExecuted; - uint32_t numGather4CPOExecuted; - uint32_t numGather4CPOCExecuted; - uint32_t numLodExecuted; + uint32_t counter numInstExecuted; + uint32_t counter numSampleExecuted; + uint32_t counter numSampleLExecuted; + uint32_t counter numSampleBExecuted; + uint32_t counter numSampleCExecuted; + uint32_t counter numSampleCLZExecuted; + uint32_t counter numSampleCDExecuted; + uint32_t counter numGather4Executed; + uint32_t counter numGather4CExecuted; + uint32_t counter numGather4CPOExecuted; + uint32_t counter numGather4CPOCExecuted; + uint32_t counter numLodExecuted; }; event PSInfo { uint32_t drawId; - uint32_t numInstExecuted; - uint32_t numSampleExecuted; - uint32_t numSampleLExecuted; - uint32_t numSampleBExecuted; - uint32_t numSampleCExecuted; - uint32_t numSampleCLZExecuted; - uint32_t numSampleCDExecuted; - uint32_t numGather4Executed; - uint32_t numGather4CExecuted; - uint32_t numGather4CPOExecuted; - uint32_t numGather4CPOCExecuted; - uint32_t numLodExecuted; + uint32_t counter numInstExecuted; + uint32_t counter numSampleExecuted; + uint32_t counter numSampleLExecuted; + uint32_t counter numSampleBExecuted; + uint32_t counter numSampleCExecuted; + uint32_t counter numSampleCLZExecuted; + uint32_t counter numSampleCDExecuted; + uint32_t counter numGather4Executed; + uint32_t counter numGather4CExecuted; + uint32_t counter numGather4CPOExecuted; + uint32_t counter numGather4CPOCExecuted; + uint32_t counter numLodExecuted; }; event CSInfo { uint32_t drawId; - uint32_t numInstExecuted; - uint32_t numSampleExecuted; - uint32_t numSampleLExecuted; - uint32_t numSampleBExecuted; - uint32_t numSampleCExecuted; - uint32_t numSampleCLZExecuted; - uint32_t numSampleCDExecuted; - uint32_t numGather4Executed; - uint32_t numGather4CExecuted; - uint32_t numGather4CPOExecuted; - uint32_t numGather4CPOCExecuted; - uint32_t numLodExecuted; + uint32_t counter numInstExecuted; + uint32_t counter numSampleExecuted; + uint32_t counter numSampleLExecuted; + uint32_t counter numSampleBExecuted; + uint32_t counter numSampleCExecuted; + uint32_t counter numSampleCLZExecuted; + uint32_t counter numSampleCDExecuted; + uint32_t counter numGather4Executed; + uint32_t counter numGather4CExecuted; + uint32_t counter numGather4CPOExecuted; + uint32_t counter numGather4CPOCExecuted; + uint32_t counter numLodExecuted; }; event SWTagFrameEvent { + uint64_t swTagFrame; }; event SWTagRenderpassEvent { + uint64_t swTagFrame; + uint32_t swTagDrawOrDispatch; + uint32_t swTagDraw; + uint32_t swTagDispatch; + uint32_t swTagRenderpassCount; }; event SWTagDrawEvent { - uint32_t drawId; + uint64_t swTagFrame; + uint32_t swTagDrawOrDispatch; + uint32_t swTagDraw; + uint32_t swTagDispatch; }; event SWTagDispatchEvent { - uint32_t drawId; + uint64_t swTagFrame; + uint32_t swTagDrawOrDispatch; + uint32_t swTagDraw; + uint32_t swTagDispatch; }; event SWTagFlushEvent { - uint32_t drawId; - char flushReason[256]; - uint32_t flushType; + uint64_t swTagFrame; + uint32_t swTagDrawOrDispatch; + uint32_t swTagDraw; + uint32_t swTagDispatch; + uint32_t swTagFlushCounter; + char swTagFlushReason[256]; + uint32_t swTagFlushType; }; \ No newline at end of file diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py index 6182504..b4b6127 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py +++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py @@ -27,6 +27,9 @@ import re from gen_common import * def parse_event_fields(lines, idx, event_dict): + """ + Parses lines from a proto file that contain an event definition and stores it in event_dict + """ fields = [] end_of_event = False @@ -36,13 +39,14 @@ def parse_event_fields(lines, idx, event_dict): line = lines[idx].rstrip() idx += 1 - match = re.match(r'(\s*)([\w\*]+)(\s*)([\w]+)(\[\d+\])*', line) + match = re.match(r'(\s*)([\w\*]+)(\s+)(counter\s+)*([\w]+)(\[\d+\])*', line) if match: field = { "type": match.group(2), - "name": match.group(4), - "size": int(match.group(5)[1:-1]) if match.group(5) else 1 + "name": match.group(5), + "size": int(match.group(6)[1:-1]) if match.group(6) else 1, + "counter": True if match.group(4) else False } fields.append(field) @@ -54,6 +58,9 @@ def parse_event_fields(lines, idx, event_dict): return idx def parse_enums(lines, idx, event_dict): + """ + Parses lines from a proto file that contain an enum definition and stores it in event_dict + """ enum_names = [] end_of_enum = False @@ -77,15 +84,21 @@ def parse_enums(lines, idx, event_dict): return idx def parse_protos(files, verbose=False): - + """ + Parses a proto file and returns a dictionary of event definitions + """ 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['event_map'] = {} # dictionary to map event ids to event names protos['enums'] = {} protos['enum_names'] = [] eventId = 0 + if type(files) is not list: + files = [files] + for filename in files: if verbose: print("Parsing proto file: %s" % os.path.normpath(filename)) @@ -106,21 +119,22 @@ def parse_protos(files, verbose=False): if match: eventId += 1 event_name = match.group(3) - protos['event_names'].append(event_name) + protos["event_names"].append(event_name) - protos['events'][event_name] = {} - protos['events'][event_name]['event_id'] = eventId - idx = parse_event_fields(lines, idx, protos['events'][event_name]) + protos["events"][event_name] = {} + protos["events"][event_name]["event_id"] = eventId + protos["event_map"][eventId] = event_name + idx = parse_event_fields(lines, idx, protos["events"][event_name]) # search for enums. match = re.match(r'(\s*)enum(\s*)(\w+)', line) if match: enum_name = match.group(3) - protos['enum_names'].append(enum_name) + protos["enum_names"].append(enum_name) - protos['enums'][enum_name] = {} - idx = parse_enums(lines, idx, protos['enums'][enum_name]) + protos["enums"][enum_name] = {} + idx = parse_enums(lines, idx, protos["enums"][enum_name]) return protos 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 index 884a321..6c592f7 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.hpp +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.hpp @@ -113,7 +113,7 @@ namespace ArchRast % for i in range(len(fields)): % if fields[i]['size'] > 1: % if fields[i]['type'] == 'char': - // Copy size of string (null-terminated) followed by string buffer info entire buffer + // Copy size of string (null-terminated) followed by string into entire buffer SWR_ASSERT(${fields[i]['name']}_size + 1 < ${fields[i]['size']} - sizeof(uint32_t), "String length must be less than size of char buffer - size(uint32_t)!"); memcpy(data.${fields[i]['name']}, &${fields[i]['name']}_size, sizeof(uint32_t)); strcpy_s(data.${fields[i]['name']} + sizeof(uint32_t), ${fields[i]['name']}_size + 1, ${fields[i]['name']}); -- 2.7.4