diff --git a/docs/python_api/examples/renderdoc/decode_mesh.py b/docs/python_api/examples/renderdoc/decode_mesh.py index 82dc6362a..e4ef4acde 100644 --- a/docs/python_api/examples/renderdoc/decode_mesh.py +++ b/docs/python_api/examples/renderdoc/decode_mesh.py @@ -275,6 +275,8 @@ def loadCapture(filename): 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) @@ -286,3 +288,5 @@ else: controller.Shutdown() cap.Shutdown() + rd.ShutdownReplay() + diff --git a/docs/python_api/examples/renderdoc/display_window.py b/docs/python_api/examples/renderdoc/display_window.py index 390c5942c..566e7853d 100644 --- a/docs/python_api/examples/renderdoc/display_window.py +++ b/docs/python_api/examples/renderdoc/display_window.py @@ -37,6 +37,8 @@ else: print('Usage: python3 {} filename.rdc'.format(sys.argv[0])) sys.exit(0) + rd.InitialiseReplay(rd.GlobalEnvironment(), []) + cap,controller = loadCapture(sys.argv[1]) # Use tkinter to create windows @@ -139,3 +141,6 @@ window.mainloop() controller.Shutdown() cap.Shutdown() + +if 'pyrenderdoc' not in globals(): + rd.ShutdownReplay() diff --git a/docs/python_api/examples/renderdoc/fetch_counters.py b/docs/python_api/examples/renderdoc/fetch_counters.py index f16a032f1..f8952c047 100644 --- a/docs/python_api/examples/renderdoc/fetch_counters.py +++ b/docs/python_api/examples/renderdoc/fetch_counters.py @@ -90,6 +90,8 @@ def loadCapture(filename): 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) @@ -101,3 +103,5 @@ else: controller.Shutdown() cap.Shutdown() + rd.ShutdownReplay() + diff --git a/docs/python_api/examples/renderdoc/fetch_shader.py b/docs/python_api/examples/renderdoc/fetch_shader.py index 1593ba8dd..6219312a3 100644 --- a/docs/python_api/examples/renderdoc/fetch_shader.py +++ b/docs/python_api/examples/renderdoc/fetch_shader.py @@ -81,6 +81,8 @@ def loadCapture(filename): 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) @@ -92,3 +94,5 @@ else: controller.Shutdown() cap.Shutdown() + rd.ShutdownReplay() + diff --git a/docs/python_api/examples/renderdoc/iter_draws.py b/docs/python_api/examples/renderdoc/iter_draws.py index 28ce6002c..dd7d163f6 100644 --- a/docs/python_api/examples/renderdoc/iter_draws.py +++ b/docs/python_api/examples/renderdoc/iter_draws.py @@ -84,6 +84,8 @@ def loadCapture(filename): 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) @@ -95,3 +97,5 @@ else: controller.Shutdown() cap.Shutdown() + rd.ShutdownReplay() + diff --git a/docs/python_api/examples/renderdoc/remote_capture.py b/docs/python_api/examples/renderdoc/remote_capture.py index 94add438a..1dc34b6bb 100644 --- a/docs/python_api/examples/renderdoc/remote_capture.py +++ b/docs/python_api/examples/renderdoc/remote_capture.py @@ -9,6 +9,8 @@ import time # the executable and trigger the capture at the desired time raise RuntimeError("This sample should not be run directly, read the source") +rd.InitialiseReplay(rd.GlobalEnvironment(), []) + protocols = rd.GetSupportedDeviceProtocols() print(f"Supported device protocols: {protocols}") @@ -194,3 +196,5 @@ controller.Shutdown() # save the capture, etc remote.ShutdownServerAndConnection() + +rd.ShutdownReplay() diff --git a/docs/python_api/examples/renderdoc/save_texture.py b/docs/python_api/examples/renderdoc/save_texture.py index d5f3bd710..fe98f0023 100644 --- a/docs/python_api/examples/renderdoc/save_texture.py +++ b/docs/python_api/examples/renderdoc/save_texture.py @@ -99,10 +99,18 @@ def loadCapture(filename): if 'pyrenderdoc' in globals(): pyrenderdoc.Replay().BlockInvoke(sampleCode) else: - cap,controller = loadCapture('test.rdc') + 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() + diff --git a/docs/python_api/examples/renderdoc_intro.py b/docs/python_api/examples/renderdoc_intro.py index bf2a6e0a5..cb2662750 100644 --- a/docs/python_api/examples/renderdoc_intro.py +++ b/docs/python_api/examples/renderdoc_intro.py @@ -1,5 +1,7 @@ import renderdoc as rd +rd.InitialiseReplay(rd.GlobalEnvironment(), []) + # Open a capture file handle cap = rd.OpenCaptureFile() @@ -26,3 +28,5 @@ print("%d top-level drawcalls" % len(controller.GetDrawcalls())) controller.Shutdown() cap.Shutdown() + +rd.ShutdownReplay() diff --git a/docs/python_api/examples/renderdoc_intro.rst b/docs/python_api/examples/renderdoc_intro.rst index 57195f50a..917d302a3 100644 --- a/docs/python_api/examples/renderdoc_intro.rst +++ b/docs/python_api/examples/renderdoc_intro.rst @@ -47,6 +47,14 @@ Loading a Capture Given a capture file ``test.rdc`` we want to load it, begin the replay and get ready to perform analysis on it. +Before doing anything, we must initialise the replay API. We do that by calling :py:meth:`~renderdoc.InitialiseReplay`. Generally no special configuration is needed so passing a default :py:class:`~renderdoc.GlobalEnvironment` and an empty list of arguments is fine. + + +.. highlight:: python +.. code:: python + + rd.InitialiseReplay(rd.GlobalEnvironment(), []) + To begin with, we use :py:meth:`~renderdoc.OpenCaptureFile` to obtain a :py:class:`~renderdoc.CaptureFile` instance. This gives us access to control over a capture file at a meta level. For more information see the :py:class:`CaptureFile` reference - the interface can also be used to create. To open a file, use :py:meth:`~renderdoc.CaptureFile.OpenFile` on the :py:class:`~renderdoc.CaptureFile` instance. This function allows conversion from other formats via an importer, but here we'll use it just for opening a regular ``rdc`` file. It returns a :py:class:`~renderdoc.ReplayStatus` which can be used to determine what went wrong in the event that there was a problem. We then check that the capture uses an API which can be replayed locally - for example not every platform supports ``D3D11``, so on linux this would return no local replay support. @@ -89,6 +97,8 @@ This function call will open the capture and begin to replay it, and initialise Once we're done with the interfaces, we should call the ``Shutdown`` function on each, this allows the C++ interface to release the resources allocated. +Once all work is done we can shutdown the replay API. + .. highlight:: python .. code:: python @@ -97,6 +107,8 @@ Once we're done with the interfaces, we should call the ``Shutdown`` function on cap.Shutdown() + rd.ShutdownReplay() + Example Source -------------- diff --git a/docs/python_api/renderdoc/funcs.rst b/docs/python_api/renderdoc/funcs.rst index cf9048c1c..56493dd12 100644 --- a/docs/python_api/renderdoc/funcs.rst +++ b/docs/python_api/renderdoc/funcs.rst @@ -5,6 +5,12 @@ Functions .. module:: renderdoc +Initialisation and Shutdown +--------------------------- + +.. autofunction:: renderdoc.InitialiseReplay +.. autofunction:: renderdoc.ShutdownReplay + Capture File Access ------------------- diff --git a/docs/python_api/renderdoc/main_ifaces.rst b/docs/python_api/renderdoc/main_ifaces.rst index bf46dfb85..a99954270 100644 --- a/docs/python_api/renderdoc/main_ifaces.rst +++ b/docs/python_api/renderdoc/main_ifaces.rst @@ -46,3 +46,10 @@ CaptureFile .. autoclass:: renderdoc.CaptureFile :members: :undoc-members: + +GlobalEnvironment +----------------- + +.. autoclass:: renderdoc.GlobalEnvironment + :members: + :undoc-members: diff --git a/renderdoc/api/replay/control_types.h b/renderdoc/api/replay/control_types.h index 6b573a98e..3fa3301db 100644 --- a/renderdoc/api/replay/control_types.h +++ b/renderdoc/api/replay/control_types.h @@ -874,7 +874,8 @@ struct GlobalEnvironment Display *xlibDisplay = NULL; DOCUMENT( - "The handle to the X display to use internally. If left ``NULL``, wayland cannot be used."); + "The handle to the wayland display to use internally. If left ``NULL``, wayland cannot be " + "used."); wl_display *waylandDisplay = NULL; DOCUMENT(R"(Whether to enumerate available GPUs. If the replay program is only being used for