summaryrefslogtreecommitdiffstats
path: root/Graphics/HLSL2GLSLConverterLib
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-08-09 16:05:51 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-08-09 16:05:51 +0000
commit86ce0b5436ef7b44563648feab2ddde01a9af784 (patch)
treeb87c4ee922a65d81d3e3e3965bf5bcf08920ec73 /Graphics/HLSL2GLSLConverterLib
parentImproved incorrect buffer parameters error reporting (diff)
downloadDiligentCore-86ce0b5436ef7b44563648feab2ddde01a9af784.tar.gz
DiligentCore-86ce0b5436ef7b44563648feab2ddde01a9af784.zip
OpenGL backend: added handling of Buffers and RW Buffers
Diffstat (limited to 'Graphics/HLSL2GLSLConverterLib')
-rw-r--r--Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h12
-rw-r--r--Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h12
-rw-r--r--Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp18
3 files changed, 38 insertions, 4 deletions
diff --git a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h
index 928f3196..a428e2f9 100644
--- a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h
+++ b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h
@@ -786,6 +786,11 @@ vec4 _frexp(vec4 f4, out vec4 fexp4)
_TypeConvertStore( NumberOfSamples, 0 );\
}
+#define GetTexBufferDimensions_1(Sampler, Width)\
+{ \
+ _TypeConvertStore( Width, textureSize(Sampler) );\
+}
+
// https://www.opengl.org/sdk/docs/man/html/imageSize.xhtml
// imageSize returns the dimensions of the image bound to image. The components in the
@@ -828,6 +833,10 @@ vec4 _frexp(vec4 f4, out vec4 fexp4)
_TypeConvertStore( Depth, i3Size.z ); \
}
+#define GetRWTexBufferDimensions_1(Tex, Width)\
+{ \
+ _TypeConvertStore( Width, imageSize(Tex) ); \
+}
// Texture sampling operations
@@ -946,6 +955,7 @@ vec4 _frexp(vec4 f4, out vec4 fexp4)
#define LoadTex2DMS_3(Tex, Location, Sample, Offset)texelFetch(Tex, _ToIvec2( (Location).x + (Offset).x, (Location).y + (Offset).y), int(Sample) ) // No texelFetchOffset for texture2DMS
#define LoadTex2DMSArr_2(Tex, Location, Sample) texelFetch(Tex, _ToIvec( (Location).xyz), _ToInt(Sample))
#define LoadTex2DMSArr_3(Tex, Location, Sample, Offset)texelFetch(Tex, _ToIvec3( (Location).x + (Offset).x, (Location).y + (Offset).y, (Location).z), int(Sample)) // No texelFetchOffset for texture2DMSArray
+#define LoadTexBuffer_1(Tex, Location) texelFetch(Tex, _ToInt(Location))
//https://www.opengl.org/sdk/docs/man/html/imageLoad.xhtml
#define LoadRWTex1D_1(Tex, Location) imageLoad(Tex, _ToInt(Location) )
@@ -953,7 +963,7 @@ vec4 _frexp(vec4 f4, out vec4 fexp4)
#define LoadRWTex2D_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xy) )
#define LoadRWTex2DArr_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xyz) )
#define LoadRWTex3D_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xyz) )
-
+#define LoadRWTexBuffer_1(Tex, Location)imageLoad(Tex, _ToInt(Location) )
#define Gather_2(Tex, Sampler, Location) textureGather (Tex, _ToVec(Location))
#define Gather_3(Tex, Sampler, Location, Offset)textureGatherOffset(Tex, _ToVec(Location), Offset)
diff --git a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h
index 04434245..b46c0177 100644
--- a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h
+++ b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h
@@ -786,6 +786,11 @@
" _TypeConvertStore( NumberOfSamples, 0 );\\\n"
"}\n"
"\n"
+"#define GetTexBufferDimensions_1(Sampler, Width)\\\n"
+"{ \\\n"
+" _TypeConvertStore( Width, textureSize(Sampler) );\\\n"
+"}\n"
+"\n"
"\n"
"// https://www.opengl.org/sdk/docs/man/html/imageSize.xhtml\n"
"// imageSize returns the dimensions of the image bound to image. The components in the \n"
@@ -828,6 +833,10 @@
" _TypeConvertStore( Depth, i3Size.z ); \\\n"
"}\n"
"\n"
+"#define GetRWTexBufferDimensions_1(Tex, Width)\\\n"
+"{ \\\n"
+" _TypeConvertStore( Width, imageSize(Tex) ); \\\n"
+"}\n"
"\n"
"\n"
"// Texture sampling operations\n"
@@ -946,6 +955,7 @@
"#define LoadTex2DMS_3(Tex, Location, Sample, Offset)texelFetch(Tex, _ToIvec2( (Location).x + (Offset).x, (Location).y + (Offset).y), int(Sample) ) // No texelFetchOffset for texture2DMS\n"
"#define LoadTex2DMSArr_2(Tex, Location, Sample) texelFetch(Tex, _ToIvec( (Location).xyz), _ToInt(Sample))\n"
"#define LoadTex2DMSArr_3(Tex, Location, Sample, Offset)texelFetch(Tex, _ToIvec3( (Location).x + (Offset).x, (Location).y + (Offset).y, (Location).z), int(Sample)) // No texelFetchOffset for texture2DMSArray\n"
+"#define LoadTexBuffer_1(Tex, Location) texelFetch(Tex, _ToInt(Location))\n"
"\n"
"//https://www.opengl.org/sdk/docs/man/html/imageLoad.xhtml\n"
"#define LoadRWTex1D_1(Tex, Location) imageLoad(Tex, _ToInt(Location) )\n"
@@ -953,7 +963,7 @@
"#define LoadRWTex2D_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xy) )\n"
"#define LoadRWTex2DArr_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xyz) )\n"
"#define LoadRWTex3D_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xyz) )\n"
-"\n"
+"#define LoadRWTexBuffer_1(Tex, Location)imageLoad(Tex, _ToInt(Location) )\n"
"\n"
"#define Gather_2(Tex, Sampler, Location) textureGather (Tex, _ToVec(Location))\n"
"#define Gather_3(Tex, Sampler, Location, Offset)textureGatherOffset(Tex, _ToVec(Location), Offset)\n"
diff --git a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
index 40a624ef..770a00ca 100644
--- a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
+++ b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp
@@ -543,6 +543,8 @@ HLSL2GLSLConverterImpl::HLSL2GLSLConverterImpl()
DEFINE_GET_DIM_STUB( "GetTex2DArrDimensions_3", "samplerCubeArray", 3 ); // GetDimensions( Width, Height, ArrElems )
DEFINE_GET_DIM_STUB( "GetTex2DArrDimensions_5", "samplerCubeArray", 5 ); // GetDimensions( Mip, Width, Height, ArrElems, NumberOfMips )
+ DEFINE_GET_DIM_STUB( "GetTexBufferDimensions_1", "samplerBuffer", 1 ); // GetDimensions( Width )
+
if( Suff == "" )
{
// No shadow samplers for Tex3D, Tex2DMS and Tex2DMSArr
@@ -558,12 +560,14 @@ HLSL2GLSLConverterImpl::HLSL2GLSLConverterImpl()
DEFINE_GET_DIM_STUB( "GetRWTex2DDimensions_2", "image2D", 2 ); // GetDimensions( Width, Height )
DEFINE_GET_DIM_STUB( "GetRWTex2DArrDimensions_3", "image2DArray", 3 ); // GetDimensions( Width, Height, ArrElems )
DEFINE_GET_DIM_STUB( "GetRWTex3DDimensions_3", "image3D", 3 ); // GetDimensions( Width, Height, Depth )
+ DEFINE_GET_DIM_STUB( "GetRWTexBufferDimensions_1","imageBuffer", 1 ); // GetDimensions( Width )
m_ImageTypes.insert( HashMapStringKey(Pref+"image1D") );
m_ImageTypes.insert( HashMapStringKey(Pref+"image1DArray") );
m_ImageTypes.insert( HashMapStringKey(Pref+"image2D") );
m_ImageTypes.insert( HashMapStringKey(Pref+"image2DArray") );
m_ImageTypes.insert( HashMapStringKey(Pref+"image3D") );
+ m_ImageTypes.insert( HashMapStringKey(Pref+"imageBuffer") );
}
#undef DEFINE_GET_DIM_STUB
}
@@ -642,11 +646,14 @@ HLSL2GLSLConverterImpl::HLSL2GLSLConverterImpl()
DEFINE_STUB( "LoadTex2DMS_3", Pref + "sampler2DMS", "Load", 3 ); // Load( Location, Sample, Offset )
DEFINE_STUB( "LoadTex2DMSArr_3", Pref + "sampler2DMSArray", "Load", 3 ); // Load( Location, Sample, Offset )
+ DEFINE_STUB( "LoadTexBuffer_1", Pref + "samplerBuffer", "Load", 1 ); // Load( Location )
+
DEFINE_STUB( "LoadRWTex1D_1", Pref + "image1D", "Load", 1 ); // Load( Location )
DEFINE_STUB( "LoadRWTex1DArr_1", Pref + "image1DArray", "Load", 1 ); // Load( Location )
DEFINE_STUB( "LoadRWTex2D_1", Pref + "image2D", "Load", 1 ); // Load( Location )
DEFINE_STUB( "LoadRWTex2DArr_1", Pref + "image2DArray", "Load", 1 ); // Load( Location )
DEFINE_STUB( "LoadRWTex3D_1", Pref + "image3D", "Load", 1 ); // Load( Location )
+ DEFINE_STUB( "LoadRWTexBuffer_1", Pref + "imageBuffer", "Load", 1 ); // Load( Location )
}
// SampleCmp() returns float independent of the number of components, so
@@ -1739,7 +1746,8 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessTextureDeclaration( TokenL
TextureDim == TokenType::kw_RWTexture1DArray ||
TextureDim == TokenType::kw_RWTexture2D ||
TextureDim == TokenType::kw_RWTexture2DArray ||
- TextureDim == TokenType::kw_RWTexture3D;
+ TextureDim == TokenType::kw_RWTexture3D ||
+ TextureDim == TokenType::kw_RWBuffer;
String ImgFormat;
++Token;
@@ -1872,6 +1880,10 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessTextureDeclaration( TokenL
case TokenType::kw_TextureCubeArray: GLSLSampler += "CubeArray"; break;
case TokenType::kw_Texture2DMS: GLSLSampler += "2DMS"; break;
case TokenType::kw_Texture2DMSArray: GLSLSampler += "2DMSArray"; break;
+
+ case TokenType::kw_RWBuffer:
+ case TokenType::kw_Buffer: GLSLSampler += "Buffer"; break;
+
default: UNEXPECTED("Unexpected texture type");
}
@@ -4656,11 +4668,13 @@ String HLSL2GLSLConverterImpl::ConversionStream::Convert(const Char* EntryPoint,
Token->Type == TokenType::kw_TextureCubeArray ||
Token->Type == TokenType::kw_Texture2DMS ||
Token->Type == TokenType::kw_Texture2DMSArray ||
+ Token->Type == TokenType::kw_Buffer ||
Token->Type == TokenType::kw_RWTexture1D ||
Token->Type == TokenType::kw_RWTexture1DArray ||
Token->Type == TokenType::kw_RWTexture2D ||
Token->Type == TokenType::kw_RWTexture2DArray ||
- Token->Type == TokenType::kw_RWTexture3D )
+ Token->Type == TokenType::kw_RWTexture3D ||
+ Token->Type == TokenType::kw_RWBuffer)
{
// Process texture declaration, and add it to the top of the
// object stack