This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit b578433e37
7 changed files with 784842 additions and 0 deletions

View file

@ -0,0 +1,78 @@
namespace Brutal.RenderDocApi;
public static partial class RenderDoc
{
public static partial class CaptureOptions
{
public static bool AllowVSync
{
get => GetCaptureOptionBool(CaptureOption.AllowVSync);
set => SetCaptureOption(CaptureOption.AllowVSync, value);
}
public static bool AllowFullscreen
{
get => GetCaptureOptionBool(CaptureOption.AllowFullscreen);
set => SetCaptureOption(CaptureOption.AllowFullscreen, value);
}
public static bool APIValidation
{
get => GetCaptureOptionBool(CaptureOption.APIValidation);
set => SetCaptureOption(CaptureOption.APIValidation, value);
}
public static bool CaptureCallstacks
{
get => GetCaptureOptionBool(CaptureOption.CaptureCallstacks);
set => SetCaptureOption(CaptureOption.CaptureCallstacks, value);
}
public static bool CaptureCallstacksOnlyActions
{
get => GetCaptureOptionBool(CaptureOption.CaptureCallstacksOnlyActions);
set => SetCaptureOption(CaptureOption.CaptureCallstacksOnlyActions, value);
}
public static float DelayForDebugger
{
get => GetCaptureOptionF32(CaptureOption.DelayForDebugger);
set => SetCaptureOption(CaptureOption.DelayForDebugger, value);
}
public static bool VerifyBufferAccess
{
get => GetCaptureOptionBool(CaptureOption.VerifyBufferAccess);
set => SetCaptureOption(CaptureOption.VerifyBufferAccess, value);
}
public static bool HookIntoChildren
{
get => GetCaptureOptionBool(CaptureOption.HookIntoChildren);
set => SetCaptureOption(CaptureOption.HookIntoChildren, value);
}
public static bool RefAllResources
{
get => GetCaptureOptionBool(CaptureOption.RefAllResources);
set => SetCaptureOption(CaptureOption.RefAllResources, value);
}
public static bool SaveAllInitials
{
get => GetCaptureOptionBool(CaptureOption.SaveAllInitials);
set => SetCaptureOption(CaptureOption.SaveAllInitials, value);
}
public static bool CaptureAllCmdLists
{
get => GetCaptureOptionBool(CaptureOption.CaptureAllCmdLists);
set => SetCaptureOption(CaptureOption.CaptureAllCmdLists, value);
}
public static bool DebugOutputMute
{
get => GetCaptureOptionBool(CaptureOption.DebugOutputMute);
set => SetCaptureOption(CaptureOption.DebugOutputMute, value);
}
public static bool AllowUnsupportedVendorExtensions
{
get => GetCaptureOptionBool(CaptureOption.AllowUnsupportedVendorExtensions);
set => SetCaptureOption(CaptureOption.AllowUnsupportedVendorExtensions, value);
}
public static uint SoftMemoryLimit
{
get => GetCaptureOptionU32(CaptureOption.SoftMemoryLimit);
set => SetCaptureOption(CaptureOption.SoftMemoryLimit, value);
}
}
}

View file

@ -0,0 +1,50 @@
namespace Brutal.RenderDocApi;
/// RenderDoc uses semantic versioning (http://semver.org/).
/// MAJOR version is incremented when incompatible API changes happen.
/// MINOR version is incremented when functionality is added in a backwards-compatible manner.
/// PATCH version is incremented when backwards-compatible bug fixes happen.
/// Note that this means the API returned can be higher than the one you might have requested.
/// e.g. if you are running against a newer RenderDoc that supports 1.0.1, it will be returned
/// instead of 1.0.0. You can check this with the GetAPIVersion entry point
public enum ApiVersions : int
{
/// eRENDERDOC_API_Version_1_0_0
V1_0_0 = 10000,
/// eRENDERDOC_API_Version_1_0_1
V1_0_1 = 10001,
/// eRENDERDOC_API_Version_1_0_2
V1_0_2 = 10002,
/// eRENDERDOC_API_Version_1_1_0
V1_1_0 = 10100,
/// eRENDERDOC_API_Version_1_1_1
V1_1_1 = 10101,
/// eRENDERDOC_API_Version_1_1_2
V1_1_2 = 10102,
/// eRENDERDOC_API_Version_1_2_0
V1_2_0 = 10200,
/// eRENDERDOC_API_Version_1_3_0
V1_3_0 = 10300,
/// eRENDERDOC_API_Version_1_4_0
V1_4_0 = 10400,
/// eRENDERDOC_API_Version_1_4_1
V1_4_1 = 10401,
/// eRENDERDOC_API_Version_1_4_2
V1_4_2 = 10402,
/// eRENDERDOC_API_Version_1_5_0
V1_5_0 = 10500,
/// eRENDERDOC_API_Version_1_6_0
V1_6_0 = 10600,
}

View file

@ -0,0 +1,48 @@
namespace Brutal.RenderDocApi;
/// ///////////////////////////////////////////////////////////////////////////////////////////////
/// RenderDoc capture options
public enum CaptureOption : int
{
/// eRENDERDOC_Option_AllowVSync
AllowVSync = 0,
/// eRENDERDOC_Option_AllowFullscreen
AllowFullscreen = 1,
/// eRENDERDOC_Option_APIValidation
APIValidation = 2,
/// eRENDERDOC_Option_CaptureCallstacks
CaptureCallstacks = 3,
/// eRENDERDOC_Option_CaptureCallstacksOnlyActions
CaptureCallstacksOnlyActions = 4,
/// eRENDERDOC_Option_DelayForDebugger
DelayForDebugger = 5,
/// eRENDERDOC_Option_VerifyBufferAccess
VerifyBufferAccess = 6,
/// eRENDERDOC_Option_HookIntoChildren
HookIntoChildren = 7,
/// eRENDERDOC_Option_RefAllResources
RefAllResources = 8,
/// eRENDERDOC_Option_SaveAllInitials
SaveAllInitials = 9,
/// eRENDERDOC_Option_CaptureAllCmdLists
CaptureAllCmdLists = 10,
/// eRENDERDOC_Option_DebugOutputMute
DebugOutputMute = 11,
/// eRENDERDOC_Option_AllowUnsupportedVendorExtensions
AllowUnsupportedVendorExtensions = 12,
/// eRENDERDOC_Option_SoftMemoryLimit
SoftMemoryLimit = 13,
}

View file

@ -0,0 +1,197 @@
namespace Brutal.RenderDocApi;
///
public enum InputButton : int
{
/// eRENDERDOC_Key_0
Num0 = 0x30,
/// eRENDERDOC_Key_1
Num1 = 0x31,
/// eRENDERDOC_Key_2
Num2 = 0x32,
/// eRENDERDOC_Key_3
Num3 = 0x33,
/// eRENDERDOC_Key_4
Num4 = 0x34,
/// eRENDERDOC_Key_5
Num5 = 0x35,
/// eRENDERDOC_Key_6
Num6 = 0x36,
/// eRENDERDOC_Key_7
Num7 = 0x37,
/// eRENDERDOC_Key_8
Num8 = 0x38,
/// eRENDERDOC_Key_9
Num9 = 0x39,
/// eRENDERDOC_Key_A
A = 0x41,
/// eRENDERDOC_Key_B
B = 0x42,
/// eRENDERDOC_Key_C
C = 0x43,
/// eRENDERDOC_Key_D
D = 0x44,
/// eRENDERDOC_Key_E
E = 0x45,
/// eRENDERDOC_Key_F
F = 0x46,
/// eRENDERDOC_Key_G
G = 0x47,
/// eRENDERDOC_Key_H
H = 0x48,
/// eRENDERDOC_Key_I
I = 0x49,
/// eRENDERDOC_Key_J
J = 0x4A,
/// eRENDERDOC_Key_K
K = 0x4B,
/// eRENDERDOC_Key_L
L = 0x4C,
/// eRENDERDOC_Key_M
M = 0x4D,
/// eRENDERDOC_Key_N
N = 0x4E,
/// eRENDERDOC_Key_O
O = 0x4F,
/// eRENDERDOC_Key_P
P = 0x50,
/// eRENDERDOC_Key_Q
Q = 0x51,
/// eRENDERDOC_Key_R
R = 0x52,
/// eRENDERDOC_Key_S
S = 0x53,
/// eRENDERDOC_Key_T
T = 0x54,
/// eRENDERDOC_Key_U
U = 0x55,
/// eRENDERDOC_Key_V
V = 0x56,
/// eRENDERDOC_Key_W
W = 0x57,
/// eRENDERDOC_Key_X
X = 0x58,
/// eRENDERDOC_Key_Y
Y = 0x59,
/// eRENDERDOC_Key_Z
Z = 0x5A,
/// eRENDERDOC_Key_NonPrintable
NonPrintable = 0x100,
/// eRENDERDOC_Key_Divide
Divide,
/// eRENDERDOC_Key_Multiply
Multiply,
/// eRENDERDOC_Key_Subtract
Subtract,
/// eRENDERDOC_Key_Plus
Plus,
/// eRENDERDOC_Key_F1
F1,
/// eRENDERDOC_Key_F2
F2,
/// eRENDERDOC_Key_F3
F3,
/// eRENDERDOC_Key_F4
F4,
/// eRENDERDOC_Key_F5
F5,
/// eRENDERDOC_Key_F6
F6,
/// eRENDERDOC_Key_F7
F7,
/// eRENDERDOC_Key_F8
F8,
/// eRENDERDOC_Key_F9
F9,
/// eRENDERDOC_Key_F10
F10,
/// eRENDERDOC_Key_F11
F11,
/// eRENDERDOC_Key_F12
F12,
/// eRENDERDOC_Key_Home
Home,
/// eRENDERDOC_Key_End
End,
/// eRENDERDOC_Key_Insert
Insert,
/// eRENDERDOC_Key_Delete
Delete,
/// eRENDERDOC_Key_PageUp
PageUp,
/// eRENDERDOC_Key_PageDn
PageDn,
/// eRENDERDOC_Key_Backspace
Backspace,
/// eRENDERDOC_Key_Tab
Tab,
/// eRENDERDOC_Key_PrtScrn
PrtScrn,
/// eRENDERDOC_Key_Pause
Pause,
/// eRENDERDOC_Key_Max
Max,
}

View file

@ -0,0 +1,27 @@
namespace Brutal.RenderDocApi;
///
[Flags]
public enum OverlayBits : int
{
/// eRENDERDOC_Overlay_Enabled
Enabled = 0x1,
/// eRENDERDOC_Overlay_FrameRate
FrameRate = 0x2,
/// eRENDERDOC_Overlay_FrameNumber
FrameNumber = 0x4,
/// eRENDERDOC_Overlay_CaptureList
CaptureList = 0x8,
/// eRENDERDOC_Overlay_Default
Default = (Enabled | FrameRate | FrameNumber | CaptureList),
/// eRENDERDOC_Overlay_All
All = 0x7ffffff,
/// eRENDERDOC_Overlay_None
None = 0,
}

View file

@ -0,0 +1,147 @@
namespace Brutal.RenderDocApi;
public static unsafe partial class RenderDoc
{
[ApiVersion(1, 0)]
public static void GetApiVersion(out int major, out int minor, out int patch)
{
fixed (int* major_fixed = &major)
fixed (int* minor_fixed = &minor)
fixed (int* patch_fixed = &patch)
Api->GetAPIVersion(major_fixed, minor_fixed, patch_fixed);
}
[ApiVersion(1, 0)]
public static int SetCaptureOption(CaptureOption opt, uint val) => Api->SetCaptureOptionU32(opt, val);
[ApiVersion(1, 0)]
public static int SetCaptureOption(CaptureOption opt, float val) => Api->SetCaptureOptionF32(opt, val);
[ApiVersion(1, 0)]
public static uint GetCaptureOptionU32(CaptureOption opt) => Api->GetCaptureOptionU32(opt);
[ApiVersion(1, 0)]
public static float GetCaptureOptionF32(CaptureOption opt) => Api->GetCaptureOptionF32(opt);
[ApiVersion(1, 0)]
public static void SetFocusToggleKeys(ReadOnlySpan<InputButton> keys)
{
fixed (InputButton* keys_fixed = keys)
Api->SetFocusToggleKeys(keys_fixed, keys.Length);
}
[ApiVersion(1, 0)]
public static void SetCaptureKeys(ReadOnlySpan<InputButton> keys)
{
fixed (InputButton* keys_fixed = keys)
Api->SetCaptureKeys(keys_fixed, keys.Length);
}
[ApiVersion(1, 0)]
public static OverlayBits OverlayBits
{
get => Api->GetOverlayBits();
set => Api->MaskOverlayBits(0, value);
}
[ApiVersion(1, 0)]
public static void MaskOverlayBits(OverlayBits And, OverlayBits Or) => Api->MaskOverlayBits(And, Or);
[ApiVersion(1, 0)]
public static partial void RemoveHooks();
[ApiVersion(1, 0)]
public static void UnloadCrashHandler() => Api->UnloadCrashHandler();
[ApiVersion(1, 0)]
public static void SetCaptureFilePathTemplate(String8In pathtemplate)
{
fixed (byte* pathtemplate_fixed = pathtemplate)
Api->SetCaptureFilePathTemplate(pathtemplate_fixed);
}
[ApiVersion(1, 0)]
public static String8Return CaptureFilePathTemplate
{
get => Utf8.GetNullTerminatedSpan(Api->GetCaptureFilePathTemplate());
set => SetCaptureFilePathTemplate(value);
}
[ApiVersion(1, 0)]
public static uint NumCaptures => Api->GetNumCaptures();
[ApiVersion(1, 0)]
public static bool GetCapture(uint idx, String8Out filename, out uint pathlength, out ulong timestamp)
{
fixed (byte* filename_fixed = filename)
fixed (uint* pathlength_fixed = &pathlength)
fixed (ulong* timestamp_fixed = &timestamp)
return Api->GetCapture(idx, filename_fixed, pathlength_fixed, timestamp_fixed);
}
[ApiVersion(1, 0)]
public static void TriggerCapture() => Api->TriggerCapture();
[ApiVersion(1, 0)]
public static bool IsTargetControlConnected => Api->IsTargetControlConnected();
[ApiVersion(1, 0)]
public static bool LaunchReplayUI(bool connectTargetControl, String8In cmdline)
{
fixed (byte* cmdline_fixed = cmdline)
return Api->LaunchReplayUI(connectTargetControl, cmdline_fixed);
}
[ApiVersion(1, 0)]
public static void SetActiveWindow(DevicePointer device, WindowHandle wndHandle) =>
Api->SetActiveWindow(device, wndHandle);
[ApiVersion(1, 0)]
public static void StartFrameCapture(DevicePointer device, WindowHandle wndHandle) =>
Api->StartFrameCapture(device, wndHandle);
[ApiVersion(1, 0)]
public static bool IsFrameCapturing => Api->IsFrameCapturing();
[ApiVersion(1, 0)]
public static uint EndFrameCapture(DevicePointer device, WindowHandle wndHandle) =>
Api->EndFrameCapture(device, wndHandle);
[ApiVersion(1, 1)]
public static void TriggerMultiFrameCapture(uint numFrames)
{
EnsureApiVersion(1, 1);
Api->TriggerMultiFrameCapture(numFrames);
}
[ApiVersion(1, 2)]
public static void SetCaptureFileComments(String8In filePath, String8In comments)
{
EnsureApiVersion(1, 2);
fixed (byte* filePath_fixed = filePath)
fixed (byte* comments_fixed = comments)
Api->SetCaptureFileComments(filePath_fixed, comments_fixed);
}
[ApiVersion(1, 4)]
public static uint DiscardFrameCapture(DevicePointer device, WindowHandle wndHandle)
{
EnsureApiVersion(1, 4);
return Api->DiscardFrameCapture(device, wndHandle);
}
[ApiVersion(1, 5)]
public static bool ShowReplayUI()
{
EnsureApiVersion(1, 5);
return Api->ShowReplayUI();
}
[ApiVersion(1, 6)]
public static void SetCaptureTitle(String8In title)
{
EnsureApiVersion(1, 6);
fixed (byte* title_fixed = title)
Api->SetCaptureTitle(title_fixed);
}
}

View file

@ -0,0 +1,140 @@
namespace Brutal.RenderDocApi;
/// API version changelog:
/// 1.0.0 - initial release
/// 1.0.1 - Bugfix: IsFrameCapturing() was returning false for captures that were triggered
/// by keypress or TriggerCapture, instead of Start/EndFrameCapture.
/// 1.0.2 - Refactor: Renamed eRENDERDOC_Option_DebugDeviceMode to eRENDERDOC_Option_APIValidation
/// 1.1.0 - Add feature: TriggerMultiFrameCapture(). Backwards compatible with 1.0.x since the new
/// function pointer is added to the end of the struct, the original layout is identical
/// 1.1.1 - Refactor: Renamed remote access to target control (to better disambiguate from remote
/// replay/remote server concept in replay UI)
/// 1.1.2 - Refactor: Renamed &quot;log file&quot; in function names to just capture, to clarify that these
/// are captures and not debug logging files. This is the first API version in the v1.0
/// branch.
/// 1.2.0 - Added feature: SetCaptureFileComments() to add comments to a capture file that will be
/// displayed in the UI program on load.
/// 1.3.0 - Added feature: New capture option eRENDERDOC_Option_AllowUnsupportedVendorExtensions
/// which allows users to opt-in to allowing unsupported vendor extensions to function.
/// Should be used at the user&apos;s own risk.
/// Refactor: Renamed eRENDERDOC_Option_VerifyMapWrites to
/// eRENDERDOC_Option_VerifyBufferAccess, which now also controls initialisation to
/// 0xdddddddd of uninitialised buffer contents.
/// 1.4.0 - Added feature: DiscardFrameCapture() to discard a frame capture in progress and stop
/// capturing without saving anything to disk.
/// 1.4.1 - Refactor: Renamed Shutdown to RemoveHooks to better clarify what is happening
/// 1.4.2 - Refactor: Renamed &apos;draws&apos; to &apos;actions&apos; in callstack capture option.
/// 1.5.0 - Added feature: ShowReplayUI() to request that the replay UI show itself if connected
/// 1.6.0 - Added feature: SetCaptureTitle() which can be used to set a title for a
/// capture made with StartFrameCapture() or EndFrameCapture()
[StructLayout(LayoutKind.Explicit, Size = 216)]
public unsafe partial struct RenderDocApi()
{
///
[FieldOffset(0)]
public delegate* unmanaged[Cdecl]<int*, int*, int*, void> GetAPIVersion;
///
[FieldOffset(8)]
public delegate* unmanaged[Cdecl]<CaptureOption, uint, int> SetCaptureOptionU32;
///
[FieldOffset(16)]
public delegate* unmanaged[Cdecl]<CaptureOption, float, int> SetCaptureOptionF32;
///
[FieldOffset(24)]
public delegate* unmanaged[Cdecl]<CaptureOption, uint> GetCaptureOptionU32;
///
[FieldOffset(32)]
public delegate* unmanaged[Cdecl]<CaptureOption, float> GetCaptureOptionF32;
///
[FieldOffset(40)]
public delegate* unmanaged[Cdecl]<InputButton*, int, void> SetFocusToggleKeys;
///
[FieldOffset(48)]
public delegate* unmanaged[Cdecl]<InputButton*, int, void> SetCaptureKeys;
///
[FieldOffset(56)]
public delegate* unmanaged[Cdecl]<OverlayBits> GetOverlayBits;
///
[FieldOffset(64)]
public delegate* unmanaged[Cdecl]<OverlayBits, OverlayBits, void> MaskOverlayBits;
///
[FieldOffset(72)]
public delegate* unmanaged[Cdecl]<void> RemoveHooks;
///
[FieldOffset(80)]
public delegate* unmanaged[Cdecl]<void> UnloadCrashHandler;
/// current name
[FieldOffset(88)]
public delegate* unmanaged[Cdecl]<byte*, void> SetCaptureFilePathTemplate;
/// current name
[FieldOffset(96)]
public delegate* unmanaged[Cdecl]<byte*> GetCaptureFilePathTemplate;
///
[FieldOffset(104)]
public delegate* unmanaged[Cdecl]<uint> GetNumCaptures;
///
[FieldOffset(112)]
public delegate* unmanaged[Cdecl]<uint, byte*, uint*, ulong*, Bool32> GetCapture;
///
[FieldOffset(120)]
public delegate* unmanaged[Cdecl]<void> TriggerCapture;
/// current name
[FieldOffset(128)]
public delegate* unmanaged[Cdecl]<Bool32> IsTargetControlConnected;
///
[FieldOffset(136)]
public delegate* unmanaged[Cdecl]<Bool32, byte*, Bool32> LaunchReplayUI;
///
[FieldOffset(144)]
public delegate* unmanaged[Cdecl]<DevicePointer, WindowHandle, void> SetActiveWindow;
///
[FieldOffset(152)]
public delegate* unmanaged[Cdecl]<DevicePointer, WindowHandle, void> StartFrameCapture;
///
[FieldOffset(160)]
public delegate* unmanaged[Cdecl]<Bool32> IsFrameCapturing;
///
[FieldOffset(168)]
public delegate* unmanaged[Cdecl]<DevicePointer, WindowHandle, uint> EndFrameCapture;
/// new function in 1.1.0
[FieldOffset(176)]
public delegate* unmanaged[Cdecl]<uint, void> TriggerMultiFrameCapture;
/// new function in 1.2.0
[FieldOffset(184)]
public delegate* unmanaged[Cdecl]<byte*, byte*, void> SetCaptureFileComments;
/// new function in 1.4.0
[FieldOffset(192)]
public delegate* unmanaged[Cdecl]<DevicePointer, WindowHandle, uint> DiscardFrameCapture;
/// new function in 1.5.0
[FieldOffset(200)]
public delegate* unmanaged[Cdecl]<Bool32> ShowReplayUI;
/// new function in 1.6.0
[FieldOffset(208)]
public delegate* unmanaged[Cdecl]<byte*, void> SetCaptureTitle;
}