diff options
author | Alok Hota <[email protected]> | 2018-09-17 14:50:47 -0500 |
---|---|---|
committer | Alok Hota <[email protected]> | 2019-05-01 15:11:30 +0000 |
commit | a44420d9ccceaa113ab9db9f60d37621b10c733b (patch) | |
tree | 8db588ee92e82f6a093abe6430d52946e15f54e8 /src/gallium/drivers/swr/rasterizer/codegen | |
parent | b8adb540a0dca76bab94bb52de3dbfb4a4faf726 (diff) |
swr/rast: Add general SWTag statistics
Update Archrast parser to use stats, used with an internal tool
Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr/rasterizer/codegen')
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py | 36 | ||||
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.hpp | 2 |
2 files changed, 26 insertions, 12 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py index 6182504567a..b4b6127c8cc 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 884a3210039..6c592f74461 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']}); |