diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2021-03-07 18:11:56 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2021-03-19 00:38:16 +0000 |
| commit | 176e4de5f14b5332d58f02dc6088ea751189ebba (patch) | |
| tree | b2ff0c4bbb60a71c170fa0877bcb93ede42694a7 /Graphics/GraphicsEngineOpenGL | |
| parent | Unified resource signature handling by pipeline state in D3D12, Vk and GL (diff) | |
| download | DiligentCore-176e4de5f14b5332d58f02dc6088ea751189ebba.tar.gz DiligentCore-176e4de5f14b5332d58f02dc6088ea751189ebba.zip | |
Reworked non-separable programs in GL; added more PSO and PRS validation
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
3 files changed, 19 insertions, 75 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp index f4a4cefb..9c37301f 100644 --- a/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp @@ -190,12 +190,6 @@ public: #endif private: - PipelineResourceSignatureGLImpl(IReferenceCounters* pRefCounters, - RenderDeviceGLImpl* pDevice, - const PipelineResourceSignatureDesc& Desc, - bool bIsDeviceInternal, - int Internal); - // Copies static resources from the static resource cache to the destination cache void CopyStaticResources(ShaderResourceCacheGL& ResourceCache) const; diff --git a/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp index 60cae558..1373c446 100644 --- a/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp @@ -33,6 +33,7 @@ namespace Diligent { + namespace { @@ -46,32 +47,6 @@ inline bool ResourcesCompatible(const PipelineResourceSignatureGLImpl::ResourceA // clang-format on } -struct PatchedPipelineResourceSignatureDesc : PipelineResourceSignatureDesc -{ - std::vector<ImmutableSamplerDesc> m_ImmutableSamplers; - - PatchedPipelineResourceSignatureDesc(RenderDeviceGLImpl* pDeviceGL, const PipelineResourceSignatureDesc& Desc) : - PipelineResourceSignatureDesc{Desc} - { - if (NumImmutableSamplers > 0 && ImmutableSamplers != nullptr && !pDeviceGL->GetDeviceCaps().Features.SeparablePrograms) - { - m_ImmutableSamplers.resize(NumImmutableSamplers); - - SHADER_TYPE ActiveStages = SHADER_TYPE_UNKNOWN; - for (Uint32 r = 0; r < NumResources; ++r) - ActiveStages |= Resources[r].ShaderStages; - - for (Uint32 s = 0; s < NumImmutableSamplers; ++s) - { - m_ImmutableSamplers[s] = ImmutableSamplers[s]; - m_ImmutableSamplers[s].ShaderStages |= ActiveStages; - } - - ImmutableSamplers = m_ImmutableSamplers.data(); - } - } -}; - } // namespace @@ -117,14 +92,6 @@ PipelineResourceSignatureGLImpl::PipelineResourceSignatureGLImpl(IReferenceCount RenderDeviceGLImpl* pDeviceGL, const PipelineResourceSignatureDesc& Desc, bool bIsDeviceInternal) : - PipelineResourceSignatureGLImpl{pRefCounters, pDeviceGL, PatchedPipelineResourceSignatureDesc{pDeviceGL, Desc}, bIsDeviceInternal, 0} -{} - -PipelineResourceSignatureGLImpl::PipelineResourceSignatureGLImpl(IReferenceCounters* pRefCounters, - RenderDeviceGLImpl* pDeviceGL, - const PipelineResourceSignatureDesc& Desc, - bool bIsDeviceInternal, - int) : TPipelineResourceSignatureBase{pRefCounters, pDeviceGL, Desc, bIsDeviceInternal}, m_SRBMemAllocator{GetRawAllocator()} { diff --git a/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp index 334b20d7..cc1d115d 100644 --- a/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp @@ -48,9 +48,8 @@ RefCntAutoPtr<PipelineResourceSignatureGLImpl> PipelineStateGLImpl::CreateDefaul { std::vector<PipelineResourceDesc> Resources; - const auto& LayoutDesc = CreateInfo.PSODesc.ResourceLayout; - const auto DefaultVarType = LayoutDesc.DefaultVariableType; - ShaderResourcesGL ProgramResources; + const auto& LayoutDesc = CreateInfo.PSODesc.ResourceLayout; + const auto DefaultVarType = LayoutDesc.DefaultVariableType; struct UniqueResource { @@ -83,42 +82,25 @@ RefCntAutoPtr<PipelineResourceSignatureGLImpl> PipelineStateGLImpl::CreateDefaul ResDesc.VarType = DefaultVarType; ResDesc.Flags = Flags; - if (m_IsProgramPipelineSupported) + const auto VarIndex = FindPipelineResourceLayoutVariable(LayoutDesc, Attribs.Name, ResDesc.ShaderStages, nullptr); + if (VarIndex != InvalidPipelineResourceLayoutVariableIndex) { - const auto VarIndex = FindPipelineResourceLayoutVariable(LayoutDesc, Attribs.Name, ResDesc.ShaderStages, nullptr); - if (VarIndex != InvalidPipelineResourceLayoutVariableIndex) - { - const auto& Var = LayoutDesc.Variables[VarIndex]; - ResDesc.ShaderStages = Var.ShaderStages; - ResDesc.VarType = Var.Type; - } + const auto& Var = LayoutDesc.Variables[VarIndex]; + ResDesc.ShaderStages = Var.ShaderStages; + ResDesc.VarType = Var.Type; + } - auto IterAndAssigned = UniqueResources.emplace(UniqueResource{Attribs, ResDesc.ShaderStages}); - if (IterAndAssigned.second) - { - Resources.push_back(ResDesc); - } - else - { - DEV_CHECK_ERR(IterAndAssigned.first->Attribs.ResourceType == Attribs.ResourceType, - "Shader variable '", Attribs.Name, - "' exists in multiple shaders from the same shader stage, but its type is not consistent between " - "shaders. All variables with the same name from the same shader stage must have the same type."); - } + auto IterAndAssigned = UniqueResources.emplace(UniqueResource{Attribs, ResDesc.ShaderStages}); + if (IterAndAssigned.second) + { + Resources.push_back(ResDesc); } else { - for (Uint32 i = 0; i < LayoutDesc.NumVariables; ++i) - { - const auto& Var = LayoutDesc.Variables[i]; - if ((Var.ShaderStages & Attribs.ShaderStages) != 0 && - std::strcmp(Attribs.Name, Var.Name) == 0) - { - ResDesc.VarType = Var.Type; - break; - } - } - Resources.push_back(ResDesc); + DEV_CHECK_ERR(IterAndAssigned.first->Attribs.ResourceType == Attribs.ResourceType, + "Shader variable '", Attribs.Name, + "' exists in multiple shaders from the same shader stage, but its type is not consistent between " + "shaders. All variables with the same name from the same shader stage must have the same type."); } }; const auto HandleUB = [&](const ShaderResourcesGL::UniformBufferInfo& Attribs) { @@ -134,6 +116,7 @@ RefCntAutoPtr<PipelineResourceSignatureGLImpl> PipelineStateGLImpl::CreateDefaul HandleResource(Attribs, PIPELINE_RESOURCE_FLAG_UNKNOWN); }; + ShaderResourcesGL ProgramResources; if (m_IsProgramPipelineSupported) { for (size_t i = 0; i < ShaderStages.size(); ++i) @@ -325,7 +308,7 @@ PipelineStateGLImpl::PipelineStateGLImpl(IReferenceCounters* ShaderCI.Source = "void main(){}"; ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL; ShaderCI.Desc.Name = "Dummy fragment shader"; - pDeviceGL->CreateShader(ShaderCI, reinterpret_cast<IShader**>(static_cast<ShaderGLImpl**>(&pTempPS))); + pDeviceGL->CreateShader(ShaderCI, pTempPS.DblPtr<IShader>()); Shaders.emplace_back(pTempPS); } |
