From 040e4cb7e454d532d249d2a5de6f2aba0c902baa Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 24 Dec 2019 19:23:32 -0800 Subject: Updated submodules; removed tests folder (tests are now part of every submodule) --- unityplugin/GhostCubeScene/src/GhostCubeScene.cpp | 15 ++++++----- .../src/DiligentGraphicsAdapterD3D11.cpp | 2 -- .../src/DiligentGraphicsAdapterD3D12.cpp | 1 - .../src/DiligentGraphicsAdapterGL.cpp | 31 +++++++++++++++++++--- 4 files changed, 36 insertions(+), 13 deletions(-) (limited to 'unityplugin') diff --git a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp index 41d17f5..6646a10 100644 --- a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp +++ b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp @@ -148,18 +148,19 @@ void GhostCubeScene::Update(double CurrTime, double ElapsedTime) void GhostCubeScene::Render(UnityRenderingEvent RenderEventFunc) { - auto pDevice = m_DiligentGraphics->GetDevice(); - auto pCtx = m_DiligentGraphics->GetContext(); + auto* pDevice = m_DiligentGraphics->GetDevice(); + auto* pCtx = m_DiligentGraphics->GetContext(); + auto* pSwapChain = m_DiligentGraphics->GetSwapChain(); const auto& DeviceCaps = pDevice->GetDeviceCaps(); const bool bIsGL = DeviceCaps.IsGLDevice(); auto ReverseZ = m_DiligentGraphics->UsesReverseZ(); // In OpenGL, render targets must be bound to the pipeline to be cleared - ITextureView *pRTVs[] = { m_pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET) }; + ITextureView *pRTV = m_pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET); ITextureView *pDSV = m_pDepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); - pCtx->SetRenderTargets(1, pRTVs, pDSV, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + pCtx->SetRenderTargets(1, &pRTV, pDSV, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); const float ClearColor[] = { 0.f, 0.2f, 0.5f, 1.0f }; - pCtx->ClearRenderTarget(pRTVs[0], ClearColor, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + pCtx->ClearRenderTarget(pRTV, ClearColor, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); pCtx->ClearDepthStencil(pDSV, CLEAR_DEPTH_FLAG, ReverseZ ? 0.f : 1.f, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); if (DeviceCaps.DevType == DeviceType::D3D12) @@ -194,7 +195,9 @@ void GhostCubeScene::Render(UnityRenderingEvent RenderEventFunc) // We need to invalidate the context state since the plugin has used d3d11 context pCtx->InvalidateState(); - pCtx->SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + pRTV = pSwapChain->GetCurrentBackBufferRTV(); + pDSV = pSwapChain->GetDepthBufferDSV(); + pCtx->SetRenderTargets(1, &pRTV, pDSV, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); pCtx->SetPipelineState(m_pMirrorPSO); pCtx->CommitShaderResources(m_pMirrorSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); diff --git a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp index c01ff0a..fb1eb4d 100644 --- a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp +++ b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp @@ -134,8 +134,6 @@ void DiligentGraphicsAdapterD3D11::InitProxySwapChain() 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); - - m_pDeviceCtx->SetSwapChain(m_pProxySwapChain); } void DiligentGraphicsAdapterD3D11::BeginFrame() diff --git a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp index 6c09f5c..3f02630 100644 --- a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp +++ b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp @@ -219,7 +219,6 @@ void DiligentGraphicsAdapterD3D12::InitProxySwapChain() auto ProxySwapChain = NEW_RC_OBJ(DefaultAllocator, "UnityCommandQueueImpl instance", ProxySwapChainD3D12)(m_pDevice, m_pDeviceCtx, SCDesc); ProxySwapChain->CreateBuffers(GraphicsImpl->GetDXGISwapChain(), GraphicsImpl->GetDepthBuffer()); m_pProxySwapChain = ProxySwapChain; - m_pDeviceCtx->SetSwapChain(ProxySwapChain); } void DiligentGraphicsAdapterD3D12::PreSwapChainResize() diff --git a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp index 0e81625..364a9d1 100644 --- a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp +++ b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp @@ -9,6 +9,8 @@ #include "UnityGraphicsGL_Impl.h" #include "SwapChainGL.h" +#include "RenderDeviceGL.h" +#include "DeviceContextGL.h" using namespace Diligent; @@ -27,7 +29,26 @@ public: const SwapChainDesc& SCDesc ) : TBase(pRefCounters, pDevice, pDeviceContext,SCDesc), m_UnityGraphicsGL(UnityGraphicsGL) - {} + { + TextureDesc DummyTexDesc; + DummyTexDesc.Name = "Back buffer proxy"; + DummyTexDesc.Type = RESOURCE_DIM_TEX_2D; + DummyTexDesc.Format = SCDesc.ColorBufferFormat; + DummyTexDesc.Width = SCDesc.Width; + DummyTexDesc.Height = SCDesc.Height; + DummyTexDesc.BindFlags = BIND_RENDER_TARGET; + RefCntAutoPtr pDeviceGL(pDevice, IID_RenderDeviceGL); + RefCntAutoPtr pDummyRenderTarget; + pDeviceGL->CreateDummyTexture(DummyTexDesc, RESOURCE_STATE_RENDER_TARGET, &pDummyRenderTarget); + m_pRTV = pDummyRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET); + + DummyTexDesc.Name = "Depth buffer proxy"; + DummyTexDesc.Format = SCDesc.DepthBufferFormat; + DummyTexDesc.BindFlags = BIND_DEPTH_STENCIL; + RefCntAutoPtr pDummyDepthBuffer; + pDeviceGL->CreateDummyTexture(DummyTexDesc, RESOURCE_STATE_DEPTH_WRITE, &pDummyDepthBuffer); + m_pDSV = pDummyDepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); + } virtual void Present(Uint32 SyncInterval)override final { @@ -54,11 +75,13 @@ public: return m_UnityGraphicsGL.GetGraphicsImpl()->GetDefaultFBO(); } - virtual ITextureView* GetCurrentBackBufferRTV()override final{return nullptr;} - virtual ITextureView* GetDepthBufferDSV()override final{return nullptr;} + virtual ITextureView* GetCurrentBackBufferRTV()override final{return m_pRTV;} + virtual ITextureView* GetDepthBufferDSV()override final{return m_pDSV;} private: const UnityGraphicsGLCoreES_Emulator& m_UnityGraphicsGL; + RefCntAutoPtr m_pRTV; + RefCntAutoPtr m_pDSV; }; } @@ -103,7 +126,7 @@ DiligentGraphicsAdapterGL::DiligentGraphicsAdapterGL(const UnityGraphicsGLCoreES auto pProxySwapChainGL = NEW_RC_OBJ(DefaultAllocator, "ProxySwapChainGL instance", ProxySwapChainGL)(m_UnityGraphicsGL, m_pDevice, m_pDeviceCtx, SCDesc); pProxySwapChainGL->QueryInterface(IID_SwapChain, reinterpret_cast(static_cast(&m_pProxySwapChain))); - m_pDeviceCtx->SetSwapChain(m_pProxySwapChain); + RefCntAutoPtr(m_pDeviceCtx, IID_DeviceContextGL)->SetSwapChain(pProxySwapChainGL); } void DiligentGraphicsAdapterGL::BeginFrame() -- cgit v1.2.3