mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-27 04:11:05 +00:00
Rename 'draw' or 'drawcall' to action
* There's not a good accepted terminology for this kind of event, and for historical reasons 'drawcall' has been the accepted term, even though that can be quite confusing when a dispatch or a copy is a 'drawcall'. * This is particularly highlighted by the event browser filters where $draw() includes draws and dispatches, but $dispatch() only includes dispatches, it's hard to intuitively understand why $draw() matches all of these calls. * As a result we've defined the term 'action' to cover these types of events in the same way that we defined 'event' in the first place to mean a single atomic API call.
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
import sys
|
||||
|
||||
# Import renderdoc if not already imported (e.g. in the UI)
|
||||
if 'renderdoc' not in sys.modules and '_renderdoc' not in sys.modules:
|
||||
import renderdoc
|
||||
|
||||
# Alias renderdoc for legibility
|
||||
rd = renderdoc
|
||||
|
||||
# Define a recursive function for iterating over actions
|
||||
def iterAction(d, indent = ''):
|
||||
# Print this action
|
||||
print('%s%d: %s' % (indent, d.eventId, d.name))
|
||||
|
||||
# Iterate over the action's children
|
||||
for d in d.children:
|
||||
iterAction(d, indent + ' ')
|
||||
|
||||
def sampleCode(controller):
|
||||
# Iterate over all of the root actions
|
||||
for d in controller.GetRootActions():
|
||||
iterAction(d)
|
||||
|
||||
# Start iterating from the first real action as a child of markers
|
||||
action = controller.GetRootActions()[0]
|
||||
|
||||
while len(action.children) > 0:
|
||||
action = action.children[0]
|
||||
|
||||
# Counter for which pass we're in
|
||||
passnum = 0
|
||||
# Counter for how many actions are in the pass
|
||||
passcontents = 0
|
||||
# Whether we've started seeing actions in the pass - i.e. we're past any
|
||||
# starting clear calls that may be batched together
|
||||
inpass = False
|
||||
|
||||
print("Pass #0 starts with %d: %s" % (action.eventId, action.name))
|
||||
|
||||
while action != None:
|
||||
# When we encounter a clear
|
||||
if action.flags & rd.ActionFlags.Clear:
|
||||
if inpass:
|
||||
print("Pass #%d contained %d actions" % (passnum, passcontents))
|
||||
passnum += 1
|
||||
print("Pass #%d starts with %d: %s" % (passnum, action.eventId, action.name))
|
||||
passcontents = 0
|
||||
inpass = False
|
||||
else:
|
||||
passcontents += 1
|
||||
inpass = True
|
||||
|
||||
# Advance to the next action
|
||||
action = action.next
|
||||
if action is None:
|
||||
break
|
||||
|
||||
if inpass:
|
||||
print("Pass #%d contained %d actions" % (passnum, passcontents))
|
||||
|
||||
def loadCapture(filename):
|
||||
# Open a capture file handle
|
||||
cap = rd.OpenCaptureFile()
|
||||
|
||||
# Open a particular file - see also OpenBuffer to load from memory
|
||||
status = cap.OpenFile(filename, '', None)
|
||||
|
||||
# Make sure the file opened successfully
|
||||
if status != rd.ReplayStatus.Succeeded:
|
||||
raise RuntimeError("Couldn't open file: " + str(status))
|
||||
|
||||
# Make sure we can replay
|
||||
if not cap.LocalReplaySupport():
|
||||
raise RuntimeError("Capture cannot be replayed")
|
||||
|
||||
# Initialise the replay
|
||||
status,controller = cap.OpenCapture(rd.ReplayOptions(), None)
|
||||
|
||||
if status != rd.ReplayStatus.Succeeded:
|
||||
raise RuntimeError("Couldn't initialise replay: " + str(status))
|
||||
|
||||
return cap,controller
|
||||
|
||||
if 'pyrenderdoc' in globals():
|
||||
pyrenderdoc.Replay().BlockInvoke(sampleCode)
|
||||
else:
|
||||
rd.InitialiseReplay(rd.GlobalEnvironment(), [])
|
||||
|
||||
if len(sys.argv) <= 1:
|
||||
print('Usage: python3 {} filename.rdc'.format(sys.argv[0]))
|
||||
sys.exit(0)
|
||||
|
||||
cap,controller = loadCapture(sys.argv[1])
|
||||
|
||||
sampleCode(controller)
|
||||
|
||||
controller.Shutdown()
|
||||
cap.Shutdown()
|
||||
|
||||
rd.ShutdownReplay()
|
||||
|
||||
Reference in New Issue
Block a user