summaryrefslogtreecommitdiffstats
path: root/Graphics/HLSL2GLSLConverterLib
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-10-11 16:03:03 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-10-11 16:03:03 +0000
commit854fb9130b8030bc9ff94304285eacaa3120cd14 (patch)
tree16d9f0eecd88d9f1aec3ef57d268db48ccaa631b /Graphics/HLSL2GLSLConverterLib
parentUpdated readme (diff)
downloadDiligentCore-854fb9130b8030bc9ff94304285eacaa3120cd14.tar.gz
DiligentCore-854fb9130b8030bc9ff94304285eacaa3120cd14.zip
Fixed https://github.com/DiligentGraphics/DiligentCore/issues/2 (make '_sampler' suffix configurable through shader creation attributes)
Diffstat (limited to 'Graphics/HLSL2GLSLConverterLib')
-rw-r--r--Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h7
-rw-r--r--Graphics/HLSL2GLSLConverterLib/interface/HLSL2GLSLConverter.h2
-rw-r--r--Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp17
3 files changed, 14 insertions, 12 deletions
diff --git a/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h b/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h
index 1c30c6f2..43d3bdc9 100644
--- a/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h
+++ b/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h
@@ -100,6 +100,7 @@ namespace Diligent
SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN;
bool IncludeDefinitions = false;
const Char* InputFileName = nullptr;
+ const Char* SamplerSuffix = "_sampler";
};
String Convert(ConversionAttribs &Attribs)const;
@@ -223,8 +224,8 @@ namespace Diligent
size_t NumSymbols,
bool bPreserveTokens);
- String Convert(const Char* EntryPoint, SHADER_TYPE ShaderType, bool IncludeDefintions);
- virtual void Convert(const Char* EntryPoint, SHADER_TYPE ShaderType, bool IncludeDefintions, IDataBlob **ppGLSLSource)override;
+ String Convert(const Char* EntryPoint, SHADER_TYPE ShaderType, bool IncludeDefintions, const char* SamplerSuffix);
+ virtual void Convert(const Char* EntryPoint, SHADER_TYPE ShaderType, bool IncludeDefintions, const char* SamplerSuffix, IDataBlob **ppGLSLSource)override;
IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_HLSL2GLSLConversionStream, TBase )
@@ -251,7 +252,7 @@ namespace Diligent
void ProcessConstantBuffer(TokenListType::iterator &Token);
void ProcessStructuredBuffer(TokenListType::iterator &Token);
void ParseSamplers(TokenListType::iterator &ScopeStart, SamplerHashType &SamplersHash);
- void ProcessTextureDeclaration(TokenListType::iterator &Token, const std::vector<SamplerHashType> &SamplersHash, ObjectsTypeHashType &Objects);
+ 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);
Uint32 CountFunctionArguments(TokenListType::iterator &Token, const TokenListType::iterator &ScopeEnd);
bool ProcessRWTextureStore(TokenListType::iterator &Token, const TokenListType::iterator &ScopeEnd);
diff --git a/Graphics/HLSL2GLSLConverterLib/interface/HLSL2GLSLConverter.h b/Graphics/HLSL2GLSLConverterLib/interface/HLSL2GLSLConverter.h
index 3b4d64c0..0b37ae02 100644
--- a/Graphics/HLSL2GLSLConverterLib/interface/HLSL2GLSLConverter.h
+++ b/Graphics/HLSL2GLSLConverterLib/interface/HLSL2GLSLConverter.h
@@ -39,7 +39,7 @@ static constexpr INTERFACE_ID IID_HLSL2GLSLConversionStream =
class IHLSL2GLSLConversionStream : public IObject
{
public:
- virtual void Convert(const Char* EntryPoint, SHADER_TYPE ShaderType, bool IncludeDefintions, IDataBlob **ppGLSLSource) = 0;
+ virtual void Convert(const Char* EntryPoint, SHADER_TYPE ShaderType, bool IncludeDefintions, const char* SamplerSuffix, IDataBlob **ppGLSLSource) = 0;
};
diff --git a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
index bd032a06..5e53bd4e 100644
--- a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
+++ b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
@@ -1727,7 +1727,8 @@ void ParseImageFormat(const String &Comment, String& ImageFormat)
//
void HLSL2GLSLConverterImpl::ConversionStream::ProcessTextureDeclaration( TokenListType::iterator &Token,
const std::vector<SamplerHashType> &Samplers,
- ObjectsTypeHashType &Objects )
+ ObjectsTypeHashType &Objects,
+ const char* SamplerSuffix )
{
auto TexDeclToken = Token;
auto TextureDim = TexDeclToken->Type;
@@ -1908,7 +1909,7 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessTextureDeclaration( TokenL
if( !IsRWTexture )
{
// Try to find matching sampler
- auto SamplerName = TextureName + "_sampler";
+ auto SamplerName = TextureName + SamplerSuffix;
// Search all scopes starting with the innermost
for( auto ScopeIt = Samplers.rbegin(); ScopeIt != Samplers.rend(); ++ScopeIt )
{
@@ -4372,7 +4373,7 @@ String HLSL2GLSLConverterImpl::Convert(ConversionAttribs &Attribs)const
if(Attribs.ppConversionStream == nullptr)
{
ConversionStream Stream(nullptr, *this, Attribs.InputFileName, Attribs.pSourceStreamFactory, Attribs.HLSLSource, Attribs.NumSymbols, false);
- return Stream.Convert(Attribs.EntryPoint, Attribs.ShaderType, Attribs.IncludeDefinitions);
+ return Stream.Convert(Attribs.EntryPoint, Attribs.ShaderType, Attribs.IncludeDefinitions, Attribs.SamplerSuffix);
}
else
{
@@ -4395,7 +4396,7 @@ String HLSL2GLSLConverterImpl::Convert(ConversionAttribs &Attribs)const
pStream = ValidatedCast<ConversionStream>(*Attribs.ppConversionStream);
}
- return pStream->Convert(Attribs.EntryPoint, Attribs.ShaderType, Attribs.IncludeDefinitions);
+ return pStream->Convert(Attribs.EntryPoint, Attribs.ShaderType, Attribs.IncludeDefinitions, Attribs.SamplerSuffix);
}
}
@@ -4416,11 +4417,11 @@ void HLSL2GLSLConverterImpl::CreateStream(const Char* InputFileName,
}
}
-void HLSL2GLSLConverterImpl::ConversionStream::Convert(const Char* EntryPoint, SHADER_TYPE ShaderType, bool IncludeDefintions, IDataBlob **ppGLSLSource)
+void HLSL2GLSLConverterImpl::ConversionStream::Convert(const Char* EntryPoint, SHADER_TYPE ShaderType, bool IncludeDefintions, const char* SamplerSuffix, IDataBlob **ppGLSLSource)
{
try
{
- auto GLSLSource = Convert(EntryPoint, ShaderType, IncludeDefintions);
+ auto GLSLSource = Convert(EntryPoint, ShaderType, IncludeDefintions, SamplerSuffix);
StringDataBlobImpl *pDataBlob = MakeNewRCObj<StringDataBlobImpl>()( std::move(GLSLSource) );
pDataBlob->QueryInterface( IID_DataBlob, reinterpret_cast<IObject**>(ppGLSLSource) );
}
@@ -4430,7 +4431,7 @@ void HLSL2GLSLConverterImpl::ConversionStream::Convert(const Char* EntryPoint, S
}
}
-String HLSL2GLSLConverterImpl::ConversionStream::Convert( const Char* EntryPoint, SHADER_TYPE ShaderType, bool IncludeDefintions )
+String HLSL2GLSLConverterImpl::ConversionStream::Convert( const Char* EntryPoint, SHADER_TYPE ShaderType, bool IncludeDefintions, const char* SamplerSuffix )
{
TokenListType TokensCopy(m_bPreserveTokens ? m_Tokens : TokenListType());
@@ -4629,7 +4630,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() );
+ ProcessTextureDeclaration( Token, Samplers, m_Objects.back(), SamplerSuffix );
}
else
++Token;