diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-11-24 19:15:28 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-11-24 19:15:28 +0000 |
| commit | 82198dc5b8284382d27d5f6776fb2531b805a83e (patch) | |
| tree | 6734be86fdf30c87a7d244e13133bc2bcf7452d2 /unityplugin | |
| parent | Updated core (fixed state transiton issue in D3D11) (diff) | |
| download | DiligentEngine-82198dc5b8284382d27d5f6776fb2531b805a83e.tar.gz DiligentEngine-82198dc5b8284382d27d5f6776fb2531b805a83e.zip | |
Added explicit control over resource transitions in draw command
Added explicit static resource binding initialization in SRB objects
Diffstat (limited to 'unityplugin')
4 files changed, 7 insertions, 3 deletions
diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp index aee52b2..adef5a3 100644 --- a/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp +++ b/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp @@ -97,6 +97,7 @@ SamplePlugin::SamplePlugin(Diligent::IRenderDevice *pDevice, bool UseReverseZ, T PSODesc.GraphicsPipeline.InputLayout.LayoutElements = LayoutElems; PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof(LayoutElems); pDevice->CreatePipelineState(PSODesc, &m_PSO); + m_PSO->CreateShaderResourceBinding(&m_SRB, true); } { @@ -163,7 +164,7 @@ void SamplePlugin::Render(Diligent::IDeviceContext *pContext, const float4x4 &Vi pContext->SetIndexBuffer(m_CubeIndexBuffer, 0); pContext->SetPipelineState(m_PSO); - pContext->CommitShaderResources(nullptr, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES); + pContext->CommitShaderResources(m_SRB, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES); DrawAttribs DrawAttrs; DrawAttrs.IsIndexed = true; diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.h b/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.h index 56b4a33..879db60 100644 --- a/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.h +++ b/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.h @@ -17,4 +17,5 @@ private: Diligent::RefCntAutoPtr<Diligent::IBuffer> m_CubeIndexBuffer; Diligent::RefCntAutoPtr<Diligent::IBuffer> m_VSConstants; Diligent::RefCntAutoPtr<Diligent::IPipelineState> m_PSO; + Diligent::RefCntAutoPtr<Diligent::IShaderResourceBinding> m_SRB; }; 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<Diligent::ITexture> m_pDepthBuffer; Diligent::RefCntAutoPtr<Diligent::IBuffer> m_pMirrorVSConstants; Diligent::RefCntAutoPtr<Diligent::IPipelineState> m_pMirrorPSO; + Diligent::RefCntAutoPtr<Diligent::IShaderResourceBinding> m_pMirrorSRB; };
\ No newline at end of file |
