Handle push/pop markers when inserting via queuesubmit

* This allows push/pop regions to cross command buffers, as long as they
  are submitted in the right order etc.
This commit is contained in:
baldurk
2016-02-07 18:50:14 +01:00
parent 69409f9ea4
commit 2107b2fe55
6 changed files with 74 additions and 60 deletions
+21 -20
View File
@@ -399,28 +399,29 @@ enum ResourceUsage
enum DrawcallFlags
{
// types
eDraw_Clear = 0x01,
eDraw_Drawcall = 0x02,
eDraw_Dispatch = 0x04,
eDraw_CmdList = 0x08,
eDraw_SetMarker = 0x10,
eDraw_PushMarker = 0x20,
eDraw_Present = 0x40,
eDraw_MultiDraw = 0x80,
eDraw_Copy = 0x100,
eDraw_Resolve = 0x200,
eDraw_GenMips = 0x400,
eDraw_PassBoundary = 0x800,
eDraw_Clear = 0x0001,
eDraw_Drawcall = 0x0002,
eDraw_Dispatch = 0x0004,
eDraw_CmdList = 0x0008,
eDraw_SetMarker = 0x0010,
eDraw_PushMarker = 0x0020,
eDraw_PopMarker = 0x0040, // this is only for internal tracking use
eDraw_Present = 0x0080,
eDraw_MultiDraw = 0x0100,
eDraw_Copy = 0x0200,
eDraw_Resolve = 0x0400,
eDraw_GenMips = 0x0800,
eDraw_PassBoundary = 0x1000,
// flags
eDraw_UseIBuffer = 0x01000,
eDraw_Instanced = 0x02000,
eDraw_Auto = 0x04000,
eDraw_Indirect = 0x08000,
eDraw_ClearColour = 0x10000,
eDraw_ClearDepthStencil = 0x20000,
eDraw_BeginPass = 0x40000,
eDraw_EndPass = 0x80000,
eDraw_UseIBuffer = 0x010000,
eDraw_Instanced = 0x020000,
eDraw_Auto = 0x040000,
eDraw_Indirect = 0x080000,
eDraw_ClearColour = 0x100000,
eDraw_ClearDepthStencil = 0x200000,
eDraw_BeginPass = 0x400000,
eDraw_EndPass = 0x800000,
};
enum SolidShadeMode
+1 -13
View File
@@ -1391,19 +1391,7 @@ void WrappedVulkan::ContextProcessChunk(uint64_t offset, VulkanChunkType chunk,
{
// no push/pop necessary
}
else if(m_State == READING && chunk == BEGIN_EVENT)
{
// push down the drawcallstack to the latest drawcall
GetDrawcallStack().push_back(&GetDrawcallStack().back()->children.back());
}
else if(m_State == READING && chunk == END_EVENT)
{
// refuse to pop off further than the root drawcall (mismatched begin/end events e.g.)
RDCASSERT(GetDrawcallStack().size() > 1);
if(GetDrawcallStack().size() > 1)
GetDrawcallStack().pop_back();
}
else if(m_State == READING && (chunk == BEGIN_CMD_BUFFER || chunk == END_CMD_BUFFER))
else if(m_State == READING && (chunk == BEGIN_CMD_BUFFER || chunk == END_CMD_BUFFER || chunk == BEGIN_EVENT || chunk == END_EVENT))
{
// don't add these events - they will be handled when inserted in-line into queue submit
}
+1 -1
View File
@@ -476,7 +476,7 @@ private:
VulkanDrawcallTreeNode m_ParentDrawcall;
void InsertDrawsAndRefreshIDs(vector<VulkanDrawcallTreeNode> &nodes, vector<VulkanDrawcallTreeNode> &cmdBufNodes, uint32_t baseEventID, uint32_t baseDrawID);
void InsertDrawsAndRefreshIDs(vector<VulkanDrawcallTreeNode> &cmdBufNodes, uint32_t baseEventID, uint32_t baseDrawID);
list<VulkanDrawcallTreeNode *> m_DrawcallStack;
@@ -2131,10 +2131,21 @@ bool WrappedVulkan::Serialise_vkCmdDbgMarkerEnd(Serialiser* localSerialiser, VkC
{
FetchDrawcall draw;
draw.name = "API Calls";
draw.flags |= eDraw_SetMarker;
draw.flags = eDraw_SetMarker;
AddDrawcall(draw, true);
}
if(m_State == READING)
{
// dummy draw that is consumed when this command buffer
// is being in-lined into the call stream
FetchDrawcall draw;
draw.name = "Pop()";
draw.flags = eDraw_PopMarker;
AddDrawcall(draw, false);
}
return true;
}
@@ -218,7 +218,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(
m_RootEventID++;
// insert the baked command buffer in-line into this list of notes, assigning new event and drawIDs
InsertDrawsAndRefreshIDs(GetDrawcallStack().back()->children, m_BakedCmdBufferInfo[cmdIds[c]].draw->children, m_RootEventID, m_RootDrawcallID);
InsertDrawsAndRefreshIDs(m_BakedCmdBufferInfo[cmdIds[c]].draw->children, m_RootEventID, m_RootDrawcallID);
m_PartialReplayData.cmdBufferSubmits[cmdIds[c]].push_back(m_RootEventID);
@@ -352,12 +352,21 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(
return true;
}
void WrappedVulkan::InsertDrawsAndRefreshIDs(vector<VulkanDrawcallTreeNode> &nodes, vector<VulkanDrawcallTreeNode> &cmdBufNodes,
uint32_t baseEventID, uint32_t baseDrawID)
void WrappedVulkan::InsertDrawsAndRefreshIDs(vector<VulkanDrawcallTreeNode> &cmdBufNodes, uint32_t baseEventID, uint32_t baseDrawID)
{
// assign new drawcall IDs
for(size_t i=0; i < cmdBufNodes.size(); i++)
{
if(cmdBufNodes[i].draw.flags & eDraw_PopMarker)
{
RDCASSERT(GetDrawcallStack().size() > 1);
if(GetDrawcallStack().size() > 1)
GetDrawcallStack().pop_back();
// Skip - pop marker draws aren't processed otherwise, we just apply them to the drawcall stack.
continue;
}
VulkanDrawcallTreeNode n = cmdBufNodes[i];
n.draw.eventID += baseEventID;
n.draw.drawcallID += baseDrawID;
@@ -374,8 +383,7 @@ void WrappedVulkan::InsertDrawsAndRefreshIDs(vector<VulkanDrawcallTreeNode> &nod
auto it = std::lower_bound(m_DrawcallUses.begin(), m_DrawcallUses.end(), use);
m_DrawcallUses.insert(it, use);
n.children.clear();
InsertDrawsAndRefreshIDs(n.children, cmdBufNodes[i].children, baseEventID, baseDrawID);
RDCASSERT(n.children.empty());
for(auto it=n.resourceUsage.begin(); it != n.resourceUsage.end(); ++it)
{
@@ -384,7 +392,11 @@ void WrappedVulkan::InsertDrawsAndRefreshIDs(vector<VulkanDrawcallTreeNode> &nod
m_ResourceUses[it->first].push_back(u);
}
nodes.push_back(n);
GetDrawcallStack().back()->children.push_back(n);
// if this is a push marker too, step down the drawcall stack
if(cmdBufNodes[i].draw.flags & eDraw_PushMarker)
GetDrawcallStack().push_back(&GetDrawcallStack().back()->children.back());
}
}
+21 -19
View File
@@ -396,27 +396,29 @@ namespace renderdoc
public enum DrawcallFlags
{
// types
Clear = 0x01,
Drawcall = 0x02,
Dispatch = 0x04,
CmdList = 0x08,
SetMarker = 0x10,
PushMarker = 0x20,
Present = 0x40,
MultiDraw = 0x80,
Copy = 0x100,
Resolve = 0x200,
PassBoundary = 0x400,
Clear = 0x0001,
Drawcall = 0x0002,
Dispatch = 0x0004,
CmdList = 0x0008,
SetMarker = 0x0010,
PushMarker = 0x0020,
PopMarker = 0x0040, // this is only for internal tracking use
Present = 0x0080,
MultiDraw = 0x0100,
Copy = 0x0200,
Resolve = 0x0400,
GenMips = 0x0800,
PassBoundary = 0x1000,
// flags
UseIBuffer = 0x01000,
Instanced = 0x02000,
Auto = 0x04000,
Indirect = 0x08000,
ClearColour = 0x10000,
ClearDepth = 0x20000,
BeginPass = 0x40000,
EndPass = 0x80000,
UseIBuffer = 0x010000,
Instanced = 0x020000,
Auto = 0x040000,
Indirect = 0x080000,
ClearColour = 0x100000,
ClearDepthStencil = 0x200000,
BeginPass = 0x400000,
EndPass = 0x800000,
};
public enum SolidShadeMode