summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-10-03 03:36:54 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-10-03 03:36:54 +0000
commitc92f527a45f85f8f229bb7996e9591a9619c2a9c (patch)
tree1677e2add17b693ec92877aa2988daccfb3fd3e3 /Graphics
parentGL backend: fixed Android issues (diff)
downloadDiligentCore-c92f527a45f85f8f229bb7996e9591a9619c2a9c.tar.gz
DiligentCore-c92f527a45f85f8f229bb7996e9591a9619c2a9c.zip
HLSL2GLSL converter: implemented automatic assignment of shader storage buffer binding points
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp3
-rw-r--r--Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h2
-rw-r--r--Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp16
3 files changed, 16 insertions, 5 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
index 9e1a8a2b..c04d54ea 100644
--- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
@@ -665,7 +665,8 @@ namespace Diligent
LOG_WARNING_MESSAGE_ONCE("glShaderStorageBlockBinding is not available on this device and "
"the engine is unable to automatically assign shader storage block bindindg points. "
"To make shader storage blocks work properly, all binding points must be explicitly assigned "
- "in the shader starting from 0 and proceeding in the storage block declaration order.");
+ "in the shader starting from 0 and proceeding in the storage block declaration order. "
+ "Note that the binding points are properly assigned by HLSL->GLSL converter.");
}
++StorageBufferBindSlot;
diff --git a/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h b/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h
index 6db5cf61..9bb04d38 100644
--- a/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h
+++ b/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h
@@ -258,7 +258,7 @@ namespace Diligent
void RegisterStruct(TokenListType::iterator& Token);
void ProcessConstantBuffer(TokenListType::iterator& Token);
- void ProcessStructuredBuffer(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);
bool ProcessObjectMethod(TokenListType::iterator& Token, const TokenListType::iterator& ScopeStart, const TokenListType::iterator& ScopeEnd);
diff --git a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
index 91d4127d..11c52576 100644
--- a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
+++ b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
@@ -1423,12 +1423,20 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessConstantBuffer( TokenListT
}
}
-void HLSL2GLSLConverterImpl::ConversionStream::ProcessStructuredBuffer(TokenListType::iterator &Token)
+void HLSL2GLSLConverterImpl::ConversionStream::ProcessStructuredBuffer(TokenListType::iterator& Token, Uint32& ShaderStorageBlockBinding)
{
// StructuredBuffer<DataType> g_Data;
// ^
VERIFY_EXPR( Token->Type == TokenType::kw_StructuredBuffer || Token->Type == TokenType::kw_RWStructuredBuffer );
- Token->Literal = "layout(std140) buffer";
+ if (Token->Type == TokenType::kw_RWStructuredBuffer)
+ {
+ std::stringstream ss;
+ ss << "layout(std140, binding=" << ShaderStorageBlockBinding << ") buffer";
+ Token->Literal = ss.str();
+ ++ShaderStorageBlockBinding;
+ }
+ else
+ Token->Literal = "layout(std140) buffer";
// buffer<DataType> g_Data;
// ^
@@ -4481,6 +4489,8 @@ String HLSL2GLSLConverterImpl::ConversionStream::Convert(const Char* EntryPoint,
m_bUseInOutLocationQualifiers = UseInOutLocationQualifiers;
TokenListType TokensCopy(m_bPreserveTokens ? m_Tokens : TokenListType());
+ Uint32 ShaderStorageBlockBinding = 0;
+
std::unordered_map<String, bool> SamplersHash;
auto Token = m_Tokens.begin();
// Process constant buffers, fix floating point constants and
@@ -4495,7 +4505,7 @@ String HLSL2GLSLConverterImpl::ConversionStream::Convert(const Char* EntryPoint,
case TokenType::kw_RWStructuredBuffer:
case TokenType::kw_StructuredBuffer:
- ProcessStructuredBuffer( Token );
+ ProcessStructuredBuffer( Token, ShaderStorageBlockBinding );
break;
case TokenType::kw_struct: