Semantics: Geometry stage can support max_vertices = 0.

To do this, more generally use a named -1 as a not set value.
This commit is contained in:
John Kessenich 2015-12-11 15:44:12 -07:00
parent 3c24a06c8c
commit 494a02a2b0
18 changed files with 93 additions and 36 deletions

View file

@ -327,6 +327,8 @@ enum TBlendEquationShift {
class TQualifier {
public:
static const int layoutNotSet = -1;
void clear()
{
precision = EpqNone;
@ -489,8 +491,8 @@ public:
{
layoutMatrix = ElmNone;
layoutPacking = ElpNone;
layoutOffset = -1;
layoutAlign = -1;
layoutOffset = layoutNotSet;
layoutAlign = layoutNotSet;
layoutLocation = layoutLocationEnd;
layoutComponent = layoutComponentEnd;
@ -567,11 +569,11 @@ public:
}
bool hasOffset() const
{
return layoutOffset != -1;
return layoutOffset != layoutNotSet;
}
bool hasAlign() const
{
return layoutAlign != -1;
return layoutAlign != layoutNotSet;
}
bool hasAnyLocation() const
{
@ -789,7 +791,7 @@ struct TShaderQualifiers {
originUpperLeft = false;
pixelCenterInteger = false;
invocations = 0; // 0 means no declaration
vertices = 0;
vertices = TQualifier::layoutNotSet;
spacing = EvsNone;
order = EvoNone;
pointMode = false;
@ -813,7 +815,7 @@ struct TShaderQualifiers {
originUpperLeft = src.originUpperLeft;
if (src.invocations != 0)
invocations = src.invocations;
if (src.vertices != 0)
if (src.vertices != TQualifier::layoutNotSet)
vertices = src.vertices;
if (src.spacing != EvsNone)
spacing = src.spacing;

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.839"
#define GLSLANG_REVISION "SPIRV99.841"
#define GLSLANG_DATE "11-Dec-2015"

View file

@ -662,7 +662,7 @@ void TParseContext::handleIoResizeArrayAccess(const TSourceLoc& /*loc*/, TInterm
// fix array size, if it can be fixed and needs to be fixed (will allow variable indexing)
if (symbolNode->getType().isImplicitlySizedArray()) {
int newSize = getIoArrayImplicitSize();
if (newSize)
if (newSize > 0)
symbolNode->getWritableType().changeOuterArraySize(newSize);
}
}
@ -703,7 +703,7 @@ int TParseContext::getIoArrayImplicitSize() const
if (language == EShLangGeometry)
return TQualifier::mapGeometryToSize(intermediate.getInputPrimitive());
else if (language == EShLangTessControl)
return intermediate.getVertices();
return intermediate.getVertices() != TQualifier::layoutNotSet ? intermediate.getVertices() : 0;
else
return 0;
}
@ -3875,7 +3875,10 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
case EShLangTessControl:
if (id == "vertices") {
publicType.shaderQualifiers.vertices = value;
if (value == 0)
error(loc, "must be greater than 0", "vertices", "");
else
publicType.shaderQualifiers.vertices = value;
return;
}
break;
@ -4275,7 +4278,7 @@ void TParseContext::checkNoShaderLayouts(const TSourceLoc& loc, const TShaderQua
error(loc, message, TQualifier::getGeometryString(shaderQualifiers.geometry), "");
if (shaderQualifiers.invocations > 0)
error(loc, message, "invocations", "");
if (shaderQualifiers.vertices > 0) {
if (shaderQualifiers.vertices != TQualifier::layoutNotSet) {
if (language == EShLangGeometry)
error(loc, message, "max_vertices", "");
else if (language == EShLangTessControl)
@ -5438,7 +5441,7 @@ void TParseContext::invariantCheck(const TSourceLoc& loc, const TQualifier& qual
//
void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, const TPublicType& publicType)
{
if (publicType.shaderQualifiers.vertices) {
if (publicType.shaderQualifiers.vertices != TQualifier::layoutNotSet) {
assert(language == EShLangTessControl || language == EShLangGeometry);
const char* id = (language == EShLangTessControl) ? "vertices" : "max_vertices";

View file

@ -100,7 +100,7 @@ void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
else if (outputPrimitive != unit.outputPrimitive)
error(infoSink, "Contradictory output layout primitives");
if (vertices == 0)
if (vertices == TQualifier::layoutNotSet)
vertices = unit.vertices;
else if (vertices != unit.vertices) {
if (language == EShLangGeometry)
@ -409,7 +409,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink)
case EShLangVertex:
break;
case EShLangTessControl:
if (vertices == 0)
if (vertices == TQualifier::layoutNotSet)
error(infoSink, "At least one shader must specify an output layout(vertices=...)");
break;
case EShLangTessEvaluation:
@ -425,7 +425,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink)
error(infoSink, "At least one shader must specify an input layout primitive");
if (outputPrimitive == ElgNone)
error(infoSink, "At least one shader must specify an output layout primitive");
if (vertices == 0)
if (vertices == TQualifier::layoutNotSet)
error(infoSink, "At least one shader must specify a layout(max_vertices = value)");
break;
case EShLangFragment:

View file

@ -126,7 +126,7 @@ 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(0), inputPrimitive(ElgNone), outputPrimitive(ElgNone), pixelCenterInteger(false), originUpperLeft(false),
invocations(0), 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;
@ -212,7 +212,7 @@ public:
int getInvocations() const { return invocations; }
bool setVertices(int m)
{
if (vertices > 0)
if (vertices != TQualifier::layoutNotSet)
return vertices == m;
vertices = m;
return true;