File: show_buffer.rst

package info (click to toggle)
renderdoc 1.24%2Bdfsg-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 105,156 kB
  • sloc: cpp: 759,405; ansic: 309,460; python: 26,606; xml: 22,599; java: 11,365; cs: 7,181; makefile: 6,707; yacc: 5,682; ruby: 4,648; perl: 3,461; sh: 2,354; php: 2,119; lisp: 1,835; javascript: 1,524; tcl: 1,068; ml: 747
file content (50 lines) | stat: -rw-r--r-- 1,826 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Display buffer with format
==========================

This example shows an easy way to automate a repro case. It could be run as a command line argument when starting the UI, to avoid repetitive steps.

First the code opens a specified file, although this step could be omitted if the desired capture is already open.

.. highlight:: python
.. code:: python

    filename = "test.rdc"

    pyrenderdoc.LoadCapture(filename, renderdoc.ReplayOptions(), filename, False, True)

Next we iterate through the list of buffers to find the one we want. The selection criteria are up to you, in this case we look at the name provided and identify the buffer by that, however it could also be a particular size, or the buffer bound at a given event.

.. highlight:: python
.. code:: python

    mybuf = renderdoc.ResourceId.Null()

    for buf in pyrenderdoc.GetBuffers():
        print("buf %s is %s" % (buf.resourceId, pyrenderdoc.GetResourceName(buf.resourceId)))

        # here put your actual selection criteria - i.e. look for a particular name
        if pyrenderdoc.GetResourceName(buf.resourceId) == "dataBuffer":
            mybuf = buf.resourceId
            break

    print("selected %s" % pyrenderdoc.GetResourceName(mybuf))

Once we've identified the buffer we want to view, we create a buffer viewer and display it on the main tool area.

.. highlight:: python
.. code:: python

    # Open a new buffer viewer for this buffer, with the given format
    bufview = pyrenderdoc.ViewBuffer(0, 0, mybuf, formatter)

    # Show the buffer viewer on the main tool area
    pyrenderdoc.AddDockWindow(bufview.Widget(), qrenderdoc.DockReference.MainToolArea, None)

Example Source
--------------

.. only:: html and not htmlhelp

    :download:`Download the example script <show_buffer.py>`.

.. literalinclude:: show_buffer.py