From 82d59de0d193554e1231b06347078d41ed8ec8d3 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 30 Nov 2018 23:15:55 -0800 Subject: Improved thread safety of enum flags; added explicit state transitions to SetRenderTargets() --- unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D11.cpp | 2 +- unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp | 2 +- .../GhostCubePlugin/PluginSource/src/RenderAPI_OpenGLCoreES.cpp | 2 +- unityplugin/GhostCubeScene/src/GhostCubeScene.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'unityplugin') diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D11.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D11.cpp index 46d3ac8..818ef04 100644 --- a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D11.cpp +++ b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D11.cpp @@ -66,7 +66,7 @@ void RenderAPI_D3D11::ProcessDeviceEvent(UnityGfxDeviceEventType type, IUnityInt void RenderAPI_D3D11::BeginRendering() { ITextureView *RTVs[] = { m_RTV }; - m_Context->SetRenderTargets(1, RTVs, m_DSV); + m_Context->SetRenderTargets(1, RTVs, m_DSV, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); } void RenderAPI_D3D11::AttachToNativeRenderTexture(void *nativeRenderTargetHandle, void *nativeDepthTextureHandle) diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp index 3f4f9ea..f62e635 100644 --- a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp +++ b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp @@ -166,7 +166,7 @@ void RenderAPI_D3D12::BeginRendering() m_RenderTarget->SetD3D12ResourceState(D3D12_RESOURCE_STATE_RENDER_TARGET); m_DepthBuffer->SetD3D12ResourceState(D3D12_RESOURCE_STATE_DEPTH_WRITE); ITextureView *RTVs[] = { m_RTV }; - m_Context->SetRenderTargets(1, RTVs, m_DSV); + m_Context->SetRenderTargets(1, RTVs, m_DSV, SET_RENDER_TARGETS_FLAG_VERIFY_STATES); } void RenderAPI_D3D12::EndRendering() diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_OpenGLCoreES.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_OpenGLCoreES.cpp index cac774d..94f6ec4 100644 --- a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_OpenGLCoreES.cpp +++ b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_OpenGLCoreES.cpp @@ -117,7 +117,7 @@ void RenderAPI_OpenGLCoreES::BeginRendering() } ITextureView *RTVs[] = { m_RTV }; - m_Context->SetRenderTargets(1, RTVs, m_DSV); + m_Context->SetRenderTargets(1, RTVs, m_DSV, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); } void RenderAPI_OpenGLCoreES::AttachToNativeRenderTexture(void *nativeRenderTargetHandle, void *nativeDepthTextureHandle) diff --git a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp index e1f9937..b3762e6 100644 --- a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp +++ b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp @@ -156,7 +156,7 @@ void GhostCubeScene::Render(UnityRenderingEvent RenderEventFunc) // In OpenGL, render targets must be bound to the pipeline to be cleared ITextureView *pRTVs[] = { m_pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET) }; ITextureView *pDSV = m_pDepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); - pCtx->SetRenderTargets(1, pRTVs, pDSV); + pCtx->SetRenderTargets(1, pRTVs, pDSV, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); const float ClearColor[] = { 0.f, 0.2f, 0.5f, 1.0f }; pCtx->ClearRenderTarget(pRTVs[0], ClearColor); pCtx->ClearDepthStencil(pDSV, CLEAR_DEPTH_FLAG, ReverseZ ? 0.f : 1.f, 0); @@ -193,7 +193,7 @@ 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); + pCtx->SetRenderTargets(0, nullptr, nullptr, SET_RENDER_TARGETS_FLAG_TRANSITION_ALL); pCtx->SetPipelineState(m_pMirrorPSO); pCtx->CommitShaderResources(m_pMirrorSRB, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES); -- cgit v1.2.3