Files
renderdoc/docs/python_api/examples/renderdoc/iter_actions.rst
T
baldurk 7149302680 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.
2021-07-01 15:15:05 +01:00

106 lines
4.3 KiB
ReStructuredText

Iterate Action tree
===================
In this example we will show how to iterate over actions.
The actions returned from :py:meth:`~renderdoc.ReplayController.GetRootActions` are actions or marker regions at the root level - with no parent marker region. There are multiple ways to iterate through the list of actions.
The first way illustrated in this sample is to walk the tree using :py:attr:`~renderdoc.ActionDescription.children`, which contains the list of child actions at any point in the tree. There is also :py:attr:`~renderdoc.ActionDescription.parent` which points to the parent action.
The second is to use :py:attr:`~renderdoc.ActionDescription.previous` and :py:attr:`~renderdoc.ActionDescription.next`, which point to the previous and next action respectively in a linear fashion, regardless of nesting depth.
In the example we use this iteration to determine the number of passes, using the action flags to denote the start of each pass by a starting clear call.
Example Source
--------------
.. only:: html and not htmlhelp
:download:`Download the example script <iter_actions.py>`.
.. literalinclude:: iter_actions.py
Sample output:
.. sourcecode:: text
1: Scene
2: ClearRenderTargetView(0.000000, 0.000000, 0.000000, 1.000000)
3: ClearDepthStencilView(D=1.000000, S=00)
9: ClearRenderTargetView(0.000000, 0.000000, 0.000000, 0.000000)
10: ClearRenderTargetView(0.000000, 0.000000, 0.000000, 0.000000)
11: ClearDepthStencilView(D=1.000000, S=00)
13: GBuffer
28: DrawIndexed(4800)
43: DrawIndexed(36)
56: DrawIndexed(5220)
69: DrawIndexed(5580)
82: DrawIndexed(5580)
95: DrawIndexed(5580)
108: DrawIndexed(5580)
121: DrawIndexed(5580)
134: DrawIndexed(5580)
147: DrawIndexed(5580)
160: DrawIndexed(5580)
173: DrawIndexed(5580)
186: DrawIndexed(5580)
199: DrawIndexed(5220)
212: DrawIndexed(5220)
225: DrawIndexed(5220)
238: DrawIndexed(5220)
251: DrawIndexed(5220)
264: DrawIndexed(5220)
277: DrawIndexed(5220)
290: DrawIndexed(5220)
303: DrawIndexed(5220)
316: DrawIndexed(5220)
319: ClearDepthStencilView(D=1.000000, S=00)
321: Shadowmap
333: DrawIndexed(4800)
345: DrawIndexed(36)
355: DrawIndexed(5220)
365: DrawIndexed(5580)
375: DrawIndexed(5580)
385: DrawIndexed(5580)
395: DrawIndexed(5580)
405: DrawIndexed(5580)
415: DrawIndexed(5580)
425: DrawIndexed(5580)
435: DrawIndexed(5580)
445: DrawIndexed(5580)
455: DrawIndexed(5580)
465: DrawIndexed(5220)
475: DrawIndexed(5220)
485: DrawIndexed(5220)
495: DrawIndexed(5220)
505: DrawIndexed(5220)
515: DrawIndexed(5220)
525: DrawIndexed(5220)
535: DrawIndexed(5220)
545: DrawIndexed(5220)
555: DrawIndexed(5220)
558: ClearRenderTargetView(0.000000, 0.000000, 0.000000, 1.000000)
559: ClearDepthStencilView(D=1.000000, S=00)
561: Lighting
563: ClearRenderTargetView(0.000000, 0.000000, 0.000000, 0.000000)
564: ClearRenderTargetView(0.000000, 0.000000, 0.000000, 0.000000)
580: DrawIndexed(36)
597: DrawIndexed(36)
614: DrawIndexed(36)
617: ClearRenderTargetView(0.000000, 0.000000, 0.000000, 1.000000)
618: ClearDepthStencilView(D=1.000000, S=00)
620: Shading
630: Draw(6)
645: DrawIndexed(960)
652: API Calls
655: End of Frame
Pass #0 starts with 2: ClearRenderTargetView(0.000000, 0.000000, 0.000000, 1.000000)
Pass #0 contained 24 actions
Pass #1 starts with 319: ClearDepthStencilView(D=1.000000, S=00)
Pass #1 contained 24 actions
Pass #2 starts with 558: ClearRenderTargetView(0.000000, 0.000000, 0.000000, 1.000000)
Pass #2 contained 3 actions
Pass #3 starts with 617: ClearRenderTargetView(0.000000, 0.000000, 0.000000, 1.000000)
Pass #3 contained 4 actions