summaryrefslogtreecommitdiffstats
path: root/unityplugin
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-10-19 01:50:01 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-10-19 01:50:01 +0000
commit170f13b9c2a2ca17d13e848b037d273abd9efcf5 (patch)
treebcf49568f1aa732044516e6c295ef4fd44e2bb7d /unityplugin
parentUpdated core (diff)
downloadDiligentEngine-170f13b9c2a2ca17d13e848b037d273abd9efcf5.tar.gz
DiligentEngine-170f13b9c2a2ca17d13e848b037d273abd9efcf5.zip
PSO creation refactoring (API240075)
Diffstat (limited to 'unityplugin')
-rw-r--r--unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp44
-rw-r--r--unityplugin/GhostCubeScene/src/GhostCubeScene.cpp23
2 files changed, 35 insertions, 32 deletions
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);