renderdoc_app.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. /******************************************************************************
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2019-2025 Baldur Karlsson
  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. //////////////////////////////////////////////////////////////////////////////////////////////////
  26. //
  27. // Documentation for the API is available at https://renderdoc.org/docs/in_application_api.html
  28. //
  29. #if !defined(RENDERDOC_NO_STDINT)
  30. #include <stdint.h>
  31. #endif
  32. #if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
  33. #define RENDERDOC_CC __cdecl
  34. #elif defined(__linux__) || defined(__FreeBSD__)
  35. #define RENDERDOC_CC
  36. #elif defined(__APPLE__)
  37. #define RENDERDOC_CC
  38. #else
  39. #error "Unknown platform"
  40. #endif
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. //////////////////////////////////////////////////////////////////////////////////////////////////
  45. // Constants not used directly in below API
  46. // This is a GUID/magic value used for when applications pass a path where shader debug
  47. // information can be found to match up with a stripped shader.
  48. // the define can be used like so: const GUID RENDERDOC_ShaderDebugMagicValue =
  49. // RENDERDOC_ShaderDebugMagicValue_value
  50. #define RENDERDOC_ShaderDebugMagicValue_struct \
  51. { \
  52. 0xeab25520, 0x6670, 0x4865, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
  53. }
  54. // as an alternative when you want a byte array (assuming x86 endianness):
  55. #define RENDERDOC_ShaderDebugMagicValue_bytearray \
  56. { \
  57. 0x20, 0x55, 0xb2, 0xea, 0x70, 0x66, 0x65, 0x48, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
  58. }
  59. // truncated version when only a uint64_t is available (e.g. Vulkan tags):
  60. #define RENDERDOC_ShaderDebugMagicValue_truncated 0x48656670eab25520ULL
  61. //////////////////////////////////////////////////////////////////////////////////////////////////
  62. // RenderDoc capture options
  63. //
  64. typedef enum RENDERDOC_CaptureOption
  65. {
  66. // Allow the application to enable vsync
  67. //
  68. // Default - enabled
  69. //
  70. // 1 - The application can enable or disable vsync at will
  71. // 0 - vsync is force disabled
  72. eRENDERDOC_Option_AllowVSync = 0,
  73. // Allow the application to enable fullscreen
  74. //
  75. // Default - enabled
  76. //
  77. // 1 - The application can enable or disable fullscreen at will
  78. // 0 - fullscreen is force disabled
  79. eRENDERDOC_Option_AllowFullscreen = 1,
  80. // Record API debugging events and messages
  81. //
  82. // Default - disabled
  83. //
  84. // 1 - Enable built-in API debugging features and records the results into
  85. // the capture, which is matched up with events on replay
  86. // 0 - no API debugging is forcibly enabled
  87. eRENDERDOC_Option_APIValidation = 2,
  88. eRENDERDOC_Option_DebugDeviceMode = 2, // deprecated name of this enum
  89. // Capture CPU callstacks for API events
  90. //
  91. // Default - disabled
  92. //
  93. // 1 - Enables capturing of callstacks
  94. // 0 - no callstacks are captured
  95. eRENDERDOC_Option_CaptureCallstacks = 3,
  96. // When capturing CPU callstacks, only capture them from actions.
  97. // This option does nothing without the above option being enabled
  98. //
  99. // Default - disabled
  100. //
  101. // 1 - Only captures callstacks for actions.
  102. // Ignored if CaptureCallstacks is disabled
  103. // 0 - Callstacks, if enabled, are captured for every event.
  104. eRENDERDOC_Option_CaptureCallstacksOnlyDraws = 4,
  105. eRENDERDOC_Option_CaptureCallstacksOnlyActions = 4,
  106. // Specify a delay in seconds to wait for a debugger to attach, after
  107. // creating or injecting into a process, before continuing to allow it to run.
  108. //
  109. // 0 indicates no delay, and the process will run immediately after injection
  110. //
  111. // Default - 0 seconds
  112. //
  113. eRENDERDOC_Option_DelayForDebugger = 5,
  114. // Verify buffer access. This includes checking the memory returned by a Map() call to
  115. // detect any out-of-bounds modification, as well as initialising buffers with undefined contents
  116. // to a marker value to catch use of uninitialised memory.
  117. //
  118. // NOTE: This option is only valid for OpenGL and D3D11. Explicit APIs such as D3D12 and Vulkan do
  119. // not do the same kind of interception & checking and undefined contents are really undefined.
  120. //
  121. // Default - disabled
  122. //
  123. // 1 - Verify buffer access
  124. // 0 - No verification is performed, and overwriting bounds may cause crashes or corruption in
  125. // RenderDoc.
  126. eRENDERDOC_Option_VerifyBufferAccess = 6,
  127. // The old name for eRENDERDOC_Option_VerifyBufferAccess was eRENDERDOC_Option_VerifyMapWrites.
  128. // This option now controls the filling of uninitialised buffers with 0xdddddddd which was
  129. // previously always enabled
  130. eRENDERDOC_Option_VerifyMapWrites = eRENDERDOC_Option_VerifyBufferAccess,
  131. // Hooks any system API calls that create child processes, and injects
  132. // RenderDoc into them recursively with the same options.
  133. //
  134. // Default - disabled
  135. //
  136. // 1 - Hooks into spawned child processes
  137. // 0 - Child processes are not hooked by RenderDoc
  138. eRENDERDOC_Option_HookIntoChildren = 7,
  139. // By default RenderDoc only includes resources in the final capture necessary
  140. // for that frame, this allows you to override that behaviour.
  141. //
  142. // Default - disabled
  143. //
  144. // 1 - all live resources at the time of capture are included in the capture
  145. // and available for inspection
  146. // 0 - only the resources referenced by the captured frame are included
  147. eRENDERDOC_Option_RefAllResources = 8,
  148. // **NOTE**: As of RenderDoc v1.1 this option has been deprecated. Setting or
  149. // getting it will be ignored, to allow compatibility with older versions.
  150. // In v1.1 the option acts as if it's always enabled.
  151. //
  152. // By default RenderDoc skips saving initial states for resources where the
  153. // previous contents don't appear to be used, assuming that writes before
  154. // reads indicate previous contents aren't used.
  155. //
  156. // Default - disabled
  157. //
  158. // 1 - initial contents at the start of each captured frame are saved, even if
  159. // they are later overwritten or cleared before being used.
  160. // 0 - unless a read is detected, initial contents will not be saved and will
  161. // appear as black or empty data.
  162. eRENDERDOC_Option_SaveAllInitials = 9,
  163. // In APIs that allow for the recording of command lists to be replayed later,
  164. // RenderDoc may choose to not capture command lists before a frame capture is
  165. // triggered, to reduce overheads. This means any command lists recorded once
  166. // and replayed many times will not be available and may cause a failure to
  167. // capture.
  168. //
  169. // NOTE: This is only true for APIs where multithreading is difficult or
  170. // discouraged. Newer APIs like Vulkan and D3D12 will ignore this option
  171. // and always capture all command lists since the API is heavily oriented
  172. // around it and the overheads have been reduced by API design.
  173. //
  174. // 1 - All command lists are captured from the start of the application
  175. // 0 - Command lists are only captured if their recording begins during
  176. // the period when a frame capture is in progress.
  177. eRENDERDOC_Option_CaptureAllCmdLists = 10,
  178. // Mute API debugging output when the API validation mode option is enabled
  179. //
  180. // Default - enabled
  181. //
  182. // 1 - Mute any API debug messages from being displayed or passed through
  183. // 0 - API debugging is displayed as normal
  184. eRENDERDOC_Option_DebugOutputMute = 11,
  185. // Option to allow vendor extensions to be used even when they may be
  186. // incompatible with RenderDoc and cause corrupted replays or crashes.
  187. //
  188. // Default - inactive
  189. //
  190. // No values are documented, this option should only be used when absolutely
  191. // necessary as directed by a RenderDoc developer.
  192. eRENDERDOC_Option_AllowUnsupportedVendorExtensions = 12,
  193. // Define a soft memory limit which some APIs may aim to keep overhead under where
  194. // possible. Anything above this limit will where possible be saved directly to disk during
  195. // capture.
  196. // This will cause increased disk space use (which may cause a capture to fail if disk space is
  197. // exhausted) as well as slower capture times.
  198. //
  199. // Not all memory allocations may be deferred like this so it is not a guarantee of a memory
  200. // limit.
  201. //
  202. // Units are in MBs, suggested values would range from 200MB to 1000MB.
  203. //
  204. // Default - 0 Megabytes
  205. eRENDERDOC_Option_SoftMemoryLimit = 13,
  206. } RENDERDOC_CaptureOption;
  207. // Sets an option that controls how RenderDoc behaves on capture.
  208. //
  209. // Returns 1 if the option and value are valid
  210. // Returns 0 if either is invalid and the option is unchanged
  211. typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionU32)(RENDERDOC_CaptureOption opt, uint32_t val);
  212. typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionF32)(RENDERDOC_CaptureOption opt, float val);
  213. // Gets the current value of an option as a uint32_t
  214. //
  215. // If the option is invalid, 0xffffffff is returned
  216. typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionU32)(RENDERDOC_CaptureOption opt);
  217. // Gets the current value of an option as a float
  218. //
  219. // If the option is invalid, -FLT_MAX is returned
  220. typedef float(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionF32)(RENDERDOC_CaptureOption opt);
  221. typedef enum RENDERDOC_InputButton
  222. {
  223. // '0' - '9' matches ASCII values
  224. eRENDERDOC_Key_0 = 0x30,
  225. eRENDERDOC_Key_1 = 0x31,
  226. eRENDERDOC_Key_2 = 0x32,
  227. eRENDERDOC_Key_3 = 0x33,
  228. eRENDERDOC_Key_4 = 0x34,
  229. eRENDERDOC_Key_5 = 0x35,
  230. eRENDERDOC_Key_6 = 0x36,
  231. eRENDERDOC_Key_7 = 0x37,
  232. eRENDERDOC_Key_8 = 0x38,
  233. eRENDERDOC_Key_9 = 0x39,
  234. // 'A' - 'Z' matches ASCII values
  235. eRENDERDOC_Key_A = 0x41,
  236. eRENDERDOC_Key_B = 0x42,
  237. eRENDERDOC_Key_C = 0x43,
  238. eRENDERDOC_Key_D = 0x44,
  239. eRENDERDOC_Key_E = 0x45,
  240. eRENDERDOC_Key_F = 0x46,
  241. eRENDERDOC_Key_G = 0x47,
  242. eRENDERDOC_Key_H = 0x48,
  243. eRENDERDOC_Key_I = 0x49,
  244. eRENDERDOC_Key_J = 0x4A,
  245. eRENDERDOC_Key_K = 0x4B,
  246. eRENDERDOC_Key_L = 0x4C,
  247. eRENDERDOC_Key_M = 0x4D,
  248. eRENDERDOC_Key_N = 0x4E,
  249. eRENDERDOC_Key_O = 0x4F,
  250. eRENDERDOC_Key_P = 0x50,
  251. eRENDERDOC_Key_Q = 0x51,
  252. eRENDERDOC_Key_R = 0x52,
  253. eRENDERDOC_Key_S = 0x53,
  254. eRENDERDOC_Key_T = 0x54,
  255. eRENDERDOC_Key_U = 0x55,
  256. eRENDERDOC_Key_V = 0x56,
  257. eRENDERDOC_Key_W = 0x57,
  258. eRENDERDOC_Key_X = 0x58,
  259. eRENDERDOC_Key_Y = 0x59,
  260. eRENDERDOC_Key_Z = 0x5A,
  261. // leave the rest of the ASCII range free
  262. // in case we want to use it later
  263. eRENDERDOC_Key_NonPrintable = 0x100,
  264. eRENDERDOC_Key_Divide,
  265. eRENDERDOC_Key_Multiply,
  266. eRENDERDOC_Key_Subtract,
  267. eRENDERDOC_Key_Plus,
  268. eRENDERDOC_Key_F1,
  269. eRENDERDOC_Key_F2,
  270. eRENDERDOC_Key_F3,
  271. eRENDERDOC_Key_F4,
  272. eRENDERDOC_Key_F5,
  273. eRENDERDOC_Key_F6,
  274. eRENDERDOC_Key_F7,
  275. eRENDERDOC_Key_F8,
  276. eRENDERDOC_Key_F9,
  277. eRENDERDOC_Key_F10,
  278. eRENDERDOC_Key_F11,
  279. eRENDERDOC_Key_F12,
  280. eRENDERDOC_Key_Home,
  281. eRENDERDOC_Key_End,
  282. eRENDERDOC_Key_Insert,
  283. eRENDERDOC_Key_Delete,
  284. eRENDERDOC_Key_PageUp,
  285. eRENDERDOC_Key_PageDn,
  286. eRENDERDOC_Key_Backspace,
  287. eRENDERDOC_Key_Tab,
  288. eRENDERDOC_Key_PrtScrn,
  289. eRENDERDOC_Key_Pause,
  290. eRENDERDOC_Key_Max,
  291. } RENDERDOC_InputButton;
  292. // Sets which key or keys can be used to toggle focus between multiple windows
  293. //
  294. // If keys is NULL or num is 0, toggle keys will be disabled
  295. typedef void(RENDERDOC_CC *pRENDERDOC_SetFocusToggleKeys)(RENDERDOC_InputButton *keys, int num);
  296. // Sets which key or keys can be used to capture the next frame
  297. //
  298. // If keys is NULL or num is 0, captures keys will be disabled
  299. typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureKeys)(RENDERDOC_InputButton *keys, int num);
  300. typedef enum RENDERDOC_OverlayBits
  301. {
  302. // This single bit controls whether the overlay is enabled or disabled globally
  303. eRENDERDOC_Overlay_Enabled = 0x1,
  304. // Show the average framerate over several seconds as well as min/max
  305. eRENDERDOC_Overlay_FrameRate = 0x2,
  306. // Show the current frame number
  307. eRENDERDOC_Overlay_FrameNumber = 0x4,
  308. // Show a list of recent captures, and how many captures have been made
  309. eRENDERDOC_Overlay_CaptureList = 0x8,
  310. // Default values for the overlay mask
  311. eRENDERDOC_Overlay_Default = (eRENDERDOC_Overlay_Enabled | eRENDERDOC_Overlay_FrameRate |
  312. eRENDERDOC_Overlay_FrameNumber | eRENDERDOC_Overlay_CaptureList),
  313. // Enable all bits
  314. eRENDERDOC_Overlay_All = ~0U,
  315. // Disable all bits
  316. eRENDERDOC_Overlay_None = 0,
  317. } RENDERDOC_OverlayBits;
  318. // returns the overlay bits that have been set
  319. typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetOverlayBits)();
  320. // sets the overlay bits with an and & or mask
  321. typedef void(RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or);
  322. // this function will attempt to remove RenderDoc's hooks in the application.
  323. //
  324. // Note: that this can only work correctly if done immediately after
  325. // the module is loaded, before any API work happens. RenderDoc will remove its
  326. // injected hooks and shut down. Behaviour is undefined if this is called
  327. // after any API functions have been called, and there is still no guarantee of
  328. // success.
  329. typedef void(RENDERDOC_CC *pRENDERDOC_RemoveHooks)();
  330. // DEPRECATED: compatibility for code compiled against pre-1.4.1 headers.
  331. typedef pRENDERDOC_RemoveHooks pRENDERDOC_Shutdown;
  332. // This function will unload RenderDoc's crash handler.
  333. //
  334. // If you use your own crash handler and don't want RenderDoc's handler to
  335. // intercede, you can call this function to unload it and any unhandled
  336. // exceptions will pass to the next handler.
  337. typedef void(RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)();
  338. // Sets the capture file path template
  339. //
  340. // pathtemplate is a UTF-8 string that gives a template for how captures will be named
  341. // and where they will be saved.
  342. //
  343. // Any extension is stripped off the path, and captures are saved in the directory
  344. // specified, and named with the filename and the frame number appended. If the
  345. // directory does not exist it will be created, including any parent directories.
  346. //
  347. // If pathtemplate is NULL, the template will remain unchanged
  348. //
  349. // Example:
  350. //
  351. // SetCaptureFilePathTemplate("my_captures/example");
  352. //
  353. // Capture #1 -> my_captures/example_frame123.rdc
  354. // Capture #2 -> my_captures/example_frame456.rdc
  355. typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFilePathTemplate)(const char *pathtemplate);
  356. // returns the current capture path template, see SetCaptureFileTemplate above, as a UTF-8 string
  357. typedef const char *(RENDERDOC_CC *pRENDERDOC_GetCaptureFilePathTemplate)();
  358. // DEPRECATED: compatibility for code compiled against pre-1.1.2 headers.
  359. typedef pRENDERDOC_SetCaptureFilePathTemplate pRENDERDOC_SetLogFilePathTemplate;
  360. typedef pRENDERDOC_GetCaptureFilePathTemplate pRENDERDOC_GetLogFilePathTemplate;
  361. // returns the number of captures that have been made
  362. typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
  363. // This function returns the details of a capture, by index. New captures are added
  364. // to the end of the list.
  365. //
  366. // filename will be filled with the absolute path to the capture file, as a UTF-8 string
  367. // pathlength will be written with the length in bytes of the filename string
  368. // timestamp will be written with the time of the capture, in seconds since the Unix epoch
  369. //
  370. // Any of the parameters can be NULL and they'll be skipped.
  371. //
  372. // The function will return 1 if the capture index is valid, or 0 if the index is invalid
  373. // If the index is invalid, the values will be unchanged
  374. //
  375. // Note: when captures are deleted in the UI they will remain in this list, so the
  376. // capture path may not exist anymore.
  377. typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, char *filename,
  378. uint32_t *pathlength, uint64_t *timestamp);
  379. // Sets the comments associated with a capture file. These comments are displayed in the
  380. // UI program when opening.
  381. //
  382. // filePath should be a path to the capture file to add comments to. If set to NULL or ""
  383. // the most recent capture file created made will be used instead.
  384. // comments should be a NULL-terminated UTF-8 string to add as comments.
  385. //
  386. // Any existing comments will be overwritten.
  387. typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFileComments)(const char *filePath,
  388. const char *comments);
  389. // returns 1 if the RenderDoc UI is connected to this application, 0 otherwise
  390. typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsTargetControlConnected)();
  391. // DEPRECATED: compatibility for code compiled against pre-1.1.1 headers.
  392. // This was renamed to IsTargetControlConnected in API 1.1.1, the old typedef is kept here for
  393. // backwards compatibility with old code, it is castable either way since it's ABI compatible
  394. // as the same function pointer type.
  395. typedef pRENDERDOC_IsTargetControlConnected pRENDERDOC_IsRemoteAccessConnected;
  396. // This function will launch the Replay UI associated with the RenderDoc library injected
  397. // into the running application.
  398. //
  399. // if connectTargetControl is 1, the Replay UI will be launched with a command line parameter
  400. // to connect to this application
  401. // cmdline is the rest of the command line, as a UTF-8 string. E.g. a captures to open
  402. // if cmdline is NULL, the command line will be empty.
  403. //
  404. // returns the PID of the replay UI if successful, 0 if not successful.
  405. typedef uint32_t(RENDERDOC_CC *pRENDERDOC_LaunchReplayUI)(uint32_t connectTargetControl,
  406. const char *cmdline);
  407. // RenderDoc can return a higher version than requested if it's backwards compatible,
  408. // this function returns the actual version returned. If a parameter is NULL, it will be
  409. // ignored and the others will be filled out.
  410. typedef void(RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(int *major, int *minor, int *patch);
  411. // Requests that the replay UI show itself (if hidden or not the current top window). This can be
  412. // used in conjunction with IsTargetControlConnected and LaunchReplayUI to intelligently handle
  413. // showing the UI after making a capture.
  414. //
  415. // This will return 1 if the request was successfully passed on, though it's not guaranteed that
  416. // the UI will be on top in all cases depending on OS rules. It will return 0 if there is no current
  417. // target control connection to make such a request, or if there was another error
  418. typedef uint32_t(RENDERDOC_CC *pRENDERDOC_ShowReplayUI)();
  419. //////////////////////////////////////////////////////////////////////////
  420. // Capturing functions
  421. //
  422. // A device pointer is a pointer to the API's root handle.
  423. //
  424. // This would be an ID3D11Device, HGLRC/GLXContext, ID3D12Device, etc
  425. typedef void *RENDERDOC_DevicePointer;
  426. // A window handle is the OS's native window handle
  427. //
  428. // This would be an HWND, GLXDrawable, etc
  429. typedef void *RENDERDOC_WindowHandle;
  430. // A helper macro for Vulkan, where the device handle cannot be used directly.
  431. //
  432. // Passing the VkInstance to this macro will return the RENDERDOC_DevicePointer to use.
  433. //
  434. // Specifically, the value needed is the dispatch table pointer, which sits as the first
  435. // pointer-sized object in the memory pointed to by the VkInstance. Thus we cast to a void** and
  436. // indirect once.
  437. #define RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(inst) (*((void **)(inst)))
  438. // This sets the RenderDoc in-app overlay in the API/window pair as 'active' and it will
  439. // respond to keypresses. Neither parameter can be NULL
  440. typedef void(RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(RENDERDOC_DevicePointer device,
  441. RENDERDOC_WindowHandle wndHandle);
  442. // capture the next frame on whichever window and API is currently considered active
  443. typedef void(RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
  444. // capture the next N frames on whichever window and API is currently considered active
  445. typedef void(RENDERDOC_CC *pRENDERDOC_TriggerMultiFrameCapture)(uint32_t numFrames);
  446. // When choosing either a device pointer or a window handle to capture, you can pass NULL.
  447. // Passing NULL specifies a 'wildcard' match against anything. This allows you to specify
  448. // any API rendering to a specific window, or a specific API instance rendering to any window,
  449. // or in the simplest case of one window and one API, you can just pass NULL for both.
  450. //
  451. // In either case, if there are two or more possible matching (device,window) pairs it
  452. // is undefined which one will be captured.
  453. //
  454. // Note: for headless rendering you can pass NULL for the window handle and either specify
  455. // a device pointer or leave it NULL as above.
  456. // Immediately starts capturing API calls on the specified device pointer and window handle.
  457. //
  458. // If there is no matching thing to capture (e.g. no supported API has been initialised),
  459. // this will do nothing.
  460. //
  461. // The results are undefined (including crashes) if two captures are started overlapping,
  462. // even on separate devices and/oror windows.
  463. typedef void(RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(RENDERDOC_DevicePointer device,
  464. RENDERDOC_WindowHandle wndHandle);
  465. // Returns whether or not a frame capture is currently ongoing anywhere.
  466. //
  467. // This will return 1 if a capture is ongoing, and 0 if there is no capture running
  468. typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsFrameCapturing)();
  469. // Ends capturing immediately.
  470. //
  471. // This will return 1 if the capture succeeded, and 0 if there was an error capturing.
  472. typedef uint32_t(RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(RENDERDOC_DevicePointer device,
  473. RENDERDOC_WindowHandle wndHandle);
  474. // Ends capturing immediately and discard any data stored without saving to disk.
  475. //
  476. // This will return 1 if the capture was discarded, and 0 if there was an error or no capture
  477. // was in progress
  478. typedef uint32_t(RENDERDOC_CC *pRENDERDOC_DiscardFrameCapture)(RENDERDOC_DevicePointer device,
  479. RENDERDOC_WindowHandle wndHandle);
  480. // Only valid to be called between a call to StartFrameCapture and EndFrameCapture. Gives a custom
  481. // title to the capture produced which will be displayed in the UI.
  482. //
  483. // If multiple captures are ongoing, this title will be applied to the first capture to end after
  484. // this call. The second capture to end will have no title, unless this function is called again.
  485. //
  486. // Calling this function has no effect if no capture is currently running, and if it is called
  487. // multiple times only the last title will be used.
  488. typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureTitle)(const char *title);
  489. //////////////////////////////////////////////////////////////////////////////////////////////////
  490. // RenderDoc API versions
  491. //
  492. // RenderDoc uses semantic versioning (http://semver.org/).
  493. //
  494. // MAJOR version is incremented when incompatible API changes happen.
  495. // MINOR version is incremented when functionality is added in a backwards-compatible manner.
  496. // PATCH version is incremented when backwards-compatible bug fixes happen.
  497. //
  498. // Note that this means the API returned can be higher than the one you might have requested.
  499. // e.g. if you are running against a newer RenderDoc that supports 1.0.1, it will be returned
  500. // instead of 1.0.0. You can check this with the GetAPIVersion entry point
  501. typedef enum RENDERDOC_Version
  502. {
  503. eRENDERDOC_API_Version_1_0_0 = 10000, // RENDERDOC_API_1_0_0 = 1 00 00
  504. eRENDERDOC_API_Version_1_0_1 = 10001, // RENDERDOC_API_1_0_1 = 1 00 01
  505. eRENDERDOC_API_Version_1_0_2 = 10002, // RENDERDOC_API_1_0_2 = 1 00 02
  506. eRENDERDOC_API_Version_1_1_0 = 10100, // RENDERDOC_API_1_1_0 = 1 01 00
  507. eRENDERDOC_API_Version_1_1_1 = 10101, // RENDERDOC_API_1_1_1 = 1 01 01
  508. eRENDERDOC_API_Version_1_1_2 = 10102, // RENDERDOC_API_1_1_2 = 1 01 02
  509. eRENDERDOC_API_Version_1_2_0 = 10200, // RENDERDOC_API_1_2_0 = 1 02 00
  510. eRENDERDOC_API_Version_1_3_0 = 10300, // RENDERDOC_API_1_3_0 = 1 03 00
  511. eRENDERDOC_API_Version_1_4_0 = 10400, // RENDERDOC_API_1_4_0 = 1 04 00
  512. eRENDERDOC_API_Version_1_4_1 = 10401, // RENDERDOC_API_1_4_1 = 1 04 01
  513. eRENDERDOC_API_Version_1_4_2 = 10402, // RENDERDOC_API_1_4_2 = 1 04 02
  514. eRENDERDOC_API_Version_1_5_0 = 10500, // RENDERDOC_API_1_5_0 = 1 05 00
  515. eRENDERDOC_API_Version_1_6_0 = 10600, // RENDERDOC_API_1_6_0 = 1 06 00
  516. } RENDERDOC_Version;
  517. // API version changelog:
  518. //
  519. // 1.0.0 - initial release
  520. // 1.0.1 - Bugfix: IsFrameCapturing() was returning false for captures that were triggered
  521. // by keypress or TriggerCapture, instead of Start/EndFrameCapture.
  522. // 1.0.2 - Refactor: Renamed eRENDERDOC_Option_DebugDeviceMode to eRENDERDOC_Option_APIValidation
  523. // 1.1.0 - Add feature: TriggerMultiFrameCapture(). Backwards compatible with 1.0.x since the new
  524. // function pointer is added to the end of the struct, the original layout is identical
  525. // 1.1.1 - Refactor: Renamed remote access to target control (to better disambiguate from remote
  526. // replay/remote server concept in replay UI)
  527. // 1.1.2 - Refactor: Renamed "log file" in function names to just capture, to clarify that these
  528. // are captures and not debug logging files. This is the first API version in the v1.0
  529. // branch.
  530. // 1.2.0 - Added feature: SetCaptureFileComments() to add comments to a capture file that will be
  531. // displayed in the UI program on load.
  532. // 1.3.0 - Added feature: New capture option eRENDERDOC_Option_AllowUnsupportedVendorExtensions
  533. // which allows users to opt-in to allowing unsupported vendor extensions to function.
  534. // Should be used at the user's own risk.
  535. // Refactor: Renamed eRENDERDOC_Option_VerifyMapWrites to
  536. // eRENDERDOC_Option_VerifyBufferAccess, which now also controls initialisation to
  537. // 0xdddddddd of uninitialised buffer contents.
  538. // 1.4.0 - Added feature: DiscardFrameCapture() to discard a frame capture in progress and stop
  539. // capturing without saving anything to disk.
  540. // 1.4.1 - Refactor: Renamed Shutdown to RemoveHooks to better clarify what is happening
  541. // 1.4.2 - Refactor: Renamed 'draws' to 'actions' in callstack capture option.
  542. // 1.5.0 - Added feature: ShowReplayUI() to request that the replay UI show itself if connected
  543. // 1.6.0 - Added feature: SetCaptureTitle() which can be used to set a title for a
  544. // capture made with StartFrameCapture() or EndFrameCapture()
  545. typedef struct RENDERDOC_API_1_6_0
  546. {
  547. pRENDERDOC_GetAPIVersion GetAPIVersion;
  548. pRENDERDOC_SetCaptureOptionU32 SetCaptureOptionU32;
  549. pRENDERDOC_SetCaptureOptionF32 SetCaptureOptionF32;
  550. pRENDERDOC_GetCaptureOptionU32 GetCaptureOptionU32;
  551. pRENDERDOC_GetCaptureOptionF32 GetCaptureOptionF32;
  552. pRENDERDOC_SetFocusToggleKeys SetFocusToggleKeys;
  553. pRENDERDOC_SetCaptureKeys SetCaptureKeys;
  554. pRENDERDOC_GetOverlayBits GetOverlayBits;
  555. pRENDERDOC_MaskOverlayBits MaskOverlayBits;
  556. // Shutdown was renamed to RemoveHooks in 1.4.1.
  557. // These unions allow old code to continue compiling without changes
  558. union
  559. {
  560. pRENDERDOC_Shutdown Shutdown;
  561. pRENDERDOC_RemoveHooks RemoveHooks;
  562. };
  563. pRENDERDOC_UnloadCrashHandler UnloadCrashHandler;
  564. // Get/SetLogFilePathTemplate was renamed to Get/SetCaptureFilePathTemplate in 1.1.2.
  565. // These unions allow old code to continue compiling without changes
  566. union
  567. {
  568. // deprecated name
  569. pRENDERDOC_SetLogFilePathTemplate SetLogFilePathTemplate;
  570. // current name
  571. pRENDERDOC_SetCaptureFilePathTemplate SetCaptureFilePathTemplate;
  572. };
  573. union
  574. {
  575. // deprecated name
  576. pRENDERDOC_GetLogFilePathTemplate GetLogFilePathTemplate;
  577. // current name
  578. pRENDERDOC_GetCaptureFilePathTemplate GetCaptureFilePathTemplate;
  579. };
  580. pRENDERDOC_GetNumCaptures GetNumCaptures;
  581. pRENDERDOC_GetCapture GetCapture;
  582. pRENDERDOC_TriggerCapture TriggerCapture;
  583. // IsRemoteAccessConnected was renamed to IsTargetControlConnected in 1.1.1.
  584. // This union allows old code to continue compiling without changes
  585. union
  586. {
  587. // deprecated name
  588. pRENDERDOC_IsRemoteAccessConnected IsRemoteAccessConnected;
  589. // current name
  590. pRENDERDOC_IsTargetControlConnected IsTargetControlConnected;
  591. };
  592. pRENDERDOC_LaunchReplayUI LaunchReplayUI;
  593. pRENDERDOC_SetActiveWindow SetActiveWindow;
  594. pRENDERDOC_StartFrameCapture StartFrameCapture;
  595. pRENDERDOC_IsFrameCapturing IsFrameCapturing;
  596. pRENDERDOC_EndFrameCapture EndFrameCapture;
  597. // new function in 1.1.0
  598. pRENDERDOC_TriggerMultiFrameCapture TriggerMultiFrameCapture;
  599. // new function in 1.2.0
  600. pRENDERDOC_SetCaptureFileComments SetCaptureFileComments;
  601. // new function in 1.4.0
  602. pRENDERDOC_DiscardFrameCapture DiscardFrameCapture;
  603. // new function in 1.5.0
  604. pRENDERDOC_ShowReplayUI ShowReplayUI;
  605. // new function in 1.6.0
  606. pRENDERDOC_SetCaptureTitle SetCaptureTitle;
  607. } RENDERDOC_API_1_6_0;
  608. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_0_0;
  609. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_0_1;
  610. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_0_2;
  611. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_1_0;
  612. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_1_1;
  613. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_1_2;
  614. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_2_0;
  615. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_3_0;
  616. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_4_0;
  617. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_4_1;
  618. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_4_2;
  619. typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_5_0;
  620. //////////////////////////////////////////////////////////////////////////////////////////////////
  621. // RenderDoc API entry point
  622. //
  623. // This entry point can be obtained via GetProcAddress/dlsym if RenderDoc is available.
  624. //
  625. // The name is the same as the typedef - "RENDERDOC_GetAPI"
  626. //
  627. // This function is not thread safe, and should not be called on multiple threads at once.
  628. // Ideally, call this once as early as possible in your application's startup, before doing
  629. // any API work, since some configuration functionality etc has to be done also before
  630. // initialising any APIs.
  631. //
  632. // Parameters:
  633. // version is a single value from the RENDERDOC_Version above.
  634. //
  635. // outAPIPointers will be filled out with a pointer to the corresponding struct of function
  636. // pointers.
  637. //
  638. // Returns:
  639. // 1 - if the outAPIPointers has been filled with a pointer to the API struct requested
  640. // 0 - if the requested version is not supported or the arguments are invalid.
  641. //
  642. typedef int(RENDERDOC_CC *pRENDERDOC_GetAPI)(RENDERDOC_Version version, void **outAPIPointers);
  643. #ifdef __cplusplus
  644. } // extern "C"
  645. #endif