8. io mapping refine & qualifier member check & resolver expand (#2396)
* Code refine and adding missing features 1. Add new level for built in symbols. 2. Fix issues for structure members' qualifiers. 3. Global qualifier fix. 4. IO Mapper refine. Add support for checking with mangle names. * Additional missing features * Invariant member. (Only check non-interface). * Split block nesting level and struct nesting level. To fix issues of checking 'invariant' qualifier. Current grammar would check block/struct member without its parent class's information. So we split nesting level, and 'invariant' would only be checked within a struct. * Format anonymous block names. Refine codes for symbols from all kinds of resouces. * Fix writeonly check. * Use LValueBase to find operator. * Fix random null ptr issue. * invariant check, stage in io mapping, reference parameter should be used and remove wrong codes introduced with ordering vector. * Remained: to be fixed with double check link.vk.multiblocksValid * Fix version error. invariant * Revert loc modification.
This commit is contained in:
parent
d550bebee9
commit
478b232952
25 changed files with 565 additions and 149 deletions
|
|
@ -3368,7 +3368,7 @@ void TParseContext::transparentOpaqueCheck(const TSourceLoc& loc, const TType& t
|
|||
//
|
||||
void TParseContext::memberQualifierCheck(glslang::TPublicType& publicType)
|
||||
{
|
||||
globalQualifierFixCheck(publicType.loc, publicType.qualifier);
|
||||
globalQualifierFixCheck(publicType.loc, publicType.qualifier, true);
|
||||
checkNoShaderLayouts(publicType.loc, publicType.shaderQualifiers);
|
||||
if (publicType.qualifier.isNonUniform()) {
|
||||
error(publicType.loc, "not allowed on block or structure members", "nonuniformEXT", "");
|
||||
|
|
@ -3379,7 +3379,7 @@ void TParseContext::memberQualifierCheck(glslang::TPublicType& publicType)
|
|||
//
|
||||
// Check/fix just a full qualifier (no variables or types yet, but qualifier is complete) at global level.
|
||||
//
|
||||
void TParseContext::globalQualifierFixCheck(const TSourceLoc& loc, TQualifier& qualifier)
|
||||
void TParseContext::globalQualifierFixCheck(const TSourceLoc& loc, TQualifier& qualifier, bool isMemberCheck)
|
||||
{
|
||||
bool nonuniformOkay = false;
|
||||
|
||||
|
|
@ -3404,6 +3404,16 @@ void TParseContext::globalQualifierFixCheck(const TSourceLoc& loc, TQualifier& q
|
|||
case EvqTemporary:
|
||||
nonuniformOkay = true;
|
||||
break;
|
||||
case EvqUniform:
|
||||
// According to GLSL spec: The std430 qualifier is supported only for shader storage blocks; a shader using
|
||||
// the std430 qualifier on a uniform block will fail to compile.
|
||||
// Only check the global declaration: layout(std430) uniform;
|
||||
if (blockName == nullptr &&
|
||||
qualifier.layoutPacking == ElpStd430)
|
||||
{
|
||||
error(loc, "it is invalid to declare std430 qualifier on uniform", "", "");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -3411,7 +3421,9 @@ void TParseContext::globalQualifierFixCheck(const TSourceLoc& loc, TQualifier& q
|
|||
if (!nonuniformOkay && qualifier.isNonUniform())
|
||||
error(loc, "for non-parameter, can only apply to 'in' or no storage qualifier", "nonuniformEXT", "");
|
||||
|
||||
invariantCheck(loc, qualifier);
|
||||
// Storage qualifier isn't ready for memberQualifierCheck, we should skip invariantCheck for it.
|
||||
if (!isMemberCheck || structNestingLevel > 0)
|
||||
invariantCheck(loc, qualifier);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -4083,6 +4095,9 @@ void TParseContext::checkRuntimeSizable(const TSourceLoc& loc, const TIntermType
|
|||
if (isRuntimeLength(base))
|
||||
return;
|
||||
|
||||
if (base.getType().getQualifier().builtIn == EbvSampleMask)
|
||||
return;
|
||||
|
||||
// Check for last member of a bufferreference type, which is runtime sizeable
|
||||
// but doesn't support runtime length
|
||||
if (base.getType().getQualifier().storage == EvqBuffer) {
|
||||
|
|
@ -4634,14 +4649,14 @@ void TParseContext::paramCheckFix(const TSourceLoc& loc, const TQualifier& quali
|
|||
|
||||
void TParseContext::nestedBlockCheck(const TSourceLoc& loc)
|
||||
{
|
||||
if (structNestingLevel > 0)
|
||||
if (structNestingLevel > 0 || blockNestingLevel > 0)
|
||||
error(loc, "cannot nest a block definition inside a structure or block", "", "");
|
||||
++structNestingLevel;
|
||||
++blockNestingLevel;
|
||||
}
|
||||
|
||||
void TParseContext::nestedStructCheck(const TSourceLoc& loc)
|
||||
{
|
||||
if (structNestingLevel > 0)
|
||||
if (structNestingLevel > 0 || blockNestingLevel > 0)
|
||||
error(loc, "cannot nest a structure definition inside a structure or block", "", "");
|
||||
++structNestingLevel;
|
||||
}
|
||||
|
|
@ -6537,13 +6552,15 @@ void TParseContext::declareTypeDefaults(const TSourceLoc& loc, const TPublicType
|
|||
error(loc, "atomic_uint binding is too large", "binding", "");
|
||||
return;
|
||||
}
|
||||
|
||||
if(publicType.qualifier.hasOffset()) {
|
||||
if (publicType.qualifier.hasOffset())
|
||||
atomicUintOffsets[publicType.qualifier.layoutBinding] = publicType.qualifier.layoutOffset;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (publicType.arraySizes) {
|
||||
error(loc, "expect an array name", "", "");
|
||||
}
|
||||
|
||||
if (publicType.qualifier.hasLayout() && !publicType.qualifier.hasBufferReference())
|
||||
warn(loc, "useless application of layout qualifier", "layout", "");
|
||||
#endif
|
||||
|
|
@ -6634,6 +6651,22 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
|
|||
if (type.getQualifier().storage == EvqShared && type.containsCoopMat())
|
||||
error(loc, "qualifier", "Cooperative matrix types must not be used in shared memory", "");
|
||||
|
||||
if (profile == EEsProfile) {
|
||||
if (type.getQualifier().isPipeInput() && type.getBasicType() == EbtStruct) {
|
||||
if (type.getQualifier().isArrayedIo(language)) {
|
||||
TType perVertexType(type, 0);
|
||||
if (perVertexType.containsArray() && perVertexType.containsBuiltIn() == false) {
|
||||
error(loc, "A per vertex structure containing an array is not allowed as input in ES", type.getTypeName().c_str(), "");
|
||||
}
|
||||
}
|
||||
else if (type.containsArray() && type.containsBuiltIn() == false) {
|
||||
error(loc, "A structure containing an array is not allowed as input in ES", type.getTypeName().c_str(), "");
|
||||
}
|
||||
if (type.containsStructure())
|
||||
error(loc, "A structure containing an struct is not allowed as input in ES", type.getTypeName().c_str(), "");
|
||||
}
|
||||
}
|
||||
|
||||
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", "");
|
||||
if (identifier != "gl_FragDepth" && publicType.shaderQualifiers.getDepth() != EldNone)
|
||||
|
|
@ -6956,6 +6989,15 @@ TIntermTyped* TParseContext::convertInitializerList(const TSourceLoc& loc, const
|
|||
error(loc, "wrong vector size (or rows in a matrix column):", "initializer list", type.getCompleteString().c_str());
|
||||
return nullptr;
|
||||
}
|
||||
TBasicType destType = type.getBasicType();
|
||||
for (int i = 0; i < type.getVectorSize(); ++i) {
|
||||
TBasicType initType = initList->getSequence()[i]->getAsTyped()->getBasicType();
|
||||
if (destType != initType && !intermediate.canImplicitlyPromote(initType, destType)) {
|
||||
error(loc, "type mismatch in initializer list", "initializer list", type.getCompleteString().c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
error(loc, "unexpected initializer-list type:", "initializer list", type.getCompleteString().c_str());
|
||||
return nullptr;
|
||||
|
|
@ -7492,10 +7534,10 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
|
|||
TType& memberType = *typeList[member].type;
|
||||
TQualifier& memberQualifier = memberType.getQualifier();
|
||||
const TSourceLoc& memberLoc = typeList[member].loc;
|
||||
globalQualifierFixCheck(memberLoc, memberQualifier);
|
||||
if (memberQualifier.storage != EvqTemporary && memberQualifier.storage != EvqGlobal && memberQualifier.storage != currentBlockQualifier.storage)
|
||||
error(memberLoc, "member storage qualifier cannot contradict block storage qualifier", memberType.getFieldName().c_str(), "");
|
||||
memberQualifier.storage = currentBlockQualifier.storage;
|
||||
globalQualifierFixCheck(memberLoc, memberQualifier);
|
||||
#ifndef GLSLANG_WEB
|
||||
inheritMemoryQualifiers(currentBlockQualifier, memberQualifier);
|
||||
if (currentBlockQualifier.perPrimitiveNV)
|
||||
|
|
@ -8193,7 +8235,7 @@ void TParseContext::invariantCheck(const TSourceLoc& loc, const TQualifier& qual
|
|||
|
||||
bool pipeOut = qualifier.isPipeOutput();
|
||||
bool pipeIn = qualifier.isPipeInput();
|
||||
if (version >= 300 || (!isEsProfile() && version >= 420)) {
|
||||
if ((version >= 300 && isEsProfile()) || (!isEsProfile() && version >= 420)) {
|
||||
if (! pipeOut)
|
||||
error(loc, "can only apply to an output", "invariant", "");
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue