Hi unity_baldurk,
I imagine it would be quite useful for catching one-off bake processes and such.
Yes, this is exactly what I wanted it for in the Editor. That and being able to quickly & easily send off a shader under tightly controlled conditions for debugging purposes.
> Knowing that, there’s a workaround that doesn’t even need renderdoc modifications in this case - you should be able to just pass NULL for both device and window in start and end capture
Thanks for that! For anyone whos not aware, RenderDoc doesn’t export the StartFrameCapture and EndFrameCapture (even parametrised) directly, but its simple to get references to them via the GetAPI function that is exported… (I really like RenderDoc…):
[StructLayout(LayoutKind.Sequential)]
struct RENDERDOC_API_1_0_0
{
public IntPtr GetAPIVersion;
public IntPtr SetCaptureOptionU32;
public IntPtr SetCaptureOptionF32;
public IntPtr GetCaptureOptionU32;
public IntPtr GetCaptureOptionF32;
public IntPtr SetFocusToggleKeys;
public IntPtr SetCaptureKeys;
public IntPtr GetOverlayBits;
public IntPtr MaskOverlayBits;
public IntPtr Shutdown;
public IntPtr UnloadCrashHandler;
public IntPtr SetLogFilePathTemplate;
public IntPtr GetLogFilePathTemplate;
public IntPtr GetNumCaptures;
public IntPtr GetCapture;
public IntPtr TriggerCapture;
public IntPtr IsRemoteAccessConnected;
public IntPtr LaunchReplayUI;
public IntPtr SetActiveWindow;
public StartFrameCapture StartFrameCapture;
public IntPtr IsFrameCapturing;
public EndFrameCapture EndFrameCapture;
}
//typedef void (RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(RENDERDOC_DevicePointer device, RENDERDOC_WindowHandle wndHandle);
public delegate void StartFrameCapture(IntPtr device, IntPtr window);
//typedef uint32_t (RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(RENDERDOC_DevicePointer device, RENDERDOC_WindowHandle wndHandle);
public delegate int EndFrameCapture(IntPtr device, IntPtr window);
[DllImport(“renderdoc.dll”, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int RENDERDOC_GetAPI(int version, out IntPtr outAPIPointers);
private static int eRENDERDOC_API_Version_1_0_0 = 10000;
public static void StartCapture()
{
IntPtr pAPI = new IntPtr();
int ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_0_0, out pAPI);
RENDERDOC_API_1_0_0 api = (RENDERDOC_API_1_0_0)Marshal.PtrToStructure(pAPI, typeof(RENDERDOC_API_1_0_0));
api.StartFrameCapture(new IntPtr(), new IntPtr());
}
public static void EndCapture()
{
IntPtr pAPI = new IntPtr();
int ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_0_0, out pAPI);
RENDERDOC_API_1_0_0 api = (RENDERDOC_API_1_0_0)Marshal.PtrToStructure(pAPI, typeof(RENDERDOC_API_1_0_0));
api.EndFrameCapture(new IntPtr(), new IntPtr());
}
Now vanilla 0.26 can be used when starting the Editor directly, and the capturing works just as it did with the modified API.
> I made a similar-ish change upstream in renderdoc’s repository. StartCapture() will now set the captured window active, as a kind of insurance against any future problems to make sure that clicking ‘trigger capture’ from the renderdoc UI will at least be able to capture the correct window:
When StartFrameCapture() is called on API, also make that wnd active · baldurk/renderdoc@278a977 · GitHub. This isn’t quite the same as what you did, so I might add something to the API to allow for the precise behaviour you have just in case.
Awesome!
Thanks for all your assistance with this, it is great to have it working.