diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-10-19 01:50:01 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-10-19 01:50:01 +0000 |
| commit | 170f13b9c2a2ca17d13e848b037d273abd9efcf5 (patch) | |
| tree | bcf49568f1aa732044516e6c295ef4fd44e2bb7d | |
| parent | Updated core (diff) | |
| download | DiligentEngine-170f13b9c2a2ca17d13e848b037d273abd9efcf5.tar.gz DiligentEngine-170f13b9c2a2ca17d13e848b037d273abd9efcf5.zip | |
PSO creation refactoring (API240075)
| m--------- | DiligentCore | 0 | ||||
| m--------- | DiligentFX | 0 | ||||
| m--------- | DiligentSamples | 0 | ||||
| m--------- | DiligentTools | 0 | ||||
| -rw-r--r-- | Projects/Asteroids/src/asteroids_DE.cpp | 88 | ||||
| -rw-r--r-- | unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp | 44 | ||||
| -rw-r--r-- | unityplugin/GhostCubeScene/src/GhostCubeScene.cpp | 23 |
7 files changed, 82 insertions, 73 deletions
diff --git a/DiligentCore b/DiligentCore -Subproject b3fec8bd40e80115086281bce74774617aa95e2 +Subproject ff88c0507d8e8d4571b00adb421557bca1f4ed4 diff --git a/DiligentFX b/DiligentFX -Subproject 202c54b91d96ae8910574b253758bf0699ae57c +Subproject 0210497f58607308685ca3c6e0afe7980d614b5 diff --git a/DiligentSamples b/DiligentSamples -Subproject fba172ebb923b53d8633693a7aae315690cc8be +Subproject 8fc7c7c9f6a7f01ba384731dc814b8782684c76 diff --git a/DiligentTools b/DiligentTools -Subproject 8a8c9c12289ad2b0fe2044f3e38ef436b771626 +Subproject 17ce0880a5a53f62e84c950d0bc542db2bf33b8 diff --git a/Projects/Asteroids/src/asteroids_DE.cpp b/Projects/Asteroids/src/asteroids_DE.cpp index 9c15e47..80a8338 100644 --- a/Projects/Asteroids/src/asteroids_DE.cpp +++ b/Projects/Asteroids/src/asteroids_DE.cpp @@ -298,8 +298,9 @@ Asteroids::Asteroids(const Settings& settings, AsteroidsSimulation* asteroids, G // create pipeline state { - PipelineStateCreateInfo PSOCreateInfo; - PipelineStateDesc& PSODesc = PSOCreateInfo.PSODesc; + GraphicsPipelineStateCreateInfo PSOCreateInfo; + PipelineStateDesc& PSODesc = PSOCreateInfo.PSODesc; + GraphicsPipelineDesc& GraphicsPipeline = PSOCreateInfo.GraphicsPipeline; // clang-format off LayoutElement inputDesc[] = @@ -310,11 +311,11 @@ Asteroids::Asteroids(const Settings& settings, AsteroidsSimulation* asteroids, G }; // clang-format on - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = inputDesc; + GraphicsPipeline.InputLayout.LayoutElements = inputDesc; // In bindless mode we will use instance ID buffer as the third input - PSODesc.GraphicsPipeline.InputLayout.NumElements = (m_BindingMode == BindingMode::Bindless) ? 3 : 2; + GraphicsPipeline.InputLayout.NumElements = (m_BindingMode == BindingMode::Bindless) ? 3 : 2; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthFunc = COMPARISON_FUNC_GREATER_EQUAL; + GraphicsPipeline.DepthStencilDesc.DepthFunc = COMPARISON_FUNC_GREATER_EQUAL; RefCntAutoPtr<IShader> vs, ps; { @@ -379,15 +380,16 @@ Asteroids::Asteroids(const Settings& settings, AsteroidsSimulation* asteroids, G PSODesc.ResourceLayout.Variables = Variables.data(); PSODesc.ResourceLayout.NumVariables = static_cast<Uint32>(Variables.size()); - PSODesc.GraphicsPipeline.RTVFormats[0] = mSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.DSVFormat = mSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - PSODesc.Name = "Asteroids PSO"; + GraphicsPipeline.RTVFormats[0] = mSwapChain->GetDesc().ColorBufferFormat; + GraphicsPipeline.NumRenderTargets = 1; + GraphicsPipeline.DSVFormat = mSwapChain->GetDesc().DepthBufferFormat; + GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - PSODesc.GraphicsPipeline.pVS = vs; - PSODesc.GraphicsPipeline.pPS = ps; - mDevice->CreatePipelineState(PSOCreateInfo, &mAsteroidsPSO); + PSODesc.Name = "Asteroids PSO"; + + PSOCreateInfo.pVS = vs; + PSOCreateInfo.pPS = ps; + mDevice->CreateGraphicsPipelineState(PSOCreateInfo, &mAsteroidsPSO); mAsteroidsPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "DrawConstantBuffer")->Set(mDrawConstantBuffer); Uint32 NumSRBs = 0; @@ -466,8 +468,9 @@ Asteroids::Asteroids(const Settings& settings, AsteroidsSimulation* asteroids, G attribs.Desc.ShaderType = SHADER_TYPE_PIXEL; mDevice->CreateShader(attribs, &ps); - PipelineStateCreateInfo PSOCreateInfo; - PipelineStateDesc& PSODesc = PSOCreateInfo.PSODesc; + GraphicsPipelineStateCreateInfo PSOCreateInfo; + PipelineStateDesc& PSODesc = PSOCreateInfo.PSODesc; + GraphicsPipelineDesc& GraphicsPipeline = PSOCreateInfo.GraphicsPipeline; PSODesc.ResourceLayout.DefaultVariableType = SHADER_RESOURCE_VARIABLE_TYPE_STATIC; @@ -484,20 +487,22 @@ Asteroids::Asteroids(const Settings& settings, AsteroidsSimulation* asteroids, G PSODesc.ResourceLayout.StaticSamplers = &ssdesc; PSODesc.ResourceLayout.NumStaticSamplers = 1; - PSODesc.Name = "Skybox PSO"; - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = inputDesc; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof(inputDesc); + PSODesc.Name = "Skybox PSO"; + + GraphicsPipeline.InputLayout.LayoutElements = inputDesc; + GraphicsPipeline.InputLayout.NumElements = _countof(inputDesc); + + GraphicsPipeline.DepthStencilDesc.DepthFunc = COMPARISON_FUNC_GREATER_EQUAL; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthFunc = COMPARISON_FUNC_GREATER_EQUAL; - PSODesc.GraphicsPipeline.pVS = vs; - PSODesc.GraphicsPipeline.pPS = ps; + PSOCreateInfo.pVS = vs; + PSOCreateInfo.pPS = ps; - PSODesc.GraphicsPipeline.RTVFormats[0] = mSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.DSVFormat = mSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + GraphicsPipeline.RTVFormats[0] = mSwapChain->GetDesc().ColorBufferFormat; + GraphicsPipeline.NumRenderTargets = 1; + GraphicsPipeline.DSVFormat = mSwapChain->GetDesc().DepthBufferFormat; + GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - mDevice->CreatePipelineState(PSOCreateInfo, &mSkyboxPSO); + mDevice->CreateGraphicsPipelineState(PSOCreateInfo, &mSkyboxPSO); mSkyboxPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "SkyboxConstantBuffer")->Set(mSkyboxConstantBuffer); mSkyboxPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "Skybox")->Set(mSkyboxSRV); mSkyboxPSO->CreateShaderResourceBinding(&mSkyboxSRB, true); @@ -524,8 +529,9 @@ Asteroids::Asteroids(const Settings& settings, AsteroidsSimulation* asteroids, G // Sprites and fonts { - PipelineStateCreateInfo PSOCreateInfo; - PipelineStateDesc& PSODesc = PSOCreateInfo.PSODesc; + GraphicsPipelineStateCreateInfo PSOCreateInfo; + PipelineStateDesc& PSODesc = PSOCreateInfo.PSODesc; + GraphicsPipelineDesc& GraphicsPipeline = PSOCreateInfo.GraphicsPipeline; // clang-format off LayoutElement inputDesc[] = @@ -535,10 +541,10 @@ Asteroids::Asteroids(const Settings& settings, AsteroidsSimulation* asteroids, G }; // clang-format on - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = inputDesc; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof(inputDesc); + GraphicsPipeline.InputLayout.LayoutElements = inputDesc; + GraphicsPipeline.InputLayout.NumElements = _countof(inputDesc); - auto& BlendState = PSODesc.GraphicsPipeline.BlendDesc; + auto& BlendState = GraphicsPipeline.BlendDesc; { // Premultiplied over blend BlendState.RenderTargets[0].BlendEnable = TRUE; @@ -547,12 +553,12 @@ Asteroids::Asteroids(const Settings& settings, AsteroidsSimulation* asteroids, G BlendState.RenderTargets[0].DestBlend = BLEND_FACTOR_INV_SRC_ALPHA; } - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = false; + GraphicsPipeline.DepthStencilDesc.DepthEnable = false; - PSODesc.GraphicsPipeline.RTVFormats[0] = mSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.DSVFormat = mSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + GraphicsPipeline.RTVFormats[0] = mSwapChain->GetDesc().ColorBufferFormat; + GraphicsPipeline.NumRenderTargets = 1; + GraphicsPipeline.DSVFormat = mSwapChain->GetDesc().DepthBufferFormat; + GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; RefCntAutoPtr<IShader> sprite_vs, sprite_ps, font_ps; { @@ -593,15 +599,15 @@ Asteroids::Asteroids(const Settings& settings, AsteroidsSimulation* asteroids, G PSODesc.Name = "Sprite PSO"; PSODesc.ResourceLayout.DefaultVariableType = SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC; - PSODesc.GraphicsPipeline.pVS = sprite_vs; - PSODesc.GraphicsPipeline.pPS = sprite_ps; - mDevice->CreatePipelineState(PSOCreateInfo, &mSpritePSO); + PSOCreateInfo.pVS = sprite_vs; + PSOCreateInfo.pPS = sprite_ps; + mDevice->CreateGraphicsPipelineState(PSOCreateInfo, &mSpritePSO); mSpritePSO->CreateShaderResourceBinding(&mSpriteSRB, true); PSODesc.Name = "Font PSO"; PSODesc.ResourceLayout.DefaultVariableType = SHADER_RESOURCE_VARIABLE_TYPE_STATIC; - PSODesc.GraphicsPipeline.pPS = font_ps; - mDevice->CreatePipelineState(PSOCreateInfo, &mFontPSO); + PSOCreateInfo.pPS = font_ps; + mDevice->CreateGraphicsPipelineState(PSOCreateInfo, &mFontPSO); mFontPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "Tex")->Set(mFontTextureSRV); mFontPSO->CreateShaderResourceBinding(&mFontSRB, true); } diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp index ed7da87..a9a5f24 100644 --- a/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp +++ b/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp @@ -43,24 +43,26 @@ SamplePlugin::SamplePlugin(Diligent::IRenderDevice *pDevice, bool UseReverseZ, T { auto deviceType = pDevice->GetDeviceCaps().DevType; { - PipelineStateCreateInfo PSOCreateInfo; - PipelineStateDesc& PSODesc = PSOCreateInfo.PSODesc; + GraphicsPipelineStateCreateInfo PSOCreateInfo; + PipelineStateDesc& PSODesc = PSOCreateInfo.PSODesc; + GraphicsPipelineDesc& GraphicsPipeline = PSOCreateInfo.GraphicsPipeline; PSODesc.PipelineType = PIPELINE_TYPE_GRAPHICS; - PSODesc.Name = "Render sample cube PSO"; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = RTVFormat; - PSODesc.GraphicsPipeline.DSVFormat = DSVFormat; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_BACK; - PSODesc.GraphicsPipeline.RasterizerDesc.FrontCounterClockwise = deviceType == RENDER_DEVICE_TYPE_D3D11 || deviceType == RENDER_DEVICE_TYPE_D3D12 ? true : false; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthFunc = UseReverseZ ? COMPARISON_FUNC_GREATER_EQUAL : COMPARISON_FUNC_LESS_EQUAL; - - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].BlendEnable = True; - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].SrcBlend = BLEND_FACTOR_SRC_ALPHA; - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].DestBlend = BLEND_FACTOR_INV_SRC_ALPHA; - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].SrcBlendAlpha = BLEND_FACTOR_ZERO; - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].DestBlendAlpha = BLEND_FACTOR_ONE; + PSODesc.Name = "Render sample cube PSO"; + + GraphicsPipeline.NumRenderTargets = 1; + GraphicsPipeline.RTVFormats[0] = RTVFormat; + GraphicsPipeline.DSVFormat = DSVFormat; + GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_BACK; + GraphicsPipeline.RasterizerDesc.FrontCounterClockwise = deviceType == RENDER_DEVICE_TYPE_D3D11 || deviceType == RENDER_DEVICE_TYPE_D3D12 ? true : false; + GraphicsPipeline.DepthStencilDesc.DepthFunc = UseReverseZ ? COMPARISON_FUNC_GREATER_EQUAL : COMPARISON_FUNC_LESS_EQUAL; + + GraphicsPipeline.BlendDesc.RenderTargets[0].BlendEnable = True; + GraphicsPipeline.BlendDesc.RenderTargets[0].SrcBlend = BLEND_FACTOR_SRC_ALPHA; + GraphicsPipeline.BlendDesc.RenderTargets[0].DestBlend = BLEND_FACTOR_INV_SRC_ALPHA; + GraphicsPipeline.BlendDesc.RenderTargets[0].SrcBlendAlpha = BLEND_FACTOR_ZERO; + GraphicsPipeline.BlendDesc.RenderTargets[0].DestBlendAlpha = BLEND_FACTOR_ONE; ShaderCreateInfo ShaderCI; ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; @@ -93,11 +95,11 @@ SamplePlugin::SamplePlugin(Diligent::IRenderDevice *pDevice, bool UseReverseZ, T }; PSODesc.ResourceLayout.DefaultVariableType = SHADER_RESOURCE_VARIABLE_TYPE_STATIC; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = LayoutElems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof(LayoutElems); - pDevice->CreatePipelineState(PSOCreateInfo, &m_PSO); + PSOCreateInfo.pVS = pVS; + PSOCreateInfo.pPS = pPS; + GraphicsPipeline.InputLayout.LayoutElements = LayoutElems; + GraphicsPipeline.InputLayout.NumElements = _countof(LayoutElems); + pDevice->CreateGraphicsPipelineState(PSOCreateInfo, &m_PSO); m_PSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "Constants")->Set(m_VSConstants); m_PSO->CreateShaderResourceBinding(&m_SRB, true); } diff --git a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp index 3b63cdf..8586090 100644 --- a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp +++ b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp @@ -86,18 +86,19 @@ void GhostCubeScene::OnGraphicsInitialized() const auto &SCDesc = m_DiligentGraphics->GetSwapChain()->GetDesc(); auto UseReverseZ = m_DiligentGraphics->UsesReverseZ(); - PipelineStateCreateInfo PSOCreateInfo; - PipelineStateDesc& PSODesc = PSOCreateInfo.PSODesc; + GraphicsPipelineStateCreateInfo PSOCreateInfo; + PipelineStateDesc& PSODesc = PSOCreateInfo.PSODesc; + GraphicsPipelineDesc& GraphicsPipeline = PSOCreateInfo.GraphicsPipeline; PSODesc.PipelineType = PIPELINE_TYPE_GRAPHICS; PSODesc.Name = "Mirror PSO"; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; + GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = SCDesc.ColorBufferFormat; - PSODesc.GraphicsPipeline.DSVFormat = SCDesc.DepthBufferFormat; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; - PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_BACK; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthFunc = UseReverseZ ? COMPARISON_FUNC_GREATER_EQUAL : COMPARISON_FUNC_LESS_EQUAL; + GraphicsPipeline.RTVFormats[0] = SCDesc.ColorBufferFormat; + GraphicsPipeline.DSVFormat = SCDesc.DepthBufferFormat; + GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; + GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_BACK; + GraphicsPipeline.DepthStencilDesc.DepthFunc = UseReverseZ ? COMPARISON_FUNC_GREATER_EQUAL : COMPARISON_FUNC_LESS_EQUAL; ShaderCreateInfo ShaderCI; RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory; @@ -135,9 +136,9 @@ void GhostCubeScene::OnGraphicsInitialized() PSODesc.ResourceLayout.StaticSamplers = StaticSamplers; PSODesc.ResourceLayout.NumStaticSamplers = _countof(StaticSamplers); - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pPS = pPS; - pDevice->CreatePipelineState(PSOCreateInfo, &m_pMirrorPSO); + PSOCreateInfo.pVS = pVS; + PSOCreateInfo.pPS = pPS; + pDevice->CreateGraphicsPipelineState(PSOCreateInfo, &m_pMirrorPSO); m_pMirrorPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "Constants")->Set(m_pMirrorVSConstants); m_pMirrorPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2Reflection")->Set(m_pRenderTarget->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)); m_pMirrorPSO->CreateShaderResourceBinding(&m_pMirrorSRB, true); |
