From 5e38dd84c3575d04081af3a5402299f53b66c2a2 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 31 Jan 2020 08:39:24 -0800 Subject: Fixed 32-bit build --- .../src/DiligentGraphicsAdapterD3D11.cpp | 74 ++++++------ .../src/DiligentGraphicsAdapterD3D12.cpp | 132 ++++++++++----------- .../src/DiligentGraphicsAdapterGL.cpp | 14 +-- 3 files changed, 110 insertions(+), 110 deletions(-) (limited to 'unityplugin/UnityEmulator') diff --git a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp index ce041c9..04c244f 100644 --- a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp +++ b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp @@ -13,7 +13,7 @@ using namespace Diligent; -namespace +namespace { class ProxySwapChainD3D11 : public SwapChainBase @@ -21,27 +21,27 @@ class ProxySwapChainD3D11 : public SwapChainBase public: using TBase = SwapChainBase; - ProxySwapChainD3D11( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, - IDeviceContext *pDeviceContext, - const SwapChainDesc& SCDesc ) : - TBase(pRefCounters, pDevice, pDeviceContext,SCDesc) + ProxySwapChainD3D11(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + IDeviceContext* pDeviceContext, + const SwapChainDesc& SCDesc) : + TBase(pRefCounters, pDevice, pDeviceContext, SCDesc) {} - + IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_SwapChainD3D11, TBase) - virtual IDXGISwapChain *GetDXGISwapChain()override final + virtual IDXGISwapChain* DILIGENT_CALL_TYPE GetDXGISwapChain() override final { UNEXPECTED("DXGI swap chain cannot be requested through the proxy swap chain"); return nullptr; } - virtual void Present(Uint32 SyncInterval)override final + virtual void DILIGENT_CALL_TYPE Present(Uint32 SyncInterval) override final { UNEXPECTED("Present is not expected to be called directly"); } - virtual void Resize(Uint32 NewWidth, Uint32 NewHeight)override final + virtual void DILIGENT_CALL_TYPE Resize(Uint32 NewWidth, Uint32 NewHeight) override final { TBase::Resize(NewWidth, NewHeight, 0); } @@ -65,11 +65,11 @@ public: pd3dDepthBuffer->QueryInterface(__uuidof(ID3D11Texture2D), reinterpret_cast(&pd3dTex2DDepthBuffer)); RefCntAutoPtr pRenderDeviceD3D11(m_pRenderDevice, IID_RenderDeviceD3D11); - RefCntAutoPtr pBackBuffer; + RefCntAutoPtr pBackBuffer; pRenderDeviceD3D11->CreateTexture2DFromD3DResource(pd3dTex2DBackBuffer, RESOURCE_STATE_UNDEFINED, &pBackBuffer); TextureViewDesc RTVDesc; RTVDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET; - RTVDesc.Format = m_SwapChainDesc.ColorBufferFormat; + RTVDesc.Format = m_SwapChainDesc.ColorBufferFormat; RefCntAutoPtr pRTV; pBackBuffer->CreateView(RTVDesc, &pRTV); m_pRTV = RefCntAutoPtr(pRTV, IID_TextureViewD3D11); @@ -79,59 +79,59 @@ public: m_pDSV = RefCntAutoPtr(pDepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL), IID_TextureViewD3D11); } - virtual void SetFullscreenMode(const DisplayModeAttribs &DisplayMode)override final + virtual void DILIGENT_CALL_TYPE SetFullscreenMode(const DisplayModeAttribs& DisplayMode) override final { UNEXPECTED("Fullscreen mode cannot be set through the proxy swap chain"); } - virtual void SetWindowedMode()override final + virtual void DILIGENT_CALL_TYPE SetWindowedMode() override final { UNEXPECTED("Windowed mode cannot be set through the proxy swap chain"); } - virtual ITextureViewD3D11* GetCurrentBackBufferRTV()override final{return m_pRTV;} - virtual ITextureViewD3D11* GetDepthBufferDSV() override final{return m_pDSV;} - - bool BuffersInitialized() const {return m_pRTV && m_pDSV;} + virtual ITextureViewD3D11* DILIGENT_CALL_TYPE GetCurrentBackBufferRTV() override final { return m_pRTV; } + virtual ITextureViewD3D11* DILIGENT_CALL_TYPE GetDepthBufferDSV() override final { return m_pDSV; } + + bool BuffersInitialized() const { return m_pRTV && m_pDSV; } private: RefCntAutoPtr m_pRTV; RefCntAutoPtr m_pDSV; }; -} +} // namespace -DiligentGraphicsAdapterD3D11::DiligentGraphicsAdapterD3D11(const UnityGraphicsD3D11Emulator& UnityGraphicsD3D11)noexcept : +DiligentGraphicsAdapterD3D11::DiligentGraphicsAdapterD3D11(const UnityGraphicsD3D11Emulator& UnityGraphicsD3D11) noexcept : m_UnityGraphicsD3D11(UnityGraphicsD3D11) { - auto *GraphicsD3D11Impl = m_UnityGraphicsD3D11.GetGraphicsImpl(); - ID3D11Device *pd3d11Device = GraphicsD3D11Impl->GetD3D11Device(); - ID3D11DeviceContext *pd3d11Context = GraphicsD3D11Impl->GetD3D11Context(); - auto *pFactoryD3d11 = GetEngineFactoryD3D11(); + auto* GraphicsD3D11Impl = m_UnityGraphicsD3D11.GetGraphicsImpl(); + ID3D11Device* pd3d11Device = GraphicsD3D11Impl->GetD3D11Device(); + ID3D11DeviceContext* pd3d11Context = GraphicsD3D11Impl->GetD3D11Context(); + auto* pFactoryD3d11 = GetEngineFactoryD3D11(); EngineD3D11CreateInfo Attribs; pFactoryD3d11->AttachToD3D11Device(pd3d11Device, pd3d11Context, Attribs, &m_pDevice, &m_pDeviceCtx); } void DiligentGraphicsAdapterD3D11::InitProxySwapChain() { - auto *GraphicsD3D11Impl = m_UnityGraphicsD3D11.GetGraphicsImpl(); + auto* GraphicsD3D11Impl = m_UnityGraphicsD3D11.GetGraphicsImpl(); D3D11_RENDER_TARGET_VIEW_DESC RTVDesc; - auto *pBackBufferRTV = GraphicsD3D11Impl->GetRTV(); + auto* pBackBufferRTV = GraphicsD3D11Impl->GetRTV(); pBackBufferRTV->GetDesc(&RTVDesc); D3D11_DEPTH_STENCIL_VIEW_DESC DSVDesc; - auto *pDepthBufferDSV = GraphicsD3D11Impl->GetDSV(); + auto* pDepthBufferDSV = GraphicsD3D11Impl->GetDSV(); pDepthBufferDSV->GetDesc(&DSVDesc); SwapChainDesc SCDesc; SCDesc.ColorBufferFormat = DXGI_FormatToTexFormat(RTVDesc.Format); SCDesc.DepthBufferFormat = DXGI_FormatToTexFormat(DSVDesc.Format); - SCDesc.Width = GraphicsD3D11Impl->GetBackBufferWidth(); - SCDesc.Height = GraphicsD3D11Impl->GetBackBufferHeight(); + SCDesc.Width = GraphicsD3D11Impl->GetBackBufferWidth(); + SCDesc.Height = GraphicsD3D11Impl->GetBackBufferHeight(); // This field is irrelevant SCDesc.BufferCount = 0; - auto &DefaultAllocator = DefaultRawMemoryAllocator::GetAllocator(); - auto pProxySwapChainD3D11 = NEW_RC_OBJ(DefaultAllocator, "ProxySwapChainD3D11 instance", ProxySwapChainD3D11)(m_pDevice, m_pDeviceCtx, SCDesc); + auto& DefaultAllocator = DefaultRawMemoryAllocator::GetAllocator(); + auto pProxySwapChainD3D11 = NEW_RC_OBJ(DefaultAllocator, "ProxySwapChainD3D11 instance", ProxySwapChainD3D11)(m_pDevice, m_pDeviceCtx, SCDesc); pProxySwapChainD3D11->QueryInterface(IID_SwapChain, reinterpret_cast(static_cast(&m_pProxySwapChain))); pProxySwapChainD3D11->CreateViews(pBackBufferRTV, pDepthBufferDSV); } @@ -142,24 +142,24 @@ void DiligentGraphicsAdapterD3D11::BeginFrame() void DiligentGraphicsAdapterD3D11::PreSwapChainResize() { - auto *pProxySwapChainD3D11 = m_pProxySwapChain.RawPtr(); + auto* pProxySwapChainD3D11 = m_pProxySwapChain.RawPtr(); pProxySwapChainD3D11->ReleaseViews(); } void DiligentGraphicsAdapterD3D11::PostSwapChainResize() { - auto *GraphicsD3D11Impl = m_UnityGraphicsD3D11.GetGraphicsImpl(); - auto *pProxySwapChainD3D11 = m_pProxySwapChain.RawPtr(); + auto* GraphicsD3D11Impl = m_UnityGraphicsD3D11.GetGraphicsImpl(); + auto* pProxySwapChainD3D11 = m_pProxySwapChain.RawPtr(); pProxySwapChainD3D11->Resize(GraphicsD3D11Impl->GetBackBufferWidth(), GraphicsD3D11Impl->GetBackBufferHeight()); pProxySwapChainD3D11->CreateViews(GraphicsD3D11Impl->GetRTV(), GraphicsD3D11Impl->GetDSV()); } - + void DiligentGraphicsAdapterD3D11::EndFrame() { m_pDeviceCtx->InvalidateState(); } bool DiligentGraphicsAdapterD3D11::UsesReverseZ() -{ - return m_UnityGraphicsD3D11.UsesReverseZ(); +{ + return m_UnityGraphicsD3D11.UsesReverseZ(); } \ No newline at end of file diff --git a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp index fc89874..813c11f 100644 --- a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp +++ b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp @@ -27,7 +27,7 @@ class ProxyCommandQueueD3D12 : public ObjectBase { public: using TBase = ObjectBase; - ProxyCommandQueueD3D12(IReferenceCounters *pRefCounters, UnityGraphicsD3D12Impl& GraphicsD3D12Impl) : + ProxyCommandQueueD3D12(IReferenceCounters* pRefCounters, UnityGraphicsD3D12Impl& GraphicsD3D12Impl) : TBase(pRefCounters), m_GraphicsD3D12Impl(GraphicsD3D12Impl) { @@ -37,39 +37,39 @@ public: { } - IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_CommandQueueD3D12, TBase ) + IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_CommandQueueD3D12, TBase) - // Returns the fence value that will be signaled next time - virtual Uint64 GetNextFenceValue()const override final + // Returns the fence value that will be signaled next time + virtual Uint64 DILIGENT_CALL_TYPE GetNextFenceValue() const override final { return m_GraphicsD3D12Impl.GetNextFenceValue(); } - // Executes a given command list - virtual Uint64 Submit(ID3D12GraphicsCommandList* commandList)override final + // Executes a given command list + virtual Uint64 DILIGENT_CALL_TYPE Submit(ID3D12GraphicsCommandList* commandList) override final { return m_GraphicsD3D12Impl.ExecuteCommandList(commandList); } // Returns D3D12 command queue. May return null if queue is anavailable - virtual ID3D12CommandQueue* GetD3D12CommandQueue() + virtual ID3D12CommandQueue* DILIGENT_CALL_TYPE GetD3D12CommandQueue() { return nullptr; } /// Returns value of the last completed fence - virtual Uint64 GetCompletedFenceValue()override final + virtual Uint64 DILIGENT_CALL_TYPE GetCompletedFenceValue() override final { return m_GraphicsD3D12Impl.GetCompletedFenceValue(); } /// Blocks execution until all pending GPU commands are complete - virtual Uint64 WaitForIdle()override final + virtual Uint64 DILIGENT_CALL_TYPE WaitForIdle() override final { return m_GraphicsD3D12Impl.IdleGPU(); } - virtual void SignalFence(ID3D12Fence* pFence, Uint64 Value)override final + virtual void DILIGENT_CALL_TYPE SignalFence(ID3D12Fence* pFence, Uint64 Value) override final { m_GraphicsD3D12Impl.GetCommandQueue()->Signal(pFence, Value); } @@ -84,48 +84,48 @@ class ProxySwapChainD3D12 : public SwapChainBase public: using TBase = SwapChainBase; - ProxySwapChainD3D12( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, - IDeviceContext *pDeviceContext, - const SwapChainDesc& SCDesc ) : - TBase(pRefCounters, pDevice, pDeviceContext,SCDesc) + ProxySwapChainD3D12(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + IDeviceContext* pDeviceContext, + const SwapChainDesc& SCDesc) : + TBase(pRefCounters, pDevice, pDeviceContext, SCDesc) { } - + IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_SwapChainD3D12, TBase) - virtual IDXGISwapChain *GetDXGISwapChain()override final + virtual IDXGISwapChain* DILIGENT_CALL_TYPE GetDXGISwapChain() override final { UNEXPECTED("DXGI swap chain cannot be requested through the proxy swap chain"); return nullptr; } - virtual ITextureViewD3D12* GetCurrentBackBufferRTV() + virtual ITextureViewD3D12* DILIGENT_CALL_TYPE GetCurrentBackBufferRTV() { return m_RTVs[m_CurrentBackBufferIndex]; } - virtual ITextureViewD3D12* GetDepthBufferDSV() + virtual ITextureViewD3D12* DILIGENT_CALL_TYPE GetDepthBufferDSV() { return m_DSV; } - virtual void Present(Uint32 SyncInterval)override final + virtual void DILIGENT_CALL_TYPE Present(Uint32 SyncInterval) override final { UNEXPECTED("Present is not expected to be called directly"); } - virtual void SetFullscreenMode(const DisplayModeAttribs &DisplayMode)override final + virtual void DILIGENT_CALL_TYPE SetFullscreenMode(const DisplayModeAttribs& DisplayMode) override final { UNEXPECTED("Fullscreen mode cannot be set through the proxy swap chain"); } - virtual void SetWindowedMode()override final + virtual void DILIGENT_CALL_TYPE SetWindowedMode() override final { UNEXPECTED("Windowed mode cannot be set through the proxy swap chain"); } - virtual void Resize(Uint32 NewWidth, Uint32 NewHeight)override final + virtual void DILIGENT_CALL_TYPE Resize(Uint32 NewWidth, Uint32 NewHeight) override final { TBase::Resize(NewWidth, NewHeight, 0); } @@ -140,36 +140,36 @@ public: void SetBackBufferIndex(Uint32 BackBufferIndex) { m_CurrentBackBufferIndex = BackBufferIndex; } - void CreateBuffers(IDXGISwapChain3 *pDXGISwapChain, ID3D12Resource *pd3d12DepthBuffer) + void CreateBuffers(IDXGISwapChain3* pDXGISwapChain, ID3D12Resource* pd3d12DepthBuffer) { DXGI_SWAP_CHAIN_DESC1 SwapChainDesc; pDXGISwapChain->GetDesc1(&SwapChainDesc); - m_SwapChainDesc.BufferCount = SwapChainDesc.BufferCount; - m_SwapChainDesc.Width = SwapChainDesc.Width; - m_SwapChainDesc.Height = SwapChainDesc.Height; + m_SwapChainDesc.BufferCount = SwapChainDesc.BufferCount; + m_SwapChainDesc.Width = SwapChainDesc.Width; + m_SwapChainDesc.Height = SwapChainDesc.Height; m_SwapChainDesc.ColorBufferFormat = DXGI_FormatToTexFormat(SwapChainDesc.Format); if (m_SwapChainDesc.ColorBufferFormat == TEX_FORMAT_RGBA8_UNORM) m_SwapChainDesc.ColorBufferFormat = TEX_FORMAT_RGBA8_UNORM_SRGB; - const auto DepthBufferDesc = pd3d12DepthBuffer->GetDesc(); + const auto DepthBufferDesc = pd3d12DepthBuffer->GetDesc(); m_SwapChainDesc.DepthBufferFormat = DXGI_FormatToTexFormat(DepthBufferDesc.Format); RefCntAutoPtr pRenderDeviceD3D12(m_pRenderDevice, IID_RenderDeviceD3D12); m_BackBuffers.reserve(m_SwapChainDesc.BufferCount); m_RTVs.reserve(m_SwapChainDesc.BufferCount); - for(Uint32 backbuff = 0; backbuff < m_SwapChainDesc.BufferCount; ++backbuff) + for (Uint32 backbuff = 0; backbuff < m_SwapChainDesc.BufferCount; ++backbuff) { - CComPtr pd3d12BackBuffer; - auto hr = pDXGISwapChain->GetBuffer(backbuff, __uuidof(pd3d12BackBuffer), reinterpret_cast( static_cast(&pd3d12BackBuffer) )); - if(FAILED(hr)) - LOG_ERROR_AND_THROW("Failed to get back buffer ", backbuff," from the swap chain"); + CComPtr pd3d12BackBuffer; + auto hr = pDXGISwapChain->GetBuffer(backbuff, __uuidof(pd3d12BackBuffer), reinterpret_cast(static_cast(&pd3d12BackBuffer))); + if (FAILED(hr)) + LOG_ERROR_AND_THROW("Failed to get back buffer ", backbuff, " from the swap chain"); RefCntAutoPtr pBackBuffer; pRenderDeviceD3D12->CreateTextureFromD3DResource(pd3d12BackBuffer, RESOURCE_STATE_UNDEFINED, &pBackBuffer); - m_BackBuffers.emplace_back( RefCntAutoPtr(pBackBuffer, IID_TextureD3D12) ); + m_BackBuffers.emplace_back(RefCntAutoPtr(pBackBuffer, IID_TextureD3D12)); TextureViewDesc TexViewDesc; TexViewDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET; - TexViewDesc.Format = TEX_FORMAT_RGBA8_UNORM_SRGB; + TexViewDesc.Format = TEX_FORMAT_RGBA8_UNORM_SRGB; RefCntAutoPtr pRTV; pBackBuffer->CreateView(TexViewDesc, &pRTV); m_RTVs.emplace_back(RefCntAutoPtr(pRTV, IID_TextureViewD3D12)); @@ -178,55 +178,55 @@ public: RefCntAutoPtr pDepthBuffer; pRenderDeviceD3D12->CreateTextureFromD3DResource(pd3d12DepthBuffer, RESOURCE_STATE_UNDEFINED, &pDepthBuffer); m_DepthBuffer = RefCntAutoPtr(pDepthBuffer, IID_TextureD3D12); - auto *pDSV = m_DepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); - m_DSV = RefCntAutoPtr(pDSV, IID_TextureViewD3D12); + auto* pDSV = m_DepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); + m_DSV = RefCntAutoPtr(pDSV, IID_TextureViewD3D12); } ITextureD3D12* GetCurrentBackBuffer() { return m_BackBuffers[m_CurrentBackBufferIndex]; } ITextureD3D12* GetDepthBuffer() { return m_DepthBuffer; } private: - std::vector> m_BackBuffers; + std::vector> m_BackBuffers; std::vector> m_RTVs; - RefCntAutoPtr m_DepthBuffer; - RefCntAutoPtr m_DSV; - Uint32 m_CurrentBackBufferIndex = 0; + RefCntAutoPtr m_DepthBuffer; + RefCntAutoPtr m_DSV; + Uint32 m_CurrentBackBufferIndex = 0; }; -} +} // namespace -DiligentGraphicsAdapterD3D12::DiligentGraphicsAdapterD3D12(UnityGraphicsD3D12Emulator& UnityGraphicsD3D12)noexcept : +DiligentGraphicsAdapterD3D12::DiligentGraphicsAdapterD3D12(UnityGraphicsD3D12Emulator& UnityGraphicsD3D12) noexcept : m_UnityGraphicsD3D12(UnityGraphicsD3D12) { - auto *GraphicsImpl = UnityGraphicsD3D12.GetGraphicsImpl(); - auto *d3d12Device = GraphicsImpl->GetD3D12Device(); + auto* GraphicsImpl = UnityGraphicsD3D12.GetGraphicsImpl(); + auto* d3d12Device = GraphicsImpl->GetD3D12Device(); - auto &DefaultAllocator = DefaultRawMemoryAllocator::GetAllocator(); - auto CmdQueue = NEW_RC_OBJ(DefaultAllocator, "UnityCommandQueueImpl instance", ProxyCommandQueueD3D12)(*GraphicsImpl); + auto& DefaultAllocator = DefaultRawMemoryAllocator::GetAllocator(); + auto CmdQueue = NEW_RC_OBJ(DefaultAllocator, "UnityCommandQueueImpl instance", ProxyCommandQueueD3D12)(*GraphicsImpl); - auto *pFactoryD3D12 = GetEngineFactoryD3D12(); - EngineD3D12CreateInfo Attribs; + auto* pFactoryD3D12 = GetEngineFactoryD3D12(); + EngineD3D12CreateInfo Attribs; std::array CmdQueues = {CmdQueue}; pFactoryD3D12->AttachToD3D12Device(d3d12Device, CmdQueues.size(), CmdQueues.data(), Attribs, &m_pDevice, &m_pDeviceCtx); } void DiligentGraphicsAdapterD3D12::InitProxySwapChain() { - auto *GraphicsImpl = m_UnityGraphicsD3D12.GetGraphicsImpl(); - auto &DefaultAllocator = DefaultRawMemoryAllocator::GetAllocator(); + auto* GraphicsImpl = m_UnityGraphicsD3D12.GetGraphicsImpl(); + auto& DefaultAllocator = DefaultRawMemoryAllocator::GetAllocator(); SwapChainDesc SCDesc; - auto ProxySwapChain = NEW_RC_OBJ(DefaultAllocator, "UnityCommandQueueImpl instance", ProxySwapChainD3D12)(m_pDevice, m_pDeviceCtx, SCDesc); + auto ProxySwapChain = NEW_RC_OBJ(DefaultAllocator, "UnityCommandQueueImpl instance", ProxySwapChainD3D12)(m_pDevice, m_pDeviceCtx, SCDesc); ProxySwapChain->CreateBuffers(GraphicsImpl->GetDXGISwapChain(), GraphicsImpl->GetDepthBuffer()); m_pProxySwapChain = ProxySwapChain; } void DiligentGraphicsAdapterD3D12::PreSwapChainResize() { - auto *pProxySwapChainD3D12 = m_pProxySwapChain.RawPtr(); - auto *pDeviceD3D12 = m_pDevice.RawPtr(); + auto* pProxySwapChainD3D12 = m_pProxySwapChain.RawPtr(); + auto* pDeviceD3D12 = m_pDevice.RawPtr(); pProxySwapChainD3D12->ReleaseBuffers(); - auto *GraphicsImpl = m_UnityGraphicsD3D12.GetGraphicsImpl(); + auto* GraphicsImpl = m_UnityGraphicsD3D12.GetGraphicsImpl(); pDeviceD3D12->ReleaseStaleResources(); // We must idle GPU GraphicsImpl->IdleGPU(); @@ -237,30 +237,30 @@ void DiligentGraphicsAdapterD3D12::PreSwapChainResize() void DiligentGraphicsAdapterD3D12::PostSwapChainResize() { - auto *GraphicsImpl = m_UnityGraphicsD3D12.GetGraphicsImpl(); - auto *pProxySwapChainD3D12 = m_pProxySwapChain.RawPtr(); + auto* GraphicsImpl = m_UnityGraphicsD3D12.GetGraphicsImpl(); + auto* pProxySwapChainD3D12 = m_pProxySwapChain.RawPtr(); pProxySwapChainD3D12->CreateBuffers(GraphicsImpl->GetDXGISwapChain(), GraphicsImpl->GetDepthBuffer()); } void DiligentGraphicsAdapterD3D12::BeginFrame() { - auto *GraphicsImpl = m_UnityGraphicsD3D12.GetGraphicsImpl(); - auto *pProxySwapChainD3D12 = m_pProxySwapChain.RawPtr(); + auto* GraphicsImpl = m_UnityGraphicsD3D12.GetGraphicsImpl(); + auto* pProxySwapChainD3D12 = m_pProxySwapChain.RawPtr(); pProxySwapChainD3D12->SetBackBufferIndex(GraphicsImpl->GetCurrentBackBufferIndex()); // Unity graphics emulator transitions render target to D3D12_RESOURCE_STATE_RENDER_TARGET, // and depth buffer to D3D12_RESOURCE_STATE_DEPTH_WRITE state pProxySwapChainD3D12->GetCurrentBackBuffer()->SetD3D12ResourceState(D3D12_RESOURCE_STATE_RENDER_TARGET); pProxySwapChainD3D12->GetDepthBuffer()->SetD3D12ResourceState(D3D12_RESOURCE_STATE_DEPTH_WRITE); } - + void DiligentGraphicsAdapterD3D12::EndFrame() { // Unity graphics emulator expects render target to be D3D12_RESOURCE_STATE_RENDER_TARGET, // and depth buffer to be in D3D12_RESOURCE_STATE_DEPTH_WRITE state - auto *pCtxD3D12 = m_pDeviceCtx.RawPtr(); - auto *pProxySwapChainD3D12 = m_pProxySwapChain.RawPtr(); - auto *pCurrentBackBuffer = pProxySwapChainD3D12->GetCurrentBackBuffer(); - auto *pDepthBuffer = pProxySwapChainD3D12->GetDepthBuffer(); + auto* pCtxD3D12 = m_pDeviceCtx.RawPtr(); + auto* pProxySwapChainD3D12 = m_pProxySwapChain.RawPtr(); + auto* pCurrentBackBuffer = pProxySwapChainD3D12->GetCurrentBackBuffer(); + auto* pDepthBuffer = pProxySwapChainD3D12->GetDepthBuffer(); pCtxD3D12->TransitionTextureState(pCurrentBackBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET); pCtxD3D12->TransitionTextureState(pDepthBuffer, D3D12_RESOURCE_STATE_DEPTH_WRITE); m_pDeviceCtx->Flush(); @@ -270,6 +270,6 @@ void DiligentGraphicsAdapterD3D12::EndFrame() } bool DiligentGraphicsAdapterD3D12::UsesReverseZ() -{ - return m_UnityGraphicsD3D12.UsesReverseZ(); +{ + return m_UnityGraphicsD3D12.UsesReverseZ(); } diff --git a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp index fd4b9e8..56c314b 100644 --- a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp +++ b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp @@ -33,22 +33,22 @@ public: CreateDummyBuffers(); } - virtual void Present(Uint32 SyncInterval)override final + virtual void DILIGENT_CALL_TYPE Present(Uint32 SyncInterval)override final { UNEXPECTED("Present is not expected to be called directly"); } - virtual void SetFullscreenMode(const DisplayModeAttribs &DisplayMode)override final + virtual void DILIGENT_CALL_TYPE SetFullscreenMode(const DisplayModeAttribs &DisplayMode)override final { UNEXPECTED("Fullscreen mode cannot be set through the proxy swap chain"); } - virtual void SetWindowedMode()override final + virtual void DILIGENT_CALL_TYPE SetWindowedMode()override final { UNEXPECTED("Windowed mode cannot be set through the proxy swap chain"); } - virtual void Resize(Uint32 NewWidth, Uint32 NewHeight)override final + virtual void DILIGENT_CALL_TYPE Resize(Uint32 NewWidth, Uint32 NewHeight)override final { if (TBase::Resize(NewWidth, NewHeight, 0)) { @@ -56,13 +56,13 @@ public: } } - virtual GLuint GetDefaultFBO()const override final + virtual GLuint DILIGENT_CALL_TYPE GetDefaultFBO()const override final { return m_UnityGraphicsGL.GetGraphicsImpl()->GetDefaultFBO(); } - virtual ITextureView* GetCurrentBackBufferRTV()override final{return m_pRTV;} - virtual ITextureView* GetDepthBufferDSV()override final{return m_pDSV;} + virtual ITextureView* DILIGENT_CALL_TYPE GetCurrentBackBufferRTV()override final{return m_pRTV;} + virtual ITextureView* DILIGENT_CALL_TYPE GetDepthBufferDSV()override final{return m_pDSV;} private: void CreateDummyBuffers() -- cgit v1.2.3