Batch up command lists used for preparing and applying initial state

This commit is contained in:
baldurk
2016-11-18 21:19:18 +01:00
parent 4ecd99bf52
commit 46e4ccb5ee
4 changed files with 64 additions and 12 deletions
+1 -1
View File
@@ -466,7 +466,7 @@ void WrappedID3D12CommandQueue::ReplayLog(LogState readType, uint32_t startEvent
if(readType == READING)
{
GetResourceManager()->ApplyInitialContents();
m_pDevice->ApplyInitialContents();
m_pDevice->ExecuteLists();
m_pDevice->FlushLists();
+46 -2
View File
@@ -529,6 +529,20 @@ HRESULT WrappedID3D12Device::QueryInterface(REFIID riid, void **ppvObject)
return m_RefCounter.QueryInterface(riid, ppvObject);
}
void WrappedID3D12Device::ApplyInitialContents()
{
initStateCurBatch = 0;
initStateCurList = NULL;
GetResourceManager()->ApplyInitialContents();
// close the final list
initStateCurList->Close();
initStateCurBatch = 0;
initStateCurList = NULL;
}
void WrappedID3D12Device::CheckForDeath()
{
if(!m_Alive)
@@ -1145,8 +1159,18 @@ void WrappedID3D12Device::StartFrameCapture(void *dev, void *wnd)
// and go into the frame record.
{
SCOPED_LOCK(m_CapTransitionLock);
initStateCurBatch = 0;
initStateCurList = NULL;
GetResourceManager()->PrepareInitialContents();
// close the final list
initStateCurList->Close();
initStateCurBatch = 0;
initStateCurList = NULL;
ExecuteLists();
FlushLists();
@@ -1925,6 +1949,26 @@ ID3D12GraphicsCommandList *WrappedID3D12Device::GetNewList()
return ret;
}
ID3D12GraphicsCommandList *WrappedID3D12Device::GetInitialStateList()
{
if(initStateCurBatch >= initialStateMaxBatch)
{
CloseInitialStateList();
}
if(initStateCurList == NULL)
initStateCurList = GetNewList();
return initStateCurList;
}
void WrappedID3D12Device::CloseInitialStateList()
{
initStateCurList->Close();
initStateCurList = NULL;
initStateCurBatch = 0;
}
void WrappedID3D12Device::ExecuteList(ID3D12GraphicsCommandList *list, ID3D12CommandQueue *queue)
{
if(queue == NULL)
@@ -2119,7 +2163,7 @@ void WrappedID3D12Device::ReadLogInitialisation()
{
frameOffset = offset;
GetResourceManager()->ApplyInitialContents();
ApplyInitialContents();
m_Queue->ReplayLog(READING, 0, 0, false);
}
@@ -2216,7 +2260,7 @@ void WrappedID3D12Device::ReplayLog(uint32_t startEventID, uint32_t endEventID,
if(!partial)
{
GetResourceManager()->ApplyInitialContents();
ApplyInitialContents();
GetResourceManager()->ReleaseInFrameResources();
ExecuteLists();
+10
View File
@@ -416,7 +416,17 @@ public:
// -> FlushLists()--------back to freecmds--------^
} m_InternalCmds;
// batch this many initial state lists together. Balance between
// creating fewer temporary lists and making too bloated lists
static const int initialStateMaxBatch = 100;
int initStateCurBatch;
ID3D12GraphicsCommandList *initStateCurList;
ID3D12GraphicsCommandList *GetNewList();
ID3D12GraphicsCommandList *GetInitialStateList();
void CloseInitialStateList();
void ApplyInitialContents();
void ExecuteList(ID3D12GraphicsCommandList *list, ID3D12CommandQueue *queue = NULL);
void ExecuteLists(ID3D12CommandQueue *queue = NULL);
void FlushLists(bool forceSync = false, ID3D12CommandQueue *queue = NULL);
+7 -9
View File
@@ -703,11 +703,9 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res)
if(SUCCEEDED(hr))
{
ID3D12GraphicsCommandList *list = Unwrap(m_Device->GetNewList());
ID3D12GraphicsCommandList *list = Unwrap(m_Device->GetInitialStateList());
list->CopyResource(copyDst, r->GetReal());
list->Close();
}
else
{
@@ -716,6 +714,8 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res)
if(nonresident)
{
m_Device->CloseInitialStateList();
m_Device->ExecuteLists();
m_Device->FlushLists();
@@ -768,7 +768,7 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res)
if(SUCCEEDED(hr))
{
ID3D12GraphicsCommandList *list = Unwrap(m_Device->GetNewList());
ID3D12GraphicsCommandList *list = Unwrap(m_Device->GetInitialStateList());
vector<D3D12_RESOURCE_BARRIER> barriers;
@@ -817,8 +817,6 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res)
if(!barriers.empty())
list->ResourceBarrier((UINT)barriers.size(), &barriers[0]);
list->Close();
}
else
{
@@ -827,6 +825,8 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res)
if(nonresident)
{
m_Device->CloseInitialStateList();
m_Device->ExecuteLists();
m_Device->FlushLists();
@@ -1185,7 +1185,7 @@ void D3D12ResourceManager::Apply_InitialState(ID3D12DeviceChild *live, InitialCo
}
else
{
ID3D12GraphicsCommandList *list = Unwrap(m_Device->GetNewList());
ID3D12GraphicsCommandList *list = Unwrap(m_Device->GetInitialStateList());
vector<D3D12_RESOURCE_BARRIER> barriers;
@@ -1255,8 +1255,6 @@ void D3D12ResourceManager::Apply_InitialState(ID3D12DeviceChild *live, InitialCo
if(!barriers.empty())
list->ResourceBarrier((UINT)barriers.size(), &barriers[0]);
list->Close();
#if ENABLED(SINGLE_FLUSH_VALIDATE)
m_Device->ExecuteLists();
m_Device->FlushLists(true);