Add multiple-frame capture, grabbing N successive frames to captures

* In-application API is bumped to 1.1.0 as a new function pointer is
  added to the end of the structure.
* This comes with some caveats - capturing a frame is fairly heavy
  weight, so capturing a frame might throw off timing-related bugs you
  are trying to capture in subsequent frames. If you know your bug is
  every other frame though, capturing two can be a quick way to ensure
  you get it.
This commit is contained in:
baldurk
2016-07-18 18:51:36 +02:00
parent 1e10f34e1d
commit 5a64a78d2a
10 changed files with 115 additions and 46 deletions
+16 -7
View File
@@ -379,9 +379,6 @@ typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, char *logfile,
uint32_t *pathlength, uint64_t *timestamp);
// capture the next frame on whichever window and API is currently considered active
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
// returns 1 if the RenderDoc UI is connected to this application, 0 otherwise
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsRemoteAccessConnected)();
@@ -421,6 +418,12 @@ typedef void *RENDERDOC_WindowHandle;
typedef void(RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// capture the next frame on whichever window and API is currently considered active
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
// capture the next N frames on whichever window and API is currently considered active
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerMultiFrameCapture)(uint32_t numFrames);
// When choosing either a device pointer or a window handle to capture, you can pass NULL.
// Passing NULL specifies a 'wildcard' match against anything. This allows you to specify
// any API rendering to a specific window, or a specific API instance rendering to any window,
@@ -470,6 +473,7 @@ typedef enum {
eRENDERDOC_API_Version_1_0_0 = 10000, // RENDERDOC_API_1_0_0 = 1 00 00
eRENDERDOC_API_Version_1_0_1 = 10001, // RENDERDOC_API_1_0_1 = 1 00 01
eRENDERDOC_API_Version_1_0_2 = 10002, // RENDERDOC_API_1_0_2 = 1 00 02
eRENDERDOC_API_Version_1_1_0 = 10100, // RENDERDOC_API_1_1_0 = 1 01 00
} RENDERDOC_Version;
// API version changelog:
@@ -478,8 +482,10 @@ typedef enum {
// 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
// eRENDERDOC_API_Version_1_0_2
// eRENDERDOC_API_Version_1_1_0
typedef struct
{
pRENDERDOC_GetAPIVersion GetAPIVersion;
@@ -515,10 +521,13 @@ typedef struct
pRENDERDOC_StartFrameCapture StartFrameCapture;
pRENDERDOC_IsFrameCapturing IsFrameCapturing;
pRENDERDOC_EndFrameCapture EndFrameCapture;
} RENDERDOC_API_1_0_2;
typedef RENDERDOC_API_1_0_2 RENDERDOC_API_1_0_0;
typedef RENDERDOC_API_1_0_2 RENDERDOC_API_1_0_1;
pRENDERDOC_TriggerMultiFrameCapture TriggerMultiFrameCapture;
} RENDERDOC_API_1_1_0;
typedef RENDERDOC_API_1_1_0 RENDERDOC_API_1_0_0;
typedef RENDERDOC_API_1_1_0 RENDERDOC_API_1_0_1;
typedef RENDERDOC_API_1_1_0 RENDERDOC_API_1_0_2;
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc API entry point
+3 -2
View File
@@ -374,7 +374,7 @@ struct IRemoteAccess
virtual uint32_t GetPID() = 0;
virtual const char *GetBusyClient() = 0;
virtual void TriggerCapture() = 0;
virtual void TriggerCapture(uint32_t numFrames) = 0;
virtual void QueueCapture(uint32_t frameNumber) = 0;
virtual void CopyCapture(uint32_t remoteID, const char *localpath) = 0;
@@ -402,7 +402,8 @@ extern "C" RENDERDOC_API const char *RENDERDOC_CC RemoteAccess_GetAPI(RemoteAcce
extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RemoteAccess_GetPID(RemoteAccess *access);
extern "C" RENDERDOC_API const char *RENDERDOC_CC RemoteAccess_GetBusyClient(RemoteAccess *access);
extern "C" RENDERDOC_API void RENDERDOC_CC RemoteAccess_TriggerCapture(RemoteAccess *access);
extern "C" RENDERDOC_API void RENDERDOC_CC RemoteAccess_TriggerCapture(RemoteAccess *access,
uint32_t numFrames);
extern "C" RENDERDOC_API void RENDERDOC_CC RemoteAccess_QueueCapture(RemoteAccess *access,
uint32_t frameNumber);
extern "C" RENDERDOC_API void RENDERDOC_CC RemoteAccess_CopyCapture(RemoteAccess *access,
+6 -5
View File
@@ -168,7 +168,7 @@ RenderDoc::RenderDoc()
m_Replay = false;
m_Cap = false;
m_Cap = 0;
m_FocusKeys.clear();
m_FocusKeys.push_back(eRENDERDOC_Key_F11);
@@ -459,7 +459,7 @@ void RenderDoc::Tick()
if(!prev_focus && cur_focus)
{
m_Cap = false;
m_Cap = 0;
// can only shift focus if we have multiple windows
if(m_WindowFrameCapturers.size() > 1)
@@ -483,7 +483,7 @@ void RenderDoc::Tick()
}
if(!prev_cap && cur_cap)
{
TriggerCapture();
TriggerCapture(1);
}
prev_focus = cur_focus;
@@ -492,9 +492,10 @@ void RenderDoc::Tick()
bool RenderDoc::ShouldTriggerCapture(uint32_t frameNumber)
{
bool ret = m_Cap;
bool ret = m_Cap > 0;
m_Cap = false;
if(m_Cap > 0)
m_Cap--;
set<uint32_t> frames;
frames.swap(m_QueuedFrameCaptures);
+2 -2
View File
@@ -274,7 +274,7 @@ public:
return dev == m_ActiveWindow.dev && wnd == m_ActiveWindow.wnd;
}
void TriggerCapture() { m_Cap = true; }
void TriggerCapture(uint32_t numFrames) { m_Cap = numFrames; }
uint32_t GetOverlayBits() { return m_Overlay; }
void MaskOverlayBits(uint32_t And, uint32_t Or) { m_Overlay = (m_Overlay & And) | Or; }
void QueueCapture(uint32_t frameNumber) { m_QueuedFrameCaptures.insert(frameNumber); }
@@ -303,7 +303,7 @@ private:
bool m_Replay;
bool m_Cap;
uint32_t m_Cap;
vector<RENDERDOC_InputButton> m_FocusKeys;
vector<RENDERDOC_InputButton> m_CaptureKeys;
+16 -5
View File
@@ -165,7 +165,10 @@ void RenderDoc::RemoteAccessClientThread(void *s)
}
else if(type == ePacket_TriggerCapture)
{
RenderDoc::Inst().TriggerCapture();
uint32_t numFrames = 0;
recvser->Serialise("", numFrames);
RenderDoc::Inst().TriggerCapture(numFrames);
}
else if(type == ePacket_QueueCapture)
{
@@ -417,10 +420,17 @@ public:
const char *GetAPI() { return m_API.c_str(); }
uint32_t GetPID() { return m_PID; }
const char *GetBusyClient() { return m_BusyClient.c_str(); }
void TriggerCapture()
void TriggerCapture(uint32_t numFrames)
{
if(!SendPacket(m_Socket, ePacket_TriggerCapture))
Serialiser ser("", Serialiser::WRITING, false);
ser.Serialise("", numFrames);
if(!SendPacket(m_Socket, ePacket_TriggerCapture, ser))
{
SAFE_DELETE(m_Socket);
return;
}
}
void QueueCapture(uint32_t frameNumber)
@@ -635,9 +645,10 @@ extern "C" RENDERDOC_API const char *RENDERDOC_CC RemoteAccess_GetBusyClient(Rem
return access->GetBusyClient();
}
extern "C" RENDERDOC_API void RENDERDOC_CC RemoteAccess_TriggerCapture(RemoteAccess *access)
extern "C" RENDERDOC_API void RENDERDOC_CC RemoteAccess_TriggerCapture(RemoteAccess *access,
uint32_t numFrames)
{
access->TriggerCapture();
access->TriggerCapture(numFrames);
}
extern "C" RENDERDOC_API void RENDERDOC_CC RemoteAccess_QueueCapture(RemoteAccess *access,
uint32_t frameNumber)
+19 -11
View File
@@ -105,7 +105,12 @@ static uint32_t GetCapture(uint32_t idx, char *logfile, uint32_t *pathlength, ui
static void TriggerCapture()
{
RenderDoc::Inst().TriggerCapture();
RenderDoc::Inst().TriggerCapture(1);
}
static void TriggerMultiFrameCapture(uint32_t numFrames)
{
RenderDoc::Inst().TriggerCapture(numFrames);
}
static uint32_t IsRemoteAccessConnected()
@@ -160,22 +165,22 @@ int RENDERDOC_CC SetCaptureOptionF32(RENDERDOC_CaptureOption opt, float val);
uint32_t RENDERDOC_CC GetCaptureOptionU32(RENDERDOC_CaptureOption opt);
float RENDERDOC_CC GetCaptureOptionF32(RENDERDOC_CaptureOption opt);
void RENDERDOC_CC GetAPIVersion_1_0_2(int *major, int *minor, int *patch)
void RENDERDOC_CC GetAPIVersion_1_1_0(int *major, int *minor, int *patch)
{
if(major)
*major = 1;
if(minor)
*minor = 0;
*minor = 1;
if(patch)
*patch = 2;
*patch = 0;
}
RENDERDOC_API_1_0_2 api_1_0_2;
void Init_1_0_2()
RENDERDOC_API_1_1_0 api_1_1_0;
void Init_1_1_0()
{
RENDERDOC_API_1_0_2 &api = api_1_0_2;
RENDERDOC_API_1_1_0 &api = api_1_1_0;
api.GetAPIVersion = &GetAPIVersion_1_0_2;
api.GetAPIVersion = &GetAPIVersion_1_1_0;
api.SetCaptureOptionU32 = &SetCaptureOptionU32;
api.SetCaptureOptionF32 = &SetCaptureOptionF32;
@@ -208,6 +213,8 @@ void Init_1_0_2()
api.StartFrameCapture = &StartFrameCapture;
api.IsFrameCapturing = &IsFrameCapturing;
api.EndFrameCapture = &EndFrameCapture;
api.TriggerMultiFrameCapture = &TriggerMultiFrameCapture;
}
extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_GetAPI(RENDERDOC_Version version,
@@ -231,9 +238,10 @@ extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_GetAPI(RENDERDOC_Version ver
ret = 1; \
}
API_VERSION_HANDLE(1_0_0, 1_0_2);
API_VERSION_HANDLE(1_0_1, 1_0_2);
API_VERSION_HANDLE(1_0_2, 1_0_2);
API_VERSION_HANDLE(1_0_0, 1_1_0);
API_VERSION_HANDLE(1_0_1, 1_1_0);
API_VERSION_HANDLE(1_0_2, 1_1_0);
API_VERSION_HANDLE(1_1_0, 1_1_0);
#undef API_VERSION_HANDLE
+3 -3
View File
@@ -930,7 +930,7 @@ namespace renderdoc
private static extern IntPtr RemoteAccess_GetBusyClient(IntPtr real);
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern void RemoteAccess_TriggerCapture(IntPtr real);
private static extern void RemoteAccess_TriggerCapture(IntPtr real, UInt32 numFrames);
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern void RemoteAccess_QueueCapture(IntPtr real, UInt32 frameNumber);
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
@@ -994,9 +994,9 @@ namespace renderdoc
m_Real = IntPtr.Zero;
}
public void TriggerCapture()
public void TriggerCapture(UInt32 numFrames)
{
RemoteAccess_TriggerCapture(m_Real);
RemoteAccess_TriggerCapture(m_Real, numFrames);
}
public void QueueCapture(UInt32 frameNum)
+44 -10
View File
@@ -35,6 +35,7 @@
System.Windows.Forms.GroupBox groupBox1;
System.Windows.Forms.ToolStrip toolStrip1;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LiveCapture));
System.Windows.Forms.Label label4;
this.queueCap = new System.Windows.Forms.Button();
this.captureFrame = new System.Windows.Forms.NumericUpDown();
this.captureDelay = new System.Windows.Forms.NumericUpDown();
@@ -59,11 +60,13 @@
this.deleteThisCaptureToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.captureCountdown = new System.Windows.Forms.Timer(this.components);
this.childUpdateTimer = new System.Windows.Forms.Timer(this.components);
this.numFrames = new System.Windows.Forms.NumericUpDown();
label1 = new System.Windows.Forms.Label();
label2 = new System.Windows.Forms.Label();
label3 = new System.Windows.Forms.Label();
groupBox1 = new System.Windows.Forms.GroupBox();
toolStrip1 = new System.Windows.Forms.ToolStrip();
label4 = new System.Windows.Forms.Label();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.captureFrame)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.captureDelay)).BeginInit();
@@ -71,6 +74,7 @@
this.tableLayoutPanel1.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.rightclickContext.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numFrames)).BeginInit();
this.SuspendLayout();
//
// label1
@@ -106,6 +110,8 @@
groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
groupBox1.Controls.Add(this.numFrames);
groupBox1.Controls.Add(label4);
groupBox1.Controls.Add(this.queueCap);
groupBox1.Controls.Add(this.captureFrame);
groupBox1.Controls.Add(label3);
@@ -114,7 +120,7 @@
groupBox1.Controls.Add(this.triggerCapture);
groupBox1.Location = new System.Drawing.Point(3, 34);
groupBox1.Name = "groupBox1";
groupBox1.Size = new System.Drawing.Size(351, 75);
groupBox1.Size = new System.Drawing.Size(356, 75);
groupBox1.TabIndex = 7;
groupBox1.TabStop = false;
groupBox1.Text = "Tools";
@@ -156,12 +162,12 @@
//
this.captureDelay.Location = new System.Drawing.Point(96, 19);
this.captureDelay.Name = "captureDelay";
this.captureDelay.Size = new System.Drawing.Size(120, 20);
this.captureDelay.Size = new System.Drawing.Size(46, 20);
this.captureDelay.TabIndex = 1;
//
// triggerCapture
//
this.triggerCapture.Location = new System.Drawing.Point(222, 17);
this.triggerCapture.Location = new System.Drawing.Point(253, 16);
this.triggerCapture.Name = "triggerCapture";
this.triggerCapture.Size = new System.Drawing.Size(92, 23);
this.triggerCapture.TabIndex = 2;
@@ -181,7 +187,7 @@
toolStrip1.Location = new System.Drawing.Point(0, 375);
toolStrip1.Name = "toolStrip1";
toolStrip1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
toolStrip1.Size = new System.Drawing.Size(357, 25);
toolStrip1.Size = new System.Drawing.Size(362, 25);
toolStrip1.Stretch = true;
toolStrip1.TabIndex = 8;
toolStrip1.Text = "toolStrip1";
@@ -256,7 +262,7 @@
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(357, 400);
this.tableLayoutPanel1.Size = new System.Drawing.Size(362, 400);
this.tableLayoutPanel1.TabIndex = 0;
//
// captures
@@ -266,7 +272,7 @@
this.captures.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.captures.Location = new System.Drawing.Point(3, 221);
this.captures.Name = "captures";
this.captures.Size = new System.Drawing.Size(351, 151);
this.captures.Size = new System.Drawing.Size(356, 151);
this.captures.TabIndex = 6;
this.captures.TileSize = new System.Drawing.Size(300, 100);
this.captures.UseCompatibleStateImageBehavior = false;
@@ -283,7 +289,7 @@
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 3);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(351, 25);
this.flowLayoutPanel1.Size = new System.Drawing.Size(356, 25);
this.flowLayoutPanel1.TabIndex = 4;
this.flowLayoutPanel1.WrapContents = false;
//
@@ -321,9 +327,9 @@
this.childProcesses.Dock = System.Windows.Forms.DockStyle.Fill;
this.childProcesses.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.childProcesses.Location = new System.Drawing.Point(3, 143);
this.childProcesses.MinimumSize = new System.Drawing.Size(0, 40);
this.childProcesses.MinimumSize = new System.Drawing.Size(4, 40);
this.childProcesses.Name = "childProcesses";
this.childProcesses.Size = new System.Drawing.Size(351, 40);
this.childProcesses.Size = new System.Drawing.Size(356, 40);
this.childProcesses.TabIndex = 5;
this.childProcesses.UseCompatibleStateImageBehavior = false;
this.childProcesses.View = System.Windows.Forms.View.Tile;
@@ -385,11 +391,37 @@
this.childUpdateTimer.Enabled = true;
this.childUpdateTimer.Tick += new System.EventHandler(this.childUpdateTimer_Tick);
//
// label4
//
label4.AutoSize = true;
label4.Location = new System.Drawing.Point(148, 21);
label4.Name = "label4";
label4.Size = new System.Drawing.Size(54, 13);
label4.TabIndex = 5;
label4.Text = "# Frames:";
//
// numFrames
//
this.numFrames.Location = new System.Drawing.Point(208, 19);
this.numFrames.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numFrames.Name = "numFrames";
this.numFrames.Size = new System.Drawing.Size(39, 20);
this.numFrames.TabIndex = 6;
this.numFrames.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// LiveCapture
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(357, 400);
this.ClientSize = new System.Drawing.Size(362, 400);
this.Controls.Add(this.tableLayoutPanel1);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "LiveCapture";
@@ -408,6 +440,7 @@
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
this.rightclickContext.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numFrames)).EndInit();
this.ResumeLayout(false);
}
@@ -438,5 +471,6 @@
private System.Windows.Forms.ToolStripSplitButton openMenu;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem newInstanceToolStripMenuItem;
private System.Windows.Forms.NumericUpDown numFrames;
}
}
+3 -1
View File
@@ -54,6 +54,7 @@ namespace renderdocui.Windows
Thread m_ConnectThread = null;
bool m_TriggerCapture = false;
bool m_QueueCapture = false;
int m_CaptureNumFrames = 1;
int m_CaptureFrameNum = 0;
int m_CaptureCounter = 0;
bool m_Disconnect = false;
@@ -174,7 +175,7 @@ namespace renderdocui.Windows
if (m_TriggerCapture)
{
m_Connection.TriggerCapture();
m_Connection.TriggerCapture((uint)m_CaptureNumFrames);
m_TriggerCapture = false;
}
@@ -703,6 +704,7 @@ namespace renderdocui.Windows
private void triggerCapture_Click(object sender, EventArgs e)
{
m_CaptureNumFrames = (int)numFrames.Value;
if (captureDelay.Value == 0)
{
m_TriggerCapture = true;
@@ -129,6 +129,9 @@
<metadata name="groupBox1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label4.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="toolStrip1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>