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