Last active
December 23, 2024 02:36
-
-
Save notcancername/5b02713f744e935b9ab350f1c38cf499 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import sys | |
import renderdoc as rd | |
actions = {} | |
def iterDraw(d, indent = ''): | |
global actions | |
actions[d.eventId] = d | |
for d in d.children: | |
iterDraw(d, indent + ' ') | |
class DurationMatch: | |
def __init__(self, duration, count): | |
self.duration = duration | |
self.count = count | |
duration_matches = {} | |
# Get all events | |
def pev(controller): | |
global duration_matches | |
for d in controller.GetRootActions(): | |
iterDraw(d) | |
desc = controller.DescribeCounter(rd.GPUCounter.EventGPUDuration) | |
results = controller.FetchCounters([rd.GPUCounter.EventGPUDuration]) | |
for r in results: | |
for event in actions[r.eventId].events: | |
name = pyrenderdoc.GetEventBrowser().GetEventName(event.eventId) | |
matches = None | |
for match_name in duration_matches: | |
if match_name in name: | |
matches = match_name | |
if matches is None: | |
continue | |
duration_matches[matches] = DurationMatch(duration = duration_matches[matches].duration + r.value.d, count = duration_matches[matches].count + 1) | |
duration_matches = { | |
"ScreenSpaceAmbientOcclusion": DurationMatch(0, 0), | |
"Bloom": DurationMatch(0, 0), | |
"UberPost": DurationMatch(0, 0), | |
"CopyDepth": DurationMatch(0, 0), | |
"Complex Lit": DurationMatch(0, 0), | |
"Simple Lit": DurationMatch(0, 0), | |
"LutBuilderLdr": DurationMatch(0, 0), | |
"BlackCutOut": DurationMatch(0, 0), | |
"CharacterTrial": DurationMatch(0, 0), | |
"Blit": DurationMatch(0, 0), | |
"UI/Default": DurationMatch(0, 0), | |
"TextMeshPro": DurationMatch(0, 0), | |
} | |
pyrenderdoc.Replay().BlockInvoke(pev) | |
for m in sorted(duration_matches.items(), key=lambda d: d[1].duration, reverse=True): | |
print(m[0], f"{m[1].count}x: {m[1].duration * 1_000_000:.2f}us") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment