diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2021-03-04 04:25:39 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2021-03-19 00:38:14 +0000 |
| commit | 13d03c5eafcf3884abddfc69657f5a2b7e079d83 (patch) | |
| tree | 9b8cbd00730ad01b5496f79d64e67c9e5129cc71 /Graphics/GraphicsEngineOpenGL | |
| parent | OpenGL: added resource signature (diff) | |
| download | DiligentCore-13d03c5eafcf3884abddfc69657f5a2b7e079d83.tar.gz DiligentCore-13d03c5eafcf3884abddfc69657f5a2b7e079d83.zip | |
GL backend: some cosmetic code changes
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
11 files changed, 103 insertions, 102 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp index 3e6f30db..73d654a9 100644 --- a/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp @@ -30,7 +30,6 @@ #include "BufferViewGL.h" #include "BaseInterfacesGL.h" #include "BufferViewBase.hpp" -#include "RenderDevice.h" #include "GLObjectWrapper.hpp" #include "RenderDeviceGLImpl.hpp" diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContextState.hpp b/Graphics/GraphicsEngineOpenGL/include/GLContextState.hpp index 084125a3..05a3e7d3 100644 --- a/Graphics/GraphicsEngineOpenGL/include/GLContextState.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/GLContextState.hpp @@ -58,7 +58,7 @@ public: void EnsureMemoryBarrier(MEMORY_BARRIER RequiredBarriers, class AsyncWritableResource *pRes = nullptr); void SetPendingMemoryBarriers(MEMORY_BARRIER PendingBarriers); - + void EnableDepthTest (bool bEnable); void EnableDepthWrites (bool bEnable); void SetDepthFunc (COMPARISON_FUNCTION CmpFunc); diff --git a/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp index 852e24e6..ca9b7a1a 100644 --- a/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp @@ -38,8 +38,9 @@ namespace Diligent { + class RenderDeviceGLImpl; -class ShaderVariableGL; +class ShaderVariableManagerGL; enum BINDING_RANGE : Uint32 { @@ -78,7 +79,7 @@ public: static constexpr Uint32 InvalidSamplerInd = (1u << _SamplerIndBits) - 1; // clang-format off - const Uint32 CacheOffset; // SRB and Signature has the same cache offsets for static resources. + const Uint32 CacheOffset; // SRB and Signature use the same cache offsets for static resources. // Binding = m_FirstBinding[Range] + CacheOffset const Uint32 SamplerInd : _SamplerIndBits; // ImtblSamplerAssigned == true: index of the immutable sampler in m_ImmutableSamplers. // ImtblSamplerAssigned == false: index of the assigned sampler in m_Desc.Resources. @@ -95,7 +96,7 @@ public: // clang-format on { VERIFY(SamplerInd == _SamplerInd, "Sampler index (", _SamplerInd, ") exceeds maximum representable value"); - VERIFY(!_ImtblSamplerAssigned || SamplerInd != InvalidSamplerInd, "Immutable sampler assigned, but sampler index is not valid"); + VERIFY(!_ImtblSamplerAssigned || SamplerInd != InvalidSamplerInd, "Immutable sampler is assigned, but sampler index is not valid"); } bool IsSamplerAssigned() const { return SamplerInd != InvalidSamplerInd; } @@ -116,7 +117,7 @@ public: bool HasDynamicResources() const { - auto IndexRange = GetResourceIndexRange(SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); + const auto IndexRange = GetResourceIndexRange(SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); return IndexRange.second > IndexRange.first; } @@ -127,7 +128,13 @@ public: SHADER_TYPE Stages, const TBindings& Bindings) const; - void AddBindings(TBindings& Bindings) const; + __forceinline void AddBindings(TBindings& Bindings) const + { + for (Uint32 i = 0; i < Bindings.size(); ++i) + { + Bindings[i] += m_BindingCount[i]; + } + } /// Implementation of IPipelineResourceSignature::CreateShaderResourceBinding. virtual void DILIGENT_CALL_TYPE CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding, @@ -204,19 +211,10 @@ private: // Resource cache for static resource variables only ShaderResourceCacheGL* m_pStaticResCache = nullptr; - ShaderVariableGL* m_StaticVarsMgrs = nullptr; // [GetNumStaticResStages()] + ShaderVariableManagerGL* m_StaticVarsMgrs = nullptr; // [GetNumStaticResStages()] using SamplerPtr = RefCntAutoPtr<ISampler>; SamplerPtr* m_ImmutableSamplers = nullptr; // [m_Desc.NumImmutableSamplers] }; - -__forceinline void PipelineResourceSignatureGLImpl::AddBindings(TBindings& Bindings) const -{ - for (Uint32 i = 0; i < Bindings.size(); ++i) - { - Bindings[i] += m_BindingCount[i]; - } -} - } // namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp index 6442b7ee..08efc5fe 100644 --- a/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp @@ -77,7 +77,7 @@ private: ShaderResourceCacheGL m_ShaderResourceCache; // The resource layout only references mutable and dynamic variables - ShaderVariableGL* m_pShaderVarMgrs = nullptr; // [GetNumShaders()] + ShaderVariableManagerGL* m_pShaderVarMgrs = nullptr; // [GetNumShaders()] }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/include/ShaderResourcesGL.hpp b/Graphics/GraphicsEngineOpenGL/include/ShaderResourcesGL.hpp index 602bd107..7d7a954c 100644 --- a/Graphics/GraphicsEngineOpenGL/include/ShaderResourcesGL.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/ShaderResourcesGL.hpp @@ -74,7 +74,8 @@ public: /* 8 */ const SHADER_TYPE ShaderStages; /* 12 */ const SHADER_RESOURCE_TYPE ResourceType; /* 16 */ Uint32 ArraySize; -/* 20 */ // End of data +/* 20 */ +/* 24 */ // End of data // clang-format on GLResourceAttribs(const Char* _Name, diff --git a/Graphics/GraphicsEngineOpenGL/include/ShaderVariableGL.hpp b/Graphics/GraphicsEngineOpenGL/include/ShaderVariableGL.hpp index 18fd9665..78ea737a 100644 --- a/Graphics/GraphicsEngineOpenGL/include/ShaderVariableGL.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/ShaderVariableGL.hpp @@ -27,7 +27,7 @@ #pragma once -// ShaderVariableGL class manages resource bindings for all stages in a pipeline +// ShaderVariableManagerGL class manages resource bindings for all stages in a pipeline // // @@ -45,7 +45,7 @@ // Ref Ref Ref Ref // .-==========================-. _____|____________________________________|________________________|____________________________|______________ // || || | | | | | | | | | | | -// __|| ShaderVariableGL ||------->| UBInfo[0] | UBInfo[1] | ... | SamInfo[0] | SamInfo[1] | ... | ImgInfo[0] | ... | SSBO[0] | ... | +// __|| ShaderVariableManagerGL ||------->| UBInfo[0] | UBInfo[1] | ... | SamInfo[0] | SamInfo[1] | ... | ImgInfo[0] | ... | SSBO[0] | ... | // | || || |___________|___________|_______|____________|____________|_______|____________|_________|___________|__________| // | '-==========================-' / \ // | Ref Ref @@ -63,7 +63,7 @@ // |_______________________| |___________________________|___________________________|___________________________|___________________________| // // -// Note that ShaderResourcesGL are kept by PipelineStateGLImpl. ShaderVariableGL class is either part of the same PSO class, +// Note that ShaderResourcesGL are kept by PipelineStateGLImpl. ShaderVariableManagerGL class is either part of the same PSO class, // or part of ShaderResourceBindingGLImpl object that keeps a strong reference to the pipeline. So all references from GLVariableBase // are always valid. @@ -77,23 +77,23 @@ namespace Diligent { -// sizeof(ShaderVariableGL) == 48 (x64, msvc, Release) -class ShaderVariableGL +// sizeof(ShaderVariableManagerGL) == 48 (x64, msvc, Release) +class ShaderVariableManagerGL { public: - ShaderVariableGL(IObject& Owner, ShaderResourceCacheGL& ResourceCache) noexcept : + ShaderVariableManagerGL(IObject& Owner, ShaderResourceCacheGL& ResourceCache) noexcept : m_Owner(Owner), m_ResourceCache{ResourceCache} {} - ~ShaderVariableGL(); + ~ShaderVariableManagerGL(); // No copies, only moves are allowed // clang-format off - ShaderVariableGL (const ShaderVariableGL&) = delete; - ShaderVariableGL& operator = (const ShaderVariableGL&) = delete; - ShaderVariableGL ( ShaderVariableGL&&) = default; - ShaderVariableGL& operator = ( ShaderVariableGL&&) = delete; + ShaderVariableManagerGL (const ShaderVariableManagerGL&) = delete; + ShaderVariableManagerGL& operator = (const ShaderVariableManagerGL&) = delete; + ShaderVariableManagerGL ( ShaderVariableManagerGL&&) = default; + ShaderVariableManagerGL& operator = ( ShaderVariableManagerGL&&) = delete; // clang-format on void Initialize(const PipelineResourceSignatureGLImpl& Signature, @@ -120,10 +120,10 @@ public: } - struct GLVariableBase : public ShaderVariableBase<ShaderVariableGL> + struct GLVariableBase : public ShaderVariableBase<ShaderVariableManagerGL> { - using TBase = ShaderVariableBase<ShaderVariableGL>; - GLVariableBase(ShaderVariableGL& ParentLayout, Uint32 ResIndex) : + using TBase = ShaderVariableBase<ShaderVariableManagerGL>; + GLVariableBase(ShaderVariableManagerGL& ParentLayout, Uint32 ResIndex) : TBase{ParentLayout}, m_ResIndex{ResIndex} {} @@ -155,7 +155,7 @@ public: struct UniformBuffBindInfo final : GLVariableBase { - UniformBuffBindInfo(ShaderVariableGL& ParentLayout, Uint32 ResIndex) : + UniformBuffBindInfo(ShaderVariableManagerGL& ParentLayout, Uint32 ResIndex) : GLVariableBase{ParentLayout, ResIndex} {} @@ -187,7 +187,7 @@ public: struct SamplerBindInfo final : GLVariableBase { - SamplerBindInfo(ShaderVariableGL& ParentLayout, Uint32 ResIndex) : + SamplerBindInfo(ShaderVariableManagerGL& ParentLayout, Uint32 ResIndex) : GLVariableBase{ParentLayout, ResIndex} {} @@ -219,7 +219,7 @@ public: struct ImageBindInfo final : GLVariableBase { - ImageBindInfo(ShaderVariableGL& ParentLayout, Uint32 ResIndex) : + ImageBindInfo(ShaderVariableManagerGL& ParentLayout, Uint32 ResIndex) : GLVariableBase{ParentLayout, ResIndex} {} @@ -251,7 +251,7 @@ public: struct StorageBufferBindInfo final : GLVariableBase { - StorageBufferBindInfo(ShaderVariableGL& ParentLayout, Uint32 ResIndex) : + StorageBufferBindInfo(ShaderVariableManagerGL& ParentLayout, Uint32 ResIndex) : GLVariableBase{ParentLayout, ResIndex} {} @@ -417,25 +417,25 @@ private: template <> -inline Uint32 ShaderVariableGL::GetNumResources<ShaderVariableGL::UniformBuffBindInfo>() const +inline Uint32 ShaderVariableManagerGL::GetNumResources<ShaderVariableManagerGL::UniformBuffBindInfo>() const { return GetNumUBs(); } template <> -inline Uint32 ShaderVariableGL::GetNumResources<ShaderVariableGL::SamplerBindInfo>() const +inline Uint32 ShaderVariableManagerGL::GetNumResources<ShaderVariableManagerGL::SamplerBindInfo>() const { return GetNumTextures(); } template <> -inline Uint32 ShaderVariableGL::GetNumResources<ShaderVariableGL::ImageBindInfo>() const +inline Uint32 ShaderVariableManagerGL::GetNumResources<ShaderVariableManagerGL::ImageBindInfo>() const { return GetNumImages(); } template <> -inline Uint32 ShaderVariableGL::GetNumResources<ShaderVariableGL::StorageBufferBindInfo>() const +inline Uint32 ShaderVariableManagerGL::GetNumResources<ShaderVariableManagerGL::StorageBufferBindInfo>() const { return GetNumStorageBuffers(); } @@ -443,29 +443,29 @@ inline Uint32 ShaderVariableGL::GetNumResources<ShaderVariableGL::StorageBufferB template <> -inline ShaderVariableGL::OffsetType ShaderVariableGL:: - GetResourceOffset<ShaderVariableGL::UniformBuffBindInfo>() const +inline ShaderVariableManagerGL::OffsetType ShaderVariableManagerGL:: + GetResourceOffset<ShaderVariableManagerGL::UniformBuffBindInfo>() const { return m_UBOffset; } template <> -inline ShaderVariableGL::OffsetType ShaderVariableGL:: - GetResourceOffset<ShaderVariableGL::SamplerBindInfo>() const +inline ShaderVariableManagerGL::OffsetType ShaderVariableManagerGL:: + GetResourceOffset<ShaderVariableManagerGL::SamplerBindInfo>() const { return m_TextureOffset; } template <> -inline ShaderVariableGL::OffsetType ShaderVariableGL:: - GetResourceOffset<ShaderVariableGL::ImageBindInfo>() const +inline ShaderVariableManagerGL::OffsetType ShaderVariableManagerGL:: + GetResourceOffset<ShaderVariableManagerGL::ImageBindInfo>() const { return m_ImageOffset; } template <> -inline ShaderVariableGL::OffsetType ShaderVariableGL:: - GetResourceOffset<ShaderVariableGL::StorageBufferBindInfo>() const +inline ShaderVariableManagerGL::OffsetType ShaderVariableManagerGL:: + GetResourceOffset<ShaderVariableManagerGL::StorageBufferBindInfo>() const { return m_StorageBufferOffset; } diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp index d5812133..fa4d4e10 100644 --- a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp @@ -351,7 +351,7 @@ void BufferGLImpl::BufferMemoryBarrier(MEMORY_BARRIER RequiredBarriers, GLContex #if GL_ARB_shader_image_load_store # ifdef DILIGENT_DEBUG { - constexpr Uint32 BufferBarriers = MEMORY_BARRIER_ALL_BUFFER_BARRIERS; + constexpr auto BufferBarriers = MEMORY_BARRIER_ALL_BUFFER_BARRIERS; VERIFY((RequiredBarriers & BufferBarriers) != 0, "At least one buffer memory barrier flag should be set"); VERIFY((RequiredBarriers & ~BufferBarriers) == 0, "Inappropriate buffer memory barrier flag"); } diff --git a/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp index 42131f1e..e321e4d5 100644 --- a/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/PipelineResourceSignatureGLImpl.cpp @@ -93,7 +93,7 @@ const char* GetBindingRangeName(BINDING_RANGE Range) BINDING_RANGE PipelineResourceToBindingRange(const PipelineResourceDesc& Desc) { - static_assert(SHADER_RESOURCE_TYPE_LAST == SHADER_RESOURCE_TYPE_ACCEL_STRUCT, "Please update the switch below to handle the new shader resource type"); + static_assert(SHADER_RESOURCE_TYPE_LAST == 8, "Please update the switch below to handle the new shader resource type"); switch (Desc.ResourceType) { // clang-format off @@ -102,7 +102,7 @@ BINDING_RANGE PipelineResourceToBindingRange(const PipelineResourceDesc& Desc) case SHADER_RESOURCE_TYPE_BUFFER_SRV: return (Desc.Flags & PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER) ? BINDING_RANGE_TEXTURE : BINDING_RANGE_STORAGE_BUFFER; case SHADER_RESOURCE_TYPE_TEXTURE_UAV: return BINDING_RANGE_IMAGE; case SHADER_RESOURCE_TYPE_BUFFER_UAV: return (Desc.Flags & PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER) ? BINDING_RANGE_IMAGE : BINDING_RANGE_STORAGE_BUFFER; - // clang-format on + // clang-format on case SHADER_RESOURCE_TYPE_SAMPLER: case SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT: case SHADER_RESOURCE_TYPE_ACCEL_STRUCT: @@ -140,7 +140,7 @@ PipelineResourceSignatureGLImpl::PipelineResourceSignatureGLImpl(IReferenceCount if (NumStaticResStages > 0) { MemPool.AddSpace<ShaderResourceCacheGL>(1); - MemPool.AddSpace<ShaderVariableGL>(NumStaticResStages); + MemPool.AddSpace<ShaderVariableManagerGL>(NumStaticResStages); } MemPool.Reserve(); @@ -158,7 +158,7 @@ PipelineResourceSignatureGLImpl::PipelineResourceSignatureGLImpl(IReferenceCount if (NumStaticResStages > 0) { m_pStaticResCache = MemPool.Construct<ShaderResourceCacheGL>(ShaderResourceCacheGL::CacheContentType::Signature); - m_StaticVarsMgrs = MemPool.ConstructArray<ShaderVariableGL>(NumStaticResStages, std::ref(*this), std::ref(*m_pStaticResCache)); + m_StaticVarsMgrs = MemPool.ConstructArray<ShaderVariableManagerGL>(NumStaticResStages, std::ref(*this), std::ref(*m_pStaticResCache)); } CreateLayouts(); @@ -326,7 +326,7 @@ void PipelineResourceSignatureGLImpl::Destruct() for (auto Idx : m_StaticResStageIndex) { if (Idx >= 0) - m_StaticVarsMgrs[Idx].~ShaderVariableGL(); + m_StaticVarsMgrs[Idx].~ShaderVariableManagerGL(); } m_StaticVarsMgrs = nullptr; } @@ -375,7 +375,7 @@ void PipelineResourceSignatureGLImpl::ApplyBindings(GLObjectWrappers::GLProgramO { auto UniformBlockIndex = glGetUniformBlockIndex(GLProgram, ResDesc.Name); if (UniformBlockIndex == GL_INVALID_INDEX) - break; // Uniform block defined in resource signature, but not presented in shader program. + break; // Uniform block is defined in resource signature, but not presented in shader program. for (Uint32 ArrInd = 0; ArrInd < ResDesc.ArraySize; ++ArrInd) { @@ -388,7 +388,7 @@ void PipelineResourceSignatureGLImpl::ApplyBindings(GLObjectWrappers::GLProgramO { auto UniformLocation = glGetUniformLocation(GLProgram, ResDesc.Name); if (UniformLocation < 0) - break; // Uniform defined in resource signature, but not presented in shader program. + break; // Uniform is defined in resource signature, but not presented in shader program. for (Uint32 ArrInd = 0; ArrInd < ResDesc.ArraySize; ++ArrInd) { diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp index a2713fbf..06f364c6 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderResourceBindingGLImpl.cpp @@ -50,9 +50,9 @@ ShaderResourceBindingGLImpl::ShaderResourceBindingGLImpl(IReferenceCounters* const auto NumShaders = GetNumShaders(); FixedLinearAllocator MemPool{GetRawAllocator()}; - MemPool.AddSpace<ShaderVariableGL>(NumShaders); + MemPool.AddSpace<ShaderVariableManagerGL>(NumShaders); MemPool.Reserve(); - m_pShaderVarMgrs = MemPool.ConstructArray<ShaderVariableGL>(NumShaders, std::ref(*this), std::ref(m_ShaderResourceCache)); + m_pShaderVarMgrs = MemPool.ConstructArray<ShaderVariableManagerGL>(NumShaders, std::ref(*this), std::ref(m_ShaderResourceCache)); // The memory is now owned by ShaderResourceBindingVkImpl and will be freed by Destruct(). auto* Ptr = MemPool.ReleaseOwnership(); @@ -98,7 +98,7 @@ void ShaderResourceBindingGLImpl::Destruct() { const auto NumShaders = GetNumShaders(); for (Uint32 s = 0; s < NumShaders; ++s) - m_pShaderVarMgrs[s].~ShaderVariableGL(); + m_pShaderVarMgrs[s].~ShaderVariableManagerGL(); RawAllocator.Free(m_pShaderVarMgrs); m_pShaderVarMgrs = nullptr; diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderResourcesGL.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderResourcesGL.cpp index a0eb2e25..6096d5f9 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderResourcesGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderResourcesGL.cpp @@ -36,8 +36,10 @@ namespace Diligent { + namespace { + void GLTextureTypeToResourceDim(GLenum TextureType, RESOURCE_DIMENSION& ResDim, bool& IsMS) { IsMS = false; @@ -181,6 +183,7 @@ void GLTextureTypeToResourceDim(GLenum TextureType, RESOURCE_DIMENSION& ResDim, #endif } } + } // namespace ShaderResourcesGL::ShaderResourcesGL(ShaderResourcesGL&& Program) noexcept : diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp index 68485b78..af9f8f34 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp @@ -36,11 +36,11 @@ namespace Diligent { -void ShaderVariableGL::CountResources(const PipelineResourceSignatureGLImpl& Signature, - const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, - Uint32 NumAllowedTypes, - const SHADER_TYPE ShaderType, - ResourceCounters& Counters) +void ShaderVariableManagerGL::CountResources(const PipelineResourceSignatureGLImpl& Signature, + const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, + Uint32 NumAllowedTypes, + const SHADER_TYPE ShaderType, + ResourceCounters& Counters) { ProcessSignatureResources( Signature, AllowedVarTypes, NumAllowedTypes, ShaderType, @@ -62,11 +62,11 @@ void ShaderVariableGL::CountResources(const PipelineResourceSignatureGLImpl& Sig } template <typename HandlerType> -void ShaderVariableGL::ProcessSignatureResources(const PipelineResourceSignatureGLImpl& Signature, - const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, - Uint32 NumAllowedTypes, - SHADER_TYPE ShaderType, - HandlerType Handler) +void ShaderVariableManagerGL::ProcessSignatureResources(const PipelineResourceSignatureGLImpl& Signature, + const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, + Uint32 NumAllowedTypes, + SHADER_TYPE ShaderType, + HandlerType Handler) { const Uint32 AllowedTypeBits = GetAllowedTypeBits(AllowedVarTypes, NumAllowedTypes); @@ -93,10 +93,10 @@ void ShaderVariableGL::ProcessSignatureResources(const PipelineResourceSignature } } -size_t ShaderVariableGL::GetRequiredMemorySize(const PipelineResourceSignatureGLImpl& Signature, - const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, - Uint32 NumAllowedTypes, - SHADER_TYPE ShaderType) +size_t ShaderVariableManagerGL::GetRequiredMemorySize(const PipelineResourceSignatureGLImpl& Signature, + const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, + Uint32 NumAllowedTypes, + SHADER_TYPE ShaderType) { ResourceCounters Counters; CountResources(Signature, AllowedVarTypes, NumAllowedTypes, ShaderType, Counters); @@ -110,10 +110,10 @@ size_t ShaderVariableGL::GetRequiredMemorySize(const PipelineResourceSignatureGL return RequiredSize; } -void ShaderVariableGL::Initialize(const PipelineResourceSignatureGLImpl& Signature, - const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, - Uint32 NumAllowedTypes, - SHADER_TYPE ShaderType) +void ShaderVariableManagerGL::Initialize(const PipelineResourceSignatureGLImpl& Signature, + const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, + Uint32 NumAllowedTypes, + SHADER_TYPE ShaderType) { ResourceCounters Counters; CountResources(Signature, AllowedVarTypes, NumAllowedTypes, ShaderType, Counters); @@ -192,7 +192,7 @@ void ShaderVariableGL::Initialize(const PipelineResourceSignatureGLImpl& Signatu // clang-format on } -ShaderVariableGL::~ShaderVariableGL() +ShaderVariableManagerGL::~ShaderVariableManagerGL() { // clang-format off HandleResources( @@ -219,8 +219,8 @@ ShaderVariableGL::~ShaderVariableGL() // clang-format on } -void ShaderVariableGL::UniformBuffBindInfo::BindResource(IDeviceObject* pBuffer, - Uint32 ArrayIndex) +void ShaderVariableManagerGL::UniformBuffBindInfo::BindResource(IDeviceObject* pBuffer, + Uint32 ArrayIndex) { const auto& Desc = GetDesc(); const auto& Attr = GetAttribs(); @@ -245,8 +245,8 @@ void ShaderVariableGL::UniformBuffBindInfo::BindResource(IDeviceObject* pBuffer, -void ShaderVariableGL::SamplerBindInfo::BindResource(IDeviceObject* pView, - Uint32 ArrayIndex) +void ShaderVariableManagerGL::SamplerBindInfo::BindResource(IDeviceObject* pView, + Uint32 ArrayIndex) { const auto& Desc = GetDesc(); const auto& Attr = GetAttribs(); @@ -309,8 +309,8 @@ void ShaderVariableGL::SamplerBindInfo::BindResource(IDeviceObject* pView, } -void ShaderVariableGL::ImageBindInfo::BindResource(IDeviceObject* pView, - Uint32 ArrayIndex) +void ShaderVariableManagerGL::ImageBindInfo::BindResource(IDeviceObject* pView, + Uint32 ArrayIndex) { const auto& Desc = GetDesc(); const auto& Attr = GetAttribs(); @@ -367,8 +367,8 @@ void ShaderVariableGL::ImageBindInfo::BindResource(IDeviceObject* pView, -void ShaderVariableGL::StorageBufferBindInfo::BindResource(IDeviceObject* pView, - Uint32 ArrayIndex) +void ShaderVariableManagerGL::StorageBufferBindInfo::BindResource(IDeviceObject* pView, + Uint32 ArrayIndex) { const auto& Desc = GetDesc(); const auto& Attr = GetAttribs(); @@ -453,7 +453,7 @@ private: }; -void ShaderVariableGL::BindResources(IResourceMapping* pResourceMapping, Uint32 Flags) +void ShaderVariableManagerGL::BindResources(IResourceMapping* pResourceMapping, Uint32 Flags) { if (pResourceMapping == nullptr) { @@ -493,7 +493,7 @@ void ShaderVariableGL::BindResources(IResourceMapping* pResourceMapping, Uint32 template <typename ResourceType> -IShaderResourceVariable* ShaderVariableGL::GetResourceByName(const Char* Name) const +IShaderResourceVariable* ShaderVariableManagerGL::GetResourceByName(const Char* Name) const { auto NumResources = GetNumResources<ResourceType>(); for (Uint32 res = 0; res < NumResources; ++res) @@ -508,7 +508,7 @@ IShaderResourceVariable* ShaderVariableGL::GetResourceByName(const Char* Name) c } -IShaderResourceVariable* ShaderVariableGL::GetVariable(const Char* Name) const +IShaderResourceVariable* ShaderVariableManagerGL::GetVariable(const Char* Name) const { if (auto* pUB = GetResourceByName<UniformBuffBindInfo>(Name)) return pUB; @@ -525,7 +525,7 @@ IShaderResourceVariable* ShaderVariableGL::GetVariable(const Char* Name) const return nullptr; } -Uint32 ShaderVariableGL::GetVariableCount() const +Uint32 ShaderVariableManagerGL::GetVariableCount() const { return GetNumUBs() + GetNumTextures() + GetNumImages() + GetNumStorageBuffers(); } @@ -533,8 +533,8 @@ Uint32 ShaderVariableGL::GetVariableCount() const class ShaderVariableLocator { public: - ShaderVariableLocator(const ShaderVariableGL& _Layout, - Uint32 _Index) : + ShaderVariableLocator(const ShaderVariableManagerGL& _Layout, + Uint32 _Index) : // clang-format off Layout {_Layout}, Index {_Index} @@ -555,12 +555,12 @@ public: } private: - ShaderVariableGL const& Layout; - Uint32 Index; + ShaderVariableManagerGL const& Layout; + Uint32 Index; }; -IShaderResourceVariable* ShaderVariableGL::GetVariable(Uint32 Index) const +IShaderResourceVariable* ShaderVariableManagerGL::GetVariable(Uint32 Index) const { ShaderVariableLocator VarLocator(*this, Index); @@ -585,7 +585,7 @@ IShaderResourceVariable* ShaderVariableGL::GetVariable(Uint32 Index) const class ShaderVariableIndexLocator { public: - ShaderVariableIndexLocator(const ShaderVariableGL& _Layout, const ShaderVariableGL::GLVariableBase& Variable) : + ShaderVariableIndexLocator(const ShaderVariableManagerGL& _Layout, const ShaderVariableManagerGL::GLVariableBase& Variable) : // clang-format off Layout {_Layout}, VarOffset(reinterpret_cast<const Uint8*>(&Variable) - reinterpret_cast<const Uint8*>(_Layout.m_ResourceBuffer.get())) @@ -616,13 +616,13 @@ public: Uint32 GetIndex() const { return Index; } private: - const ShaderVariableGL& Layout; - const size_t VarOffset; - Uint32 Index = 0; + const ShaderVariableManagerGL& Layout; + const size_t VarOffset; + Uint32 Index = 0; }; -Uint32 ShaderVariableGL::GetVariableIndex(const GLVariableBase& Var) const +Uint32 ShaderVariableManagerGL::GetVariableIndex(const GLVariableBase& Var) const { if (!m_ResourceBuffer) { @@ -649,7 +649,7 @@ Uint32 ShaderVariableGL::GetVariableIndex(const GLVariableBase& Var) const } #ifdef DILIGENT_DEVELOPMENT -bool ShaderVariableGL::dvpVerifyBindings(const ShaderResourceCacheGL& ResourceCache) const +bool ShaderVariableManagerGL::dvpVerifyBindings(const ShaderResourceCacheGL& ResourceCache) const { # define LOG_MISSING_BINDING(VarType, BindInfo, ArrIndex) LOG_ERROR_MESSAGE("No resource is bound to ", VarType, " variable '", GetShaderResourcePrintName(Desc, ArrIndex), "'") |
