summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-10-11 03:52:25 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-10-11 03:52:25 +0000
commita5ce694eeda2d2b6a109da9987884fe7c3d57603 (patch)
tree8fc1cab19493c0bcd3ab04fac79e4251e30a2b56 /Graphics
parentGL backend: updated comments (diff)
downloadDiligentCore-a5ce694eeda2d2b6a109da9987884fe7c3d57603.tar.gz
DiligentCore-a5ce694eeda2d2b6a109da9987884fe7c3d57603.zip
HLSL->GLSL converter: added bindings for image uniforms
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h8
-rw-r--r--Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp16
2 files changed, 17 insertions, 7 deletions
diff --git a/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h b/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h
index 9bb04d38..6da944b1 100644
--- a/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h
+++ b/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h
@@ -260,7 +260,13 @@ namespace Diligent
void ProcessConstantBuffer(TokenListType::iterator& Token);
void ProcessStructuredBuffer(TokenListType::iterator& Token, Uint32& ShaderStorageBlockBinding);
void ParseSamplers(TokenListType::iterator& ScopeStart, SamplerHashType& SamplersHash);
- void ProcessTextureDeclaration(TokenListType::iterator& Token, const std::vector<SamplerHashType>& SamplersHash, ObjectsTypeHashType& Objects, const char* SamplerSuffix);
+
+ void ProcessTextureDeclaration(TokenListType::iterator& Token,
+ const std::vector<SamplerHashType>& SamplersHash,
+ ObjectsTypeHashType& Objects,
+ const char* SamplerSuffix,
+ Uint32& ImageBinding);
+
bool ProcessObjectMethod(TokenListType::iterator& Token, const TokenListType::iterator& ScopeStart, const TokenListType::iterator& ScopeEnd);
Uint32 CountFunctionArguments(TokenListType::iterator& Token, const TokenListType::iterator& ScopeEnd);
bool ProcessRWTextureStore(TokenListType::iterator& Token, const TokenListType::iterator& ScopeEnd);
diff --git a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
index 11c52576..346cfbcf 100644
--- a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
+++ b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
@@ -1740,10 +1740,11 @@ void ParseImageFormat(const String &Comment, String& ImageFormat)
// SamplerState g_Tex2D_sampler;
// Texture3D g_Tex3D; -> sampler3D g_Tex3D;
//
-void HLSL2GLSLConverterImpl::ConversionStream::ProcessTextureDeclaration( TokenListType::iterator &Token,
- const std::vector<SamplerHashType> &Samplers,
- ObjectsTypeHashType &Objects,
- const char* SamplerSuffix )
+void HLSL2GLSLConverterImpl::ConversionStream::ProcessTextureDeclaration(TokenListType::iterator& Token,
+ const std::vector<SamplerHashType>& Samplers,
+ ObjectsTypeHashType& Objects,
+ const char* SamplerSuffix,
+ Uint32& ImageBinding)
{
auto TexDeclToken = Token;
auto TextureDim = TexDeclToken->Type;
@@ -1852,7 +1853,9 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessTextureDeclaration( TokenL
if( ImgFormat.length() != 0 )
{
- LayoutQualifier = String("layout(") + ImgFormat + ") ";
+ std::stringstream ss;
+ ss << "layout(" << ImgFormat << ", binding=" << ImageBinding++ << ")";
+ LayoutQualifier = ss.str();
}
}
@@ -4490,6 +4493,7 @@ String HLSL2GLSLConverterImpl::ConversionStream::Convert(const Char* EntryPoint,
TokenListType TokensCopy(m_bPreserveTokens ? m_Tokens : TokenListType());
Uint32 ShaderStorageBlockBinding = 0;
+ Uint32 ImageBinding = 0;
std::unordered_map<String, bool> SamplersHash;
auto Token = m_Tokens.begin();
@@ -4688,7 +4692,7 @@ String HLSL2GLSLConverterImpl::ConversionStream::Convert(const Char* EntryPoint,
{
// Process texture declaration, and add it to the top of the
// object stack
- ProcessTextureDeclaration( Token, Samplers, m_Objects.back(), SamplerSuffix );
+ ProcessTextureDeclaration( Token, Samplers, m_Objects.back(), SamplerSuffix, ImageBinding);
}
else
++Token;