Reworked ExecuteCommandList(+s) to take an array of command lists instead of one
assiduous
2 years ago
1023 | 1023 |
// Reset mRenderSubsetsSignal while all threads are waiting for mUpdateSubsetsSignal
|
1024 | 1024 |
mRenderSubsetsSignal.Reset();
|
1025 | 1025 |
|
|
1026 |
mCmdListPtrs.resize(mCmdLists.size());
|
|
1027 |
for(size_t i=0; i < mCmdLists.size(); ++i)
|
|
1028 |
mCmdListPtrs[i] = mCmdLists[i];
|
|
1029 |
mDeviceCtxt->ExecuteCommandLists(static_cast<Uint32>(mCmdListPtrs.size()), mCmdListPtrs.data());
|
|
1030 |
|
1026 | 1031 |
for (auto& cmdList : mCmdLists)
|
1027 | 1032 |
{
|
1028 | |
mDeviceCtxt->ExecuteCommandList(cmdList);
|
1029 | 1033 |
// Release command lists now to release all outstanding references
|
1030 | 1034 |
// In d3d11 mode, command lists hold references to the swap chain's back buffer
|
1031 | 1035 |
// that cause swap chain resize to fail
|
61 | 61 |
Diligent::RefCntAutoPtr<Diligent::IDeviceContext> mDeviceCtxt;
|
62 | 62 |
std::vector< Diligent::RefCntAutoPtr<Diligent::IDeviceContext> > mDeferredCtxt;
|
63 | 63 |
std::vector< Diligent::RefCntAutoPtr<Diligent::ICommandList> > mCmdLists;
|
|
64 |
std::vector< Diligent::ICommandList* > mCmdListPtrs;
|
64 | 65 |
|
65 | 66 |
Diligent::Uint32 mBackBufferWidth, mBackBufferHeight;
|
66 | 67 |
Diligent::Uint32 mNumSubsets = 0;
|
47 | 47 |
return m_pUnityGraphicsD3D12->GetNextFrameFenceValue();
|
48 | 48 |
}
|
49 | 49 |
|
50 | |
// Executes a given command list
|
51 | |
virtual Uint64 DILIGENT_CALL_TYPE Submit(ID3D12GraphicsCommandList* commandList)override final
|
|
50 |
// Executes command lists
|
|
51 |
virtual Uint64 DILIGENT_CALL_TYPE Submit(Uint32 NumCommandLists, ID3D12CommandList* const* ppCommandLists)override final
|
52 | 52 |
{
|
53 | 53 |
auto NextFenceValue = m_pUnityGraphicsD3D12->GetNextFrameFenceValue();
|
54 | |
m_CurrentFenceValue = m_pUnityGraphicsD3D12->ExecuteCommandList(commandList, static_cast<int>(m_ResourcesToTransition.size()), m_ResourcesToTransition.empty() ? nullptr : m_ResourcesToTransition.data());
|
55 | |
VERIFY(m_CurrentFenceValue >= NextFenceValue, "Current fence value returned by ExecuteCommandList() is less than the next fence value previously queried through GetNextFrameFenceValue()");
|
56 | |
m_ResourcesToTransition.clear();
|
|
54 |
for(Uint32 i=0; i < NumCommandLists; ++i)
|
|
55 |
{
|
|
56 |
m_CurrentFenceValue = m_pUnityGraphicsD3D12->ExecuteCommandList(static_cast<ID3D12GraphicsCommandList*>(ppCommandLists[i]), static_cast<int>(m_ResourcesToTransition.size()), m_ResourcesToTransition.empty() ? nullptr : m_ResourcesToTransition.data());
|
|
57 |
VERIFY(m_CurrentFenceValue >= NextFenceValue, "Current fence value returned by ExecuteCommandList() is less than the next fence value previously queried through GetNextFrameFenceValue()");
|
|
58 |
m_ResourcesToTransition.clear();
|
|
59 |
}
|
57 | 60 |
return std::max(m_CurrentFenceValue, NextFenceValue);
|
58 | 61 |
}
|
59 | 62 |
|
44 | 44 |
return m_GraphicsD3D12Impl.GetNextFenceValue();
|
45 | 45 |
}
|
46 | 46 |
|
47 | |
// Executes a given command list
|
48 | |
virtual Uint64 DILIGENT_CALL_TYPE Submit(ID3D12GraphicsCommandList* commandList) override final
|
49 | |
{
|
50 | |
return m_GraphicsD3D12Impl.ExecuteCommandList(commandList);
|
|
47 |
// Executes command lists
|
|
48 |
virtual Uint64 DILIGENT_CALL_TYPE Submit(Uint32 NumCommandLists, ID3D12CommandList* const* ppCommandLists) override final
|
|
49 |
{
|
|
50 |
return m_GraphicsD3D12Impl.ExecuteCommandLists(NumCommandLists, ppCommandLists);
|
51 | 51 |
}
|
52 | 52 |
|
53 | 53 |
// Returns D3D12 command queue. May return null if queue is anavailable
|
397 | 397 |
return SignaledValue;
|
398 | 398 |
}
|
399 | 399 |
|
400 | |
UINT64 UnityGraphicsD3D12Impl::ExecuteCommandList(ID3D12CommandList *pCmdList)
|
401 | |
{
|
402 | |
if (pCmdList != nullptr)
|
403 | |
{
|
404 | |
ID3D12CommandList *CmdLists[] = { pCmdList };
|
405 | |
m_D3D12CmdQueue->ExecuteCommandLists(1, CmdLists);
|
|
400 |
UINT64 UnityGraphicsD3D12Impl::ExecuteCommandList(ID3D12CommandList* pCommandList)
|
|
401 |
{
|
|
402 |
return ExecuteCommandLists(pCommandList != nullptr ? 1 : 0, &pCommandList);
|
|
403 |
}
|
|
404 |
|
|
405 |
UINT64 UnityGraphicsD3D12Impl::ExecuteCommandLists(UINT NumCommandLists, ID3D12CommandList* const* ppCommandLists)
|
|
406 |
{
|
|
407 |
if (NumCommandLists !=0 && ppCommandLists != nullptr)
|
|
408 |
{
|
|
409 |
m_D3D12CmdQueue->ExecuteCommandLists(NumCommandLists, ppCommandLists);
|
406 | 410 |
}
|
407 | 411 |
auto FenceValue = m_NextFenceValue;
|
408 | 412 |
m_D3D12CmdQueue->Signal(m_D3D12FrameFence, m_NextFenceValue++);
|
53 | 53 |
}
|
54 | 54 |
UINT64 GetNextFenceValue() { return m_NextFenceValue; }
|
55 | 55 |
UINT64 GetCompletedFenceValue() { return m_D3D12FrameFence->GetCompletedValue(); }
|
56 | |
UINT64 ExecuteCommandList(ID3D12CommandList *pCmdList);
|
|
56 |
UINT64 ExecuteCommandLists(UINT NumCommandLists, ID3D12CommandList* const* ppCommandLists);
|
|
57 |
UINT64 ExecuteCommandList(ID3D12CommandList* pCmdList);
|
57 | 58 |
void SetTransitionHandler(IResourceStateTransitionHandler *pTransitionHandler) { m_pStateTransitionHandler = pTransitionHandler; }
|
58 | 59 |
void TransitonResourceStates(int stateCount, UnityGraphicsD3D12ResourceState* states);
|
59 | 60 |
IDXGISwapChain3* GetSwapChain(){ return m_SwapChain; }
|