From 82198dc5b8284382d27d5f6776fb2531b805a83e Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 24 Nov 2018 11:15:28 -0800 Subject: Added explicit control over resource transitions in draw command Added explicit static resource binding initialization in SRB objects --- unityplugin/GhostCubeScene/src/GhostCubeScene.cpp | 5 +++-- unityplugin/GhostCubeScene/src/GhostCubeScene.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'unityplugin/GhostCubeScene/src') diff --git a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp index 62fa900..e1f9937 100644 --- a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp +++ b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp @@ -84,7 +84,7 @@ void GhostCubeScene::OnGraphicsInitialized() PipelineStateDesc PSODesc; PSODesc.IsComputePipeline = false; - PSODesc.Name = "Render sample cube PSO"; + PSODesc.Name = "Mirror PSO"; PSODesc.GraphicsPipeline.NumRenderTargets = 1; PSODesc.GraphicsPipeline.RTVFormats[0] = SCDesc.ColorBufferFormat == TEX_FORMAT_RGBA8_UNORM ? TEX_FORMAT_RGBA8_UNORM_SRGB : SCDesc.ColorBufferFormat; @@ -132,6 +132,7 @@ void GhostCubeScene::OnGraphicsInitialized() PSODesc.GraphicsPipeline.pVS = pVS; PSODesc.GraphicsPipeline.pPS = pPS; pDevice->CreatePipelineState(PSODesc, &m_pMirrorPSO); + m_pMirrorPSO->CreateShaderResourceBinding(&m_pMirrorSRB, true); } #if D3D12_SUPPORTED m_pStateTransitionHandler.reset(new GhostCubeSceneResTrsnHelper(*this)); @@ -194,7 +195,7 @@ void GhostCubeScene::Render(UnityRenderingEvent RenderEventFunc) pCtx->InvalidateState(); pCtx->SetRenderTargets(0, nullptr, nullptr); pCtx->SetPipelineState(m_pMirrorPSO); - pCtx->CommitShaderResources(nullptr, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES); + pCtx->CommitShaderResources(m_pMirrorSRB, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES); { float4x4 MirrorWorldView = scaleMatrix(5,5,5) * rotationX(PI_F*0.6f) * translationMatrix(0.f, -3.0f, 10.0f); diff --git a/unityplugin/GhostCubeScene/src/GhostCubeScene.h b/unityplugin/GhostCubeScene/src/GhostCubeScene.h index f993791..0580f86 100644 --- a/unityplugin/GhostCubeScene/src/GhostCubeScene.h +++ b/unityplugin/GhostCubeScene/src/GhostCubeScene.h @@ -58,4 +58,5 @@ private: Diligent::RefCntAutoPtr m_pDepthBuffer; Diligent::RefCntAutoPtr m_pMirrorVSConstants; Diligent::RefCntAutoPtr m_pMirrorPSO; + Diligent::RefCntAutoPtr m_pMirrorSRB; }; \ No newline at end of file -- cgit v1.2.3