From eff4c4323a9ab2cfe168d01bcfd919e574547cb6 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 4 Mar 2019 21:59:51 -0800 Subject: Fixed Unity plugin to comply with the new API --- .../PluginSource/src/SamplePlugin.cpp | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'unityplugin/GhostCubePlugin/PluginSource') diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp index 859951d..d13c5fb 100644 --- a/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp +++ b/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp @@ -60,30 +60,28 @@ SamplePlugin::SamplePlugin(Diligent::IRenderDevice *pDevice, bool UseReverseZ, T PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].SrcBlendAlpha = BLEND_FACTOR_ZERO; PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].DestBlendAlpha = BLEND_FACTOR_ONE; - ShaderCreationAttribs CreationAttribs; - CreationAttribs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - CreationAttribs.Desc.DefaultVariableType = SHADER_VARIABLE_TYPE_STATIC; - CreationAttribs.UseCombinedTextureSamplers = true; + ShaderCreateInfo ShaderCI; + ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + ShaderCI.UseCombinedTextureSamplers = true; CreateUniformBuffer(pDevice, sizeof(float4x4), "SamplePlugin: VS constants CB", &m_VSConstants); RefCntAutoPtr pVS; { - CreationAttribs.Desc.ShaderType = SHADER_TYPE_VERTEX; - CreationAttribs.EntryPoint = "main"; - CreationAttribs.Desc.Name = "Sample cube VS"; - CreationAttribs.Source = VSSource; - pDevice->CreateShader(CreationAttribs, &pVS); - pVS->GetShaderVariable("Constants")->Set(m_VSConstants); + ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX; + ShaderCI.EntryPoint = "main"; + ShaderCI.Desc.Name = "Sample cube VS"; + ShaderCI.Source = VSSource; + pDevice->CreateShader(ShaderCI, &pVS); } RefCntAutoPtr pPS; { - CreationAttribs.Desc.ShaderType = SHADER_TYPE_PIXEL; - CreationAttribs.EntryPoint = "main"; - CreationAttribs.Desc.Name = "Sample cube PS"; - CreationAttribs.Source = PSSource; - pDevice->CreateShader(CreationAttribs, &pPS); + ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL; + ShaderCI.EntryPoint = "main"; + ShaderCI.Desc.Name = "Sample cube PS"; + ShaderCI.Source = PSSource; + pDevice->CreateShader(ShaderCI, &pPS); } LayoutElement LayoutElems[] = @@ -92,12 +90,15 @@ SamplePlugin::SamplePlugin(Diligent::IRenderDevice *pDevice, bool UseReverseZ, T LayoutElement{1, 0, 4, VT_FLOAT32, False} }; + 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(PSODesc, &m_PSO); m_PSO->CreateShaderResourceBinding(&m_SRB, true); + + m_PSO->GetStaticShaderVariable(SHADER_TYPE_VERTEX, "Constants")->Set(m_VSConstants); } { -- cgit v1.2.3