diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-03-07 07:08:56 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-03-07 07:08:56 +0000 |
| commit | ab236520f301243eefbd17977ff7b57f6af2fac9 (patch) | |
| tree | 925c4f2ed070e4c82337b5395f69b8c59440b83c /Graphics | |
| parent | Fixed minor issue with ShaderResources::GetShaderResourceDesc() function in D... (diff) | |
| download | DiligentCore-ab236520f301243eefbd17977ff7b57f6af2fac9.tar.gz DiligentCore-ab236520f301243eefbd17977ff7b57f6af2fac9.zip | |
Added GetShaderResourceTypeLiteralName accessory function plus fixed issue with GL resource type reflection.
Fixed https://github.com/DiligentGraphics/DiligentCore/issues/8
Diffstat (limited to 'Graphics')
3 files changed, 43 insertions, 11 deletions
diff --git a/Graphics/GraphicsAccessories/interface/GraphicsAccessories.h b/Graphics/GraphicsAccessories/interface/GraphicsAccessories.h index 4ad6ba4a..51ac05e1 100644 --- a/Graphics/GraphicsAccessories/interface/GraphicsAccessories.h +++ b/Graphics/GraphicsAccessories/interface/GraphicsAccessories.h @@ -167,21 +167,21 @@ inline TEXTURE_FORMAT GetDefaultTextureViewFormat(const TextureDesc &TexDesc, TE /// \param [in] ViewType - Texture view type. /// \return Literal name of the texture view type. -const Char *GetTexViewTypeLiteralName(TEXTURE_VIEW_TYPE ViewType); +const Char* GetTexViewTypeLiteralName(TEXTURE_VIEW_TYPE ViewType); /// Returns the literal name of a buffer view type. For instance, /// for an unordered access view, "BUFFER_VIEW_UNORDERED_ACCESS" will be returned. /// \param [in] ViewType - Buffer view type. /// \return Literal name of the buffer view type. -const Char *GetBufferViewTypeLiteralName(BUFFER_VIEW_TYPE ViewType); +const Char* GetBufferViewTypeLiteralName(BUFFER_VIEW_TYPE ViewType); /// Returns the literal name of a shader type. For instance, /// for a pixel shader, "SHADER_TYPE_PIXEL" will be returned. /// \param [in] ShaderType - Shader type. /// \return Literal name of the shader type. -const Char *GetShaderTypeLiteralName(SHADER_TYPE ShaderType); +const Char* GetShaderTypeLiteralName(SHADER_TYPE ShaderType); /// \param [in] ShaderStages - Shader stages. /// \return The string representing the shader stages. For example, @@ -197,7 +197,16 @@ String GetShaderStagesString(SHADER_TYPE ShaderStages); /// \param [in] VarType - Variable type. /// \param [in] bGetFullName - Whether to return string representation of the enum value /// \return Literal name of the shader variable type. -const Char *GetShaderVariableTypeLiteralName(SHADER_RESOURCE_VARIABLE_TYPE VarType, bool bGetFullName = false); +const Char* GetShaderVariableTypeLiteralName(SHADER_RESOURCE_VARIABLE_TYPE VarType, bool bGetFullName = false); + +/// Returns the literal name of a shader resource type. For instance, +/// for SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, if bGetFullName == true, "SHADER_RESOURCE_TYPE_CONSTANT_BUFFER" will be returned; +/// if bGetFullName == false, "constant buffer" will be returned + +/// \param [in] ResourceType - Resource type. +/// \param [in] bGetFullName - Whether to return string representation of the enum value +/// \return Literal name of the shader resource type. +const Char* GetShaderResourceTypeLiteralName(SHADER_RESOURCE_TYPE ResourceType, bool bGetFullName = false); /// Overloaded function that returns the literal name of a texture view type. /// see GetTexViewTypeLiteralName(). diff --git a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp index 7a8b1226..1a6fe2e6 100644 --- a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp +++ b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp @@ -391,9 +391,9 @@ const TextureFormatAttribs& GetTextureFormatAttribs( TEXTURE_FORMAT Format ) } -const Char *GetTexViewTypeLiteralName( TEXTURE_VIEW_TYPE ViewType ) +const Char* GetTexViewTypeLiteralName( TEXTURE_VIEW_TYPE ViewType ) { - static const Char *TexViewLiteralNames[TEXTURE_VIEW_NUM_VIEWS] = {}; + static const Char* TexViewLiteralNames[TEXTURE_VIEW_NUM_VIEWS] = {}; static bool bIsInit = false; // Note that this implementation is thread-safe // Even if two threads try to call the function at the same time, @@ -424,9 +424,9 @@ const Char *GetTexViewTypeLiteralName( TEXTURE_VIEW_TYPE ViewType ) } } -const Char *GetBufferViewTypeLiteralName( BUFFER_VIEW_TYPE ViewType ) +const Char* GetBufferViewTypeLiteralName( BUFFER_VIEW_TYPE ViewType ) { - static const Char *BuffViewLiteralNames[BUFFER_VIEW_NUM_VIEWS] = {}; + static const Char* BuffViewLiteralNames[BUFFER_VIEW_NUM_VIEWS] = {}; static bool bIsInit = false; // Note that this implementation is thread-safe // Even if two threads try to call the function at the same time, @@ -455,7 +455,7 @@ const Char *GetBufferViewTypeLiteralName( BUFFER_VIEW_TYPE ViewType ) } } -const Char *GetShaderTypeLiteralName( SHADER_TYPE ShaderType ) +const Char* GetShaderTypeLiteralName( SHADER_TYPE ShaderType ) { switch( ShaderType ) { @@ -493,7 +493,7 @@ String GetShaderStagesString(SHADER_TYPE ShaderStages) return StagesStr; } -const Char *GetShaderVariableTypeLiteralName(SHADER_RESOURCE_VARIABLE_TYPE VarType, bool bGetFullName) +const Char* GetShaderVariableTypeLiteralName(SHADER_RESOURCE_VARIABLE_TYPE VarType, bool bGetFullName) { static const Char* ShortVarTypeNameStrings[SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES]; static const Char* FullVarTypeNameStrings[SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES]; @@ -520,6 +520,24 @@ const Char *GetShaderVariableTypeLiteralName(SHADER_RESOURCE_VARIABLE_TYPE VarTy } } + +const Char* GetShaderResourceTypeLiteralName(SHADER_RESOURCE_TYPE ResourceType, bool bGetFullName) +{ + switch(ResourceType) + { + case SHADER_RESOURCE_TYPE_UNKNOWN: return bGetFullName ? "SHADER_RESOURCE_TYPE_UNKNOWN" : "unknown"; + case SHADER_RESOURCE_TYPE_CONSTANT_BUFFER: return bGetFullName ? "SHADER_RESOURCE_TYPE_CONSTANT_BUFFER" : "constant buffer"; + case SHADER_RESOURCE_TYPE_TEXTURE_SRV: return bGetFullName ? "SHADER_RESOURCE_TYPE_TEXTURE_SRV" : "texture SRV"; + case SHADER_RESOURCE_TYPE_BUFFER_SRV: return bGetFullName ? "SHADER_RESOURCE_TYPE_BUFFER_SRV" : "buffer SRV"; + case SHADER_RESOURCE_TYPE_TEXTURE_UAV: return bGetFullName ? "SHADER_RESOURCE_TYPE_TEXTURE_UAV" : "texture UAV"; + case SHADER_RESOURCE_TYPE_BUFFER_UAV: return bGetFullName ? "SHADER_RESOURCE_TYPE_BUFFER_UAV" : "buffer UAV"; + case SHADER_RESOURCE_TYPE_SAMPLER: return bGetFullName ? "SHADER_RESOURCE_TYPE_SAMPLER" : "sampler"; + default: + UNEXPECTED("Unexepcted resource type (", Uint32{ResourceType}, ")"); + return "UNKNOWN"; + } +} + const Char* GetMapTypeString(MAP_TYPE MapType) { switch(MapType) diff --git a/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp b/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp index 21a2ac5d..ff21c609 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp @@ -415,13 +415,18 @@ namespace Diligent // glGetProgramResourceLocation( program, GL_UNIFORM, name ); // The latter is only available in GL 4.4 and GLES 3.1 + auto ResourceType = dataType == GL_SAMPLER_BUFFER || + dataType == GL_INT_SAMPLER_BUFFER || + dataType == GL_UNSIGNED_INT_SAMPLER_BUFFER ? + SHADER_RESOURCE_TYPE_BUFFER_SRV : SHADER_RESOURCE_TYPE_TEXTURE_SRV; + RemoveArrayBrackets(Name.data()); Samplers.emplace_back( Owner, NamesPool.emplace(Name.data()).first->c_str(), SHADER_RESOURCE_VARIABLE_TYPE_STATIC, - SHADER_RESOURCE_TYPE_TEXTURE_SRV, + ResourceType, Uint16{0xFFFF}, // Variable index is assigned by AllocateResources static_cast<Uint32>(size), nullptr, // pResources |
