glspv.frag
ERROR: 0:4: '#error' : GL_SPIRV is set ( correct , not an error )
ERROR: 0:6: '#error' : GL_SPIR is 100
-ERROR: 0:14: 'input_attachment_index' : only allowed when using GLSL for Vulkan
-ERROR: 0:14: '' : syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
-ERROR: 4 compilation errors. No code generated.
+ERROR: 0:14: 'f' : non-opaque uniform variables need a layout(location=L)
+ERROR: 0:19: 'input_attachment_index' : only allowed when using GLSL for Vulkan
+ERROR: 0:19: '' : syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
+ERROR: 5 compilation errors. No code generated.
SPIR-V is not generated for failed compile or link
-#version 330\r
+#version 450\r
\r
#ifdef GL_SPIRV\r
#error GL_SPIRV is set ( correct, not an error )\r
{\r
}\r
\r
+uniform float f; // ERROR, no location\r
+layout(location = 2) uniform float g;\r
+uniform sampler2D s1;\r
+layout(location = 3) uniform sampler2D s2;\r
+\r
layout(input_attachment_index = 1) uniform subpassInput sub; // ERROR, no inputs\r
#version 450\r
\r
layout(constant_id = 3) const int a = 2;\r
-\r
-uniform float f;\r
+layout(location = 2) uniform float f;\r
+layout(location = 4) uniform sampler2D s1;\r
+uniform sampler2D s2;\r
\r
void main()\r
{\r
error(loc, "atomic_uints can only be used in uniform variables or function parameters:", type.getBasicTypeString().c_str(), identifier.c_str());
}
-void TParseContext::transparentCheck(const TSourceLoc& loc, const TType& type, const TString& /*identifier*/)
+void TParseContext::transparentOpaqueCheck(const TSourceLoc& loc, const TType& type, const TString& identifier)
{
if (parsingBuiltins)
return;
- // Vulkan doesn't allow transparent uniforms outside of blocks
- if (spvVersion.vulkan == 0 || type.getQualifier().storage != EvqUniform)
+ if (type.getQualifier().storage != EvqUniform)
return;
- if (type.containsNonOpaque())
- vulkanRemoved(loc, "non-opaque uniforms outside a block");
+
+ if (type.containsNonOpaque()) {
+ // Vulkan doesn't allow transparent uniforms outside of blocks
+ if (spvVersion.vulkan > 0)
+ vulkanRemoved(loc, "non-opaque uniforms outside a block");
+ // OpenGL wants locations on these
+ if (spvVersion.openGl > 0 && !type.getQualifier().hasLocation())
+ error(loc, "non-opaque uniform variables need a layout(location=L)", identifier.c_str(), "");
+ }
}
//
samplerCheck(loc, type, identifier, initializer);
atomicUintCheck(loc, type, identifier);
- transparentCheck(loc, type, identifier);
+ transparentOpaqueCheck(loc, type, identifier);
if (identifier != "gl_FragCoord" && (publicType.shaderQualifiers.originUpperLeft || publicType.shaderQualifiers.pixelCenterInteger))
error(loc, "can only apply origin_upper_left and pixel_center_origin to gl_FragCoord", "layout qualifier", "");
void boolCheck(const TSourceLoc&, const TPublicType&);
void samplerCheck(const TSourceLoc&, const TType&, const TString& identifier, TIntermTyped* initializer);
void atomicUintCheck(const TSourceLoc&, const TType&, const TString& identifier);
- void transparentCheck(const TSourceLoc&, const TType&, const TString& identifier);
+ void transparentOpaqueCheck(const TSourceLoc&, const TType&, const TString& identifier);
void globalQualifierFixCheck(const TSourceLoc&, TQualifier&);
void globalQualifierTypeCheck(const TSourceLoc&, const TQualifier&, const TPublicType&);
bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType);