Semantics: 'invocations' defaults to 1, not 0.

'invocations' was using 0 as the "shader never set" flag and as the
default. Formalize this and explicit set to 1 and link time.
This commit is contained in:
John Kessenich 2015-12-13 10:59:17 -07:00
parent 04bb8a01d6
commit 61d9fb9048
13 changed files with 34 additions and 26 deletions

View File

@ -12,7 +12,7 @@ ERROR: 7 compilation errors. No code generated.
Shader version: 410
invocations = 0
invocations = -1
max_vertices = -1
input primitive = none
output primitive = none
@ -65,7 +65,7 @@ ERROR: Linking geometry stage: At least one shader must specify an output layout
ERROR: Linking geometry stage: At least one shader must specify a layout(max_vertices = value)
Shader version: 410
invocations = 0
invocations = 1
max_vertices = -1
input primitive = none
output primitive = none

View File

@ -10,7 +10,7 @@ ERROR: 6 compilation errors. No code generated.
Shader version: 420
invocations = 0
invocations = -1
max_vertices = -1
input primitive = triangles
output primitive = none
@ -137,7 +137,7 @@ ERROR: Linking geometry stage: At least one shader must specify an output layout
ERROR: Linking geometry stage: At least one shader must specify a layout(max_vertices = value)
Shader version: 420
invocations = 0
invocations = 1
max_vertices = -1
input primitive = triangles
output primitive = none

View File

@ -5,7 +5,7 @@ ERROR: 1 compilation errors. No code generated.
Shader version: 420
invocations = 0
invocations = -1
max_vertices = -1
input primitive = triangles
output primitive = none
@ -44,7 +44,7 @@ ERROR: Linking geometry stage: At least one shader must specify an output layout
ERROR: Linking geometry stage: At least one shader must specify a layout(max_vertices = value)
Shader version: 420
invocations = 0
invocations = 1
max_vertices = -1
input primitive = triangles
output primitive = none

View File

@ -2,7 +2,7 @@
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Shader version: 450
invocations = 0
invocations = -1
max_vertices = -1
input primitive = none
output primitive = none
@ -40,7 +40,7 @@ ERROR: Linking geometry stage: At least one shader must specify an output layout
ERROR: Linking geometry stage: At least one shader must specify a layout(max_vertices = value)
Shader version: 450
invocations = 0
invocations = 1
max_vertices = -1
input primitive = none
output primitive = none

View File

@ -18,7 +18,7 @@ ERROR: 1 compilation errors. No code generated.
Shader version: 150
invocations = 0
invocations = -1
max_vertices = -1
input primitive = none
output primitive = points
@ -29,7 +29,7 @@ ERROR: node is still EOpNull!
noMain2.geom
Shader version: 150
invocations = 0
invocations = -1
max_vertices = -1
input primitive = none
output primitive = line_strip
@ -52,7 +52,7 @@ ERROR: Linking fragment stage: Multiple function bodies in multiple compilation
main(
Shader version: 150
invocations = 0
invocations = 1
max_vertices = -1
input primitive = none
output primitive = points

View File

@ -1,6 +1,6 @@
max_vertices_0.geom
Shader version: 330
invocations = 0
invocations = -1
max_vertices = 0
input primitive = points
output primitive = triangle_strip
@ -19,7 +19,7 @@ Linked geometry stage:
Shader version: 330
invocations = 0
invocations = 1
max_vertices = 0
input primitive = points
output primitive = triangle_strip

View File

@ -12,7 +12,7 @@ Linked geometry stage:
MemoryModel Logical GLSL450
EntryPoint Geometry 4 "main" 18 70 10 29 33
ExecutionMode 4 InputTrianglesAdjacency
ExecutionMode 4 Invocations 0
ExecutionMode 4 Invocations 1
ExecutionMode 4 OutputTriangleStrip
ExecutionMode 4 OutputVertices 30
Source GLSL 150

View File

@ -12,7 +12,7 @@ Linked geometry stage:
MemoryModel Logical GLSL450
EntryPoint Geometry 4 "main" 20 13
ExecutionMode 4 Triangles
ExecutionMode 4 Invocations 0
ExecutionMode 4 Invocations 1
ExecutionMode 4 OutputTriangleStrip
ExecutionMode 4 OutputVertices 3
Source GLSL 330

View File

@ -775,7 +775,7 @@ struct TShaderQualifiers {
TLayoutGeometry geometry; // geometry/tessellation shader in/out primitives
bool pixelCenterInteger; // fragment shader
bool originUpperLeft; // fragment shader
int invocations; // 0 means no declaration
int invocations;
int vertices; // both for tessellation "vertices" and geometry "max_vertices"
TVertexSpacing spacing;
TVertexOrder order;
@ -790,7 +790,7 @@ struct TShaderQualifiers {
geometry = ElgNone;
originUpperLeft = false;
pixelCenterInteger = false;
invocations = 0; // 0 means no declaration
invocations = TQualifier::layoutNotSet;
vertices = TQualifier::layoutNotSet;
spacing = EvsNone;
order = EvoNone;
@ -813,7 +813,7 @@ struct TShaderQualifiers {
pixelCenterInteger = src.pixelCenterInteger;
if (src.originUpperLeft)
originUpperLeft = src.originUpperLeft;
if (src.invocations != 0)
if (src.invocations != TQualifier::layoutNotSet)
invocations = src.invocations;
if (src.vertices != TQualifier::layoutNotSet)
vertices = src.vertices;

View File

@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "SPIRV99.841"
#define GLSLANG_DATE "12-Dec-2015"
#define GLSLANG_REVISION "SPIRV99.842"
#define GLSLANG_DATE "13-Dec-2015"

View File

@ -3889,7 +3889,10 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
case EShLangGeometry:
if (id == "invocations") {
profileRequires(loc, ECompatibilityProfile | ECoreProfile, 400, nullptr, "invocations");
publicType.shaderQualifiers.invocations = value;
if (value == 0)
error(loc, "must be at least 1", "invocations", "");
else
publicType.shaderQualifiers.invocations = value;
return;
}
if (id == "max_vertices") {
@ -4276,7 +4279,7 @@ void TParseContext::checkNoShaderLayouts(const TSourceLoc& loc, const TShaderQua
if (shaderQualifiers.geometry != ElgNone)
error(loc, message, TQualifier::getGeometryString(shaderQualifiers.geometry), "");
if (shaderQualifiers.invocations > 0)
if (shaderQualifiers.invocations != TQualifier::layoutNotSet)
error(loc, message, "invocations", "");
if (shaderQualifiers.vertices != TQualifier::layoutNotSet) {
if (language == EShLangGeometry)
@ -5453,7 +5456,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
if (language == EShLangTessControl)
checkIoArraysConsistency(loc);
}
if (publicType.shaderQualifiers.invocations) {
if (publicType.shaderQualifiers.invocations != TQualifier::layoutNotSet) {
if (publicType.qualifier.storage != EvqVaryingIn)
error(loc, "can only apply to 'in'", "invocations", "");
if (! intermediate.setInvocations(publicType.shaderQualifiers.invocations))

View File

@ -359,6 +359,10 @@ void TIntermediate::finalCheck(TInfoSink& infoSink)
// overlap/alias/missing I/O, etc.
inOutLocationCheck(infoSink);
// invocations
if (invocations == TQualifier::layoutNotSet)
invocations = 1;
if (inIoAccessed("gl_ClipDistance") && inIoAccessed("gl_ClipVertex"))
error(infoSink, "Can only use one of gl_ClipDistance or gl_ClipVertex (gl_ClipDistance is preferred)");
@ -561,7 +565,7 @@ void TIntermediate::inOutLocationCheck(TInfoSink& infoSink)
if (profile == EEsProfile) {
if (numFragOut > 1 && fragOutWithNoLocation)
error(infoSink, "when more than one fragment shader output, all must have location qualifiers");
}
}
}
TIntermSequence& TIntermediate::findLinkerObjects() const

View File

@ -126,7 +126,8 @@ class TIntermediate {
public:
explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) : language(l), treeRoot(0), profile(p), version(v), spv(0),
numMains(0), numErrors(0), recursive(false),
invocations(0), vertices(TQualifier::layoutNotSet), inputPrimitive(ElgNone), outputPrimitive(ElgNone), pixelCenterInteger(false), originUpperLeft(false),
invocations(TQualifier::layoutNotSet), vertices(TQualifier::layoutNotSet), inputPrimitive(ElgNone), outputPrimitive(ElgNone),
pixelCenterInteger(false), originUpperLeft(false),
vertexSpacing(EvsNone), vertexOrder(EvoNone), pointMode(false), earlyFragmentTests(false), depthLayout(EldNone), depthReplacing(false), blendEquations(0), xfbMode(false)
{
localSize[0] = 1;
@ -204,7 +205,7 @@ public:
bool setInvocations(int i)
{
if (invocations > 0)
if (invocations != TQualifier::layoutNotSet)
return invocations == i;
invocations = i;
return true;