renderdoc_app.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /******************************************************************************
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2014 Crytek
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. ******************************************************************************/
  24. #pragma once
  25. #include <stdint.h>
  26. #ifdef WIN32
  27. #ifdef RENDERDOC_EXPORTS
  28. #define RENDERDOC_API __declspec(dllexport)
  29. #else
  30. #define RENDERDOC_API __declspec(dllimport)
  31. #endif
  32. #define RENDERDOC_CC __cdecl
  33. #elif defined(__linux__)
  34. #ifdef RENDERDOC_EXPORTS
  35. #define RENDERDOC_API __attribute__ ((visibility ("default")))
  36. #else
  37. #define RENDERDOC_API
  38. #endif
  39. #define RENDERDOC_CC
  40. #else
  41. #error "Unknown platform"
  42. #endif
  43. struct CaptureOptions
  44. {
  45. CaptureOptions()
  46. : AllowVSync(true),
  47. AllowFullscreen(true),
  48. DebugDeviceMode(false),
  49. CaptureCallstacks(false),
  50. CaptureCallstacksOnlyDraws(false),
  51. DelayForDebugger(0),
  52. VerifyMapWrites(false),
  53. HookIntoChildren(false),
  54. RefAllResources(false),
  55. SaveAllInitials(false),
  56. CaptureAllCmdLists(false)
  57. {}
  58. // Whether or not to allow the application to enable vsync
  59. //
  60. // 1 - allows the application to enable or disable vsync at will
  61. // 0 - vsync is force disabled
  62. uint32_t AllowVSync;
  63. // Whether or not to allow the application to enable fullscreen
  64. //
  65. // 1 - allows the application to enable or disable fullscreen at will
  66. // 0 - fullscreen is force disabled
  67. uint32_t AllowFullscreen;
  68. // 1 - in-built API debugging features and records the results into the
  69. // capture logfile, which is matched up with events on replay
  70. // 0 - no API debugging is enabled
  71. uint32_t DebugDeviceMode;
  72. // 1 - Captures callstacks for every API event during capture
  73. // 0 - no callstacks are captured
  74. uint32_t CaptureCallstacks;
  75. // 1 - Only captures callstacks for drawcall type API events.
  76. // Ignored if CaptureCallstacks is disabled
  77. // 0 - Callstacks, if enabled, are captured for every event.
  78. uint32_t CaptureCallstacksOnlyDraws;
  79. // Specify a delay in seconds to wait for a debugger to attach after
  80. // creating or injecting into a process, before continuing to allow it to run.
  81. // 0 indicates no delay, and the process will run immediately after injection
  82. uint32_t DelayForDebugger;
  83. // 1 - Verify any writes to mapped buffers, to check that they don't overwrite the
  84. // bounds of the pointer returned.
  85. // 0 - No verification is performed, and overwriting bounds may cause crashes or
  86. // corruption in RenderDoc
  87. uint32_t VerifyMapWrites;
  88. // 1 - Hooks any system API events that create child processes, and injects
  89. // renderdoc into them recursively with the same options.
  90. // 0 - Child processes are not hooked by RenderDoc
  91. uint32_t HookIntoChildren;
  92. // By default renderdoc only includes resources in the final logfile necessary
  93. // for that frame, this allows you to override that behaviour
  94. //
  95. // 1 - all live resources at the time of capture are included in the log
  96. // and available for inspection
  97. // 0 - only the resources referenced by the captured frame are included
  98. uint32_t RefAllResources;
  99. // By default renderdoc skips saving initial states for resources where the
  100. // previous contents don't appear to be used, assuming that writes before
  101. // reads indicate previous contents aren't used.
  102. //
  103. // 1 - initial contents at the start of each captured frame are saved, even if
  104. // they are later overwritten or cleared before being used.
  105. // 0 - unless a read is detected, initial contents will not be saved and will
  106. // appear as black or empty data.
  107. uint32_t SaveAllInitials;
  108. // In APIs that allow for the recording of command lists to be replayed later,
  109. // renderdoc may choose to not capture command lists before a frame capture is
  110. // triggered, to reduce overheads. This means any command lists recorded once
  111. // and replayed many times will not be available and may cause a failure to
  112. // capture.
  113. //
  114. // Note this is typically only true for APIs where multithreading is difficult
  115. // or discouraged. Newer APIs like Vulkan and D3D12 will ignore this option and
  116. // always capture all command lists since the API is heavily oriented around it,
  117. // and the overheads have been reduced by API design.
  118. //
  119. // 1 - All command lists are captured from the start of the application
  120. // 0 - Command lists are only captured if their recording begins during
  121. // the period when a frame capture is in progress.
  122. uint32_t CaptureAllCmdLists;
  123. };
  124. enum KeyButton
  125. {
  126. eKey_0 = 0x30, // '0'
  127. // ...
  128. eKey_9 = 0x39, // '9'
  129. eKey_A = 0x41, // 'A'
  130. // ...
  131. eKey_Z = 0x5A, // 'Z'
  132. eKey_Divide,
  133. eKey_Multiply,
  134. eKey_Subtract,
  135. eKey_Plus,
  136. eKey_F1,
  137. eKey_F2,
  138. eKey_F3,
  139. eKey_F4,
  140. eKey_F5,
  141. eKey_F6,
  142. eKey_F7,
  143. eKey_F8,
  144. eKey_F9,
  145. eKey_F10,
  146. eKey_F11,
  147. eKey_F12,
  148. eKey_Home,
  149. eKey_End,
  150. eKey_Insert,
  151. eKey_Delete,
  152. eKey_PageUp,
  153. eKey_PageDn,
  154. eKey_Backspace,
  155. eKey_Tab,
  156. eKey_PrtScrn,
  157. eKey_Pause,
  158. eKey_Max,
  159. };
  160. enum InAppOverlay
  161. {
  162. eOverlay_Enabled = 0x1,
  163. eOverlay_FrameRate = 0x2,
  164. eOverlay_FrameNumber = 0x4,
  165. eOverlay_CaptureList = 0x8,
  166. eOverlay_Default = (eOverlay_Enabled|eOverlay_FrameRate|eOverlay_FrameNumber|eOverlay_CaptureList),
  167. eOverlay_All = ~0U,
  168. eOverlay_None = 0,
  169. };
  170. ////////////////////////////////////////////////
  171. // !!!! IMPORTANT NOTE !!!! //
  172. // //
  173. // This API is pretty much experimental and //
  174. // still in flux. The only thing guaranteed //
  175. // to remain compatible is a call to //
  176. // RENDERDOC_GetAPIVersion which must exactly //
  177. // match the version you expect. //
  178. // It will be bumped on breaking changes. //
  179. ////////////////////////////////////////////////
  180. // API breaking change history:
  181. // Version 1 -> 2 - strings changed from wchar_t* to char* (UTF-8)
  182. // Version 2 -> 3 - StartFrameCapture, EndFrameCapture and SetActiveWindow take
  183. // 'device' pointer as well as window handles.
  184. // This is either ID3D11Device* or the GL context (HGLRC/GLXContext)
  185. // You can still pass NULL to both to capture the default, as long as
  186. // there's only one device/window pair alive.
  187. #define RENDERDOC_API_VERSION 3
  188. //////////////////////////////////////////////////////////////////////////
  189. // In-program functions
  190. //////////////////////////////////////////////////////////////////////////
  191. extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_GetAPIVersion();
  192. typedef int (RENDERDOC_CC *pRENDERDOC_GetAPIVersion)();
  193. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_Shutdown();
  194. typedef void (RENDERDOC_CC *pRENDERDOC_Shutdown)();
  195. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetLogFile(const char *logfile);
  196. typedef void (RENDERDOC_CC *pRENDERDOC_SetLogFile)(const char *logfile);
  197. extern "C" RENDERDOC_API const char* RENDERDOC_CC RENDERDOC_GetLogFile();
  198. typedef const char* (RENDERDOC_CC *pRENDERDOC_GetLogFile)();
  199. extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_GetNumCaptures();
  200. typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
  201. extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_GetCapture(uint32_t idx, char *logfile, uint32_t *pathlength, uint64_t *timestamp);
  202. typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, char *logfile, uint32_t *pathlength, uint64_t *timestamp);
  203. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetCaptureOptions(const CaptureOptions *opts);
  204. typedef void (RENDERDOC_CC *pRENDERDOC_SetCaptureOptions)(const CaptureOptions *opts);
  205. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_TriggerCapture();
  206. typedef void (RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
  207. // In the below functions 'device pointer' corresponds to the API specific handle, e.g.
  208. // ID3D11Device, or the GL context pointer.
  209. // The 'window handle' is the OS's native window handle (HWND or GLXDrawable).
  210. // This must match precisely to a pair, and it sets the RenderDoc in-app overlay to select that
  211. // window as 'active' and respond to keypresses.
  212. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetActiveWindow(void *device, void *wndHandle);
  213. typedef void (RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(void *device, void *wndHandle);
  214. // Either parameter can be NULL to wild-card match, such that you can capture from any
  215. // device to a particular window, or a particular device to any window.
  216. // In either case, if there are two or more possible matching (device,window) pairs it
  217. // is undefined which one will be captured.
  218. // You can pass (NULL, NULL) if you know you only have one device and one window, and
  219. // it will match. Likewise if you have not created a window at all (only off-screen
  220. // rendering), then NULL window pointer will capture, whether you pass a NULL device
  221. // or specify a device among multiple.
  222. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_StartFrameCapture(void *device, void *wndHandle);
  223. typedef void (RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(void *device, void *wndHandle);
  224. extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_EndFrameCapture(void *device, void *wndHandle);
  225. typedef uint32_t (RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(void *device, void *wndHandle);
  226. extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_GetOverlayBits();
  227. typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetOverlayBits)();
  228. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_MaskOverlayBits(uint32_t And, uint32_t Or);
  229. typedef void (RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or);
  230. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetFocusToggleKeys(KeyButton *keys, int num);
  231. typedef void (RENDERDOC_CC *pRENDERDOC_SetFocusToggleKeys)(KeyButton *keys, int num);
  232. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetCaptureKeys(KeyButton *keys, int num);
  233. typedef void (RENDERDOC_CC *pRENDERDOC_SetCaptureKeys)(KeyButton *keys, int num);
  234. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_InitRemoteAccess(uint32_t *ident);
  235. typedef void (RENDERDOC_CC *pRENDERDOC_InitRemoteAccess)(uint32_t *ident);
  236. extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_IsRemoteAccessConnected();
  237. typedef uint32_t (RENDERDOC_CC *pRENDERDOC_IsRemoteAccessConnected)();
  238. extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_LaunchReplayUI(uint32_t connectRemoteAccess, const char *cmdline);
  239. typedef uint32_t (RENDERDOC_CC *pRENDERDOC_LaunchReplayUI)(uint32_t connectRemoteAccess, const char *cmdline);
  240. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_UnloadCrashHandler();
  241. typedef void (RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)();