From ef733fdbac35b6180964766b107f219eb41b1d75 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 6 Oct 2018 19:19:50 -0700 Subject: Updated submodules (main change: refactored release queues in D3D12 and Vulkan backends) --- .../GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'unityplugin/GhostCubePlugin/PluginSource') diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp index 4f57a93..8befeb0 100644 --- a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp +++ b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp @@ -1,4 +1,5 @@ #include +#include #include "PlatformBase.h" @@ -42,13 +43,13 @@ public: IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_CommandQueueD3D12, TBase ) // Returns the fence value that will be signaled next time - virtual UINT64 GetNextFenceValue()override final + virtual Uint64 GetNextFenceValue()override final { return m_pUnityGraphicsD3D12->GetNextFrameFenceValue(); } // Executes a given command list - virtual UINT64 ExecuteCommandList(ID3D12GraphicsCommandList* commandList)override final + virtual Uint64 Submit(ID3D12GraphicsCommandList* commandList)override final { auto NextFenceValue = m_pUnityGraphicsD3D12->GetNextFrameFenceValue(); m_CurrentFenceValue = m_pUnityGraphicsD3D12->ExecuteCommandList(commandList, static_cast(m_ResourcesToTransition.size()), m_ResourcesToTransition.empty() ? nullptr : m_ResourcesToTransition.data()); @@ -70,7 +71,7 @@ public: } // Blocks execution until all pending GPU commands are complete - virtual void IdleGPU() + virtual Uint64 WaitForIdle() { if (m_CurrentFenceValue < GetCompletedFenceValue()) { @@ -79,6 +80,7 @@ public: WaitForSingleObject(m_WaitForGPUEventHandle, INFINITE); VERIFY(GetCompletedFenceValue() >= m_CurrentFenceValue, "Unexpected signaled fence value"); } + return GetCompletedFenceValue(); } void TransitionResource(const UnityGraphicsD3D12ResourceState &ResourceState) @@ -143,7 +145,8 @@ void RenderAPI_D3D12::ProcessDeviceEvent(UnityGfxDeviceEventType type, IUnityInt m_CmdQueue = NEW_RC_OBJ(DefaultAllocator, "UnityCommandQueueImpl instance", UnityCommandQueueImpl)(m_UnityGraphicsD3D12); auto *pFactoryD3D12 = GetEngineFactoryD3D12(); EngineD3D12Attribs Attribs; - pFactoryD3D12->AttachToD3D12Device(d3d12Device, m_CmdQueue, Attribs, &m_Device, &m_Context, 0); + std::array CmdQueues = {m_CmdQueue}; + pFactoryD3D12->AttachToD3D12Device(d3d12Device, CmdQueues.size(), CmdQueues.data(), Attribs, &m_Device, &m_Context, 0); m_Device->QueryInterface(IID_RenderDeviceD3D12, reinterpret_cast(static_cast(&m_RenderDeviceD3D12))); } break; @@ -169,8 +172,9 @@ void RenderAPI_D3D12::BeginRendering() void RenderAPI_D3D12::EndRendering() { m_Context->Flush(); + m_Context->FinishFrame(); m_Context->InvalidateState(); - m_RenderDeviceD3D12->FinishFrame(); + m_RenderDeviceD3D12->ReleaseStaleResources(); } void RenderAPI_D3D12::AttachToNativeRenderTexture(void *nativeRenderTargetHandle, void *nativeDepthTextureHandle) -- cgit v1.2.3