Commit 099c0f33 by Jamie Madill Committed by Shannon Woods

Add parsing support for global and interface block scoped matrix packing qualifiers.

TRAC #23271 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods Authored-by: Jamie Madill
parent 0bd18dfb
...@@ -1445,7 +1445,12 @@ void TParseContext::parseGlobalLayoutQualifier(const TPublicType &typeQualifier) ...@@ -1445,7 +1445,12 @@ void TParseContext::parseGlobalLayoutQualifier(const TPublicType &typeQualifier)
return; return;
} }
// TODO: global matrix packing and block storage if (layoutQualifier.matrixPacking != EmpUnspecified)
{
defaultMatrixPacking = layoutQualifier.matrixPacking;
}
// TODO: block storage
} }
TFunction *TParseContext::addConstructorFunc(TPublicType publicType) TFunction *TParseContext::addConstructorFunc(TPublicType publicType)
...@@ -1899,12 +1904,17 @@ TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualif ...@@ -1899,12 +1904,17 @@ TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualif
recover(); recover();
} }
const TLayoutQualifier layoutQualifier = typeQualifier.layoutQualifier; TLayoutQualifier blockLayoutQualifier = typeQualifier.layoutQualifier;
if (layoutLocationErrorCheck(typeQualifier.line, layoutQualifier)) if (layoutLocationErrorCheck(typeQualifier.line, blockLayoutQualifier))
{ {
recover(); recover();
} }
if (blockLayoutQualifier.matrixPacking == EmpUnspecified)
{
blockLayoutQualifier.matrixPacking = defaultMatrixPacking;
}
TSymbol* blockNameSymbol = new TInterfaceBlockName(&blockName); TSymbol* blockNameSymbol = new TInterfaceBlockName(&blockName);
if (!symbolTable.declare(*blockNameSymbol)) { if (!symbolTable.declare(*blockNameSymbol)) {
error(nameLine, "redefinition", blockName.c_str(), "interface block name"); error(nameLine, "redefinition", blockName.c_str(), "interface block name");
...@@ -1933,16 +1943,29 @@ TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualif ...@@ -1933,16 +1943,29 @@ TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualif
} }
// check layout qualifiers // check layout qualifiers
if (layoutLocationErrorCheck(memberTypeLine.line, memberType->getLayoutQualifier())) TLayoutQualifier memberLayoutQualifier = memberType->getLayoutQualifier();
if (layoutLocationErrorCheck(memberTypeLine.line, memberLayoutQualifier))
{ {
recover(); recover();
} }
if (memberLayoutQualifier.matrixPacking == EmpUnspecified)
{
memberLayoutQualifier.matrixPacking = blockLayoutQualifier.matrixPacking;
}
else if (!memberType->isMatrix())
{
error(memberTypeLine.line, "invalid layout qualifier:", getMatrixPackingString(memberLayoutQualifier.matrixPacking), "can only be used on matrix types");
recover();
}
memberType->setLayoutQualifier(memberLayoutQualifier);
} }
TType* interfaceBlock = new TType(typeList, blockName); TType* interfaceBlock = new TType(typeList, blockName);
interfaceBlock->setBasicType(EbtInterfaceBlock); interfaceBlock->setBasicType(EbtInterfaceBlock);
interfaceBlock->setQualifier(typeQualifier.qualifier); interfaceBlock->setQualifier(typeQualifier.qualifier);
interfaceBlock->setLayoutQualifier(layoutQualifier); interfaceBlock->setLayoutQualifier(blockLayoutQualifier);
TString symbolName = ""; TString symbolName = "";
int symbolId = 0; int symbolId = 0;
......
...@@ -38,6 +38,7 @@ struct TParseContext { ...@@ -38,6 +38,7 @@ struct TParseContext {
currentFunctionType(NULL), currentFunctionType(NULL),
functionReturnsValue(false), functionReturnsValue(false),
checksPrecisionErrors(checksPrecErrors), checksPrecisionErrors(checksPrecErrors),
defaultMatrixPacking(EmpColumnMajor),
diagnostics(is), diagnostics(is),
shaderVersion(100), shaderVersion(100),
directiveHandler(ext, diagnostics, shaderVersion), directiveHandler(ext, diagnostics, shaderVersion),
...@@ -57,6 +58,7 @@ struct TParseContext { ...@@ -57,6 +58,7 @@ struct TParseContext {
bool functionReturnsValue; // true if a non-void function has a return bool functionReturnsValue; // true if a non-void function has a return
bool checksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit. bool checksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit.
bool fragmentPrecisionHigh; // true if highp precision is supported in the fragment language. bool fragmentPrecisionHigh; // true if highp precision is supported in the fragment language.
TLayoutMatrixPacking defaultMatrixPacking;
TString HashErrMsg; TString HashErrMsg;
TDiagnostics diagnostics; TDiagnostics diagnostics;
TDirectiveHandler directiveHandler; TDirectiveHandler directiveHandler;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment