Implement GL_NV_cooperative_matrix

This commit is contained in:
Jeff Bolz 2019-02-19 13:10:32 -06:00
parent ec484527b6
commit 4605e2ed2b
37 changed files with 5630 additions and 4211 deletions

View file

@ -1235,9 +1235,11 @@ public:
int vectorSize : 4;
int matrixCols : 4;
int matrixRows : 4;
bool coopmat : 1;
TArraySizes* arraySizes;
const TType* userDef;
TSourceLoc loc;
TArraySizes* typeParameters;
void initType(const TSourceLoc& l)
{
@ -1248,6 +1250,8 @@ public:
arraySizes = nullptr;
userDef = nullptr;
loc = l;
typeParameters = nullptr;
coopmat = false;
}
void initQualifiers(bool global = false)
@ -1299,8 +1303,8 @@ public:
// for "empty" type (no args) or simple scalar/vector/matrix
explicit TType(TBasicType t = EbtVoid, TStorageQualifier q = EvqTemporary, int vs = 1, int mc = 0, int mr = 0,
bool isVector = false) :
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), vector1(isVector && vs == 1),
arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr)
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), vector1(isVector && vs == 1), coopmat(false),
arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr), typeParameters(nullptr)
{
sampler.clear();
qualifier.clear();
@ -1310,8 +1314,8 @@ public:
// for explicit precision qualifier
TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs = 1, int mc = 0, int mr = 0,
bool isVector = false) :
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), vector1(isVector && vs == 1),
arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr)
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), vector1(isVector && vs == 1), coopmat(false),
arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr), typeParameters(nullptr)
{
sampler.clear();
qualifier.clear();
@ -1323,8 +1327,8 @@ public:
// for turning a TPublicType into a TType, using a shallow copy
explicit TType(const TPublicType& p) :
basicType(p.basicType),
vectorSize(p.vectorSize), matrixCols(p.matrixCols), matrixRows(p.matrixRows), vector1(false),
arraySizes(p.arraySizes), structure(nullptr), fieldName(nullptr), typeName(nullptr)
vectorSize(p.vectorSize), matrixCols(p.matrixCols), matrixRows(p.matrixRows), vector1(false), coopmat(p.coopmat),
arraySizes(p.arraySizes), structure(nullptr), fieldName(nullptr), typeName(nullptr), typeParameters(p.typeParameters)
{
if (basicType == EbtSampler)
sampler = p.sampler;
@ -1340,12 +1344,18 @@ public:
}
typeName = NewPoolTString(p.userDef->getTypeName().c_str());
}
if (p.coopmat && p.basicType == EbtFloat &&
p.typeParameters && p.typeParameters->getNumDims() > 0 &&
p.typeParameters->getDimSize(0) == 16) {
basicType = EbtFloat16;
qualifier.precision = EpqNone;
}
}
// for construction of sampler types
TType(const TSampler& sampler, TStorageQualifier q = EvqUniform, TArraySizes* as = nullptr) :
basicType(EbtSampler), vectorSize(1), matrixCols(0), matrixRows(0), vector1(false),
basicType(EbtSampler), vectorSize(1), matrixCols(0), matrixRows(0), vector1(false), coopmat(false),
arraySizes(as), structure(nullptr), fieldName(nullptr), typeName(nullptr),
sampler(sampler)
sampler(sampler), typeParameters(nullptr)
{
qualifier.clear();
qualifier.storage = q;
@ -1386,13 +1396,16 @@ public:
// dereference from vector to scalar
vectorSize = 1;
vector1 = false;
} else if (isCoopMat()) {
coopmat = false;
typeParameters = nullptr;
}
}
}
// for making structures, ...
TType(TTypeList* userDef, const TString& n) :
basicType(EbtStruct), vectorSize(1), matrixCols(0), matrixRows(0), vector1(false),
arraySizes(nullptr), structure(userDef), fieldName(nullptr)
basicType(EbtStruct), vectorSize(1), matrixCols(0), matrixRows(0), vector1(false), coopmat(false),
arraySizes(nullptr), structure(userDef), fieldName(nullptr), typeParameters(nullptr)
{
sampler.clear();
qualifier.clear();
@ -1400,8 +1413,8 @@ public:
}
// For interface blocks
TType(TTypeList* userDef, const TString& n, const TQualifier& q) :
basicType(EbtBlock), vectorSize(1), matrixCols(0), matrixRows(0), vector1(false),
qualifier(q), arraySizes(nullptr), structure(userDef), fieldName(nullptr)
basicType(EbtBlock), vectorSize(1), matrixCols(0), matrixRows(0), vector1(false), coopmat(false),
qualifier(q), arraySizes(nullptr), structure(userDef), fieldName(nullptr), typeParameters(nullptr)
{
sampler.clear();
typeName = NewPoolTString(n.c_str());
@ -1439,6 +1452,8 @@ public:
} else {
referentType = copyOf.referentType;
}
typeParameters = copyOf.typeParameters;
coopmat = copyOf.coopmat;
}
// Make complete copy of the whole type graph rooted at 'copyOf'.
@ -1502,6 +1517,8 @@ public:
virtual const TArraySizes* getArraySizes() const { return arraySizes; }
virtual TArraySizes* getArraySizes() { return arraySizes; }
virtual TType* getReferentType() const { return referentType; }
virtual const TArraySizes* getTypeParameters() const { return typeParameters; }
virtual TArraySizes* getTypeParameters() { return typeParameters; }
virtual bool isScalar() const { return ! isVector() && ! isMatrix() && ! isStruct() && ! isArray(); }
virtual bool isScalarOrVec1() const { return isScalar() || vector1; }
@ -1544,6 +1561,8 @@ public:
virtual bool isImage() const { return basicType == EbtSampler && getSampler().isImage(); }
virtual bool isSubpass() const { return basicType == EbtSampler && getSampler().isSubpass(); }
virtual bool isTexture() const { return basicType == EbtSampler && getSampler().isTexture(); }
virtual bool isParameterized() const { return typeParameters != nullptr; }
virtual bool isCoopMat() const { return coopmat; }
// return true if this type contains any subtype which satisfies the given predicate.
template <typename P>
@ -1633,6 +1652,11 @@ public:
return containsBasicType(EbtInt8) || containsBasicType(EbtUint8);
}
virtual bool containsCoopMat() const
{
return contains([](const TType* t) { return t->coopmat; } );
}
// Array editing methods. Array descriptors can be shared across
// type instances. This allows all uses of the same array
// to be updated at once. E.g., all nodes can be explicitly sized
@ -1705,6 +1729,46 @@ public:
}
}
void updateTypeParameters(const TType& type)
{
// For when we may already be sharing existing array descriptors,
// keeping the pointers the same, just updating the contents.
assert(typeParameters != nullptr);
assert(type.typeParameters != nullptr);
*typeParameters = *type.typeParameters;
}
void copyTypeParameters(const TArraySizes& s)
{
// For setting a fresh new set of type parameters, not yet worrying about sharing.
typeParameters = new TArraySizes;
*typeParameters = s;
}
void transferTypeParameters(TArraySizes* s)
{
// For setting an already allocated set of sizes that this type can use
// (no copy made).
typeParameters = s;
}
void clearTypeParameters()
{
typeParameters = nullptr;
}
// Add inner array sizes, to any existing sizes, via copy; the
// sizes passed in can still be reused for other purposes.
void copyTypeParametersInnerSizes(const TArraySizes* s)
{
if (s != nullptr) {
if (typeParameters == nullptr)
copyTypeParameters(*s);
else
typeParameters->addInnerSizes(*s);
}
}
const char* getBasicString() const
{
return TType::getBasicString(basicType);
@ -1919,6 +1983,15 @@ public:
}
}
}
if (isParameterized()) {
appendStr("<");
for(int i = 0; i < (int)typeParameters->getNumDims(); ++i) {
appendInt(typeParameters->getDimSize(i));
if (i != (int)typeParameters->getNumDims() - 1)
appendStr(", ");
}
appendStr(">");
}
if (qualifier.precision != EpqNone) {
appendStr(" ");
appendStr(getPrecisionQualifierString());
@ -2075,6 +2148,13 @@ public:
return arraySizes->sameInnerArrayness(*right.arraySizes);
}
// See if two type's parameters match
bool sameTypeParameters(const TType& right) const
{
return ((typeParameters == nullptr && right.typeParameters == nullptr) ||
(typeParameters != nullptr && right.typeParameters != nullptr && *typeParameters == *right.typeParameters));
}
// See if two type's elements match in all ways except basic type
bool sameElementShape(const TType& right) const
{
@ -2083,14 +2163,23 @@ public:
matrixCols == right.matrixCols &&
matrixRows == right.matrixRows &&
vector1 == right.vector1 &&
coopmat == right.coopmat &&
sameStructType(right) &&
sameReferenceType(right);
}
// See if a cooperative matrix type parameter with unspecified parameters is
// an OK function parameter
bool coopMatParameterOK(const TType& right) const
{
return coopmat && right.coopmat &&
typeParameters == nullptr && right.typeParameters != nullptr;
}
// See if two types match in all ways (just the actual type, not qualification)
bool operator==(const TType& right) const
{
return sameElementType(right) && sameArrayness(right);
return sameElementType(right) && sameArrayness(right) && sameTypeParameters(right);
}
bool operator!=(const TType& right) const
@ -2115,6 +2204,11 @@ protected:
*arraySizes = *copyOf.arraySizes;
}
if (copyOf.typeParameters) {
typeParameters = new TArraySizes;
*typeParameters = *copyOf.typeParameters;
}
if (copyOf.isStruct() && copyOf.structure) {
auto prevCopy = copiedMap.find(copyOf.structure);
if (prevCopy != copiedMap.end())
@ -2150,6 +2244,7 @@ protected:
// functionality is added.
// HLSL does have a 1-component vectors, so this will be true to disambiguate
// from a scalar.
bool coopmat : 1;
TQualifier qualifier;
TArraySizes* arraySizes; // nullptr unless an array; can be shared across types
@ -2162,6 +2257,7 @@ protected:
TString *fieldName; // for structure field names
TString *typeName; // for structure type name
TSampler sampler;
TArraySizes* typeParameters;// nullptr unless a parameterized type; can be shared across types
};
} // end namespace glslang

View file

@ -254,7 +254,9 @@ struct TArraySizes {
void addInnerSize() { addInnerSize((unsigned)UnsizedArraySize); }
void addInnerSize(int s) { addInnerSize((unsigned)s, nullptr); }
void addInnerSize(int s, TIntermTyped* n) { sizes.push_back((unsigned)s, n); }
void addInnerSize(TArraySize pair) { sizes.push_back(pair.size, pair.node); }
void addInnerSize(TArraySize pair) {
sizes.push_back(pair.size, pair.node);
}
void addInnerSizes(const TArraySizes& s) { sizes.push_back(s.sizes); }
void changeOuterSize(int s) { sizes.changeFront((unsigned)s); }
int getImplicitSize() const { return implicitArraySize; }
@ -318,8 +320,8 @@ struct TArraySizes {
void setVariablyIndexed() { variablyIndexed = true; }
bool isVariablyIndexed() const { return variablyIndexed; }
bool operator==(const TArraySizes& rhs) { return sizes == rhs.sizes; }
bool operator!=(const TArraySizes& rhs) { return sizes != rhs.sizes; }
bool operator==(const TArraySizes& rhs) const { return sizes == rhs.sizes; }
bool operator!=(const TArraySizes& rhs) const { return sizes != rhs.sizes; }
protected:
TSmallArrayVector sizes;

View file

@ -615,6 +615,10 @@ enum TOperator {
EOpAny,
EOpAll,
EOpCooperativeMatrixLoad,
EOpCooperativeMatrixStore,
EOpCooperativeMatrixMulAdd,
//
// Branch
//
@ -737,6 +741,7 @@ enum TOperator {
EOpConstructTextureSampler,
EOpConstructNonuniform, // expected to be transformed away, not present in final AST
EOpConstructReference,
EOpConstructCooperativeMatrix,
EOpConstructGuardEnd,
//

4
glslang/MachineIndependent/Constant.cpp Executable file → Normal file
View file

@ -1354,7 +1354,9 @@ TIntermTyped* TIntermediate::foldDereference(TIntermTyped* node, int index, cons
// arrays, vectors, matrices, all use simple multiplicative math
// while structures need to add up heterogeneous members
int start;
if (node->isArray() || ! node->isStruct())
if (node->getType().isCoopMat())
start = 0;
else if (node->isArray() || ! node->isStruct())
start = size * index;
else {
// it is a structure

36
glslang/MachineIndependent/Initialize.cpp Executable file → Normal file
View file

@ -4928,6 +4928,34 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
commonBuiltins.append("void controlBarrier(int, int, int, int);\n"
"void memoryBarrier(int, int, int);\n");
if (profile != EEsProfile && version >= 450) {
// coopMatStoreNV perhaps ought to have "out" on the buf parameter, but
// adding it introduces undesirable tempArgs on the stack. What we want
// is more like "buf" thought of as a pointer value being an in parameter.
stageBuiltins[EShLangCompute].append(
"void coopMatLoadNV(out fcoopmatNV m, volatile coherent float16_t[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatLoadNV(out fcoopmatNV m, volatile coherent float[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatLoadNV(out fcoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatLoadNV(out fcoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatStoreNV(fcoopmatNV m, volatile coherent float16_t[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatStoreNV(fcoopmatNV m, volatile coherent float[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatStoreNV(fcoopmatNV m, volatile coherent float64_t[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatStoreNV(fcoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatStoreNV(fcoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatStoreNV(fcoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatStoreNV(fcoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatStoreNV(fcoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
"void coopMatStoreNV(fcoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
"fcoopmatNV coopMatMulAddNV(fcoopmatNV A, fcoopmatNV B, fcoopmatNV C);\n"
);
}
//============================================================================
//
// Prototypes for built-in functions seen by fragment shaders only.
@ -8658,6 +8686,11 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
}
symbolTable.setFunctionExtensions("coopMatLoadNV", 1, &E_GL_NV_cooperative_matrix);
symbolTable.setFunctionExtensions("coopMatStoreNV", 1, &E_GL_NV_cooperative_matrix);
symbolTable.setFunctionExtensions("coopMatMulAddNV", 1, &E_GL_NV_cooperative_matrix);
break;
#ifdef NV_EXTENSIONS
case EShLangRayGenNV:
@ -9462,6 +9495,9 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.relateToOperator("fwidthCoarse",EOpFwidthCoarse);
}
#endif
symbolTable.relateToOperator("coopMatLoadNV", EOpCooperativeMatrixLoad);
symbolTable.relateToOperator("coopMatStoreNV", EOpCooperativeMatrixStore);
symbolTable.relateToOperator("coopMatMulAddNV", EOpCooperativeMatrixMulAdd);
break;
#ifdef NV_EXTENSIONS

49
glslang/MachineIndependent/Intermediate.cpp Executable file → Normal file
View file

@ -725,6 +725,11 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
return newNode;
}
TIntermTyped* TIntermediate::addConversion(TBasicType convertTo, TIntermTyped* node) const
{
return createConversion(convertTo, node);
}
// For converting a pair of operands to a binary operation to compatible
// types with each other, relative to the operation in 'op'.
// This does not cover assignment operations, which is asymmetric in that the
@ -751,6 +756,10 @@ TIntermediate::addConversion(TOperator op, TIntermTyped* node0, TIntermTyped* no
// If differing arrays, then no conversions.
if (node0->getType().isArray() || node1->getType().isArray())
return std::make_tuple(nullptr, nullptr);
// No implicit conversions for operations involving cooperative matrices
if (node0->getType().isCoopMat() || node1->getType().isCoopMat())
return std::make_tuple(node0, node1);
}
auto promoteTo = std::make_tuple(EbtNumTypes, EbtNumTypes);
@ -983,6 +992,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EOpSequence:
case EOpConstructStruct:
case EOpConstructCooperativeMatrix:
if (type.getBasicType() == EbtReference || node->getType().getBasicType() == EbtReference) {
// types must match to assign a reference
@ -998,7 +1008,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
if (canImplicitlyPromote(node->getBasicType(), type.getBasicType(), op))
promoteTo = type.getBasicType();
else
return nullptr;
return nullptr;
break;
// For GLSL, there are no conversions needed; the shift amount just needs to be an
@ -1847,6 +1857,9 @@ TOperator TIntermediate::mapTypeToConstructorOp(const TType& type) const
if (type.getQualifier().nonUniform)
return EOpConstructNonuniform;
if (type.isCoopMat())
return EOpConstructCooperativeMatrix;
switch (type.getBasicType()) {
case EbtStruct:
op = EOpConstructStruct;
@ -3319,6 +3332,40 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
break;
}
if (left->getType().isCoopMat() || right->getType().isCoopMat()) {
if (left->getType().isCoopMat() && right->getType().isCoopMat() &&
*left->getType().getTypeParameters() != *right->getType().getTypeParameters()) {
return false;
}
switch (op) {
case EOpMul:
case EOpMulAssign:
if (left->getType().isCoopMat() && right->getType().isCoopMat()) {
return false;
}
if (op == EOpMulAssign && right->getType().isCoopMat()) {
return false;
}
node.setOp(op == EOpMulAssign ? EOpMatrixTimesScalarAssign : EOpMatrixTimesScalar);
if (right->getType().isCoopMat()) {
node.setType(right->getType());
}
return true;
case EOpAdd:
case EOpSub:
case EOpDiv:
case EOpAssign:
// These require both to be cooperative matrices
if (!left->getType().isCoopMat() || !right->getType().isCoopMat()) {
return false;
}
return true;
default:
break;
}
return false;
}
// Finish handling the case, for all ops, where both operands are scalars.
if (left->isScalar() && right->isScalar())
return true;

138
glslang/MachineIndependent/ParseHelper.cpp Executable file → Normal file
View file

@ -275,6 +275,12 @@ void TParseContext::handlePragma(const TSourceLoc& loc, const TVector<TString>&
if (tokens.size() != 1)
error(loc, "extra tokens", "#pragma", "");
intermediate.setUseVulkanMemoryModel();
} else if (spvVersion.spv > 0 && tokens[0].compare("use_variable_pointers") == 0) {
if (tokens.size() != 1)
error(loc, "extra tokens", "#pragma", "");
if (spvVersion.spv < glslang::EShTargetSpv_1_3)
error(loc, "requires SPIR-V 1.3", "#pragma use_variable_pointers", "");
intermediate.setUseVariablePointers();
} else if (tokens[0].compare("once") == 0) {
warn(loc, "not implemented", "#pragma once", "");
} else if (tokens[0].compare("glslang_binary_double_output") == 0)
@ -371,7 +377,7 @@ TIntermTyped* TParseContext::handleBracketDereference(const TSourceLoc& loc, TIn
// basic type checks...
variableCheck(base);
if (! base->isArray() && ! base->isMatrix() && ! base->isVector()) {
if (! base->isArray() && ! base->isMatrix() && ! base->isVector() && ! base->getType().isCoopMat()) {
if (base->getAsSymbolNode())
error(loc, " left of '[' is not of type array, matrix, or vector ", base->getAsSymbolNode()->getName().c_str(), "");
else
@ -767,7 +773,7 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
const char* feature = ".length() on vectors and matrices";
requireProfile(loc, ~EEsProfile, feature);
profileRequires(loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, feature);
} else {
} else if (!base->getType().isCoopMat()) {
error(loc, "does not operate on this type:", field.c_str(), base->getType().getCompleteString().c_str());
return base;
@ -784,6 +790,11 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
return base;
}
if (base->getType().isCoopMat()) {
error(loc, "cannot apply to a cooperative matrix type:", ".", field.c_str());
return base;
}
// It's neither an array nor .length() if we get here,
// leaving swizzles and struct/block dereferences.
@ -1204,6 +1215,13 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
}
result = addOutputArgumentConversions(*fnCandidate, *result->getAsAggregate());
}
if (result->getAsTyped()->getType().isCoopMat() &&
!result->getAsTyped()->getType().isParameterized()) {
assert(fnCandidate->getBuiltInOp() == EOpCooperativeMatrixMulAdd);
result->setType(result->getAsAggregate()->getSequence()[2]->getAsTyped()->getType());
}
}
}
@ -1430,6 +1448,8 @@ TIntermTyped* TParseContext::handleLengthMethod(const TSourceLoc& loc, TFunction
length = type.getMatrixCols();
else if (type.isVector())
length = type.getVectorSize();
else if (type.isCoopMat())
return intermediate.addBuiltInFunctionCall(loc, EOpArrayLength, true, intermNode, TType(EbtInt));
else {
// we should not get here, because earlier semantic checking should have prevented this path
error(loc, ".length()", "unexpected use of .length()", "");
@ -1456,7 +1476,8 @@ void TParseContext::addInputArgumentConversions(const TFunction& function, TInte
// means take 'arguments' itself as the one argument.
TIntermTyped* arg = function.getParamCount() == 1 ? arguments->getAsTyped() : (aggregate ? aggregate->getSequence()[i]->getAsTyped() : arguments->getAsTyped());
if (*function[i].type != arg->getType()) {
if (function[i].type->getQualifier().isParamInput()) {
if (function[i].type->getQualifier().isParamInput() &&
!function[i].type->isCoopMat()) {
// In-qualified arguments just need an extra node added above the argument to
// convert to the correct type.
arg = intermediate.addConversion(EOpFunctionCall, *function[i].type, arg);
@ -1524,7 +1545,14 @@ TIntermTyped* TParseContext::addOutputArgumentConversions(const TFunction& funct
if (function[i].type->getQualifier().isParamOutput()) {
// Out-qualified arguments need to use the topology set up above.
// do the " ...(tempArg, ...), arg = tempArg" bit from above
TVariable* tempArg = makeInternalVariable("tempArg", *function[i].type);
TType paramType;
paramType.shallowCopy(*function[i].type);
if (arguments[i]->getAsTyped()->getType().isParameterized() &&
!paramType.isParameterized()) {
paramType.shallowCopy(arguments[i]->getAsTyped()->getType());
paramType.copyTypeParameters(*arguments[i]->getAsTyped()->getType().getTypeParameters());
}
TVariable* tempArg = makeInternalVariable("tempArg", paramType);
tempArg->getWritableType().getQualifier().makeTemporary();
TIntermSymbol* tempArgNode = intermediate.addSymbol(*tempArg, intermNode.getLoc());
TIntermTyped* tempAssign = intermediate.addAssign(EOpAssign, arguments[i]->getAsTyped(), tempArgNode, arguments[i]->getLoc());
@ -2913,6 +2941,16 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
return true;
}
if (type.isCoopMat() && function.getParamCount() != 1) {
error(loc, "wrong number of arguments", "constructor", "");
return true;
}
if (type.isCoopMat() &&
!(function[0].type->isScalar() || function[0].type->isCoopMat())) {
error(loc, "Cooperative matrix constructor argument must be scalar or cooperative matrix", "constructor", "");
return true;
}
TIntermTyped* typed = node->getAsTyped();
if (typed == nullptr) {
error(loc, "constructor argument does not have a type", "constructor", "");
@ -3534,7 +3572,7 @@ bool TParseContext::containsFieldWithBasicType(const TType& type, TBasicType bas
//
// Do size checking for an array type's size.
//
void TParseContext::arraySizeCheck(const TSourceLoc& loc, TIntermTyped* expr, TArraySize& sizePair)
void TParseContext::arraySizeCheck(const TSourceLoc& loc, TIntermTyped* expr, TArraySize& sizePair, const char *sizeType)
{
bool isConst = false;
sizePair.node = nullptr;
@ -3554,18 +3592,24 @@ void TParseContext::arraySizeCheck(const TSourceLoc& loc, TIntermTyped* expr, TA
TIntermSymbol* symbol = expr->getAsSymbolNode();
if (symbol && symbol->getConstArray().size() > 0)
size = symbol->getConstArray()[0].getIConst();
} else if (expr->getAsUnaryNode() &&
expr->getAsUnaryNode()->getOp() == glslang::EOpArrayLength &&
expr->getAsUnaryNode()->getOperand()->getType().isCoopMat()) {
isConst = true;
size = 1;
sizePair.node = expr->getAsUnaryNode();
}
}
sizePair.size = size;
if (! isConst || (expr->getBasicType() != EbtInt && expr->getBasicType() != EbtUint)) {
error(loc, "array size must be a constant integer expression", "", "");
error(loc, sizeType, "", "must be a constant integer expression");
return;
}
if (size <= 0) {
error(loc, "array size must be a positive integer", "", "");
error(loc, sizeType, "", "must be a positive integer");
return;
}
}
@ -3623,7 +3667,7 @@ bool TParseContext::arrayError(const TSourceLoc& loc, const TType& type)
//
void TParseContext::arraySizeRequiredCheck(const TSourceLoc& loc, const TArraySizes& arraySizes)
{
if (arraySizes.hasUnsized())
if (!parsingBuiltins && arraySizes.hasUnsized())
error(loc, "array size required", "", "");
}
@ -3660,7 +3704,8 @@ void TParseContext::arraySizesCheck(const TSourceLoc& loc, const TQualifier& qua
arraySizes->clearInnerUnsized();
}
if (arraySizes->isInnerSpecialization())
if (arraySizes->isInnerSpecialization() &&
(qualifier.storage != EvqTemporary && qualifier.storage != EvqGlobal && qualifier.storage != EvqShared && qualifier.storage != EvqConst))
error(loc, "only outermost dimension of an array of arrays can be a specialization constant", "[]", "");
// desktop always allows outer-dimension-unsized variable arrays,
@ -6035,9 +6080,18 @@ const TFunction* TParseContext::findFunction400(const TSourceLoc& loc, const TFu
symbolTable.findFunctionNameList(call.getMangledName(), candidateList, builtIn);
// can 'from' convert to 'to'?
const auto convertible = [this](const TType& from, const TType& to, TOperator, int) -> bool {
const auto convertible = [this,builtIn](const TType& from, const TType& to, TOperator, int) -> bool {
if (from == to)
return true;
if (from.coopMatParameterOK(to))
return true;
// Allow a sized array to be passed through an unsized array parameter, for coopMatLoad/Store functions
if (builtIn && from.isArray() && to.isUnsizedArray()) {
TType fromElementType(from, 0);
TType toElementType(to, 0);
if (fromElementType == toElementType)
return true;
}
if (from.isArray() || to.isArray() || ! from.sameElementShape(to))
return false;
return intermediate.canImplicitlyPromote(from.getBasicType(), to.getBasicType());
@ -6100,9 +6154,18 @@ const TFunction* TParseContext::findFunctionExplicitTypes(const TSourceLoc& loc,
symbolTable.findFunctionNameList(call.getMangledName(), candidateList, builtIn);
// can 'from' convert to 'to'?
const auto convertible = [this](const TType& from, const TType& to, TOperator, int) -> bool {
const auto convertible = [this,builtIn](const TType& from, const TType& to, TOperator, int) -> bool {
if (from == to)
return true;
if (from.coopMatParameterOK(to))
return true;
// Allow a sized array to be passed through an unsized array parameter, for coopMatLoad/Store functions
if (builtIn && from.isArray() && to.isUnsizedArray()) {
TType fromElementType(from, 0);
TType toElementType(to, 0);
if (fromElementType == toElementType)
return true;
}
if (from.isArray() || to.isArray() || ! from.sameElementShape(to))
return false;
return intermediate.canImplicitlyPromote(from.getBasicType(), to.getBasicType());
@ -6194,6 +6257,25 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
type.copyArrayInnerSizes(publicType.arraySizes);
arrayOfArrayVersionCheck(loc, type.getArraySizes());
if (type.isCoopMat()) {
intermediate.setUseVulkanMemoryModel();
intermediate.setUseStorageBuffer();
if (!publicType.typeParameters || publicType.typeParameters->getNumDims() != 4) {
error(loc, "expected four type parameters", identifier.c_str(), "");
}
if (publicType.typeParameters &&
publicType.typeParameters->getDimSize(0) != 16 &&
publicType.typeParameters->getDimSize(0) != 32 &&
publicType.typeParameters->getDimSize(0) != 64) {
error(loc, "expected 16, 32, or 64 bits for first type parameter", identifier.c_str(), "");
}
} else {
if (publicType.typeParameters && publicType.typeParameters->getNumDims() != 0) {
error(loc, "unexpected type parameters", identifier.c_str(), "");
}
}
if (voidErrorCheck(loc, identifier, type.getBasicType()))
return nullptr;
@ -6218,6 +6300,10 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
requireInt8Arithmetic(loc, "qualifier", "(u)int8 types can only be in uniform block or buffer storage");
}
if (type.getQualifier().storage == EvqShared &&
type.containsCoopMat())
error(loc, "qualifier", "Cooperative matrix types must not be used in shared memory", "");
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.layoutDepth != EldNone)
@ -6809,6 +6895,33 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
return nullptr;
}
case EOpConstructCooperativeMatrix:
if (!node->getType().isCoopMat()) {
if (type.getBasicType() != node->getType().getBasicType()) {
node = intermediate.addConversion(type.getBasicType(), node);
}
node = intermediate.setAggregateOperator(node, EOpConstructCooperativeMatrix, type, node->getLoc());
} else {
switch (type.getBasicType()) {
default:
assert(0);
break;
case EbtFloat:
assert(node->getType().getBasicType() == EbtFloat16);
node = intermediate.addUnaryNode(EOpConvFloat16ToFloat, node, node->getLoc(), type);
break;
case EbtFloat16:
assert(node->getType().getBasicType() == EbtFloat);
node = intermediate.addUnaryNode(EOpConvFloatToFloat16, node, node->getLoc(), type);
break;
}
// If it's a (non-specialization) constant, it must be folded.
if (node->getAsUnaryNode()->getOperand()->getAsConstantUnion())
return node->getAsUnaryNode()->getOperand()->getAsConstantUnion()->fold(op, node->getType());
}
return node;
default:
error(loc, "unsupported construction", "", "");
@ -6895,6 +7008,9 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
if (memberType.containsOpaque())
error(memberLoc, "member of block cannot be or contain a sampler, image, or atomic_uint type", typeList[member].type->getFieldName().c_str(), "");
if (memberType.containsCoopMat())
error(memberLoc, "member of block cannot be or contain a cooperative matrix type", typeList[member].type->getFieldName().c_str(), "");
}
// This might be a redeclaration of a built-in block. If so, redeclareBuiltinBlock() will

2
glslang/MachineIndependent/ParseHelper.h Executable file → Normal file
View file

@ -337,7 +337,7 @@ public:
void globalCheck(const TSourceLoc&, const char* token);
bool constructorError(const TSourceLoc&, TIntermNode*, TFunction&, TOperator, TType&);
bool constructorTextureSamplerError(const TSourceLoc&, const TFunction&);
void arraySizeCheck(const TSourceLoc&, TIntermTyped* expr, TArraySize&);
void arraySizeCheck(const TSourceLoc&, TIntermTyped* expr, TArraySize&, const char *sizeType);
bool arrayQualifierError(const TSourceLoc&, const TQualifier&);
bool arrayError(const TSourceLoc&, const TType&);
void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);

View file

@ -714,6 +714,8 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["taskNV"] = PERTASKNV;
#endif
(*KeywordMap)["fcoopmatNV"] = FCOOPMATNV;
ReservedSet = new std::unordered_set<const char*, str_hash, str_eq>;
ReservedSet->insert("common");
@ -1612,6 +1614,13 @@ int TScanContext::tokenizeIdentifier()
return identifierOrType();
#endif
case FCOOPMATNV:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
parseContext.extensionTurnedOn(E_GL_NV_cooperative_matrix))
return keyword;
return identifierOrType();
default:
parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc);
return 0;

12
glslang/MachineIndependent/Versions.cpp Executable file → Normal file
View file

@ -248,6 +248,8 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_NV_mesh_shader] = EBhDisable;
#endif
extensionBehavior[E_GL_NV_cooperative_matrix] = EBhDisable;
// AEP
extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisable;
extensionBehavior[E_GL_KHR_blend_equation_advanced] = EBhDisable;
@ -427,6 +429,8 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_NV_shader_texture_footprint 1\n"
"#define GL_NV_mesh_shader 1\n"
#endif
"#define GL_NV_cooperative_matrix 1\n"
"#define GL_EXT_shader_explicit_arithmetic_types 1\n"
"#define GL_EXT_shader_explicit_arithmetic_types_int8 1\n"
"#define GL_EXT_shader_explicit_arithmetic_types_int16 1\n"
@ -1083,6 +1087,14 @@ void TParseVersions::int64Check(const TSourceLoc& loc, const char* op, bool buil
}
}
void TParseVersions::fcoopmatCheck(const TSourceLoc& loc, const char* op, bool builtIn)
{
if (!builtIn) {
const char* const extensions[] = {E_GL_NV_cooperative_matrix};
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op);
}
}
// Call for any operation removed because SPIR-V is in use.
void TParseVersions::spvRemoved(const TSourceLoc& loc, const char* op)
{

View file

@ -225,6 +225,8 @@ const char* const viewportEXTs[] = { E_GL_ARB_shader_viewport_layer_array, E_GL_
const int Num_viewportEXTs = sizeof(viewportEXTs) / sizeof(viewportEXTs[0]);
#endif
const char* const E_GL_NV_cooperative_matrix = "GL_NV_cooperative_matrix";
// AEP
const char* const E_GL_ANDROID_extension_pack_es31a = "GL_ANDROID_extension_pack_es31a";
const char* const E_GL_KHR_blend_equation_advanced = "GL_KHR_blend_equation_advanced";

58
glslang/MachineIndependent/glslang.y Executable file → Normal file
View file

@ -100,6 +100,7 @@ using namespace glslang;
glslang::TArraySizes* arraySizes;
glslang::TIdentifierList* identifierList;
};
glslang::TArraySizes* typeParameters;
} interm;
}
@ -166,6 +167,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
%token <lex> F64MAT4X2 F64MAT4X3 F64MAT4X4
%token <lex> ATOMIC_UINT
%token <lex> ACCSTRUCTNV
%token <lex> FCOOPMATNV
// combined image/sampler
%token <lex> SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW
@ -273,6 +275,10 @@ extern int yylex(YYSTYPE*, TParseContext&);
%type <interm.type> layout_qualifier layout_qualifier_id_list layout_qualifier_id
%type <interm.type> non_uniform_qualifier
%type <interm.typeParameters> type_parameter_specifier
%type <interm.typeParameters> type_parameter_specifier_opt
%type <interm.typeParameters> type_parameter_specifier_list
%type <interm.type> type_qualifier fully_specified_type type_specifier
%type <interm.type> single_type_qualifier
%type <interm.type> type_specifier_nonarray
@ -1487,15 +1493,17 @@ type_name_list
;
type_specifier
: type_specifier_nonarray {
: type_specifier_nonarray type_parameter_specifier_opt {
$$ = $1;
$$.qualifier.precision = parseContext.getDefaultPrecision($$);
$$.typeParameters = $2;
}
| type_specifier_nonarray array_specifier {
parseContext.arrayOfArrayVersionCheck($2.loc, $2.arraySizes);
| type_specifier_nonarray type_parameter_specifier_opt array_specifier {
parseContext.arrayOfArrayVersionCheck($3.loc, $3.arraySizes);
$$ = $1;
$$.qualifier.precision = parseContext.getDefaultPrecision($$);
$$.arraySizes = $2.arraySizes;
$$.typeParameters = $2;
$$.arraySizes = $3.arraySizes;
}
;
@ -1510,7 +1518,7 @@ array_specifier
$$.arraySizes = new TArraySizes;
TArraySize size;
parseContext.arraySizeCheck($2->getLoc(), $2, size);
parseContext.arraySizeCheck($2->getLoc(), $2, size, "array size");
$$.arraySizes->addInnerSize(size);
}
| array_specifier LEFT_BRACKET RIGHT_BRACKET {
@ -1521,11 +1529,43 @@ array_specifier
$$ = $1;
TArraySize size;
parseContext.arraySizeCheck($3->getLoc(), $3, size);
parseContext.arraySizeCheck($3->getLoc(), $3, size, "array size");
$$.arraySizes->addInnerSize(size);
}
;
type_parameter_specifier_opt
: type_parameter_specifier {
$$ = $1;
}
| /* May be null */ {
$$ = 0;
}
;
type_parameter_specifier
: LEFT_ANGLE type_parameter_specifier_list RIGHT_ANGLE {
$$ = $2;
}
;
type_parameter_specifier_list
: unary_expression {
$$ = new TArraySizes;
TArraySize size;
parseContext.arraySizeCheck($1->getLoc(), $1, size, "type parameter");
$$->addInnerSize(size);
}
| type_parameter_specifier_list COMMA unary_expression {
$$ = $1;
TArraySize size;
parseContext.arraySizeCheck($3->getLoc(), $3, size, "type parameter");
$$->addInnerSize(size);
}
;
type_specifier_nonarray
: VOID {
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
@ -3172,6 +3212,12 @@ type_specifier_nonarray
$$.basicType = EbtSampler;
$$.sampler.setSubpass(EbtUint, true);
}
| FCOOPMATNV {
parseContext.fcoopmatCheck($1.loc, "fcoopmatNV", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat;
$$.coopmat = true;
}
| struct_specifier {
$$ = $1;
$$.qualifier.storage = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;

File diff suppressed because it is too large Load diff

View file

@ -220,235 +220,236 @@ extern int yydebug;
F64MAT4X4 = 430,
ATOMIC_UINT = 431,
ACCSTRUCTNV = 432,
SAMPLER1D = 433,
SAMPLER2D = 434,
SAMPLER3D = 435,
SAMPLERCUBE = 436,
SAMPLER1DSHADOW = 437,
SAMPLER2DSHADOW = 438,
SAMPLERCUBESHADOW = 439,
SAMPLER1DARRAY = 440,
SAMPLER2DARRAY = 441,
SAMPLER1DARRAYSHADOW = 442,
SAMPLER2DARRAYSHADOW = 443,
ISAMPLER1D = 444,
ISAMPLER2D = 445,
ISAMPLER3D = 446,
ISAMPLERCUBE = 447,
ISAMPLER1DARRAY = 448,
ISAMPLER2DARRAY = 449,
USAMPLER1D = 450,
USAMPLER2D = 451,
USAMPLER3D = 452,
USAMPLERCUBE = 453,
USAMPLER1DARRAY = 454,
USAMPLER2DARRAY = 455,
SAMPLER2DRECT = 456,
SAMPLER2DRECTSHADOW = 457,
ISAMPLER2DRECT = 458,
USAMPLER2DRECT = 459,
SAMPLERBUFFER = 460,
ISAMPLERBUFFER = 461,
USAMPLERBUFFER = 462,
SAMPLERCUBEARRAY = 463,
SAMPLERCUBEARRAYSHADOW = 464,
ISAMPLERCUBEARRAY = 465,
USAMPLERCUBEARRAY = 466,
SAMPLER2DMS = 467,
ISAMPLER2DMS = 468,
USAMPLER2DMS = 469,
SAMPLER2DMSARRAY = 470,
ISAMPLER2DMSARRAY = 471,
USAMPLER2DMSARRAY = 472,
SAMPLEREXTERNALOES = 473,
SAMPLEREXTERNAL2DY2YEXT = 474,
F16SAMPLER1D = 475,
F16SAMPLER2D = 476,
F16SAMPLER3D = 477,
F16SAMPLER2DRECT = 478,
F16SAMPLERCUBE = 479,
F16SAMPLER1DARRAY = 480,
F16SAMPLER2DARRAY = 481,
F16SAMPLERCUBEARRAY = 482,
F16SAMPLERBUFFER = 483,
F16SAMPLER2DMS = 484,
F16SAMPLER2DMSARRAY = 485,
F16SAMPLER1DSHADOW = 486,
F16SAMPLER2DSHADOW = 487,
F16SAMPLER1DARRAYSHADOW = 488,
F16SAMPLER2DARRAYSHADOW = 489,
F16SAMPLER2DRECTSHADOW = 490,
F16SAMPLERCUBESHADOW = 491,
F16SAMPLERCUBEARRAYSHADOW = 492,
SAMPLER = 493,
SAMPLERSHADOW = 494,
TEXTURE1D = 495,
TEXTURE2D = 496,
TEXTURE3D = 497,
TEXTURECUBE = 498,
TEXTURE1DARRAY = 499,
TEXTURE2DARRAY = 500,
ITEXTURE1D = 501,
ITEXTURE2D = 502,
ITEXTURE3D = 503,
ITEXTURECUBE = 504,
ITEXTURE1DARRAY = 505,
ITEXTURE2DARRAY = 506,
UTEXTURE1D = 507,
UTEXTURE2D = 508,
UTEXTURE3D = 509,
UTEXTURECUBE = 510,
UTEXTURE1DARRAY = 511,
UTEXTURE2DARRAY = 512,
TEXTURE2DRECT = 513,
ITEXTURE2DRECT = 514,
UTEXTURE2DRECT = 515,
TEXTUREBUFFER = 516,
ITEXTUREBUFFER = 517,
UTEXTUREBUFFER = 518,
TEXTURECUBEARRAY = 519,
ITEXTURECUBEARRAY = 520,
UTEXTURECUBEARRAY = 521,
TEXTURE2DMS = 522,
ITEXTURE2DMS = 523,
UTEXTURE2DMS = 524,
TEXTURE2DMSARRAY = 525,
ITEXTURE2DMSARRAY = 526,
UTEXTURE2DMSARRAY = 527,
F16TEXTURE1D = 528,
F16TEXTURE2D = 529,
F16TEXTURE3D = 530,
F16TEXTURE2DRECT = 531,
F16TEXTURECUBE = 532,
F16TEXTURE1DARRAY = 533,
F16TEXTURE2DARRAY = 534,
F16TEXTURECUBEARRAY = 535,
F16TEXTUREBUFFER = 536,
F16TEXTURE2DMS = 537,
F16TEXTURE2DMSARRAY = 538,
SUBPASSINPUT = 539,
SUBPASSINPUTMS = 540,
ISUBPASSINPUT = 541,
ISUBPASSINPUTMS = 542,
USUBPASSINPUT = 543,
USUBPASSINPUTMS = 544,
F16SUBPASSINPUT = 545,
F16SUBPASSINPUTMS = 546,
IMAGE1D = 547,
IIMAGE1D = 548,
UIMAGE1D = 549,
IMAGE2D = 550,
IIMAGE2D = 551,
UIMAGE2D = 552,
IMAGE3D = 553,
IIMAGE3D = 554,
UIMAGE3D = 555,
IMAGE2DRECT = 556,
IIMAGE2DRECT = 557,
UIMAGE2DRECT = 558,
IMAGECUBE = 559,
IIMAGECUBE = 560,
UIMAGECUBE = 561,
IMAGEBUFFER = 562,
IIMAGEBUFFER = 563,
UIMAGEBUFFER = 564,
IMAGE1DARRAY = 565,
IIMAGE1DARRAY = 566,
UIMAGE1DARRAY = 567,
IMAGE2DARRAY = 568,
IIMAGE2DARRAY = 569,
UIMAGE2DARRAY = 570,
IMAGECUBEARRAY = 571,
IIMAGECUBEARRAY = 572,
UIMAGECUBEARRAY = 573,
IMAGE2DMS = 574,
IIMAGE2DMS = 575,
UIMAGE2DMS = 576,
IMAGE2DMSARRAY = 577,
IIMAGE2DMSARRAY = 578,
UIMAGE2DMSARRAY = 579,
F16IMAGE1D = 580,
F16IMAGE2D = 581,
F16IMAGE3D = 582,
F16IMAGE2DRECT = 583,
F16IMAGECUBE = 584,
F16IMAGE1DARRAY = 585,
F16IMAGE2DARRAY = 586,
F16IMAGECUBEARRAY = 587,
F16IMAGEBUFFER = 588,
F16IMAGE2DMS = 589,
F16IMAGE2DMSARRAY = 590,
STRUCT = 591,
VOID = 592,
WHILE = 593,
IDENTIFIER = 594,
TYPE_NAME = 595,
FLOATCONSTANT = 596,
DOUBLECONSTANT = 597,
INT16CONSTANT = 598,
UINT16CONSTANT = 599,
INT32CONSTANT = 600,
UINT32CONSTANT = 601,
INTCONSTANT = 602,
UINTCONSTANT = 603,
INT64CONSTANT = 604,
UINT64CONSTANT = 605,
BOOLCONSTANT = 606,
FLOAT16CONSTANT = 607,
LEFT_OP = 608,
RIGHT_OP = 609,
INC_OP = 610,
DEC_OP = 611,
LE_OP = 612,
GE_OP = 613,
EQ_OP = 614,
NE_OP = 615,
AND_OP = 616,
OR_OP = 617,
XOR_OP = 618,
MUL_ASSIGN = 619,
DIV_ASSIGN = 620,
ADD_ASSIGN = 621,
MOD_ASSIGN = 622,
LEFT_ASSIGN = 623,
RIGHT_ASSIGN = 624,
AND_ASSIGN = 625,
XOR_ASSIGN = 626,
OR_ASSIGN = 627,
SUB_ASSIGN = 628,
LEFT_PAREN = 629,
RIGHT_PAREN = 630,
LEFT_BRACKET = 631,
RIGHT_BRACKET = 632,
LEFT_BRACE = 633,
RIGHT_BRACE = 634,
DOT = 635,
COMMA = 636,
COLON = 637,
EQUAL = 638,
SEMICOLON = 639,
BANG = 640,
DASH = 641,
TILDE = 642,
PLUS = 643,
STAR = 644,
SLASH = 645,
PERCENT = 646,
LEFT_ANGLE = 647,
RIGHT_ANGLE = 648,
VERTICAL_BAR = 649,
CARET = 650,
AMPERSAND = 651,
QUESTION = 652,
INVARIANT = 653,
PRECISE = 654,
HIGH_PRECISION = 655,
MEDIUM_PRECISION = 656,
LOW_PRECISION = 657,
PRECISION = 658,
PACKED = 659,
RESOURCE = 660,
SUPERP = 661
FCOOPMATNV = 433,
SAMPLER1D = 434,
SAMPLER2D = 435,
SAMPLER3D = 436,
SAMPLERCUBE = 437,
SAMPLER1DSHADOW = 438,
SAMPLER2DSHADOW = 439,
SAMPLERCUBESHADOW = 440,
SAMPLER1DARRAY = 441,
SAMPLER2DARRAY = 442,
SAMPLER1DARRAYSHADOW = 443,
SAMPLER2DARRAYSHADOW = 444,
ISAMPLER1D = 445,
ISAMPLER2D = 446,
ISAMPLER3D = 447,
ISAMPLERCUBE = 448,
ISAMPLER1DARRAY = 449,
ISAMPLER2DARRAY = 450,
USAMPLER1D = 451,
USAMPLER2D = 452,
USAMPLER3D = 453,
USAMPLERCUBE = 454,
USAMPLER1DARRAY = 455,
USAMPLER2DARRAY = 456,
SAMPLER2DRECT = 457,
SAMPLER2DRECTSHADOW = 458,
ISAMPLER2DRECT = 459,
USAMPLER2DRECT = 460,
SAMPLERBUFFER = 461,
ISAMPLERBUFFER = 462,
USAMPLERBUFFER = 463,
SAMPLERCUBEARRAY = 464,
SAMPLERCUBEARRAYSHADOW = 465,
ISAMPLERCUBEARRAY = 466,
USAMPLERCUBEARRAY = 467,
SAMPLER2DMS = 468,
ISAMPLER2DMS = 469,
USAMPLER2DMS = 470,
SAMPLER2DMSARRAY = 471,
ISAMPLER2DMSARRAY = 472,
USAMPLER2DMSARRAY = 473,
SAMPLEREXTERNALOES = 474,
SAMPLEREXTERNAL2DY2YEXT = 475,
F16SAMPLER1D = 476,
F16SAMPLER2D = 477,
F16SAMPLER3D = 478,
F16SAMPLER2DRECT = 479,
F16SAMPLERCUBE = 480,
F16SAMPLER1DARRAY = 481,
F16SAMPLER2DARRAY = 482,
F16SAMPLERCUBEARRAY = 483,
F16SAMPLERBUFFER = 484,
F16SAMPLER2DMS = 485,
F16SAMPLER2DMSARRAY = 486,
F16SAMPLER1DSHADOW = 487,
F16SAMPLER2DSHADOW = 488,
F16SAMPLER1DARRAYSHADOW = 489,
F16SAMPLER2DARRAYSHADOW = 490,
F16SAMPLER2DRECTSHADOW = 491,
F16SAMPLERCUBESHADOW = 492,
F16SAMPLERCUBEARRAYSHADOW = 493,
SAMPLER = 494,
SAMPLERSHADOW = 495,
TEXTURE1D = 496,
TEXTURE2D = 497,
TEXTURE3D = 498,
TEXTURECUBE = 499,
TEXTURE1DARRAY = 500,
TEXTURE2DARRAY = 501,
ITEXTURE1D = 502,
ITEXTURE2D = 503,
ITEXTURE3D = 504,
ITEXTURECUBE = 505,
ITEXTURE1DARRAY = 506,
ITEXTURE2DARRAY = 507,
UTEXTURE1D = 508,
UTEXTURE2D = 509,
UTEXTURE3D = 510,
UTEXTURECUBE = 511,
UTEXTURE1DARRAY = 512,
UTEXTURE2DARRAY = 513,
TEXTURE2DRECT = 514,
ITEXTURE2DRECT = 515,
UTEXTURE2DRECT = 516,
TEXTUREBUFFER = 517,
ITEXTUREBUFFER = 518,
UTEXTUREBUFFER = 519,
TEXTURECUBEARRAY = 520,
ITEXTURECUBEARRAY = 521,
UTEXTURECUBEARRAY = 522,
TEXTURE2DMS = 523,
ITEXTURE2DMS = 524,
UTEXTURE2DMS = 525,
TEXTURE2DMSARRAY = 526,
ITEXTURE2DMSARRAY = 527,
UTEXTURE2DMSARRAY = 528,
F16TEXTURE1D = 529,
F16TEXTURE2D = 530,
F16TEXTURE3D = 531,
F16TEXTURE2DRECT = 532,
F16TEXTURECUBE = 533,
F16TEXTURE1DARRAY = 534,
F16TEXTURE2DARRAY = 535,
F16TEXTURECUBEARRAY = 536,
F16TEXTUREBUFFER = 537,
F16TEXTURE2DMS = 538,
F16TEXTURE2DMSARRAY = 539,
SUBPASSINPUT = 540,
SUBPASSINPUTMS = 541,
ISUBPASSINPUT = 542,
ISUBPASSINPUTMS = 543,
USUBPASSINPUT = 544,
USUBPASSINPUTMS = 545,
F16SUBPASSINPUT = 546,
F16SUBPASSINPUTMS = 547,
IMAGE1D = 548,
IIMAGE1D = 549,
UIMAGE1D = 550,
IMAGE2D = 551,
IIMAGE2D = 552,
UIMAGE2D = 553,
IMAGE3D = 554,
IIMAGE3D = 555,
UIMAGE3D = 556,
IMAGE2DRECT = 557,
IIMAGE2DRECT = 558,
UIMAGE2DRECT = 559,
IMAGECUBE = 560,
IIMAGECUBE = 561,
UIMAGECUBE = 562,
IMAGEBUFFER = 563,
IIMAGEBUFFER = 564,
UIMAGEBUFFER = 565,
IMAGE1DARRAY = 566,
IIMAGE1DARRAY = 567,
UIMAGE1DARRAY = 568,
IMAGE2DARRAY = 569,
IIMAGE2DARRAY = 570,
UIMAGE2DARRAY = 571,
IMAGECUBEARRAY = 572,
IIMAGECUBEARRAY = 573,
UIMAGECUBEARRAY = 574,
IMAGE2DMS = 575,
IIMAGE2DMS = 576,
UIMAGE2DMS = 577,
IMAGE2DMSARRAY = 578,
IIMAGE2DMSARRAY = 579,
UIMAGE2DMSARRAY = 580,
F16IMAGE1D = 581,
F16IMAGE2D = 582,
F16IMAGE3D = 583,
F16IMAGE2DRECT = 584,
F16IMAGECUBE = 585,
F16IMAGE1DARRAY = 586,
F16IMAGE2DARRAY = 587,
F16IMAGECUBEARRAY = 588,
F16IMAGEBUFFER = 589,
F16IMAGE2DMS = 590,
F16IMAGE2DMSARRAY = 591,
STRUCT = 592,
VOID = 593,
WHILE = 594,
IDENTIFIER = 595,
TYPE_NAME = 596,
FLOATCONSTANT = 597,
DOUBLECONSTANT = 598,
INT16CONSTANT = 599,
UINT16CONSTANT = 600,
INT32CONSTANT = 601,
UINT32CONSTANT = 602,
INTCONSTANT = 603,
UINTCONSTANT = 604,
INT64CONSTANT = 605,
UINT64CONSTANT = 606,
BOOLCONSTANT = 607,
FLOAT16CONSTANT = 608,
LEFT_OP = 609,
RIGHT_OP = 610,
INC_OP = 611,
DEC_OP = 612,
LE_OP = 613,
GE_OP = 614,
EQ_OP = 615,
NE_OP = 616,
AND_OP = 617,
OR_OP = 618,
XOR_OP = 619,
MUL_ASSIGN = 620,
DIV_ASSIGN = 621,
ADD_ASSIGN = 622,
MOD_ASSIGN = 623,
LEFT_ASSIGN = 624,
RIGHT_ASSIGN = 625,
AND_ASSIGN = 626,
XOR_ASSIGN = 627,
OR_ASSIGN = 628,
SUB_ASSIGN = 629,
LEFT_PAREN = 630,
RIGHT_PAREN = 631,
LEFT_BRACKET = 632,
RIGHT_BRACKET = 633,
LEFT_BRACE = 634,
RIGHT_BRACE = 635,
DOT = 636,
COMMA = 637,
COLON = 638,
EQUAL = 639,
SEMICOLON = 640,
BANG = 641,
DASH = 642,
TILDE = 643,
PLUS = 644,
STAR = 645,
SLASH = 646,
PERCENT = 647,
LEFT_ANGLE = 648,
RIGHT_ANGLE = 649,
VERTICAL_BAR = 650,
CARET = 651,
AMPERSAND = 652,
QUESTION = 653,
INVARIANT = 654,
PRECISE = 655,
HIGH_PRECISION = 656,
MEDIUM_PRECISION = 657,
LOW_PRECISION = 658,
PRECISION = 659,
PACKED = 660,
RESOURCE = 661,
SUPERP = 662
};
#endif
@ -490,9 +491,10 @@ union YYSTYPE
glslang::TArraySizes* arraySizes;
glslang::TIdentifierList* identifierList;
};
glslang::TArraySizes* typeParameters;
} interm;
#line 496 "MachineIndependent/glslang_tab.cpp.h" /* yacc.c:1909 */
#line 498 "MachineIndependent/glslang_tab.cpp.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;

View file

@ -817,6 +817,7 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpConstructStruct: out.debug << "Construct structure"; break;
case EOpConstructTextureSampler: out.debug << "Construct combined texture-sampler"; break;
case EOpConstructReference: out.debug << "Construct reference"; break;
case EOpConstructCooperativeMatrix: out.debug << "Construct cooperative matrix"; break;
case EOpLessThan: out.debug << "Compare Less Than"; break;
case EOpGreaterThan: out.debug << "Compare Greater Than"; break;
@ -1066,6 +1067,10 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpWritePackedPrimitiveIndices4x8NV: out.debug << "writePackedPrimitiveIndices4x8NV"; break;
#endif
case EOpCooperativeMatrixLoad: out.debug << "Load cooperative matrix"; break;
case EOpCooperativeMatrixStore: out.debug << "Store cooperative matrix"; break;
case EOpCooperativeMatrixMulAdd: out.debug << "MulAdd cooperative matrices"; break;
default: out.debug.message(EPrefixError, "Bad aggregation op");
}

View file

@ -261,6 +261,7 @@ public:
useStorageBuffer(false),
useVulkanMemoryModel(false),
hlslIoMapping(false),
useVariablePointers(false),
textureSamplerTransformMode(EShTexSampTransKeep),
needToLegalize(false),
binaryDoubleOutput(false),
@ -405,6 +406,12 @@ public:
usePhysicalStorageBuffer = true;
}
bool usingPhysicalStorageBuffer() const { return usePhysicalStorageBuffer; }
void setUseVariablePointers()
{
useVariablePointers = true;
processes.addProcess("use-variable-pointers");
}
bool usingVariablePointers() const { return useVariablePointers; }
template<class T> T addCounterBufferName(const T& name) const { return name + implicitCounterName; }
bool hasCounterBufferName(const TString& name) const {
@ -491,6 +498,7 @@ public:
TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*) const;
std::tuple<TIntermTyped*, TIntermTyped*> addConversion(TOperator op, TIntermTyped* node0, TIntermTyped* node1) const;
TIntermTyped* addUniShapeConversion(TOperator, const TType&, TIntermTyped*);
TIntermTyped* addConversion(TBasicType convertTo, TIntermTyped* node) const;
void addBiShapeConversion(TOperator, TIntermTyped*& lhsNode, TIntermTyped*& rhsNode);
TIntermTyped* addShapeConversion(const TType&, TIntermTyped*);
TIntermTyped* addBinaryMath(TOperator, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
@ -852,6 +860,7 @@ protected:
bool useStorageBuffer;
bool useVulkanMemoryModel;
bool hlslIoMapping;
bool useVariablePointers;
std::set<TString> ioAccessed; // set of names of statically read/written I/O that might need extra checking
std::vector<TIoRange> usedIo[4]; // sets of used locations, one for each of in, out, uniform, and buffers

View file

@ -104,6 +104,7 @@ public:
virtual bool checkExtensionsRequested(const TSourceLoc&, int numExtensions, const char* const extensions[], const char* featureDesc);
virtual void updateExtensionBehavior(const char* const extension, TExtensionBehavior);
virtual void checkExtensionStage(const TSourceLoc&, const char* const extension);
virtual void fcoopmatCheck(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) = 0;