aboutsummaryrefslogtreecommitdiff
path: root/glslang/MachineIndependent
diff options
context:
space:
mode:
Diffstat (limited to 'glslang/MachineIndependent')
-rw-r--r--glslang/MachineIndependent/Constant.cpp2
-rw-r--r--glslang/MachineIndependent/Intermediate.cpp4
-rw-r--r--glslang/MachineIndependent/ParseHelper.cpp18
-rw-r--r--glslang/MachineIndependent/ParseHelper.h2
-rw-r--r--glslang/MachineIndependent/Versions.cpp4
-rw-r--r--glslang/MachineIndependent/Versions.h1
-rw-r--r--glslang/MachineIndependent/glslang.y18
-rw-r--r--glslang/MachineIndependent/localintermediate.h2
8 files changed, 32 insertions, 19 deletions
diff --git a/glslang/MachineIndependent/Constant.cpp b/glslang/MachineIndependent/Constant.cpp
index 7e045b6b..801cf1d1 100644
--- a/glslang/MachineIndependent/Constant.cpp
+++ b/glslang/MachineIndependent/Constant.cpp
@@ -85,7 +85,7 @@ namespace glslang {
//
// Returns a new node representing the result.
//
-TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* constantNode) const
+TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* constantNode) const
{
// For most cases, the return type matches the argument type, so set that
// up and just code to exceptions below.
diff --git a/glslang/MachineIndependent/Intermediate.cpp b/glslang/MachineIndependent/Intermediate.cpp
index eaa070ee..952d103e 100644
--- a/glslang/MachineIndependent/Intermediate.cpp
+++ b/glslang/MachineIndependent/Intermediate.cpp
@@ -782,10 +782,12 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true
// Returns the constant union node created.
//
-TIntermConstantUnion* TIntermediate::addConstantUnion(const TConstUnionArray& unionArray, const TType& t, TSourceLoc loc)
+TIntermConstantUnion* TIntermediate::addConstantUnion(const TConstUnionArray& unionArray, const TType& t, TSourceLoc loc, bool literal)
{
TIntermConstantUnion* node = new TIntermConstantUnion(unionArray, t);
node->setLoc(loc);
+ if (literal)
+ node->setLiteral();
return node;
}
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index 00b8b889..12cfb59f 100644
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -2808,12 +2808,24 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
// Put the id's layout qualifier value into the public type. This is before we know any
// type information for error checking.
-void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType, TString& id, int value)
+void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType, TString& id, const TIntermTyped* node)
{
+ const char* feature = "layout-id value";
+ const char* nonLiteralFeature = "non-literal layout-id value";
+
+ integerCheck(node, feature);
+ const TIntermConstantUnion* constUnion = node->getAsConstantUnion();
+ assert(constUnion);
+ int value = node->getAsConstantUnion()->getConstArray()[0].getIConst();
+
+ if (! constUnion->isLiteral()) {
+ requireProfile(loc, ECoreProfile | ECompatibilityProfile, nonLiteralFeature);
+ profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, GL_ARB_enhanced_layouts, nonLiteralFeature);
+ }
+
if (value < 0) {
- error(loc, "cannot be negative", "layout qualifier value", "");
+ error(loc, "cannot be negative", feature, "");
return;
- // TODO: 4.4: test the above, once expressions are allowed; until then, can't even express a negative location
}
std::transform(id.begin(), id.end(), id.begin(), ::tolower);
diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h
index b8c79063..a2dcc605 100644
--- a/glslang/MachineIndependent/ParseHelper.h
+++ b/glslang/MachineIndependent/ParseHelper.h
@@ -148,7 +148,7 @@ public:
void constantIndexExpressionCheck(TIntermNode*);
void setLayoutQualifier(TSourceLoc, TPublicType&, TString&);
- void setLayoutQualifier(TSourceLoc, TPublicType&, TString&, int);
+ void setLayoutQualifier(TSourceLoc, TPublicType&, TString&, const TIntermTyped*);
void mergeObjectLayoutQualifiers(TSourceLoc, TQualifier& dest, const TQualifier& src, bool inheritOnly);
void layoutTypeCheck(TSourceLoc, const TSymbol&);
void layoutQualifierCheck(TSourceLoc, const TQualifier&);
diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp
index 6fc97f74..5fe2de38 100644
--- a/glslang/MachineIndependent/Versions.cpp
+++ b/glslang/MachineIndependent/Versions.cpp
@@ -162,6 +162,7 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[GL_ARB_gpu_shader5] = EBhDisablePartial;
extensionBehavior[GL_ARB_separate_shader_objects] = EBhDisable;
extensionBehavior[GL_ARB_tessellation_shader] = EBhDisable;
+ extensionBehavior[GL_ARB_enhanced_layouts] = EBhDisable;
}
// Get code that is not part of a shared symbol table, is specific to this shader,
@@ -184,7 +185,8 @@ const char* TParseContext::getPreamble()
"#define GL_ARB_texture_gather 1\n"
"#define GL_ARB_gpu_shader5 1\n"
"#define GL_ARB_separate_shader_objects 1\n"
- "#define GL_ARB_tessellation_shader 1\n";
+ "#define GL_ARB_tessellation_shader 1\n"
+ "#define GL_ARB_enhanced_layouts 1\n";
}
}
diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h
index d0997b81..e7ccd2e6 100644
--- a/glslang/MachineIndependent/Versions.h
+++ b/glslang/MachineIndependent/Versions.h
@@ -86,6 +86,7 @@ const char* const GL_ARB_texture_gather = "GL_ARB_texture_gather";
const char* const GL_ARB_gpu_shader5 = "GL_ARB_gpu_shader5";
const char* const GL_ARB_separate_shader_objects = "GL_ARB_separate_shader_objects";
const char* const GL_ARB_tessellation_shader = "GL_ARB_tessellation_shader";
+const char* const GL_ARB_enhanced_layouts = "GL_ARB_enhanced_layouts";
} // end namespace glslang
diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y
index a1dda872..11d60385 100644
--- a/glslang/MachineIndependent/glslang.y
+++ b/glslang/MachineIndependent/glslang.y
@@ -228,29 +228,29 @@ primary_expression
| INTCONSTANT {
TConstUnionArray unionArray(1);
unionArray[0].setIConst($1.i);
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.loc);
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.loc, true);
}
| UINTCONSTANT {
parseContext.fullIntegerCheck($1.loc, "unsigned literal");
TConstUnionArray unionArray(1);
unionArray[0].setUConst($1.u);
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), $1.loc);
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), $1.loc, true);
}
| FLOATCONSTANT {
TConstUnionArray unionArray(1);
unionArray[0].setDConst($1.d);
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.loc);
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.loc, true);
}
| DOUBLECONSTANT {
parseContext.doubleCheck($1.loc, "double literal");
TConstUnionArray unionArray(1);
unionArray[0].setDConst($1.d);
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtDouble, EvqConst), $1.loc);
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtDouble, EvqConst), $1.loc, true);
}
| BOOLCONSTANT {
TConstUnionArray unionArray(1);
unionArray[0].setBConst($1.b);
- $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.loc);
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.loc, true);
}
| LEFT_PAREN expression RIGHT_PAREN {
$$ = $2;
@@ -1110,13 +1110,9 @@ layout_qualifier_id
$$.init($1.loc);
parseContext.setLayoutQualifier($1.loc, $$, *$1.string);
}
- | IDENTIFIER EQUAL INTCONSTANT {
+ | IDENTIFIER EQUAL constant_expression {
$$.init($1.loc);
- parseContext.setLayoutQualifier($1.loc, $$, *$1.string, $3.i);
- }
- | IDENTIFIER EQUAL UINTCONSTANT {
- $$.init($1.loc);
- parseContext.setLayoutQualifier($1.loc, $$, *$1.string, (int)$3.u);
+ parseContext.setLayoutQualifier($1.loc, $$, *$1.string, $3);
}
| SHARED { // because "shared" is both an identifier and a keyword
$$.init($1.loc);
diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h
index 2ce1f1fd..eb85dafa 100644
--- a/glslang/MachineIndependent/localintermediate.h
+++ b/glslang/MachineIndependent/localintermediate.h
@@ -96,7 +96,7 @@ public:
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, TSourceLoc);
- TIntermConstantUnion* addConstantUnion(const TConstUnionArray&, const TType&, TSourceLoc);
+ TIntermConstantUnion* addConstantUnion(const TConstUnionArray&, const TType&, TSourceLoc, bool literal = false);
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
bool parseConstTree(TIntermNode*, TConstUnionArray, TOperator, const TType&, bool singleConstantParam = false);
TIntermLoop* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);