git.s-ol.nu forks/DiligentEngine / 93a08dc
Reworked ExecuteCommandList(+s) to take an array of command lists instead of one assiduous 2 years ago
8 changed file(s) with 30 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
(No changes)
(No changes)
10231023 // Reset mRenderSubsetsSignal while all threads are waiting for mUpdateSubsetsSignal
10241024 mRenderSubsetsSignal.Reset();
10251025
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
10261031 for (auto& cmdList : mCmdLists)
10271032 {
1028 mDeviceCtxt->ExecuteCommandList(cmdList);
10291033 // Release command lists now to release all outstanding references
10301034 // In d3d11 mode, command lists hold references to the swap chain's back buffer
10311035 // that cause swap chain resize to fail
6161 Diligent::RefCntAutoPtr<Diligent::IDeviceContext> mDeviceCtxt;
6262 std::vector< Diligent::RefCntAutoPtr<Diligent::IDeviceContext> > mDeferredCtxt;
6363 std::vector< Diligent::RefCntAutoPtr<Diligent::ICommandList> > mCmdLists;
64 std::vector< Diligent::ICommandList* > mCmdListPtrs;
6465
6566 Diligent::Uint32 mBackBufferWidth, mBackBufferHeight;
6667 Diligent::Uint32 mNumSubsets = 0;
4747 return m_pUnityGraphicsD3D12->GetNextFrameFenceValue();
4848 }
4949
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
5252 {
5353 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 }
5760 return std::max(m_CurrentFenceValue, NextFenceValue);
5861 }
5962
4444 return m_GraphicsD3D12Impl.GetNextFenceValue();
4545 }
4646
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);
5151 }
5252
5353 // Returns D3D12 command queue. May return null if queue is anavailable
397397 return SignaledValue;
398398 }
399399
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);
406410 }
407411 auto FenceValue = m_NextFenceValue;
408412 m_D3D12CmdQueue->Signal(m_D3D12FrameFence, m_NextFenceValue++);
5353 }
5454 UINT64 GetNextFenceValue() { return m_NextFenceValue; }
5555 UINT64 GetCompletedFenceValue() { return m_D3D12FrameFence->GetCompletedValue(); }
56 UINT64 ExecuteCommandList(ID3D12CommandList *pCmdList);
56 UINT64 ExecuteCommandLists(UINT NumCommandLists, ID3D12CommandList* const* ppCommandLists);
57 UINT64 ExecuteCommandList(ID3D12CommandList* pCmdList);
5758 void SetTransitionHandler(IResourceStateTransitionHandler *pTransitionHandler) { m_pStateTransitionHandler = pTransitionHandler; }
5859 void TransitonResourceStates(int stateCount, UnityGraphicsD3D12ResourceState* states);
5960 IDXGISwapChain3* GetSwapChain(){ return m_SwapChain; }