mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-09 16:21:03 +00:00
Add callback hooks for dispatches, allows timing dispatch calls
This commit is contained in:
@@ -464,7 +464,7 @@ void WrappedVulkan::FlushQ()
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t WrappedVulkan::HandlePreDraw(VkCommandBuffer commandBuffer)
|
||||
uint32_t WrappedVulkan::HandlePreCallback(VkCommandBuffer commandBuffer, bool dispatch)
|
||||
{
|
||||
if(!m_DrawcallCallback) return 0;
|
||||
|
||||
@@ -485,7 +485,10 @@ uint32_t WrappedVulkan::HandlePreDraw(VkCommandBuffer commandBuffer)
|
||||
++it;
|
||||
}
|
||||
|
||||
m_DrawcallCallback->PreDraw(eventID, commandBuffer);
|
||||
if(dispatch)
|
||||
m_DrawcallCallback->PreDispatch(eventID, commandBuffer);
|
||||
else
|
||||
m_DrawcallCallback->PreDraw(eventID, commandBuffer);
|
||||
|
||||
return eventID;
|
||||
}
|
||||
|
||||
@@ -118,6 +118,11 @@ struct DrawcallCallback
|
||||
virtual void PreDraw(uint32_t eid, VkCommandBuffer cmd) = 0;
|
||||
virtual bool PostDraw(uint32_t eid, VkCommandBuffer cmd) = 0;
|
||||
virtual void PostRedraw(uint32_t eid, VkCommandBuffer cmd) = 0;
|
||||
|
||||
// same principle as above, but for dispatch calls
|
||||
virtual void PreDispatch(uint32_t eid, VkCommandBuffer cmd) = 0;
|
||||
virtual bool PostDispatch(uint32_t eid, VkCommandBuffer cmd) = 0;
|
||||
virtual void PostRedispatch(uint32_t eid, VkCommandBuffer cmd) = 0;
|
||||
|
||||
// should we re-record all command buffers? this needs to be true if the range
|
||||
// being replayed is larger than one command buffer (which usually means the
|
||||
@@ -186,8 +191,8 @@ private:
|
||||
DrawcallCallback *m_DrawcallCallback;
|
||||
|
||||
// util function to handle fetching the right eventID, calling any
|
||||
// aliases then calling PreDraw.
|
||||
uint32_t HandlePreDraw(VkCommandBuffer commandBuffer);
|
||||
// aliases then calling PreDraw/PreDispatch.
|
||||
uint32_t HandlePreCallback(VkCommandBuffer commandBuffer, bool dispatch = false);
|
||||
|
||||
uint32_t m_FrameCounter;
|
||||
|
||||
|
||||
@@ -97,6 +97,11 @@ struct GPUTimerCallback : public DrawcallCallback
|
||||
void PostRedraw(uint32_t eid, VkCommandBuffer cmd)
|
||||
{
|
||||
}
|
||||
|
||||
// we don't need to distinguish, call the Draw functions
|
||||
void PreDispatch(uint32_t eid, VkCommandBuffer cmd) { PreDraw(eid, cmd); }
|
||||
bool PostDispatch(uint32_t eid, VkCommandBuffer cmd) { return PostDraw(eid, cmd); }
|
||||
void PostRedispatch(uint32_t eid, VkCommandBuffer cmd) { PostRedraw(eid, cmd); }
|
||||
|
||||
bool RecordAllCmds()
|
||||
{
|
||||
|
||||
@@ -2701,6 +2701,11 @@ struct QuadOverdrawCallback : public DrawcallCallback
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// Dispatches don't rasterize, so do nothing
|
||||
void PreDispatch(uint32_t eid, VkCommandBuffer cmd) { }
|
||||
bool PostDispatch(uint32_t eid, VkCommandBuffer cmd) { return false; }
|
||||
void PostRedispatch(uint32_t eid, VkCommandBuffer cmd) { }
|
||||
|
||||
bool RecordAllCmds()
|
||||
{
|
||||
|
||||
@@ -4001,6 +4001,11 @@ struct InitPostVSCallback : public DrawcallCallback
|
||||
void PostRedraw(uint32_t eid, VkCommandBuffer cmd)
|
||||
{
|
||||
}
|
||||
|
||||
// Dispatches don't rasterize, so do nothing
|
||||
void PreDispatch(uint32_t eid, VkCommandBuffer cmd) { }
|
||||
bool PostDispatch(uint32_t eid, VkCommandBuffer cmd) { return false; }
|
||||
void PostRedispatch(uint32_t eid, VkCommandBuffer cmd) { }
|
||||
|
||||
bool RecordAllCmds()
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ bool WrappedVulkan::Serialise_vkCmdDraw(
|
||||
{
|
||||
commandBuffer = RerecordCmdBuf(cmdid);
|
||||
|
||||
uint32_t eventID = HandlePreDraw(commandBuffer);
|
||||
uint32_t eventID = HandlePreCallback(commandBuffer);
|
||||
|
||||
ObjDisp(commandBuffer)->CmdDraw(Unwrap(commandBuffer), vtxCount, instCount, firstVtx, firstInst);
|
||||
|
||||
@@ -1078,7 +1078,7 @@ bool WrappedVulkan::Serialise_vkCmdDrawIndexed(
|
||||
{
|
||||
commandBuffer = RerecordCmdBuf(cmdid);
|
||||
|
||||
uint32_t eventID = HandlePreDraw(commandBuffer);
|
||||
uint32_t eventID = HandlePreCallback(commandBuffer);
|
||||
|
||||
ObjDisp(commandBuffer)->CmdDrawIndexed(Unwrap(commandBuffer), idxCount, instCount, firstIdx, vtxOffs, firstInst);
|
||||
|
||||
@@ -1169,7 +1169,7 @@ bool WrappedVulkan::Serialise_vkCmdDrawIndirect(
|
||||
{
|
||||
commandBuffer = RerecordCmdBuf(cmdid);
|
||||
|
||||
uint32_t eventID = HandlePreDraw(commandBuffer);
|
||||
uint32_t eventID = HandlePreCallback(commandBuffer);
|
||||
|
||||
ObjDisp(commandBuffer)->CmdDrawIndirect(Unwrap(commandBuffer), Unwrap(buffer), offs, cnt, strd);
|
||||
|
||||
@@ -1281,7 +1281,7 @@ bool WrappedVulkan::Serialise_vkCmdDrawIndexedIndirect(
|
||||
{
|
||||
commandBuffer = RerecordCmdBuf(cmdid);
|
||||
|
||||
uint32_t eventID = HandlePreDraw(commandBuffer);
|
||||
uint32_t eventID = HandlePreCallback(commandBuffer);
|
||||
|
||||
ObjDisp(commandBuffer)->CmdDrawIndexedIndirect(Unwrap(commandBuffer), Unwrap(buffer), offs, cnt, strd);
|
||||
|
||||
@@ -1387,7 +1387,16 @@ bool WrappedVulkan::Serialise_vkCmdDispatch(
|
||||
if(ShouldRerecordCmd(cmdid) && InRerecordRange())
|
||||
{
|
||||
commandBuffer = RerecordCmdBuf(cmdid);
|
||||
|
||||
uint32_t eventID = HandlePreCallback(commandBuffer, true);
|
||||
|
||||
ObjDisp(commandBuffer)->CmdDispatch(Unwrap(commandBuffer), X, Y, Z);
|
||||
|
||||
if(eventID && m_DrawcallCallback->PostDispatch(eventID, commandBuffer))
|
||||
{
|
||||
ObjDisp(commandBuffer)->CmdDispatch(Unwrap(commandBuffer), X, Y, Z);
|
||||
m_DrawcallCallback->PostRedispatch(eventID, commandBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(m_State == READING)
|
||||
@@ -1461,7 +1470,16 @@ bool WrappedVulkan::Serialise_vkCmdDispatchIndirect(
|
||||
if(ShouldRerecordCmd(cmdid) && InRerecordRange())
|
||||
{
|
||||
commandBuffer = RerecordCmdBuf(cmdid);
|
||||
|
||||
uint32_t eventID = HandlePreCallback(commandBuffer, true);
|
||||
|
||||
ObjDisp(commandBuffer)->CmdDispatchIndirect(Unwrap(commandBuffer), Unwrap(buffer), offs);
|
||||
|
||||
if(eventID && m_DrawcallCallback->PostDispatch(eventID, commandBuffer))
|
||||
{
|
||||
ObjDisp(commandBuffer)->CmdDispatchIndirect(Unwrap(commandBuffer), Unwrap(buffer), offs);
|
||||
m_DrawcallCallback->PostRedispatch(eventID, commandBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(m_State == READING)
|
||||
|
||||
Reference in New Issue
Block a user