Handle ExecuteIndirect by cracking lists apart and patching during read

This commit is contained in:
baldurk
2016-10-21 21:44:24 +02:00
parent df903cd191
commit c23633b85d
5 changed files with 724 additions and 294 deletions
+3 -2
View File
@@ -410,8 +410,9 @@ public:
IMPLEMENT_FUNCTION_SERIALISED(virtual void STDMETHODCALLTYPE, EndEvent());
void PatchedExecuteIndirect(ID3D12GraphicsCommandList *list, ResourceId sig, UINT maxCount,
ResourceId arg, UINT64 argOffs);
void ReserveExecuteIndirect(ID3D12GraphicsCommandList *list, ResourceId sig, UINT maxCount);
void PatchExecuteIndirect(BakedCmdListInfo &info, uint32_t executeIndex);
void ReplayExecuteIndirect(ID3D12GraphicsCommandList *list, BakedCmdListInfo &info);
IMPLEMENT_FUNCTION_SERIALISED(virtual void STDMETHODCALLTYPE,
ExecuteIndirect(ID3D12CommandSignature *pCommandSignature,
File diff suppressed because it is too large Load Diff
@@ -123,8 +123,32 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis
{
for(uint32_t i = 0; i < numCmds; i++)
{
ID3D12CommandList *c = Unwrap(cmds[i]);
m_pReal->ExecuteCommandLists(1, &c);
if(m_Cmd.m_BakedCmdListInfo[cmdIds[i]].executeEvents.empty() ||
m_Cmd.m_BakedCmdListInfo[cmdIds[i]].executeEvents[0].patched)
{
ID3D12CommandList *list = Unwrap(cmds[i]);
m_pReal->ExecuteCommandLists(1, &list);
}
else
{
BakedCmdListInfo &info = m_Cmd.m_BakedCmdListInfo[cmdIds[i]];
// execute the first half of the cracked list
ID3D12CommandList *list = Unwrap(info.crackedLists[0]);
m_pReal->ExecuteCommandLists(1, &list);
for(size_t c = 1; c < info.crackedLists.size(); c++)
{
m_pDevice->GPUSync();
// readback the patch buffer and perform patching
m_ReplayList->PatchExecuteIndirect(info, uint32_t(c - 1));
// execute next list with this indirect.
list = Unwrap(info.crackedLists[c]);
m_pReal->ExecuteCommandLists(1, &list);
}
}
}
for(uint32_t i = 0; i < numCmds; i++)
+45
View File
@@ -695,6 +695,51 @@ HRESULT STDMETHODCALLTYPE WrappedID3D12GraphicsCommandList::QueryInterface(REFII
return RefCounter12::QueryInterface(riid, ppvObject);
}
void BakedCmdListInfo::ShiftForRemoved(uint32_t shiftDrawID, uint32_t shiftEID, size_t idx)
{
std::vector<D3D12DrawcallTreeNode> &draws = draw->children;
drawCount -= shiftDrawID;
eventCount -= shiftEID;
if(idx < draws.size())
{
for(size_t i = idx; i < draws.size(); i++)
{
// should have no children as we don't push in for markers since they
// can cross command list boundaries.
RDCASSERT(draws[i].children.empty());
draws[i].draw.eventID -= shiftEID;
draws[i].draw.drawcallID -= shiftDrawID;
for(int32_t e = 0; e < draws[i].draw.events.count; e++)
draws[i].draw.events[e].eventID -= shiftEID;
}
uint32_t lastEID = draws[idx].draw.eventID;
// shift any resource usage for drawcalls after the removed section
for(size_t i = 0; i < draw->resourceUsage.size(); i++)
{
if(draw->resourceUsage[i].second.eventID >= lastEID)
draw->resourceUsage[i].second.eventID -= shiftEID;
}
// patch any subsequent executes
for(size_t i = 0; i < executeEvents.size(); i++)
{
if(executeEvents[i].baseEvent >= lastEID)
{
executeEvents[i].baseEvent -= shiftEID;
if(executeEvents[i].lastEvent > 0)
executeEvents[i].lastEvent -= shiftEID;
}
}
}
}
D3D12CommandData::D3D12CommandData()
{
m_CurChunkOffset = 0;
+31
View File
@@ -131,6 +131,7 @@ struct BakedCmdListInfo
eventCount = parent.curEventID;
drawCount = parent.drawCount;
crackedLists.swap(parent.crackedLists);
executeEvents.swap(parent.executeEvents);
parentList = parentID;
@@ -144,7 +145,37 @@ struct BakedCmdListInfo
parent.debugMessages.clear();
}
void ShiftForRemoved(uint32_t shiftDrawID, uint32_t shiftEID, size_t idx);
struct ExecuteData
{
ExecuteData()
: baseEvent(0),
lastEvent(0),
patched(false),
argBuf(NULL),
countBuf(NULL),
argOffs(0),
countOffs(0),
maxCount(0),
realCount(0)
{
}
uint32_t baseEvent;
uint32_t lastEvent;
bool patched;
ID3D12Resource *argBuf;
ID3D12Resource *countBuf;
uint64_t argOffs;
uint64_t countOffs;
ResourceId sig;
UINT maxCount;
UINT realCount;
};
vector<ID3D12GraphicsCommandList *> crackedLists;
vector<ExecuteData> executeEvents;
vector<FetchAPIEvent> curEvents;
vector<DebugMessage> debugMessages;