diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-02-17 02:21:51 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-02-17 02:21:51 +0000 |
| commit | 02632fd7fbc118279ff1e68f9b72694aef222bdb (patch) | |
| tree | 6aa6f6da1179bc05882f438abca29364f8892b34 /Graphics | |
| parent | Updated GLSL definitions on Android (diff) | |
| download | DiligentCore-02632fd7fbc118279ff1e68f9b72694aef222bdb.tar.gz DiligentCore-02632fd7fbc118279ff1e68f9b72694aef222bdb.zip | |
Fixed few HLSL->GLSL conversion issues on MacOS
Diffstat (limited to 'Graphics')
5 files changed, 130 insertions, 48 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm index b578dd92..65942afb 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm @@ -30,6 +30,22 @@ #include "GLTypeConversions.h" #include "EngineGLAttribs.h" +static void glDrawArraysInstancedBaseInstance_stub(GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance) +{ + LOG_ERROR_MESSAGE_ONCE("glDrawArraysInstancedBaseInstance is not supported on MacOS"); +} + +static void glDrawElementsInstancedBaseInstance_stub(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance) +{ + LOG_ERROR_MESSAGE_ONCE("glDrawElementsInstancedBaseInstance is not supported on MacOS"); +} + +static void glDrawElementsInstancedBaseVertexBaseInstance_stub(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance) +{ + LOG_ERROR_MESSAGE_ONCE("glDrawElementsInstancedBaseVertexBaseInstance is not supported on MacOS"); +} + + namespace Diligent { GLContext::GLContext( const EngineGLAttribs &InitAttribs, DeviceCaps &DeviceCaps ) @@ -44,7 +60,13 @@ namespace Diligent GLenum err = glewInit(); if( GLEW_OK != err ) LOG_ERROR_AND_THROW( "Failed to initialize GLEW" ); - + if(glDrawArraysInstancedBaseInstance == nullptr) + glDrawArraysInstancedBaseInstance = glDrawArraysInstancedBaseInstance_stub; + if(glDrawElementsInstancedBaseInstance == nullptr) + glDrawElementsInstancedBaseInstance = glDrawElementsInstancedBaseInstance_stub; + if(glDrawElementsInstancedBaseVertexBaseInstance == nullptr) + glDrawElementsInstancedBaseVertexBaseInstance = glDrawElementsInstancedBaseVertexBaseInstance_stub; + //Checking GL version const GLubyte *GLVersionString = glGetString( GL_VERSION ); const GLubyte *GLRenderer = glGetString(GL_RENDERER); diff --git a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h index cdf517d1..cac5e9d7 100644 --- a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h +++ b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h @@ -202,13 +202,8 @@ uvec4 f32tof16( vec4 f4 ) } #endif -#ifndef GL_ES // double is not supported on GLES -double asdouble(uint lowbits, uint highbits) -{ - return packDouble2x32( uvec2( lowbits, highbits ) ); -} -#endif - +// Use #define as double is not supported on GLES +#define asdouble(lowbits, highbits) packDouble2x32( uvec2( lowbits, highbits ) ) // Floating point functions @@ -532,15 +527,50 @@ void _TypeConvertStore( out int Dst, in int Src ){ Dst = int( Src ); } void _TypeConvertStore( out int Dst, in uint Src ){ Dst = int( Src ); } void _TypeConvertStore( out int Dst, in float Src ){ Dst = int( Src ); } -int _ToInt( int x ) { return int(x); } -int _ToInt( uint x ) { return int(x); } -int _ToInt( float x ){ return int(x); } -int _ToInt( bool x ) { return x ? 1 : 0; } + +int _ToInt( int x ) { return int(x); } +int _ToInt( ivec2 v ) { return int(v.x); } +int _ToInt( ivec3 v ) { return int(v.x); } +int _ToInt( ivec4 v ) { return int(v.x); } + +int _ToInt( uint x ) { return int(x); } +int _ToInt( uvec2 v ) { return int(v.x); } +int _ToInt( uvec3 v ) { return int(v.x); } +int _ToInt( uvec4 v ) { return int(v.x); } + +int _ToInt( float x ) { return int(x); } +int _ToInt( vec2 v ) { return int(v.x); } +int _ToInt( vec3 v ) { return int(v.x); } +int _ToInt( vec4 v ) { return int(v.x); } + +int _ToInt( bool x ) { return x ? 1 : 0;} +int _ToInt( bvec2 v ) { return v.x ? 1 : 0;} +int _ToInt( bvec3 v ) { return v.x ? 1 : 0;} +int _ToInt( bvec4 v ) { return v.x ? 1 : 0;} + + float _ToFloat( int x ) { return float(x); } +float _ToFloat( ivec2 v ){ return float(v.x); } +float _ToFloat( ivec3 v ){ return float(v.x); } +float _ToFloat( ivec4 v ){ return float(v.x); } + float _ToFloat( uint x ) { return float(x); } +float _ToFloat( uvec2 v ){ return float(v.x); } +float _ToFloat( uvec3 v ){ return float(v.x); } +float _ToFloat( uvec4 v ){ return float(v.x); } + float _ToFloat( float x ){ return float(x); } -float _ToFloat( bool x ) { return x ? 1.0 : 0.0;} +float _ToFloat( vec2 v ) { return float(v.x); } +float _ToFloat( vec3 v ) { return float(v.x); } +float _ToFloat( vec4 v ) { return float(v.x); } + +float _ToFloat( bool x ) { return x ? 1.0 : 0.0;} +float _ToFloat( bvec2 v ){ return v.x ? 1.0 : 0.0;} +float _ToFloat( bvec3 v ){ return v.x ? 1.0 : 0.0;} +float _ToFloat( bvec4 v ){ return v.x ? 1.0 : 0.0;} + + uint _ToUint( int x ) { return uint(x); } uint _ToUint( uint x ) { return uint(x); } @@ -796,7 +826,7 @@ uvec4 _ToUvec( vec4 f4 ){ return _ToUvec4( f4.x, f4.y, f4.z, f4.w ); } // in the second to last component of Coords. (The second component of Coords is unused for 1D shadow lookups.) // For cube array textures, Dsub is specified as a separate parameter // mip -#define SampleCmpLevel0Tex1D_3(Tex, Sampler, Coords, CompareValue) textureLod(Tex, _ToVec3((Coords).x, 0.0, CompareValue), 0.0) +#define SampleCmpLevel0Tex1D_3(Tex, Sampler, Coords, CompareValue) textureLod(Tex, _ToVec3( Coords, 0.0, CompareValue), 0.0) #define SampleCmpLevel0Tex1DArr_3(Tex, Sampler, Coords, CompareValue) textureLod(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0) #define SampleCmpLevel0Tex2D_3(Tex, Sampler, Coords, CompareValue) textureLod(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0) #define SampleCmpLevel0Tex2DArr_3(Tex, Sampler, Coords, CompareValue) 0.0 // No textureLod for sampler2DArrayShadow @@ -804,7 +834,7 @@ uvec4 _ToUvec( vec4 f4 ){ return _ToUvec4( f4.x, f4.y, f4.z, f4.w ); } #define SampleCmpLevel0TexCubeArr_3(Tex, Sampler, Coords, CompareValue) 0.0 // No textureLod for samplerCubeArrayShadow // mip -#define SampleCmpLevel0Tex1D_4(Tex, Sampler, Coords, CompareValue, Offset) textureLodOffset(Tex, _ToVec3((Coords).x, 0.0, CompareValue), 0.0, int(Offset)) +#define SampleCmpLevel0Tex1D_4(Tex, Sampler, Coords, CompareValue, Offset) textureLodOffset(Tex, _ToVec3( Coords, 0.0, CompareValue), 0.0, int(Offset)) #define SampleCmpLevel0Tex1DArr_4(Tex, Sampler, Coords, CompareValue, Offset) textureLodOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0, int(Offset)) #define SampleCmpLevel0Tex2D_4(Tex, Sampler, Coords, CompareValue, Offset) textureLodOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0, ivec2((Offset).xy)) #define SampleCmpLevel0Tex2DArr_4(Tex, Sampler, Coords, CompareValue, Offset) 0.0 // No textureLodOffset for sampler2DArrayShadow @@ -818,14 +848,14 @@ uvec4 _ToUvec( vec4 f4 ){ return _ToUvec4( f4.x, f4.y, f4.z, f4.w ); } # define SampleBias_3(Tex, Sampler, Coords, Bias) texture (Tex, _ToVec(Coords), _ToFloat(Bias)) # define SampleBias_4(Tex, Sampler, Coords, Bias, Offset) textureOffset(Tex, _ToVec(Coords), Offset, _ToFloat(Bias)) -# define SampleCmpTex1D_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec3((Coords).x, 0.0, CompareValue)) +# define SampleCmpTex1D_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec3( Coords, 0.0, CompareValue)) # define SampleCmpTex1DArr_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue)) # define SampleCmpTex2D_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue)) # define SampleCmpTex2DArr_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, CompareValue)) # define SampleCmpTexCube_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, CompareValue)) # define SampleCmpTexCubeArr_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, (Coords).w), _ToFloat(CompareValue)) -# define SampleCmpTex1D_4(Tex, Sampler, Coords, CompareValue, Offset) textureOffset(Tex, _ToVec3((Coords).x, 0.0, CompareValue), int(Offset)) +# define SampleCmpTex1D_4(Tex, Sampler, Coords, CompareValue, Offset) textureOffset(Tex, _ToVec3( Coords, 0.0, CompareValue), int(Offset)) # define SampleCmpTex1DArr_4(Tex, Sampler, Coords, CompareValue, Offset) textureOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), int(Offset)) # define SampleCmpTex2D_4(Tex, Sampler, Coords, CompareValue, Offset) textureOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), ivec2((Offset).xy)) # define SampleCmpTex2DArr_4(Tex, Sampler, Coords, CompareValue, Offset) textureOffset(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, CompareValue), ivec2((Offset).xy)) @@ -886,7 +916,7 @@ uvec4 _ToUvec( vec4 f4 ){ return _ToUvec4( f4.x, f4.y, f4.z, f4.w ); } #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 //https://www.opengl.org/sdk/docs/man/html/imageLoad.xhtml -#define LoadRWTex1D_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).x) ) +#define LoadRWTex1D_1(Tex, Location) imageLoad(Tex, _ToInt(Location) ) #define LoadRWTex1DArr_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xy) ) #define LoadRWTex2D_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xy) ) #define LoadRWTex2DArr_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xyz) ) diff --git a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h index cda30cef..34175df4 100644 --- a/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h +++ b/Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h @@ -202,13 +202,8 @@ "}\n" "#endif\n" "\n" -"#ifndef GL_ES // double is not supported on GLES\n" -"double asdouble(uint lowbits, uint highbits)\n" -"{\n" -" return packDouble2x32( uvec2( lowbits, highbits ) );\n" -"}\n" -"#endif\n" -"\n" +"// Use #define as double is not supported on GLES\n" +"#define asdouble(lowbits, highbits) packDouble2x32( uvec2( lowbits, highbits ) )\n" "\n" "// Floating point functions\n" "\n" @@ -532,15 +527,50 @@ "void _TypeConvertStore( out int Dst, in uint Src ){ Dst = int( Src ); }\n" "void _TypeConvertStore( out int Dst, in float Src ){ Dst = int( Src ); }\n" "\n" -"int _ToInt( int x ) { return int(x); }\n" -"int _ToInt( uint x ) { return int(x); }\n" -"int _ToInt( float x ){ return int(x); }\n" -"int _ToInt( bool x ) { return x ? 1 : 0; }\n" +"\n" +"int _ToInt( int x ) { return int(x); }\n" +"int _ToInt( ivec2 v ) { return int(v.x); }\n" +"int _ToInt( ivec3 v ) { return int(v.x); }\n" +"int _ToInt( ivec4 v ) { return int(v.x); }\n" +"\n" +"int _ToInt( uint x ) { return int(x); }\n" +"int _ToInt( uvec2 v ) { return int(v.x); }\n" +"int _ToInt( uvec3 v ) { return int(v.x); }\n" +"int _ToInt( uvec4 v ) { return int(v.x); }\n" +"\n" +"int _ToInt( float x ) { return int(x); }\n" +"int _ToInt( vec2 v ) { return int(v.x); }\n" +"int _ToInt( vec3 v ) { return int(v.x); }\n" +"int _ToInt( vec4 v ) { return int(v.x); }\n" +"\n" +"int _ToInt( bool x ) { return x ? 1 : 0;}\n" +"int _ToInt( bvec2 v ) { return v.x ? 1 : 0;}\n" +"int _ToInt( bvec3 v ) { return v.x ? 1 : 0;}\n" +"int _ToInt( bvec4 v ) { return v.x ? 1 : 0;}\n" +"\n" +"\n" "\n" "float _ToFloat( int x ) { return float(x); }\n" +"float _ToFloat( ivec2 v ){ return float(v.x); }\n" +"float _ToFloat( ivec3 v ){ return float(v.x); }\n" +"float _ToFloat( ivec4 v ){ return float(v.x); }\n" +"\n" "float _ToFloat( uint x ) { return float(x); }\n" +"float _ToFloat( uvec2 v ){ return float(v.x); }\n" +"float _ToFloat( uvec3 v ){ return float(v.x); }\n" +"float _ToFloat( uvec4 v ){ return float(v.x); }\n" +"\n" "float _ToFloat( float x ){ return float(x); }\n" -"float _ToFloat( bool x ) { return x ? 1.0 : 0.0;}\n" +"float _ToFloat( vec2 v ) { return float(v.x); }\n" +"float _ToFloat( vec3 v ) { return float(v.x); }\n" +"float _ToFloat( vec4 v ) { return float(v.x); }\n" +"\n" +"float _ToFloat( bool x ) { return x ? 1.0 : 0.0;}\n" +"float _ToFloat( bvec2 v ){ return v.x ? 1.0 : 0.0;}\n" +"float _ToFloat( bvec3 v ){ return v.x ? 1.0 : 0.0;}\n" +"float _ToFloat( bvec4 v ){ return v.x ? 1.0 : 0.0;}\n" +"\n" +"\n" "\n" "uint _ToUint( int x ) { return uint(x); }\n" "uint _ToUint( uint x ) { return uint(x); }\n" @@ -796,7 +826,7 @@ "// in the second to last component of Coords. (The second component of Coords is unused for 1D shadow lookups.)\n" "// For cube array textures, Dsub is specified as a separate parameter\n" "// mip\n" -"#define SampleCmpLevel0Tex1D_3(Tex, Sampler, Coords, CompareValue) textureLod(Tex, _ToVec3((Coords).x, 0.0, CompareValue), 0.0)\n" +"#define SampleCmpLevel0Tex1D_3(Tex, Sampler, Coords, CompareValue) textureLod(Tex, _ToVec3( Coords, 0.0, CompareValue), 0.0)\n" "#define SampleCmpLevel0Tex1DArr_3(Tex, Sampler, Coords, CompareValue) textureLod(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0)\n" "#define SampleCmpLevel0Tex2D_3(Tex, Sampler, Coords, CompareValue) textureLod(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0)\n" "#define SampleCmpLevel0Tex2DArr_3(Tex, Sampler, Coords, CompareValue) 0.0 // No textureLod for sampler2DArrayShadow\n" @@ -804,7 +834,7 @@ "#define SampleCmpLevel0TexCubeArr_3(Tex, Sampler, Coords, CompareValue) 0.0 // No textureLod for samplerCubeArrayShadow\n" "\n" "// mip\n" -"#define SampleCmpLevel0Tex1D_4(Tex, Sampler, Coords, CompareValue, Offset) textureLodOffset(Tex, _ToVec3((Coords).x, 0.0, CompareValue), 0.0, int(Offset))\n" +"#define SampleCmpLevel0Tex1D_4(Tex, Sampler, Coords, CompareValue, Offset) textureLodOffset(Tex, _ToVec3( Coords, 0.0, CompareValue), 0.0, int(Offset))\n" "#define SampleCmpLevel0Tex1DArr_4(Tex, Sampler, Coords, CompareValue, Offset) textureLodOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0, int(Offset))\n" "#define SampleCmpLevel0Tex2D_4(Tex, Sampler, Coords, CompareValue, Offset) textureLodOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), 0.0, ivec2((Offset).xy))\n" "#define SampleCmpLevel0Tex2DArr_4(Tex, Sampler, Coords, CompareValue, Offset) 0.0 // No textureLodOffset for sampler2DArrayShadow\n" @@ -818,14 +848,14 @@ "# define SampleBias_3(Tex, Sampler, Coords, Bias) texture (Tex, _ToVec(Coords), _ToFloat(Bias))\n" "# define SampleBias_4(Tex, Sampler, Coords, Bias, Offset) textureOffset(Tex, _ToVec(Coords), Offset, _ToFloat(Bias))\n" "\n" -"# define SampleCmpTex1D_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec3((Coords).x, 0.0, CompareValue))\n" +"# define SampleCmpTex1D_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec3( Coords, 0.0, CompareValue))\n" "# define SampleCmpTex1DArr_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue))\n" "# define SampleCmpTex2D_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue))\n" "# define SampleCmpTex2DArr_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, CompareValue))\n" "# define SampleCmpTexCube_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, CompareValue))\n" "# define SampleCmpTexCubeArr_3(Tex, Sampler, Coords, CompareValue) texture(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, (Coords).w), _ToFloat(CompareValue))\n" "\n" -"# define SampleCmpTex1D_4(Tex, Sampler, Coords, CompareValue, Offset) textureOffset(Tex, _ToVec3((Coords).x, 0.0, CompareValue), int(Offset))\n" +"# define SampleCmpTex1D_4(Tex, Sampler, Coords, CompareValue, Offset) textureOffset(Tex, _ToVec3( Coords, 0.0, CompareValue), int(Offset))\n" "# define SampleCmpTex1DArr_4(Tex, Sampler, Coords, CompareValue, Offset) textureOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), int(Offset))\n" "# define SampleCmpTex2D_4(Tex, Sampler, Coords, CompareValue, Offset) textureOffset(Tex, _ToVec3((Coords).x, (Coords).y, CompareValue), ivec2((Offset).xy))\n" "# define SampleCmpTex2DArr_4(Tex, Sampler, Coords, CompareValue, Offset) textureOffset(Tex, _ToVec4((Coords).x, (Coords).y, (Coords).z, CompareValue), ivec2((Offset).xy))\n" @@ -886,7 +916,7 @@ "#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" "\n" "//https://www.opengl.org/sdk/docs/man/html/imageLoad.xhtml\n" -"#define LoadRWTex1D_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).x) )\n" +"#define LoadRWTex1D_1(Tex, Location) imageLoad(Tex, _ToInt(Location) )\n" "#define LoadRWTex1DArr_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xy) )\n" "#define LoadRWTex2D_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xy) )\n" "#define LoadRWTex2DArr_1(Tex, Location) imageLoad(Tex, _ToIvec((Location).xyz) )\n" diff --git a/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h b/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h index ba1a6a58..7ec35bd8 100644 --- a/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h +++ b/Graphics/HLSL2GLSLConverterLib/include/HLSL2GLSLConverterImpl.h @@ -328,7 +328,7 @@ namespace Diligent }; void ParseShaderParameter(TokenListType::iterator &Token, ShaderParameterInfo &ParamInfo); void ProcessFunctionParameters( TokenListType::iterator &Token, std::vector<ShaderParameterInfo>& Params, bool &bIsVoid ); - String AddFlatQualifier(const String& Type); + bool RequiresFlatQualifier(const String& Type); void ProcessFragmentShaderArguments( std::vector<ShaderParameterInfo>& Params, String &GlobalVariables, std::stringstream &ReturnHandlerSS, @@ -538,4 +538,4 @@ namespace Diligent // * Input variables to a shader stage must be listed in exact same order as outputs from -// the previous stage. Function return value counts as the first output argument.
\ No newline at end of file +// the previous stage. Function return value counts as the first output argument. diff --git a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp index 78bc255b..0759ab4c 100644 --- a/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp +++ b/Graphics/HLSL2GLSLConverterLib/src/HLSL2GLSLConverterImpl.cpp @@ -2917,7 +2917,7 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessShaderArgument( const Shad } } -String HLSL2GLSLConverterImpl::ConversionStream::AddFlatQualifier(const String& Type) +bool HLSL2GLSLConverterImpl::ConversionStream::RequiresFlatQualifier(const String& Type) { auto keywordIt = m_Converter.m_HLSLKeywords.find(Type.c_str()); bool RequiresFlat = false; @@ -2931,7 +2931,7 @@ String HLSL2GLSLConverterImpl::ConversionStream::AddFlatQualifier(const String& (kw >= TokenType::kw_min12int && kw <= TokenType::kw_min12int4x4) || (kw >= TokenType::kw_min16uint && kw <= TokenType::kw_min16uint4x4); } - return RequiresFlat ? String("flat ") + Type : Type; + return RequiresFlat; } void HLSL2GLSLConverterImpl::ConversionStream::ProcessFragmentShaderArguments(std::vector<ShaderParameterInfo>& Params, @@ -2954,7 +2954,7 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessFragmentShaderArguments(st else { auto InputVarName = BuildParameterName(MemberStack, '_', "_in_"); - DefineInterfaceVar(InLocation++, "in", AddFlatQualifier(Param.Type), InputVarName, InterfaceVarsSS ); + DefineInterfaceVar(InLocation++, RequiresFlatQualifier(Param.Type) ? "flat in" : "in", Param.Type, InputVarName, InterfaceVarsSS ); InitVariable(FullParamName, InputVarName, PrologueSS ); } } @@ -3071,7 +3071,7 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessVertexShaderArguments( std else { auto OutputVarName = BuildParameterName(MemberStack, '_', "_vsout_"); - DefineInterfaceVar( OutLocation++, "out", AddFlatQualifier(Param.Type), OutputVarName, InterfaceVarsSS ); + DefineInterfaceVar( OutLocation++, RequiresFlatQualifier(Param.Type) ? "flat out" : "out", Param.Type, OutputVarName, InterfaceVarsSS ); ReturnHandlerSS << OutputVarName << " = " << FullParamName << ";\\\n"; } } @@ -3143,8 +3143,8 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessGeometryShaderArguments( T { auto VarName = BuildParameterName(MemberStack, '_', "_gsin_"); auto InputVarName = VarName+"[i]"; - DefineInterfaceVar( inLocation++, "in", AddFlatQualifier(Param.Type), VarName + "[]", InterfaceVarsInSS ); - InitVariable( FullIndexedParamName, InputVarName, PrologueSS ); + DefineInterfaceVar( inLocation++, RequiresFlatQualifier(Param.Type) ? "flat in" : "in", Param.Type, VarName + "[]", InterfaceVarsInSS ); + InitVariable( FullIndexedParamName, InputVarName, PrologueSS ); } } ); @@ -3181,7 +3181,7 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessGeometryShaderArguments( T // variable that fragment shader will read. // Note that gl_Layer is available in fragment shader, but only starting with GL4.3+ auto OutputVarName = BuildParameterName(MemberStack, '_', "_gsout_"); - DefineInterfaceVar( outLocation++, "out", AddFlatQualifier(Param.Type), OutputVarName, InterfaceVarsOutSS ); + DefineInterfaceVar( outLocation++, RequiresFlatQualifier(Param.Type) ? "flat out" : "out", Param.Type, OutputVarName, InterfaceVarsOutSS ); EmitVertexDefineSS << OutputVarName << " = " << MacroArgumentName << ";\\\n"; } } @@ -3662,7 +3662,7 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessHullShaderArguments( Token auto VarName = BuildParameterName(MemberStack, '_', "_hsin_"); auto InputVarName = VarName + (IsPatch ? "[i]" : ""); // User-defined inputs can be declared as unbounded arrays - DefineInterfaceVar( inLocation++, "in", AddFlatQualifier(Param.Type), VarName + (IsPatch ? "[]" : ""), InterfaceVarsInSS ); + DefineInterfaceVar( inLocation++, RequiresFlatQualifier(Param.Type) ? "flat in" : "in", Param.Type, VarName + (IsPatch ? "[]" : ""), InterfaceVarsInSS ); InitVariable( FullIndexedParamName, InputVarName, PrologueSS ); } } @@ -3692,7 +3692,7 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessHullShaderArguments( Token auto OutputVarName = BuildParameterName(MemberStack, '_', "_hsout_"); // Per-vertex outputs are aggregated into arrays. // https://www.khronos.org/opengl/wiki/Tessellation_Control_Shader#Outputs - DefineInterfaceVar( outLocation++, "out", AddFlatQualifier(Param.Type), OutputVarName + "[]", InterfaceVarsOutSS ); + DefineInterfaceVar( outLocation++, RequiresFlatQualifier(Param.Type) ? "flat out" : "out", Param.Type, OutputVarName + "[]", InterfaceVarsOutSS ); // A TCS can only ever write to the per-vertex output variable that corresponds to their invocation, // so writes to per-vertex outputs must be of the form vertexTexCoord[gl_InvocationID] ReturnHandlerSS << OutputVarName << "[gl_InvocationID] = " << SrcParamName << ";\\\n"; @@ -3868,7 +3868,7 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessDomainShaderArguments( Tok auto VarName = BuildParameterName(MemberStack, '_', "_dsin_"); auto InputVarName = VarName + (IsPatch ? "[i]" : ""); // User-defined inputs can be declared as unbounded arrays - DefineInterfaceVar( inLocation++, "in", AddFlatQualifier(Param.Type), VarName + (IsPatch ? "[]" : ""), InterfaceVarsInSS ); + DefineInterfaceVar( inLocation++, RequiresFlatQualifier(Param.Type) ? "flat out" : "in", Param.Type, VarName + (IsPatch ? "[]" : ""), InterfaceVarsInSS ); InitVariable( FullIndexedParamName, InputVarName, PrologueSS ); } else @@ -3894,7 +3894,7 @@ void HLSL2GLSLConverterImpl::ConversionStream::ProcessDomainShaderArguments( Tok auto OutputVarName = BuildParameterName(MemberStack, '_', "_hsout_"); // Per-vertex outputs are aggregated into arrays. // https://www.khronos.org/opengl/wiki/Tessellation_Control_Shader#Outputs - DefineInterfaceVar( outLocation++, "out", AddFlatQualifier(Param.Type), OutputVarName, InterfaceVarsOutSS ); + DefineInterfaceVar( outLocation++, RequiresFlatQualifier(Param.Type) ? "flat out" : "out", Param.Type, OutputVarName, InterfaceVarsOutSS ); // A TCS can only ever write to the per-vertex output variable that corresponds to their invocation, // so writes to per-vertex outputs must be of the form vertexTexCoord[gl_InvocationID] ReturnHandlerSS << OutputVarName << " = " << SrcParamName << ";\\\n"; |
