summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-03-10 00:37:37 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-03-19 00:38:18 +0000
commita615dcf84ce573e784e56a50bc8c2809f69c7ea7 (patch)
treeb57378ad5beac728138cfd5b51fd96b926168a87 /Graphics/GraphicsEngineOpenGL
parentRemoved unused ShaderVariableManagerGL::dvpVerifyBindings (diff)
downloadDiligentCore-a615dcf84ce573e784e56a50bc8c2809f69c7ea7.tar.gz
DiligentCore-a615dcf84ce573e784e56a50bc8c2809f69c7ea7.zip
Moved ProcessSignatureResources method to PipelineResourceSignatureBase
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/ShaderVariableManagerGL.hpp66
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/ShaderVariableManagerGL.cpp54
2 files changed, 33 insertions, 87 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/ShaderVariableManagerGL.hpp b/Graphics/GraphicsEngineOpenGL/include/ShaderVariableManagerGL.hpp
index 282aadd3..78e5d195 100644
--- a/Graphics/GraphicsEngineOpenGL/include/ShaderVariableManagerGL.hpp
+++ b/Graphics/GraphicsEngineOpenGL/include/ShaderVariableManagerGL.hpp
@@ -27,45 +27,29 @@
#pragma once
-// ShaderVariableManagerGL class manages resource bindings for all stages in a pipeline
+// ShaderVariableManagerGL class manages static resources of a pipeline resource signature, and
+// all types of resources for an SRB.
//
+// .-==========================-. _______________________________________________________________________________________________________________
+// || || | | | | | | | | | | |
+// __|| ShaderVariableManagerGL ||------------>| UBInfo[0] | UBInfo[1] | ... | TexInfo[0] | TexInfo[1] | ... | ImgInfo[0] | ... | SSBO[0] | ... |
+// | || || |___________|___________|_______|____________|____________|_______|____________|_________|___________|__________|
+// | '-==========================-' / \ |
+// | | m_ResIndex m_ResIndex m_ResIndex
+// | m_pSignature / \ |
+// | _____________V___________________ ________V________________________________V___________________________V__________________________________________
+// | | | | | | | | | | | | | | | |
+// | | PipelineResourceSignatureGLImpl |------>| UB[0] | UB[1] | ... | Tex[0] | Tex[1] | ... | Img[0] | Img[1] | ... | SSBOs[0] | SSBOs[1] | ... |
+// | |_________________________________| |__________|__________|_______|________|________|_______|________|________|_______|__________|__________|_______|
+// | | | | | | | | |
+// m_ResourceCache Binding Binding Binding Binding Binding Binding Binding Binding
+// | | | | | | | | |
+// | _______________________ ____V___________V________________V_________V________________V________V________________V___________V_____________
+// | | | | | | | |
+// '-->| ShaderResourceCacheGL |-------- --->| Uinform Buffers | Textures | Images | Storge Buffers |
+// |_______________________| |___________________________|___________________________|___________________________|___________________________|
//
-// To program resource cache
-//
-// A A A A A A A A
-// | | | | | | | |
-// Binding Binding Binding Binding Binding Binding Binding Binding
-// ___________________ ____|__________|__________________|________|______________|___________|______________|____________|____________
-// | | | | | | | | | | | | | | |
-// | ShaderResourcesGL |--------------->| UB[0] | UB[1] | ... | Sam[0] | Sam[1] | ... | Img[0] | Img[1] | ... | SSBOs[0] | SSBOs[1] | ... |
-// |___________________| |__________|__________|_______|________|________|_______|________|________|_______|__________|__________|_______|
-// A A A A
-// | | | |
-// Ref Ref Ref Ref
-// .-==========================-. _____|____________________________________|________________________|____________________________|______________
-// || || | | | | | | | | | | |
-// __|| ShaderVariableManagerGL ||------->| UBInfo[0] | UBInfo[1] | ... | SamInfo[0] | SamInfo[1] | ... | ImgInfo[0] | ... | SSBO[0] | ... |
-// | || || |___________|___________|_______|____________|____________|_______|____________|_________|___________|__________|
-// | '-==========================-' / \
-// | Ref Ref
-// | / \
-// | ___________________ ________V________________________________________________V_____________________________________________________
-// | | | | | | | | | | | | | | | |
-// | | ShaderResourcesGL |--------------->| UB[0] | UB[1] | ... | Sam[0] | Sam[1] | ... | Img[0] | Img[1] | ... | SSBOs[0] | SSBOs[1] | ... |
-// | |___________________| |__________|__________|_______|________|________|_______|________|________|_______|__________|__________|_______|
-// | | | | | | | | |
-// | Binding Binding Binding Binding Binding Binding Binding Binding
-// | | | | | | | | |
-// | _______________________ ____V___________V________________V_________V________________V________V________________V___________V_____________
-// | | | | | | | |
-// '-->| ShaderResourceCacheGL |----------->| Uinform Buffers | Textures | Images | Storge Buffers |
-// |_______________________| |___________________________|___________________________|___________________________|___________________________|
-//
-//
-// 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.
#include <array>
@@ -284,9 +268,6 @@ public:
}
};
-
- // dbgResourceCache is only used for sanity check and as a remainder that the resource cache must be alive
- // while Layout is alive
void BindResources(IResourceMapping* pResourceMapping, Uint32 Flags);
IShaderResourceVariable* GetVariable(const Char* Name) const;
@@ -329,13 +310,6 @@ private:
SHADER_TYPE ShaderType,
ResourceCounters& Counters);
- template <typename HandlerType>
- static void ProcessSignatureResources(const PipelineResourceSignatureGLImpl& Signature,
- const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes,
- Uint32 NumAllowedTypes,
- SHADER_TYPE ShaderType,
- HandlerType Handler);
-
// Offsets in bytes
using OffsetType = Uint16;
diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderVariableManagerGL.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderVariableManagerGL.cpp
index 8d9a0e91..29786c30 100644
--- a/Graphics/GraphicsEngineOpenGL/src/ShaderVariableManagerGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/ShaderVariableManagerGL.cpp
@@ -45,11 +45,13 @@ void ShaderVariableManagerGL::CountResources(const PipelineResourceSignatureGLIm
const SHADER_TYPE ShaderType,
ResourceCounters& Counters)
{
- ProcessSignatureResources(
- Signature, AllowedVarTypes, NumAllowedTypes, ShaderType,
- [&](Uint32 Index) //
+ Signature.ProcessResources(
+ AllowedVarTypes, NumAllowedTypes, ShaderType,
+ [&](const PipelineResourceDesc& ResDesc, Uint32) //
{
- const auto& ResDesc = Signature.GetResourceDesc(Index);
+ if (ResDesc.ResourceType == SHADER_RESOURCE_TYPE_SAMPLER)
+ return;
+
static_assert(BINDING_RANGE_COUNT == 4, "Please update the switch below to handle the new shader resource range");
switch (PipelineResourceToBindingRange(ResDesc))
{
@@ -58,45 +60,13 @@ void ShaderVariableManagerGL::CountResources(const PipelineResourceSignatureGLIm
case BINDING_RANGE_TEXTURE: ++Counters.NumTextures; break;
case BINDING_RANGE_IMAGE: ++Counters.NumImages; break;
case BINDING_RANGE_STORAGE_BUFFER: ++Counters.NumStorageBlocks; break;
- // clang-format on
+ // clang-format on
default:
UNEXPECTED("Unsupported resource type.");
}
});
}
-template <typename HandlerType>
-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);
-
- for (Uint32 var_type = 0; var_type < SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES; ++var_type)
- {
- const auto VarType = static_cast<SHADER_RESOURCE_VARIABLE_TYPE>(var_type);
- if (IsAllowedType(VarType, AllowedTypeBits))
- {
- const auto ResIdxRange = Signature.GetResourceIndexRange(VarType);
- for (Uint32 r = ResIdxRange.first; r < ResIdxRange.second; ++r)
- {
- const auto& Res = Signature.GetResourceDesc(r);
- VERIFY_EXPR(Res.VarType == VarType);
-
- if ((Res.ShaderStages & ShaderType) == 0)
- continue;
-
- if (Res.ResourceType == SHADER_RESOURCE_TYPE_SAMPLER)
- continue;
-
- Handler(r);
- }
- }
- }
-}
-
size_t ShaderVariableManagerGL::GetRequiredMemorySize(const PipelineResourceSignatureGLImpl& Signature,
const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes,
Uint32 NumAllowedTypes,
@@ -167,11 +137,13 @@ void ShaderVariableManagerGL::Initialize(const PipelineResourceSignatureGLImpl&
// Current resource index for every resource type
ResourceCounters VarCounters = {};
- ProcessSignatureResources(
- Signature, AllowedVarTypes, NumAllowedTypes, ShaderType,
- [&](Uint32 Index) //
+ Signature.ProcessResources(
+ AllowedVarTypes, NumAllowedTypes, ShaderType,
+ [&](const PipelineResourceDesc& ResDesc, Uint32 Index) //
{
- const auto& ResDesc = Signature.GetResourceDesc(Index);
+ if (ResDesc.ResourceType == SHADER_RESOURCE_TYPE_SAMPLER)
+ return;
+
static_assert(BINDING_RANGE_COUNT == 4, "Please update the switch below to handle the new shader resource range");
switch (PipelineResourceToBindingRange(ResDesc))
{