Capture and replay commands executed on multiple queues

This commit is contained in:
baldurk
2016-10-26 10:48:03 +02:00
parent 135ec6858d
commit 8acd5ab27d
4 changed files with 39 additions and 25 deletions
@@ -52,6 +52,7 @@ void STDMETHODCALLTYPE WrappedID3D12CommandQueue::CopyTileMappings(
bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLists,
ID3D12CommandList *const *ppCommandLists)
{
SERIALISE_ELEMENT(ResourceId, queueId, GetResourceID());
SERIALISE_ELEMENT(UINT, numCmds, NumCommandLists);
vector<ResourceId> cmdIds;
@@ -119,6 +120,11 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis
}
}
ID3D12CommandQueue *real = NULL;
if(m_State <= EXECUTING)
real = Unwrap(GetResourceManager()->GetLiveAs<ID3D12CommandQueue>(queueId));
if(m_State == READING)
{
for(uint32_t i = 0; i < numCmds; i++)
@@ -127,7 +133,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis
m_Cmd.m_BakedCmdListInfo[cmdIds[i]].executeEvents[0].patched)
{
ID3D12CommandList *list = Unwrap(cmds[i]);
m_pReal->ExecuteCommandLists(1, &list);
real->ExecuteCommandLists(1, &list);
}
else
{
@@ -135,7 +141,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis
// execute the first half of the cracked list
ID3D12CommandList *list = Unwrap(info.crackedLists[0]);
m_pReal->ExecuteCommandLists(1, &list);
real->ExecuteCommandLists(1, &list);
for(size_t c = 1; c < info.crackedLists.size(); c++)
{
@@ -146,7 +152,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis
// execute next list with this indirect.
list = Unwrap(info.crackedLists[c]);
m_pReal->ExecuteCommandLists(1, &list);
real->ExecuteCommandLists(1, &list);
}
}
}
@@ -266,7 +272,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis
m_pDevice->ApplyBarriers(m_Cmd.m_BakedCmdListInfo[rerecord].barriers);
}
m_pReal->ExecuteCommandLists((UINT)rerecordedCmds.size(), &rerecordedCmds[0]);
real->ExecuteCommandLists((UINT)rerecordedCmds.size(), &rerecordedCmds[0]);
}
else if(m_Cmd.m_LastEventID > startEID && m_Cmd.m_LastEventID < m_Cmd.m_RootEventID)
{
@@ -320,7 +326,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis
RDCASSERT(trimmedCmds.size() > 0);
m_pReal->ExecuteCommandLists((UINT)trimmedCmds.size(), &trimmedCmds[0]);
real->ExecuteCommandLists((UINT)trimmedCmds.size(), &trimmedCmds[0]);
for(uint32_t i = 0; i < trimmedCmdIds.size(); i++)
{
@@ -337,7 +343,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis
ID3D12CommandList **unwrapped = new ID3D12CommandList *[numCmds];
for(uint32_t i = 0; i < numCmds; i++)
unwrapped[i] = Unwrap(cmds[i]);
m_pReal->ExecuteCommandLists(numCmds, unwrapped);
real->ExecuteCommandLists(numCmds, unwrapped);
SAFE_DELETE_ARRAY(unwrapped);
for(uint32_t i = 0; i < numCmds; i++)
+14 -8
View File
@@ -1386,10 +1386,11 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd)
Serialiser *m_pFileSerialiser = RenderDoc::Inst().OpenWriteSerialiser(
m_FrameCounter, &m_InitParams, jpgbuf, len, thwidth, thheight);
if(m_Queue->GetResourceRecord()->ContainsExecuteIndirect)
{
WrappedID3D12Resource::RefBuffers(GetResourceManager());
}
std::vector<WrappedID3D12CommandQueue *> queues = m_Queues;
for(auto it = queues.begin(); it != queues.end(); ++it)
if((*it)->GetResourceRecord()->ContainsExecuteIndirect)
WrappedID3D12Resource::RefBuffers(GetResourceManager());
{
CACHE_THREAD_SERIALISER();
@@ -1425,10 +1426,14 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd)
map<int32_t, Chunk *> recordlist;
for(auto it = queues.begin(); it != queues.end(); ++it)
{
const vector<D3D12ResourceRecord *> &cmdListRecords = m_Queue->GetCmdLists();
WrappedID3D12CommandQueue *q = *it;
RDCDEBUG("Flushing %u command list records to file serialiser", (uint32_t)cmdListRecords.size());
const vector<D3D12ResourceRecord *> &cmdListRecords = q->GetCmdLists();
RDCDEBUG("Flushing %u command list records from queue %llu", (uint32_t)cmdListRecords.size(),
q->GetResourceID());
for(size_t i = 0; i < cmdListRecords.size(); i++)
{
@@ -1438,7 +1443,7 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd)
(uint32_t)recordlist.size(), cmdListRecords[i]->GetResourceID());
}
m_Queue->GetResourceRecord()->Insert(recordlist);
q->GetResourceRecord()->Insert(recordlist);
}
{
@@ -1462,7 +1467,8 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd)
m_State = WRITING_IDLE;
m_Queue->ClearAfterCapture();
for(auto it = queues.begin(); it != queues.end(); ++it)
(*it)->ClearAfterCapture();
GetResourceManager()->MarkUnwrittenResources();
+4
View File
@@ -224,6 +224,10 @@ class WrappedID3D12Device : public IFrameCapturer, public ID3DDevice, public ID3
private:
ID3D12Device *m_pDevice;
// list of all queues being captured
std::vector<WrappedID3D12CommandQueue *> m_Queues;
// the queue we use for all internal work, the first DIRECT queue
WrappedID3D12CommandQueue *m_Queue;
ID3D12CommandAllocator *m_Alloc;
+9 -11
View File
@@ -58,15 +58,15 @@ bool WrappedID3D12Device::Serialise_CreateCommandQueue(Serialiser *localSerialis
GetResourceManager()->AddLiveResource(Queue, ret);
if(Descriptor.Type == D3D12_COMMAND_LIST_TYPE_DIRECT)
WrappedID3D12CommandQueue *wrapped = (WrappedID3D12CommandQueue *)ret;
if(Descriptor.Type == D3D12_COMMAND_LIST_TYPE_DIRECT && m_Queue == NULL)
{
if(m_Queue != NULL)
RDCERR("Don't support multiple direct queues yet!");
m_Queue = (WrappedID3D12CommandQueue *)ret;
m_Queue = wrapped;
CreateInternalResources();
}
m_Queues.push_back(wrapped);
}
}
@@ -104,16 +104,14 @@ HRESULT WrappedID3D12Device::CreateCommandQueue(const D3D12_COMMAND_QUEUE_DESC *
GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped);
}
if(pDesc->Type == D3D12_COMMAND_LIST_TYPE_DIRECT)
if(pDesc->Type == D3D12_COMMAND_LIST_TYPE_DIRECT && m_Queue == NULL)
{
if(m_Queue != NULL)
RDCERR("Don't support multiple queues yet!");
m_Queue = wrapped;
CreateInternalResources();
}
m_Queues.push_back(wrapped);
*ppCommandQueue = (ID3D12CommandQueue *)wrapped;
}