renderdoc_app.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /******************************************************************************
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2014 Crytek
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. ******************************************************************************/
  24. #pragma once
  25. #include <stdint.h>
  26. #ifdef WIN32
  27. #ifdef RENDERDOC_EXPORTS
  28. #define RENDERDOC_API __declspec(dllexport)
  29. #else
  30. #define RENDERDOC_API __declspec(dllimport)
  31. #endif
  32. #define RENDERDOC_CC __cdecl
  33. #elif defined(LINUX)
  34. #ifdef RENDERDOC_EXPORTS
  35. #define RENDERDOC_API __attribute__ ((visibility ("default")))
  36. #else
  37. #define RENDERDOC_API
  38. #endif
  39. #define RENDERDOC_CC
  40. #else
  41. #error "Unknown platform"
  42. #endif
  43. struct CaptureOptions
  44. {
  45. CaptureOptions()
  46. : AllowVSync(true),
  47. AllowFullscreen(true),
  48. DebugDeviceMode(false),
  49. CaptureCallstacks(false),
  50. CaptureCallstacksOnlyDraws(false),
  51. DelayForDebugger(0),
  52. CacheStateObjects(false),
  53. HookIntoChildren(false),
  54. RefAllResources(false),
  55. SaveAllInitials(false),
  56. CaptureAllCmdLists(false)
  57. {}
  58. // Whether or not to allow the application to enable vsync
  59. //
  60. // Enabled - allows the application to enable or disable vsync at will
  61. // Disabled - vsync is force disabled
  62. uint32_t AllowVSync;
  63. // Whether or not to allow the application to enable fullscreen
  64. //
  65. // Enabled - allows the application to enable or disable fullscreen at will
  66. // Disabled - fullscreen is force disabled
  67. uint32_t AllowFullscreen;
  68. // Enables in-built API debugging features and records the results into the
  69. // capture logfile, which is matched up with events on replay
  70. uint32_t DebugDeviceMode;
  71. // Captures callstacks for every API event during capture
  72. uint32_t CaptureCallstacks;
  73. // Only captures callstacks for drawcall type API events.
  74. // Ignored if CaptureCallstacks is disabled
  75. uint32_t CaptureCallstacksOnlyDraws;
  76. // Specify a delay in seconds to wait for a debugger to attach after
  77. // creating or injecting into a process, before continuing to allow it to run.
  78. uint32_t DelayForDebugger;
  79. // Deprecated, ignored.
  80. uint32_t CacheStateObjects;
  81. // Hooks any system API events that create child processes, and injects
  82. // renderdoc into them recursively with the same options.
  83. uint32_t HookIntoChildren;
  84. // By default renderdoc only includes resources in the final logfile necessary
  85. // for that frame, this allows you to override that behaviour
  86. //
  87. // Enabled - all live resources at the time of capture are included in the log
  88. // and available for inspection
  89. // Disabled - only the resources referenced by the captured frame are included
  90. uint32_t RefAllResources;
  91. // By default renderdoc skips saving initial states for
  92. uint32_t SaveAllInitials;
  93. // In APIs that allow for the recording of command lists to be replayed later,
  94. // renderdoc may choose to not capture command lists before a frame capture is
  95. // triggered, to reduce overheads. This means any command lists recorded once
  96. // and replayed many times will not be available and may cause a failure to
  97. // capture.
  98. //
  99. // Enabled - All command lists are captured from the start of the application
  100. // Disabled - Command lists are only captured if their recording begins during
  101. // the period when a frame capture is in progress.
  102. uint32_t CaptureAllCmdLists;
  103. };
  104. enum KeyButton
  105. {
  106. eKey_0 = 0x30, // '0'
  107. // ...
  108. eKey_9 = 0x39, // '9'
  109. eKey_A = 0x41, // 'A'
  110. // ...
  111. eKey_Z = 0x5A, // 'Z'
  112. eKey_Divide,
  113. eKey_Multiply,
  114. eKey_Subtract,
  115. eKey_Plus,
  116. eKey_F1,
  117. eKey_F2,
  118. eKey_F3,
  119. eKey_F4,
  120. eKey_F5,
  121. eKey_F6,
  122. eKey_F7,
  123. eKey_F8,
  124. eKey_F9,
  125. eKey_F10,
  126. eKey_F11,
  127. eKey_F12,
  128. eKey_Home,
  129. eKey_End,
  130. eKey_Insert,
  131. eKey_Delete,
  132. eKey_PageUp,
  133. eKey_PageDn,
  134. eKey_Backspace,
  135. eKey_Tab,
  136. eKey_PrtScrn,
  137. eKey_Pause,
  138. eKey_Max,
  139. };
  140. enum InAppOverlay
  141. {
  142. eOverlay_Enabled = 0x1,
  143. eOverlay_FrameRate = 0x2,
  144. eOverlay_FrameNumber = 0x4,
  145. eOverlay_CaptureList = 0x8,
  146. eOverlay_Default = (eOverlay_Enabled|eOverlay_FrameRate|eOverlay_FrameNumber|eOverlay_CaptureList),
  147. eOverlay_All = INT32_MAX,
  148. eOverlay_None = 0,
  149. };
  150. #define RENDERDOC_API_VERSION 1
  151. //////////////////////////////////////////////////////////////////////////
  152. // In-program functions
  153. //////////////////////////////////////////////////////////////////////////
  154. extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_GetAPIVersion();
  155. typedef int (RENDERDOC_CC *pRENDERDOC_GetAPIVersion)();
  156. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetLogFile(const wchar_t *logfile);
  157. typedef void (RENDERDOC_CC *pRENDERDOC_SetLogFile)(const wchar_t *logfile);
  158. extern "C" RENDERDOC_API const wchar_t* RENDERDOC_CC RENDERDOC_GetLogFile();
  159. typedef const wchar_t* (RENDERDOC_CC *pRENDERDOC_GetLogFile)();
  160. extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_GetCapture(uint32_t idx, wchar_t *logfile, uint32_t *pathlength, uint64_t *timestamp);
  161. typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, wchar_t *logfile, uint32_t *pathlength, uint64_t *timestamp);
  162. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetCaptureOptions(const CaptureOptions *opts);
  163. typedef void (RENDERDOC_CC *pRENDERDOC_SetCaptureOptions)(const CaptureOptions *opts);
  164. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetActiveWindow(void *wndHandle);
  165. typedef void (RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(void *wndHandle);
  166. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_TriggerCapture();
  167. typedef void (RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
  168. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_StartFrameCapture(void *wndHandle);
  169. typedef void (RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(void *wndHandle);
  170. extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_EndFrameCapture(void *wndHandle);
  171. typedef uint32_t (RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(void *wndHandle);
  172. extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_GetOverlayBits();
  173. typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetOverlayBits)();
  174. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_MaskOverlayBits(uint32_t And, uint32_t Or);
  175. typedef void (RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or);
  176. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetFocusToggleKeys(KeyButton *keys, int num);
  177. typedef void (RENDERDOC_CC *pRENDERDOC_SetFocusToggleKeys)(KeyButton *keys, int num);
  178. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetCaptureKeys(KeyButton *keys, int num);
  179. typedef void (RENDERDOC_CC *pRENDERDOC_SetCaptureKeys)(KeyButton *keys, int num);
  180. extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_InitRemoteAccess(uint32_t *ident);
  181. typedef void (RENDERDOC_CC *pRENDERDOC_InitRemoteAccess)(uint32_t *ident);
  182. //////////////////////////////////////////////////////////////////////////
  183. // Injection/execution capture functions.
  184. //////////////////////////////////////////////////////////////////////////
  185. extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_ExecuteAndInject(const wchar_t *app, const wchar_t *workingDir, const wchar_t *cmdLine,
  186. const wchar_t *logfile, const CaptureOptions *opts, uint32_t waitForExit);
  187. typedef uint32_t (RENDERDOC_CC *pRENDERDOC_ExecuteAndInject)(const wchar_t *app, const wchar_t *workingDir, const wchar_t *cmdLine,
  188. const wchar_t *logfile, const CaptureOptions *opts, uint32_t waitForExit);
  189. extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_InjectIntoProcess(uint32_t pid, const wchar_t *logfile, const CaptureOptions *opts, uint32_t waitForExit);
  190. typedef uint32_t (RENDERDOC_CC *pRENDERDOC_InjectIntoProcess)(uint32_t pid, const wchar_t *logfile, const CaptureOptions *opts, uint32_t waitForExit);