renderdoc_app.h 31 KB

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