Updated glslang.

This commit is contained in:
Бранимир Караџић
2024-04-12 21:20:43 -07:00
parent de2f308b98
commit 406c8deaba
27 changed files with 1832 additions and 1481 deletions

View File

@@ -37,5 +37,7 @@ static const int GLSLextQCOMRevision = 1;
//SPV_QCOM_image_processing
const char* const E_SPV_QCOM_image_processing = "SPV_QCOM_image_processing";
//SPV_QCOM_image_processing2
const char* const E_SPV_QCOM_image_processing2 = "SPV_QCOM_image_processing2";
#endif // #ifndef GLSLextQCOM_H

View File

@@ -228,6 +228,7 @@ protected:
spv::Id getSymbolId(const glslang::TIntermSymbol* node);
void addMeshNVDecoration(spv::Id id, int member, const glslang::TQualifier & qualifier);
void addImageProcessingQCOMDecoration(spv::Id id, spv::Decoration decor);
void addImageProcessing2QCOMDecoration(spv::Id id, bool isForGather);
spv::Id createSpvConstant(const glslang::TIntermTyped&);
spv::Id createSpvConstantFromConstUnionArray(const glslang::TType& type, const glslang::TConstUnionArray&,
int& nextConst, bool specConstant);
@@ -2006,8 +2007,9 @@ void TGlslangToSpvTraverser::finishSpv(bool compileOnly)
}
// finish off the entry-point SPV instruction by adding the Input/Output <id>
for (auto it = iOSet.cbegin(); it != iOSet.cend(); ++it)
entryPoint->addIdOperand(*it);
entryPoint->reserveOperands(iOSet.size());
for (auto id : iOSet)
entryPoint->addIdOperand(id);
}
// Add capabilities, extensions, remove unneeded decorations, etc.,
@@ -3370,6 +3372,20 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
builder.addExtension(spv::E_SPV_QCOM_image_processing);
break;
case glslang::EOpImageBlockMatchWindowSSDQCOM:
case glslang::EOpImageBlockMatchWindowSADQCOM:
builder.addCapability(spv::CapabilityTextureBlockMatchQCOM);
builder.addExtension(spv::E_SPV_QCOM_image_processing);
builder.addCapability(spv::CapabilityTextureBlockMatch2QCOM);
builder.addExtension(spv::E_SPV_QCOM_image_processing2);
break;
case glslang::EOpImageBlockMatchGatherSSDQCOM:
case glslang::EOpImageBlockMatchGatherSADQCOM:
builder.addCapability(spv::CapabilityTextureBlockMatch2QCOM);
builder.addExtension(spv::E_SPV_QCOM_image_processing2);
break;
case glslang::EOpFetchMicroTriangleVertexPositionNV:
case glslang::EOpFetchMicroTriangleVertexBarycentricNV:
builder.addExtension(spv::E_SPV_NV_displacement_micromap);
@@ -9268,6 +9284,30 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
opCode = spv::OpFetchMicroTriangleVertexPositionNV;
break;
case glslang::EOpImageBlockMatchWindowSSDQCOM:
typeId = builder.makeVectorType(builder.makeFloatType(32), 4);
opCode = spv::OpImageBlockMatchWindowSSDQCOM;
addImageProcessing2QCOMDecoration(operands[0], false);
addImageProcessing2QCOMDecoration(operands[2], false);
break;
case glslang::EOpImageBlockMatchWindowSADQCOM:
typeId = builder.makeVectorType(builder.makeFloatType(32), 4);
opCode = spv::OpImageBlockMatchWindowSADQCOM;
addImageProcessing2QCOMDecoration(operands[0], false);
addImageProcessing2QCOMDecoration(operands[2], false);
break;
case glslang::EOpImageBlockMatchGatherSSDQCOM:
typeId = builder.makeVectorType(builder.makeFloatType(32), 4);
opCode = spv::OpImageBlockMatchGatherSSDQCOM;
addImageProcessing2QCOMDecoration(operands[0], true);
addImageProcessing2QCOMDecoration(operands[2], true);
break;
case glslang::EOpImageBlockMatchGatherSADQCOM:
typeId = builder.makeVectorType(builder.makeFloatType(32), 4);
opCode = spv::OpImageBlockMatchGatherSADQCOM;
addImageProcessing2QCOMDecoration(operands[0], true);
addImageProcessing2QCOMDecoration(operands[2], true);
break;
default:
return 0;
}
@@ -9788,6 +9828,36 @@ void TGlslangToSpvTraverser::addImageProcessingQCOMDecoration(spv::Id id, spv::D
}
}
void TGlslangToSpvTraverser::addImageProcessing2QCOMDecoration(spv::Id id, bool isForGather)
{
if (isForGather) {
return addImageProcessingQCOMDecoration(id, spv::DecorationBlockMatchTextureQCOM);
}
auto addDecor =
[this](spv::Id id, spv::Decoration decor) {
spv::Id tsopc = this->builder.getOpCode(id);
if (tsopc == spv::OpLoad) {
spv::Id tsid = this->builder.getIdOperand(id, 0);
if (this->glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_4) {
assert(iOSet.count(tsid) > 0);
}
this->builder.addDecoration(tsid, decor);
}
};
spv::Id opc = builder.getOpCode(id);
bool isInterfaceObject = (opc != spv::OpSampledImage);
if (!isInterfaceObject) {
addDecor(builder.getIdOperand(id, 0), spv::DecorationBlockMatchTextureQCOM);
addDecor(builder.getIdOperand(id, 1), spv::DecorationBlockMatchSamplerQCOM);
} else {
addDecor(id, spv::DecorationBlockMatchTextureQCOM);
addDecor(id, spv::DecorationBlockMatchSamplerQCOM);
}
}
// Make a full tree of instructions to build a SPIR-V specialization constant,
// or regular constant if possible.
//
@@ -10153,7 +10223,6 @@ spv::Id TGlslangToSpvTraverser::getExtBuiltins(const char* name)
if (extBuiltinMap.find(name) != extBuiltinMap.end())
return extBuiltinMap[name];
else {
builder.addExtension(name);
spv::Id extBuiltins = builder.import(name);
extBuiltinMap[name] = extBuiltins;
return extBuiltins;

View File

@@ -157,6 +157,7 @@ Id Builder::makePointer(StorageClass storageClass, Id pointee)
// not found, make it
type = new Instruction(getUniqueId(), NoType, OpTypePointer);
type->reserveOperands(2);
type->addImmediateOperand(storageClass);
type->addIdOperand(pointee);
groupedTypes[OpTypePointer].push_back(type);
@@ -196,6 +197,7 @@ Id Builder::makePointerFromForwardPointer(StorageClass storageClass, Id forwardP
}
type = new Instruction(forwardPointerType, NoType, OpTypePointer);
type->reserveOperands(2);
type->addImmediateOperand(storageClass);
type->addIdOperand(pointee);
groupedTypes[OpTypePointer].push_back(type);
@@ -218,6 +220,7 @@ Id Builder::makeIntegerType(int width, bool hasSign)
// not found, make it
type = new Instruction(getUniqueId(), NoType, OpTypeInt);
type->reserveOperands(2);
type->addImmediateOperand(width);
type->addImmediateOperand(hasSign ? 1 : 0);
groupedTypes[OpTypeInt].push_back(type);
@@ -348,6 +351,7 @@ Id Builder::makeVectorType(Id component, int size)
// not found, make it
type = new Instruction(getUniqueId(), NoType, OpTypeVector);
type->reserveOperands(2);
type->addIdOperand(component);
type->addImmediateOperand(size);
groupedTypes[OpTypeVector].push_back(type);
@@ -380,6 +384,7 @@ Id Builder::makeMatrixType(Id component, int cols, int rows)
// not found, make it
type = new Instruction(getUniqueId(), NoType, OpTypeMatrix);
type->reserveOperands(2);
type->addIdOperand(column);
type->addImmediateOperand(cols);
groupedTypes[OpTypeMatrix].push_back(type);
@@ -411,6 +416,7 @@ Id Builder::makeCooperativeMatrixTypeKHR(Id component, Id scope, Id rows, Id col
// not found, make it
type = new Instruction(getUniqueId(), NoType, OpTypeCooperativeMatrixKHR);
type->reserveOperands(5);
type->addIdOperand(component);
type->addIdOperand(scope);
type->addIdOperand(rows);
@@ -436,6 +442,7 @@ Id Builder::makeCooperativeMatrixTypeNV(Id component, Id scope, Id rows, Id cols
// not found, make it
type = new Instruction(getUniqueId(), NoType, OpTypeCooperativeMatrixNV);
type->reserveOperands(4);
type->addIdOperand(component);
type->addIdOperand(scope);
type->addIdOperand(rows);
@@ -477,6 +484,7 @@ Id Builder::makeGenericType(spv::Op opcode, std::vector<spv::IdImmediate>& opera
// not found, make it
type = new Instruction(getUniqueId(), NoType, opcode);
type->reserveOperands(operands.size());
for (size_t op = 0; op < operands.size(); ++op) {
if (operands[op].isId)
type->addIdOperand(operands[op].word);
@@ -509,6 +517,7 @@ Id Builder::makeArrayType(Id element, Id sizeId, int stride)
// not found, make it
type = new Instruction(getUniqueId(), NoType, OpTypeArray);
type->reserveOperands(2);
type->addIdOperand(element);
type->addIdOperand(sizeId);
groupedTypes[OpTypeArray].push_back(type);
@@ -575,6 +584,7 @@ Id Builder::makeFunctionType(Id returnType, const std::vector<Id>& paramTypes)
// not found, make it
Id typeId = getUniqueId();
type = new Instruction(typeId, NoType, OpTypeFunction);
type->reserveOperands(paramTypes.size() + 1);
type->addIdOperand(returnType);
for (int p = 0; p < (int)paramTypes.size(); ++p)
type->addIdOperand(paramTypes[p]);
@@ -597,6 +607,7 @@ Id Builder::makeDebugFunctionType(Id returnType, const std::vector<Id>& paramTyp
Id typeId = getUniqueId();
auto type = new Instruction(typeId, makeVoidType(), OpExtInst);
type->reserveOperands(paramTypes.size() + 4);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeFunction);
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic));
@@ -635,6 +646,7 @@ Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, boo
// not found, make it
type = new Instruction(getUniqueId(), NoType, OpTypeImage);
type->reserveOperands(7);
type->addIdOperand(sampledType);
type->addImmediateOperand( dim);
type->addImmediateOperand( depth ? 1 : 0);
@@ -745,6 +757,7 @@ Id Builder::makeDebugInfoNone()
return debugInfoNone;
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
inst->reserveOperands(2);
inst->addIdOperand(nonSemanticShaderDebugInfo);
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugInfoNone);
@@ -769,6 +782,7 @@ Id Builder::makeBoolDebugType(int const size)
}
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->reserveOperands(6);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeBasic);
@@ -806,6 +820,7 @@ Id Builder::makeIntegerDebugType(int const width, bool const hasSign)
// not found, make it
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->reserveOperands(6);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeBasic);
type->addIdOperand(nameId); // name id
@@ -845,6 +860,7 @@ Id Builder::makeFloatDebugType(int const width)
// not found, make it
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->reserveOperands(6);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeBasic);
type->addIdOperand(nameId); // name id
@@ -875,6 +891,7 @@ Id Builder::makeSequentialDebugType(Id const baseType, Id const componentCount,
// not found, make it
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->reserveOperands(4);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(sequenceType);
type->addIdOperand(debugId[baseType]); // base type
@@ -910,6 +927,7 @@ Id Builder::makeMatrixDebugType(Id const vectorType, int const vectorCount, bool
// not found, make it
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->reserveOperands(5);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeMatrix);
type->addIdOperand(debugId[vectorType]); // vector type id
@@ -928,6 +946,7 @@ Id Builder::makeMemberDebugType(Id const memberType, DebugTypeLoc const& debugTy
assert(debugId[memberType] != 0);
Instruction* type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->reserveOperands(10);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeMember);
type->addIdOperand(getStringId(debugTypeLoc.name)); // name id
@@ -967,6 +986,7 @@ Id Builder::makeCompositeDebugType(std::vector<Id> const& memberTypes, char cons
// Create The structure debug type.
Instruction* type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->reserveOperands(memberDebugTypes.size() + 11);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeComposite);
type->addIdOperand(getStringId(name)); // name id
@@ -1011,6 +1031,7 @@ Id Builder::makePointerDebugType(StorageClass storageClass, Id const baseType)
}
Instruction* type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->reserveOperands(5);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypePointer);
type->addIdOperand(debugBaseType);
@@ -1029,6 +1050,7 @@ Id Builder::makeDebugSource(const Id fileName) {
return debugSourceId[fileName];
spv::Id resultId = getUniqueId();
Instruction* sourceInst = new Instruction(resultId, makeVoidType(), OpExtInst);
sourceInst->reserveOperands(3);
sourceInst->addIdOperand(nonSemanticShaderDebugInfo);
sourceInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugSource);
sourceInst->addIdOperand(fileName);
@@ -1059,6 +1081,7 @@ Id Builder::makeDebugCompilationUnit() {
return nonSemanticShaderCompilationUnitId;
spv::Id resultId = getUniqueId();
Instruction* sourceInst = new Instruction(resultId, makeVoidType(), OpExtInst);
sourceInst->reserveOperands(6);
sourceInst->addIdOperand(nonSemanticShaderDebugInfo);
sourceInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugCompilationUnit);
sourceInst->addIdOperand(makeUintConstant(1)); // TODO(greg-lunarg): Get rid of magic number
@@ -1082,6 +1105,7 @@ Id Builder::createDebugGlobalVariable(Id const type, char const*const name, Id c
assert(type != 0);
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
inst->reserveOperands(11);
inst->addIdOperand(nonSemanticShaderDebugInfo);
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugGlobalVariable);
inst->addIdOperand(getStringId(name)); // name id
@@ -1106,6 +1130,7 @@ Id Builder::createDebugLocalVariable(Id type, char const*const name, size_t cons
assert(!currentDebugScopeId.empty());
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
inst->reserveOperands(9);
inst->addIdOperand(nonSemanticShaderDebugInfo);
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugLocalVariable);
inst->addIdOperand(getStringId(name)); // name id
@@ -1131,6 +1156,7 @@ Id Builder::makeDebugExpression()
return debugExpression;
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
inst->reserveOperands(2);
inst->addIdOperand(nonSemanticShaderDebugInfo);
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugExpression);
@@ -1145,6 +1171,7 @@ Id Builder::makeDebugExpression()
Id Builder::makeDebugDeclare(Id const debugLocalVariable, Id const pointer)
{
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
inst->reserveOperands(5);
inst->addIdOperand(nonSemanticShaderDebugInfo);
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugDeclare);
inst->addIdOperand(debugLocalVariable); // debug local variable id
@@ -1158,6 +1185,7 @@ Id Builder::makeDebugDeclare(Id const debugLocalVariable, Id const pointer)
Id Builder::makeDebugValue(Id const debugLocalVariable, Id const value)
{
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
inst->reserveOperands(5);
inst->addIdOperand(nonSemanticShaderDebugInfo);
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugValue);
inst->addIdOperand(debugLocalVariable); // debug local variable id
@@ -1574,6 +1602,7 @@ Id Builder::makeInt64Constant(Id typeId, unsigned long long value, bool specCons
}
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
c->reserveOperands(2);
c->addImmediateOperand(op1);
c->addImmediateOperand(op2);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
@@ -1627,6 +1656,7 @@ Id Builder::makeDoubleConstant(double d, bool specConstant)
}
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
c->reserveOperands(2);
c->addImmediateOperand(op1);
c->addImmediateOperand(op2);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
@@ -1781,6 +1811,7 @@ Id Builder::makeCompositeConstant(Id typeId, const std::vector<Id>& members, boo
}
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
c->reserveOperands(members.size());
for (int op = 0; op < (int)members.size(); ++op)
c->addIdOperand(members[op]);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
@@ -1796,6 +1827,7 @@ Id Builder::makeCompositeConstant(Id typeId, const std::vector<Id>& members, boo
Instruction* Builder::addEntryPoint(ExecutionModel model, Function* function, const char* name)
{
Instruction* entryPoint = new Instruction(OpEntryPoint);
entryPoint->reserveOperands(3);
entryPoint->addImmediateOperand(model);
entryPoint->addIdOperand(function->getId());
entryPoint->addStringOperand(name);
@@ -1813,6 +1845,7 @@ void Builder::addExecutionMode(Function* entryPoint, ExecutionMode mode, int val
return;
Instruction* instr = new Instruction(OpExecutionMode);
instr->reserveOperands(3);
instr->addIdOperand(entryPoint->getId());
instr->addImmediateOperand(mode);
if (value1 >= 0)
@@ -1832,6 +1865,7 @@ void Builder::addExecutionMode(Function* entryPoint, ExecutionMode mode, const s
return;
Instruction* instr = new Instruction(OpExecutionMode);
instr->reserveOperands(literals.size() + 2);
instr->addIdOperand(entryPoint->getId());
instr->addImmediateOperand(mode);
for (auto literal : literals)
@@ -1847,6 +1881,7 @@ void Builder::addExecutionModeId(Function* entryPoint, ExecutionMode mode, const
return;
Instruction* instr = new Instruction(OpExecutionModeId);
instr->reserveOperands(operandIds.size() + 2);
instr->addIdOperand(entryPoint->getId());
instr->addImmediateOperand(mode);
for (auto operandId : operandIds)
@@ -1858,6 +1893,7 @@ void Builder::addExecutionModeId(Function* entryPoint, ExecutionMode mode, const
void Builder::addName(Id id, const char* string)
{
Instruction* name = new Instruction(OpName);
name->reserveOperands(2);
name->addIdOperand(id);
name->addStringOperand(string);
@@ -1867,6 +1903,7 @@ void Builder::addName(Id id, const char* string)
void Builder::addMemberName(Id id, int memberNumber, const char* string)
{
Instruction* name = new Instruction(OpMemberName);
name->reserveOperands(3);
name->addIdOperand(id);
name->addImmediateOperand(memberNumber);
name->addStringOperand(string);
@@ -1880,6 +1917,7 @@ void Builder::addDecoration(Id id, Decoration decoration, int num)
return;
Instruction* dec = new Instruction(OpDecorate);
dec->reserveOperands(2);
dec->addIdOperand(id);
dec->addImmediateOperand(decoration);
if (num >= 0)
@@ -1894,6 +1932,7 @@ void Builder::addDecoration(Id id, Decoration decoration, const char* s)
return;
Instruction* dec = new Instruction(OpDecorateString);
dec->reserveOperands(3);
dec->addIdOperand(id);
dec->addImmediateOperand(decoration);
dec->addStringOperand(s);
@@ -1907,6 +1946,7 @@ void Builder::addDecoration(Id id, Decoration decoration, const std::vector<unsi
return;
Instruction* dec = new Instruction(OpDecorate);
dec->reserveOperands(literals.size() + 2);
dec->addIdOperand(id);
dec->addImmediateOperand(decoration);
for (auto literal : literals)
@@ -1921,6 +1961,7 @@ void Builder::addDecoration(Id id, Decoration decoration, const std::vector<cons
return;
Instruction* dec = new Instruction(OpDecorateString);
dec->reserveOperands(strings.size() + 2);
dec->addIdOperand(id);
dec->addImmediateOperand(decoration);
for (auto string : strings)
@@ -1931,6 +1972,7 @@ void Builder::addDecoration(Id id, Decoration decoration, const std::vector<cons
void Builder::addLinkageDecoration(Id id, const char* name, spv::LinkageType linkType) {
Instruction* dec = new Instruction(OpDecorate);
dec->reserveOperands(4);
dec->addIdOperand(id);
dec->addImmediateOperand(spv::DecorationLinkageAttributes);
dec->addStringOperand(name);
@@ -1945,6 +1987,7 @@ void Builder::addDecorationId(Id id, Decoration decoration, Id idDecoration)
return;
Instruction* dec = new Instruction(OpDecorateId);
dec->reserveOperands(3);
dec->addIdOperand(id);
dec->addImmediateOperand(decoration);
dec->addIdOperand(idDecoration);
@@ -1958,6 +2001,7 @@ void Builder::addDecorationId(Id id, Decoration decoration, const std::vector<Id
return;
Instruction* dec = new Instruction(OpDecorateId);
dec->reserveOperands(operandIds.size() + 2);
dec->addIdOperand(id);
dec->addImmediateOperand(decoration);
@@ -1973,6 +2017,7 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
return;
Instruction* dec = new Instruction(OpMemberDecorate);
dec->reserveOperands(3);
dec->addIdOperand(id);
dec->addImmediateOperand(member);
dec->addImmediateOperand(decoration);
@@ -1988,6 +2033,7 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
return;
Instruction* dec = new Instruction(OpMemberDecorateStringGOOGLE);
dec->reserveOperands(4);
dec->addIdOperand(id);
dec->addImmediateOperand(member);
dec->addImmediateOperand(decoration);
@@ -2002,6 +2048,7 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
return;
Instruction* dec = new Instruction(OpMemberDecorate);
dec->reserveOperands(literals.size() + 3);
dec->addIdOperand(id);
dec->addImmediateOperand(member);
dec->addImmediateOperand(decoration);
@@ -2017,6 +2064,7 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
return;
Instruction* dec = new Instruction(OpMemberDecorateString);
dec->reserveOperands(strings.size() + 3);
dec->addIdOperand(id);
dec->addImmediateOperand(member);
dec->addImmediateOperand(decoration);
@@ -2031,6 +2079,7 @@ void Builder::addInstruction(std::unique_ptr<Instruction> inst) {
if (emitNonSemanticShaderDebugInfo && dirtyScopeTracker) {
if (buildPoint->updateDebugScope(currentDebugScopeId.top())) {
auto scopeInst = std::make_unique<Instruction>(getUniqueId(), makeVoidType(), OpExtInst);
scopeInst->reserveOperands(3);
scopeInst->addIdOperand(nonSemanticShaderDebugInfo);
scopeInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugScope);
scopeInst->addIdOperand(currentDebugScopeId.top());
@@ -2045,6 +2094,7 @@ void Builder::addInstruction(std::unique_ptr<Instruction> inst) {
if (buildPoint->updateDebugSourceLocation(currentLine, 0, currentFileId)) {
if (emitSpirvDebugInfo) {
auto lineInst = std::make_unique<Instruction>(OpLine);
lineInst->reserveOperands(3);
lineInst->addIdOperand(currentFileId);
lineInst->addImmediateOperand(currentLine);
lineInst->addImmediateOperand(0);
@@ -2052,6 +2102,7 @@ void Builder::addInstruction(std::unique_ptr<Instruction> inst) {
}
if (emitNonSemanticShaderDebugInfo) {
auto lineInst = std::make_unique<Instruction>(getUniqueId(), makeVoidType(), OpExtInst);
lineInst->reserveOperands(7);
lineInst->addIdOperand(nonSemanticShaderDebugInfo);
lineInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugLine);
lineInst->addIdOperand(makeDebugSource(currentFileId));
@@ -2191,6 +2242,7 @@ Id Builder::makeDebugFunction([[maybe_unused]] Function* function, Id nameId, Id
Id funcId = getUniqueId();
auto type = new Instruction(funcId, makeVoidType(), OpExtInst);
type->reserveOperands(11);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugFunction);
type->addIdOperand(nameId);
@@ -2212,6 +2264,7 @@ Id Builder::makeDebugLexicalBlock(uint32_t line) {
Id lexId = getUniqueId();
auto lex = new Instruction(lexId, makeVoidType(), OpExtInst);
lex->reserveOperands(6);
lex->addIdOperand(nonSemanticShaderDebugInfo);
lex->addImmediateOperand(NonSemanticShaderDebugInfo100DebugLexicalBlock);
lex->addIdOperand(makeDebugSource(currentFileId));
@@ -2282,6 +2335,7 @@ void Builder::enterFunction(Function const* function)
// Create DebugFunctionDefinition
spv::Id resultId = getUniqueId();
Instruction* defInst = new Instruction(resultId, makeVoidType(), OpExtInst);
defInst->reserveOperands(4);
defInst->addIdOperand(nonSemanticShaderDebugInfo);
defInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugFunctionDefinition);
defInst->addIdOperand(debugId[funcId]);
@@ -2413,6 +2467,7 @@ void Builder::createStore(Id rValue, Id lValue, spv::MemoryAccessMask memoryAcce
unsigned int alignment)
{
Instruction* store = new Instruction(OpStore);
store->reserveOperands(2);
store->addIdOperand(lValue);
store->addIdOperand(rValue);
@@ -2465,6 +2520,7 @@ Id Builder::createAccessChain(StorageClass storageClass, Id base, const std::vec
// Make the instruction
Instruction* chain = new Instruction(getUniqueId(), typeId, OpAccessChain);
chain->reserveOperands(offsets.size() + 1);
chain->addIdOperand(base);
for (int i = 0; i < (int)offsets.size(); ++i)
chain->addIdOperand(offsets[i]);
@@ -2477,6 +2533,7 @@ Id Builder::createArrayLength(Id base, unsigned int member)
{
spv::Id intType = makeUintType(32);
Instruction* length = new Instruction(getUniqueId(), intType, OpArrayLength);
length->reserveOperands(2);
length->addIdOperand(base);
length->addImmediateOperand(member);
addInstruction(std::unique_ptr<Instruction>(length));
@@ -2527,6 +2584,7 @@ Id Builder::createCompositeExtract(Id composite, Id typeId, unsigned index)
std::vector<Id>(1, index));
}
Instruction* extract = new Instruction(getUniqueId(), typeId, OpCompositeExtract);
extract->reserveOperands(2);
extract->addIdOperand(composite);
extract->addImmediateOperand(index);
addInstruction(std::unique_ptr<Instruction>(extract));
@@ -2542,6 +2600,7 @@ Id Builder::createCompositeExtract(Id composite, Id typeId, const std::vector<un
return createSpecConstantOp(OpCompositeExtract, typeId, std::vector<Id>(1, composite), indexes);
}
Instruction* extract = new Instruction(getUniqueId(), typeId, OpCompositeExtract);
extract->reserveOperands(indexes.size() + 1);
extract->addIdOperand(composite);
for (int i = 0; i < (int)indexes.size(); ++i)
extract->addImmediateOperand(indexes[i]);
@@ -2553,6 +2612,7 @@ Id Builder::createCompositeExtract(Id composite, Id typeId, const std::vector<un
Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, unsigned index)
{
Instruction* insert = new Instruction(getUniqueId(), typeId, OpCompositeInsert);
insert->reserveOperands(3);
insert->addIdOperand(object);
insert->addIdOperand(composite);
insert->addImmediateOperand(index);
@@ -2564,6 +2624,7 @@ Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, unsigned i
Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, const std::vector<unsigned>& indexes)
{
Instruction* insert = new Instruction(getUniqueId(), typeId, OpCompositeInsert);
insert->reserveOperands(indexes.size() + 2);
insert->addIdOperand(object);
insert->addIdOperand(composite);
for (int i = 0; i < (int)indexes.size(); ++i)
@@ -2576,6 +2637,7 @@ Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, const std:
Id Builder::createVectorExtractDynamic(Id vector, Id typeId, Id componentIndex)
{
Instruction* extract = new Instruction(getUniqueId(), typeId, OpVectorExtractDynamic);
extract->reserveOperands(2);
extract->addIdOperand(vector);
extract->addIdOperand(componentIndex);
addInstruction(std::unique_ptr<Instruction>(extract));
@@ -2586,6 +2648,7 @@ Id Builder::createVectorExtractDynamic(Id vector, Id typeId, Id componentIndex)
Id Builder::createVectorInsertDynamic(Id vector, Id typeId, Id component, Id componentIndex)
{
Instruction* insert = new Instruction(getUniqueId(), typeId, OpVectorInsertDynamic);
insert->reserveOperands(3);
insert->addIdOperand(vector);
insert->addIdOperand(component);
insert->addIdOperand(componentIndex);
@@ -2613,8 +2676,9 @@ void Builder::createNoResultOp(Op opCode, Id operand)
void Builder::createNoResultOp(Op opCode, const std::vector<Id>& operands)
{
Instruction* op = new Instruction(opCode);
for (auto it = operands.cbegin(); it != operands.cend(); ++it) {
op->addIdOperand(*it);
op->reserveOperands(operands.size());
for (auto id : operands) {
op->addIdOperand(id);
}
addInstruction(std::unique_ptr<Instruction>(op));
}
@@ -2623,6 +2687,7 @@ void Builder::createNoResultOp(Op opCode, const std::vector<Id>& operands)
void Builder::createNoResultOp(Op opCode, const std::vector<IdImmediate>& operands)
{
Instruction* op = new Instruction(opCode);
op->reserveOperands(operands.size());
for (auto it = operands.cbegin(); it != operands.cend(); ++it) {
if (it->isId)
op->addIdOperand(it->word);
@@ -2635,6 +2700,7 @@ void Builder::createNoResultOp(Op opCode, const std::vector<IdImmediate>& operan
void Builder::createControlBarrier(Scope execution, Scope memory, MemorySemanticsMask semantics)
{
Instruction* op = new Instruction(OpControlBarrier);
op->reserveOperands(3);
op->addIdOperand(makeUintConstant(execution));
op->addIdOperand(makeUintConstant(memory));
op->addIdOperand(makeUintConstant(semantics));
@@ -2644,6 +2710,7 @@ void Builder::createControlBarrier(Scope execution, Scope memory, MemorySemantic
void Builder::createMemoryBarrier(unsigned executionScope, unsigned memorySemantics)
{
Instruction* op = new Instruction(OpMemoryBarrier);
op->reserveOperands(2);
op->addIdOperand(makeUintConstant(executionScope));
op->addIdOperand(makeUintConstant(memorySemantics));
addInstruction(std::unique_ptr<Instruction>(op));
@@ -2674,6 +2741,7 @@ Id Builder::createBinOp(Op opCode, Id typeId, Id left, Id right)
return createSpecConstantOp(opCode, typeId, operands, std::vector<Id>());
}
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->reserveOperands(2);
op->addIdOperand(left);
op->addIdOperand(right);
addInstruction(std::unique_ptr<Instruction>(op));
@@ -2694,6 +2762,7 @@ Id Builder::createTriOp(Op opCode, Id typeId, Id op1, Id op2, Id op3)
opCode, typeId, operands, std::vector<Id>());
}
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->reserveOperands(3);
op->addIdOperand(op1);
op->addIdOperand(op2);
op->addIdOperand(op3);
@@ -2705,8 +2774,9 @@ Id Builder::createTriOp(Op opCode, Id typeId, Id op1, Id op2, Id op3)
Id Builder::createOp(Op opCode, Id typeId, const std::vector<Id>& operands)
{
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
for (auto it = operands.cbegin(); it != operands.cend(); ++it)
op->addIdOperand(*it);
op->reserveOperands(operands.size());
for (auto id : operands)
op->addIdOperand(id);
addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
@@ -2715,6 +2785,7 @@ Id Builder::createOp(Op opCode, Id typeId, const std::vector<Id>& operands)
Id Builder::createOp(Op opCode, Id typeId, const std::vector<IdImmediate>& operands)
{
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->reserveOperands(operands.size());
for (auto it = operands.cbegin(); it != operands.cend(); ++it) {
if (it->isId)
op->addIdOperand(it->word);
@@ -2730,6 +2801,7 @@ Id Builder::createSpecConstantOp(Op opCode, Id typeId, const std::vector<Id>& op
const std::vector<unsigned>& literals)
{
Instruction* op = new Instruction(getUniqueId(), typeId, OpSpecConstantOp);
op->reserveOperands(operands.size() + literals.size() + 1);
op->addImmediateOperand((unsigned) opCode);
for (auto it = operands.cbegin(); it != operands.cend(); ++it)
op->addIdOperand(*it);
@@ -2752,6 +2824,7 @@ Id Builder::createSpecConstantOp(Op opCode, Id typeId, const std::vector<Id>& op
Id Builder::createFunctionCall(spv::Function* function, const std::vector<spv::Id>& args)
{
Instruction* op = new Instruction(getUniqueId(), function->getReturnType(), OpFunctionCall);
op->reserveOperands(args.size() + 1);
op->addIdOperand(function->getId());
for (int a = 0; a < (int)args.size(); ++a)
op->addIdOperand(args[a]);
@@ -2773,6 +2846,7 @@ Id Builder::createRvalueSwizzle(Decoration precision, Id typeId, Id source, cons
}
Instruction* swizzle = new Instruction(getUniqueId(), typeId, OpVectorShuffle);
assert(isVector(source));
swizzle->reserveOperands(channels.size() + 2);
swizzle->addIdOperand(source);
swizzle->addIdOperand(source);
for (int i = 0; i < (int)channels.size(); ++i)
@@ -2791,6 +2865,7 @@ Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, const std::vect
Instruction* swizzle = new Instruction(getUniqueId(), typeId, OpVectorShuffle);
assert(isVector(target));
swizzle->reserveOperands(2);
swizzle->addIdOperand(target);
assert(getNumComponents(source) == (int)channels.size());
@@ -2808,6 +2883,7 @@ Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, const std::vect
components[channels[i]] = numTargetComponents + i;
// finish the instruction with these components selectors
swizzle->reserveOperands(numTargetComponents);
for (int i = 0; i < numTargetComponents; ++i)
swizzle->addImmediateOperand(components[i]);
addInstruction(std::unique_ptr<Instruction>(swizzle));
@@ -2853,6 +2929,7 @@ Id Builder::smearScalar(Decoration precision, Id scalar, Id vectorType)
smear = module.getInstruction(result_id);
} else {
smear = new Instruction(getUniqueId(), vectorType, OpCompositeConstruct);
smear->reserveOperands(numComponents);
for (int c = 0; c < numComponents; ++c)
smear->addIdOperand(scalar);
addInstruction(std::unique_ptr<Instruction>(smear));
@@ -2865,6 +2942,7 @@ Id Builder::smearScalar(Decoration precision, Id scalar, Id vectorType)
Id Builder::createBuiltinCall(Id resultType, Id builtins, int entryPoint, const std::vector<Id>& args)
{
Instruction* inst = new Instruction(getUniqueId(), resultType, OpExtInst);
inst->reserveOperands(args.size() + 2);
inst->addIdOperand(builtins);
inst->addImmediateOperand(entryPoint);
for (int arg = 0; arg < (int)args.size(); ++arg)
@@ -3059,6 +3137,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
// Build the SPIR-V instruction
Instruction* textureInst = new Instruction(getUniqueId(), resultType, opCode);
textureInst->reserveOperands(optArgNum + (texArgs.size() - (optArgNum + 1)));
for (size_t op = 0; op < optArgNum; ++op)
textureInst->addIdOperand(texArgs[op]);
if (optArgNum < texArgs.size())
@@ -3243,6 +3322,7 @@ Id Builder::createCompositeConstruct(Id typeId, const std::vector<Id>& constitue
}
Instruction* op = new Instruction(getUniqueId(), typeId, OpCompositeConstruct);
op->reserveOperands(constituents.size());
for (int c = 0; c < (int)constituents.size(); ++c)
op->addIdOperand(constituents[c]);
addInstruction(std::unique_ptr<Instruction>(op));
@@ -3532,6 +3612,7 @@ void Builder::makeSwitch(Id selector, unsigned int control, int numSegments, con
// make the switch instruction
Instruction* switchInst = new Instruction(NoResult, NoType, OpSwitch);
switchInst->reserveOperands((caseValues.size() * 2) + 2);
switchInst->addIdOperand(selector);
auto defaultOrMerge = (defaultSegment >= 0) ? segmentBlocks[defaultSegment] : mergeBlock;
switchInst->addIdOperand(defaultOrMerge->getId());
@@ -4067,6 +4148,7 @@ void Builder::createBranch(Block* block)
void Builder::createSelectionMerge(Block* mergeBlock, unsigned int control)
{
Instruction* merge = new Instruction(OpSelectionMerge);
merge->reserveOperands(2);
merge->addIdOperand(mergeBlock->getId());
merge->addImmediateOperand(control);
addInstruction(std::unique_ptr<Instruction>(merge));
@@ -4076,6 +4158,7 @@ void Builder::createLoopMerge(Block* mergeBlock, Block* continueBlock, unsigned
const std::vector<unsigned int>& operands)
{
Instruction* merge = new Instruction(OpLoopMerge);
merge->reserveOperands(operands.size() + 3);
merge->addIdOperand(mergeBlock->getId());
merge->addIdOperand(continueBlock->getId());
merge->addImmediateOperand(control);
@@ -4087,6 +4170,7 @@ void Builder::createLoopMerge(Block* mergeBlock, Block* continueBlock, unsigned
void Builder::createConditionalBranch(Id condition, Block* thenBlock, Block* elseBlock)
{
Instruction* branch = new Instruction(OpBranchConditional);
branch->reserveOperands(3);
branch->addIdOperand(condition);
branch->addIdOperand(thenBlock->getId());
branch->addIdOperand(elseBlock->getId());
@@ -4108,6 +4192,7 @@ void Builder::dumpSourceInstructions(const spv::Id fileId, const std::string& te
if (sourceLang != SourceLanguageUnknown) {
// OpSource Language Version File Source
Instruction sourceInst(NoResult, NoType, OpSource);
sourceInst.reserveOperands(3);
sourceInst.addImmediateOperand(sourceLang);
sourceInst.addImmediateOperand(sourceVersion);
// File operand

View File

@@ -80,6 +80,7 @@ enum ExtInstSet {
GLSLextNVInst,
OpenCLExtInst,
NonSemanticDebugPrintfExtInst,
NonSemanticDebugBreakExtInst,
NonSemanticShaderDebugInfo100
};
@@ -506,6 +507,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
extInstSet = OpenCLExtInst;
} else if (strcmp("NonSemantic.DebugPrintf", name) == 0) {
extInstSet = NonSemanticDebugPrintfExtInst;
} else if (strcmp("NonSemantic.DebugBreak", name) == 0) {
extInstSet = NonSemanticDebugBreakExtInst;
} else if (strcmp("NonSemantic.Shader.DebugInfo.100", name) == 0) {
extInstSet = NonSemanticShaderDebugInfo100;
} else if (strcmp(spv::E_SPV_AMD_shader_ballot, name) == 0 ||
@@ -533,6 +536,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
out << "(" << GLSLextNVGetDebugNames(name, entrypoint) << ")";
} else if (extInstSet == NonSemanticDebugPrintfExtInst) {
out << "(DebugPrintf)";
} else if (extInstSet == NonSemanticDebugBreakExtInst) {
out << "(DebugBreak)";
} else if (extInstSet == NonSemanticShaderDebugInfo100) {
out << "(" << NonSemanticShaderDebugInfo100GetDebugNames(entrypoint) << ")";
}

View File

@@ -319,6 +319,7 @@ const char* DecorationString(int decoration)
case DecorationWeightTextureQCOM: return "DecorationWeightTextureQCOM";
case DecorationBlockMatchTextureQCOM: return "DecorationBlockMatchTextureQCOM";
case DecorationBlockMatchSamplerQCOM: return "DecorationBlockMatchSamplerQCOM";
case DecorationExplicitInterpAMD: return "ExplicitInterpAMD";
case DecorationOverrideCoverageNV: return "OverrideCoverageNV";
case DecorationPassthroughNV: return "PassthroughNV";
@@ -1577,6 +1578,10 @@ const char* OpcodeString(int op)
case OpImageBoxFilterQCOM: return "OpImageBoxFilterQCOM";
case OpImageBlockMatchSADQCOM: return "OpImageBlockMatchSADQCOM";
case OpImageBlockMatchSSDQCOM: return "OpImageBlockMatchSSDQCOM";
case OpImageBlockMatchWindowSSDQCOM: return "OpImageBlockMatchWindowSSDQCOM";
case OpImageBlockMatchWindowSADQCOM: return "OpImageBlockMatchWindowSADQCOM";
case OpImageBlockMatchGatherSSDQCOM: return "OpImageBlockMatchGatherSSDQCOM";
case OpImageBlockMatchGatherSADQCOM: return "OpImageBlockMatchGatherSADQCOM";
default:
return "Bad";
@@ -3433,6 +3438,38 @@ void Parameterize()
InstructionDesc[OpImageBlockMatchSSDQCOM].operands.push(OperandId, "'block size'");
InstructionDesc[OpImageBlockMatchSSDQCOM].operands.push(OperandImageOperands, "", true);
InstructionDesc[OpImageBlockMatchSSDQCOM].setResultAndType(true, true);
InstructionDesc[OpImageBlockMatchWindowSSDQCOM].operands.push(OperandId, "'target texture'");
InstructionDesc[OpImageBlockMatchWindowSSDQCOM].operands.push(OperandId, "'target coordinates'");
InstructionDesc[OpImageBlockMatchWindowSSDQCOM].operands.push(OperandId, "'reference texture'");
InstructionDesc[OpImageBlockMatchWindowSSDQCOM].operands.push(OperandId, "'reference coordinates'");
InstructionDesc[OpImageBlockMatchWindowSSDQCOM].operands.push(OperandId, "'block size'");
InstructionDesc[OpImageBlockMatchWindowSSDQCOM].operands.push(OperandImageOperands, "", true);
InstructionDesc[OpImageBlockMatchWindowSSDQCOM].setResultAndType(true, true);
InstructionDesc[OpImageBlockMatchWindowSADQCOM].operands.push(OperandId, "'target texture'");
InstructionDesc[OpImageBlockMatchWindowSADQCOM].operands.push(OperandId, "'target coordinates'");
InstructionDesc[OpImageBlockMatchWindowSADQCOM].operands.push(OperandId, "'reference texture'");
InstructionDesc[OpImageBlockMatchWindowSADQCOM].operands.push(OperandId, "'reference coordinates'");
InstructionDesc[OpImageBlockMatchWindowSADQCOM].operands.push(OperandId, "'block size'");
InstructionDesc[OpImageBlockMatchWindowSADQCOM].operands.push(OperandImageOperands, "", true);
InstructionDesc[OpImageBlockMatchWindowSADQCOM].setResultAndType(true, true);
InstructionDesc[OpImageBlockMatchGatherSSDQCOM].operands.push(OperandId, "'target texture'");
InstructionDesc[OpImageBlockMatchGatherSSDQCOM].operands.push(OperandId, "'target coordinates'");
InstructionDesc[OpImageBlockMatchGatherSSDQCOM].operands.push(OperandId, "'reference texture'");
InstructionDesc[OpImageBlockMatchGatherSSDQCOM].operands.push(OperandId, "'reference coordinates'");
InstructionDesc[OpImageBlockMatchGatherSSDQCOM].operands.push(OperandId, "'block size'");
InstructionDesc[OpImageBlockMatchGatherSSDQCOM].operands.push(OperandImageOperands, "", true);
InstructionDesc[OpImageBlockMatchGatherSSDQCOM].setResultAndType(true, true);
InstructionDesc[OpImageBlockMatchGatherSADQCOM].operands.push(OperandId, "'target texture'");
InstructionDesc[OpImageBlockMatchGatherSADQCOM].operands.push(OperandId, "'target coordinates'");
InstructionDesc[OpImageBlockMatchGatherSADQCOM].operands.push(OperandId, "'reference texture'");
InstructionDesc[OpImageBlockMatchGatherSADQCOM].operands.push(OperandId, "'reference coordinates'");
InstructionDesc[OpImageBlockMatchGatherSADQCOM].operands.push(OperandId, "'block size'");
InstructionDesc[OpImageBlockMatchGatherSADQCOM].operands.push(OperandImageOperands, "", true);
InstructionDesc[OpImageBlockMatchGatherSADQCOM].setResultAndType(true, true);
});
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2020 The Khronos Group Inc.
// Copyright (c) 2014-2024 The Khronos Group Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
@@ -174,7 +174,7 @@ enum ExecutionMode {
ExecutionModeStencilRefUnchangedBackAMD = 5082,
ExecutionModeStencilRefGreaterBackAMD = 5083,
ExecutionModeStencilRefLessBackAMD = 5084,
ExecutionModeQuadDerivativesKHR = 5088,
ExecutionModeQuadDerivativesKHR = 5088,
ExecutionModeRequireFullQuadsKHR = 5089,
ExecutionModeOutputLinesEXT = 5269,
ExecutionModeOutputLinesNV = 5269,
@@ -200,7 +200,7 @@ enum ExecutionMode {
ExecutionModeNoGlobalOffsetINTEL = 5895,
ExecutionModeNumSIMDWorkitemsINTEL = 5896,
ExecutionModeSchedulerTargetFmaxMhzINTEL = 5903,
ExecutionModeMaximallyReconvergesKHR = 6023,
ExecutionModeMaximallyReconvergesKHR = 6023,
ExecutionModeStreamingInterfaceINTEL = 6154,
ExecutionModeNamedBarrierCountINTEL = 6417,
ExecutionModeMax = 0x7fffffff,
@@ -518,6 +518,7 @@ enum Decoration {
DecorationNoUnsignedWrap = 4470,
DecorationWeightTextureQCOM = 4487,
DecorationBlockMatchTextureQCOM = 4488,
DecorationBlockMatchSamplerQCOM = 4499,
DecorationExplicitInterpAMD = 4999,
DecorationOverrideCoverageNV = 5248,
DecorationPassthroughNV = 5250,
@@ -725,8 +726,6 @@ enum BuiltIn {
BuiltInHitTriangleVertexPositionsKHR = 5335,
BuiltInHitMicroTriangleVertexPositionsNV = 5337,
BuiltInHitMicroTriangleVertexBarycentricsNV = 5344,
BuiltInHitKindFrontFacingMicroTriangleNV = 5405,
BuiltInHitKindBackFacingMicroTriangleNV = 5406,
BuiltInIncomingRayFlagsKHR = 5351,
BuiltInIncomingRayFlagsNV = 5351,
BuiltInRayGeometryIndexKHR = 5352,
@@ -734,6 +733,8 @@ enum BuiltIn {
BuiltInSMCountNV = 5375,
BuiltInWarpIDNV = 5376,
BuiltInSMIDNV = 5377,
BuiltInHitKindFrontFacingMicroTriangleNV = 5405,
BuiltInHitKindBackFacingMicroTriangleNV = 5406,
BuiltInCullMaskKHR = 6021,
BuiltInMax = 0x7fffffff,
};
@@ -1035,6 +1036,7 @@ enum Capability {
CapabilityTextureSampleWeightedQCOM = 4484,
CapabilityTextureBoxFilterQCOM = 4485,
CapabilityTextureBlockMatchQCOM = 4486,
CapabilityTextureBlockMatch2QCOM = 4498,
CapabilityFloat16ImageAMD = 5008,
CapabilityImageGatherBiasLodAMD = 5009,
CapabilityFragmentMaskAMD = 5010,
@@ -1103,12 +1105,12 @@ enum Capability {
CapabilityDemoteToHelperInvocation = 5379,
CapabilityDemoteToHelperInvocationEXT = 5379,
CapabilityDisplacementMicromapNV = 5380,
CapabilityRayTracingDisplacementMicromapNV = 5409,
CapabilityRayTracingOpacityMicromapEXT = 5381,
CapabilityShaderInvocationReorderNV = 5383,
CapabilityBindlessTextureNV = 5390,
CapabilityRayQueryPositionFetchKHR = 5391,
CapabilityAtomicFloat16VectorNV = 5404,
CapabilityRayTracingDisplacementMicromapNV = 5409,
CapabilitySubgroupShuffleINTEL = 5568,
CapabilitySubgroupBufferBlockIOINTEL = 5569,
CapabilitySubgroupImageBlockIOINTEL = 5570,
@@ -1698,6 +1700,10 @@ enum Op {
OpImageBoxFilterQCOM = 4481,
OpImageBlockMatchSSDQCOM = 4482,
OpImageBlockMatchSADQCOM = 4483,
OpImageBlockMatchWindowSSDQCOM = 4500,
OpImageBlockMatchWindowSADQCOM = 4501,
OpImageBlockMatchGatherSSDQCOM = 4502,
OpImageBlockMatchGatherSADQCOM = 4503,
OpGroupIAddNonUniformAMD = 5000,
OpGroupFAddNonUniformAMD = 5001,
OpGroupFMinNonUniformAMD = 5002,
@@ -2381,8 +2387,6 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpGroupNonUniformLogicalXor: *hasResult = true; *hasResultType = true; break;
case OpGroupNonUniformQuadBroadcast: *hasResult = true; *hasResultType = true; break;
case OpGroupNonUniformQuadSwap: *hasResult = true; *hasResultType = true; break;
case OpGroupNonUniformQuadAllKHR: *hasResult = true; *hasResultType = true; break;
case OpGroupNonUniformQuadAnyKHR: *hasResult = true; *hasResultType = true; break;
case OpCopyLogical: *hasResult = true; *hasResultType = true; break;
case OpPtrEqual: *hasResult = true; *hasResultType = true; break;
case OpPtrNotEqual: *hasResult = true; *hasResultType = true; break;
@@ -2425,6 +2429,10 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpImageBoxFilterQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchSSDQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchSADQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchWindowSSDQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchWindowSADQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchGatherSSDQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchGatherSADQCOM: *hasResult = true; *hasResultType = true; break;
case OpGroupIAddNonUniformAMD: *hasResult = true; *hasResultType = true; break;
case OpGroupFAddNonUniformAMD: *hasResult = true; *hasResultType = true; break;
case OpGroupFMinNonUniformAMD: *hasResult = true; *hasResultType = true; break;
@@ -2436,6 +2444,8 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpFragmentMaskFetchAMD: *hasResult = true; *hasResultType = true; break;
case OpFragmentFetchAMD: *hasResult = true; *hasResultType = true; break;
case OpReadClockKHR: *hasResult = true; *hasResultType = true; break;
case OpGroupNonUniformQuadAllKHR: *hasResult = true; *hasResultType = true; break;
case OpGroupNonUniformQuadAnyKHR: *hasResult = true; *hasResultType = true; break;
case OpHitObjectRecordHitMotionNV: *hasResult = false; *hasResultType = false; break;
case OpHitObjectRecordHitWithIndexMotionNV: *hasResult = false; *hasResultType = false; break;
case OpHitObjectRecordMissMotionNV: *hasResult = false; *hasResultType = false; break;

View File

@@ -97,6 +97,10 @@ public:
Instruction(Id resultId, Id typeId, Op opCode) : resultId(resultId), typeId(typeId), opCode(opCode), block(nullptr) { }
explicit Instruction(Op opCode) : resultId(NoResult), typeId(NoType), opCode(opCode), block(nullptr) { }
virtual ~Instruction() {}
void reserveOperands(size_t count) {
operands.reserve(count);
idOperand.reserve(count);
}
void addIdOperand(Id id) {
// ids can't be 0
assert(id);
@@ -398,6 +402,7 @@ public:
void setDebugLineInfo(Id fileName, int line, int column) {
lineInstruction = std::unique_ptr<Instruction>{new Instruction(OpLine)};
lineInstruction->reserveOperands(3);
lineInstruction->addIdOperand(fileName);
lineInstruction->addImmediateOperand(line);
lineInstruction->addImmediateOperand(column);
@@ -521,6 +526,7 @@ __inline Function::Function(Id id, Id resultType, Id functionType, Id firstParam
linkType(linkage)
{
// OpFunction
functionInstruction.reserveOperands(2);
functionInstruction.addImmediateOperand(FunctionControlMaskNone);
functionInstruction.addIdOperand(functionType);
parent.mapInstruction(&functionInstruction);

View File

@@ -182,6 +182,7 @@ bool HlslEnable16BitTypes = false;
bool HlslDX9compatible = false;
bool HlslDxPositionW = false;
bool EnhancedMsgs = false;
bool AbsolutePath = false;
bool DumpBuiltinSymbols = false;
std::vector<std::string> IncludeDirectoryList;
@@ -727,6 +728,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
HlslDxPositionW = true;
} else if (lowerword == "enhanced-msgs") {
EnhancedMsgs = true;
} else if (lowerword == "absolute-path") {
AbsolutePath = true;
} else if (lowerword == "auto-sampled-textures") {
autoSampledTextures = true;
} else if (lowerword == "invert-y" || // synonyms
@@ -1159,6 +1162,8 @@ void SetMessageOptions(EShMessages& messages)
messages = (EShMessages)(messages | EShMsgBuiltinSymbolTable);
if (EnhancedMsgs)
messages = (EShMessages)(messages | EShMsgEnhanced);
if (AbsolutePath)
messages = (EShMessages)(messages | EShMsgAbsolutePath);
}
//
@@ -1190,6 +1195,7 @@ void CompileShaders(glslang::TWorklist& worklist)
if (compiler == nullptr)
return;
CompileFile(workItem->name.c_str(), compiler);
if (! (Options & EOptionSuppressInfolog))
@@ -1878,7 +1884,7 @@ void CompileFile(const char* fileName, ShHandle compiler)
for (int j = 0; j < ((Options & EOptionMemoryLeakMode) ? 100 : 1); ++j) {
// ret = ShCompile(compiler, shaderStrings, NumShaderStrings, lengths, EShOptNone, &Resources, Options, (Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
ret = ShCompile(compiler, &shaderString, 1, nullptr, EShOptNone, GetResources(), 0,
(Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
(Options & EOptionDefaultDesktop) ? 110 : 100, false, messages, fileName);
// const char* multi[12] = { "# ve", "rsion", " 300 e", "s", "\n#err",
// "or should be l", "ine 1", "string 5\n", "float glo", "bal",
// ";\n#error should be line 2\n void main() {", "global = 2.3;}" };
@@ -1993,6 +1999,7 @@ void usage()
" without explicit bindings\n"
" --auto-map-locations | --aml automatically locate input/output lacking\n"
" 'location' (fragile, not cross stage)\n"
" --absolute-path Prints absolute path for messages\n"
" --auto-sampled-textures Removes sampler variables and converts\n"
" existing textures to sampled textures\n"
" --client {vulkan<ver>|opengl<ver>} see -V and -G\n"
@@ -2160,6 +2167,20 @@ char* ReadFileData(const char* fileName)
fseek(in, 0, SEEK_SET);
if (count > 3) {
unsigned char head[3];
if (fread(head, 1, 3, in) == 3) {
if (head[0] == 0xef && head[1] == 0xbb && head[2] == 0xbf) {
// skip BOM
count -= 3;
} else {
fseek(in, 0, SEEK_SET);
}
} else {
Error("can't read input file");
}
}
char* return_data = (char*)malloc(count + 1); // freed in FreeFileData()
if ((int)fread(return_data, 1, count, in) != count) {
free(return_data);

View File

@@ -35,7 +35,7 @@
#define GLSLANG_BUILD_INFO
#define GLSLANG_VERSION_MAJOR 14
#define GLSLANG_VERSION_MINOR 0
#define GLSLANG_VERSION_MINOR 1
#define GLSLANG_VERSION_PATCH 0
#define GLSLANG_VERSION_FLAVOR ""

View File

@@ -205,6 +205,7 @@ static int c_shader_messages(glslang_messages_t messages)
CONVERT_MSG(GLSLANG_MSG_HLSL_LEGALIZATION_BIT, EShMsgHlslLegalization);
CONVERT_MSG(GLSLANG_MSG_HLSL_DX9_COMPATIBLE_BIT, EShMsgHlslDX9Compatible);
CONVERT_MSG(GLSLANG_MSG_BUILTIN_SYMBOL_TABLE_BIT, EShMsgBuiltinSymbolTable);
CONVERT_MSG(GLSLANG_MSG_ABSOLUTE_PATH, EShMsgAbsolutePath);
return res;
#undef CONVERT_MSG
}

View File

@@ -9658,6 +9658,10 @@ void HlslParseContext::correctOutput(TQualifier& qualifier)
if (language != EShLangTessControl)
qualifier.patch = false;
// Fixes Test/hlsl.entry-inout.vert (SV_Position will not become a varying).
if (qualifier.builtIn == EbvNone)
qualifier.builtIn = qualifier.declaredBuiltIn;
switch (qualifier.builtIn) {
case EbvFragDepth:
intermediate.setDepthReplacing();

View File

@@ -36,6 +36,7 @@
#define _INFOSINK_INCLUDED_
#include "../Include/Common.h"
#include <filesystem>
#include <cmath>
namespace glslang {
@@ -67,7 +68,7 @@ enum TOutputStream {
//
class TInfoSinkBase {
public:
TInfoSinkBase() : outputStream(4) {}
TInfoSinkBase() : outputStream(4), shaderFileName(nullptr) {}
void erase() { sink.erase(); }
TInfoSinkBase& operator<<(const TPersistString& t) { append(t); return *this; }
TInfoSinkBase& operator<<(char c) { append(1, c); return *this; }
@@ -94,11 +95,22 @@ public:
default: append("UNKNOWN ERROR: "); break;
}
}
void location(const TSourceLoc& loc) {
void location(const TSourceLoc& loc, bool absolute = false) {
const int maxSize = 24;
char locText[maxSize];
snprintf(locText, maxSize, ":%d", loc.line);
append(loc.getStringNameOrNum(false).c_str());
if(loc.getFilename() == nullptr && shaderFileName != nullptr && absolute) {
append(std::filesystem::absolute(shaderFileName).string());
} else {
std::string location = loc.getStringNameOrNum(false);
if (absolute) {
append(std::filesystem::absolute(location).string());
} else {
append(location);
}
}
append(locText);
append(": ");
}
@@ -119,6 +131,11 @@ public:
outputStream = output;
}
void setShaderFileName(const char* file = nullptr)
{
shaderFileName = file;
}
protected:
void append(const char* s);
@@ -131,6 +148,7 @@ protected:
void appendToStream(const char* s);
TPersistString sink;
int outputStream;
const char* shaderFileName;
};
} // end namespace glslang

View File

@@ -573,7 +573,8 @@ public:
}
const char* semanticName;
TStorageQualifier storage : 6;
TStorageQualifier storage : 7;
static_assert(EvqLast < 64, "need to increase size of TStorageQualifier bitfields!");
TBuiltInVariable builtIn : 9;
TBuiltInVariable declaredBuiltIn : 9;
static_assert(EbvLast < 256, "need to increase size of TBuiltInVariable bitfields!");
@@ -1434,13 +1435,25 @@ class TTypeParameters {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TTypeParameters() : basicType(EbtVoid), arraySizes(nullptr) {}
TTypeParameters() : basicType(EbtVoid), arraySizes(nullptr), spirvType(nullptr) {}
TBasicType basicType;
TArraySizes *arraySizes;
TSpirvType *spirvType;
bool operator==(const TTypeParameters& rhs) const { return basicType == rhs.basicType && *arraySizes == *rhs.arraySizes; }
bool operator!=(const TTypeParameters& rhs) const { return basicType != rhs.basicType || *arraySizes != *rhs.arraySizes; }
bool operator==(const TTypeParameters& rhs) const
{
bool same = basicType == rhs.basicType && *arraySizes == *rhs.arraySizes;
if (same && basicType == EbtSpirvType) {
assert(spirvType && rhs.spirvType);
return *spirvType == *rhs.spirvType;
}
return same;
}
bool operator!=(const TTypeParameters& rhs) const
{
return !(*this == rhs);
}
};
//
@@ -1617,6 +1630,10 @@ public:
}
if (p.isCoopmatKHR() && p.typeParameters && p.typeParameters->arraySizes->getNumDims() > 0) {
basicType = p.typeParameters->basicType;
if (isSpirvType()) {
assert(p.typeParameters->spirvType);
spirvType = p.typeParameters->spirvType;
}
if (p.typeParameters->arraySizes->getNumDims() == 4) {
const int dimSize = p.typeParameters->arraySizes->getDimSize(3);
@@ -2718,7 +2735,8 @@ public:
if (isCoopMatKHR() && right.isCoopMatKHR()) {
return ((getBasicType() == right.getBasicType()) || (getBasicType() == EbtCoopmat) ||
(right.getBasicType() == EbtCoopmat)) &&
typeParameters == nullptr && right.typeParameters != nullptr;
((typeParameters == nullptr && right.typeParameters != nullptr) ||
(typeParameters != nullptr && right.typeParameters == nullptr));
}
return false;
}
@@ -2824,6 +2842,7 @@ protected:
typeParameters = new TTypeParameters;
typeParameters->arraySizes = new TArraySizes;
*typeParameters->arraySizes = *copyOf.typeParameters->arraySizes;
*typeParameters->spirvType = *copyOf.typeParameters->spirvType;
typeParameters->basicType = copyOf.basicType;
}

View File

@@ -157,23 +157,24 @@ typedef enum {
/* EShMessages counterpart */
typedef enum {
GLSLANG_MSG_DEFAULT_BIT = 0,
GLSLANG_MSG_RELAXED_ERRORS_BIT = (1 << 0),
GLSLANG_MSG_SUPPRESS_WARNINGS_BIT = (1 << 1),
GLSLANG_MSG_AST_BIT = (1 << 2),
GLSLANG_MSG_SPV_RULES_BIT = (1 << 3),
GLSLANG_MSG_VULKAN_RULES_BIT = (1 << 4),
GLSLANG_MSG_ONLY_PREPROCESSOR_BIT = (1 << 5),
GLSLANG_MSG_READ_HLSL_BIT = (1 << 6),
GLSLANG_MSG_CASCADING_ERRORS_BIT = (1 << 7),
GLSLANG_MSG_KEEP_UNCALLED_BIT = (1 << 8),
GLSLANG_MSG_HLSL_OFFSETS_BIT = (1 << 9),
GLSLANG_MSG_DEBUG_INFO_BIT = (1 << 10),
GLSLANG_MSG_DEFAULT_BIT = 0,
GLSLANG_MSG_RELAXED_ERRORS_BIT = (1 << 0),
GLSLANG_MSG_SUPPRESS_WARNINGS_BIT = (1 << 1),
GLSLANG_MSG_AST_BIT = (1 << 2),
GLSLANG_MSG_SPV_RULES_BIT = (1 << 3),
GLSLANG_MSG_VULKAN_RULES_BIT = (1 << 4),
GLSLANG_MSG_ONLY_PREPROCESSOR_BIT = (1 << 5),
GLSLANG_MSG_READ_HLSL_BIT = (1 << 6),
GLSLANG_MSG_CASCADING_ERRORS_BIT = (1 << 7),
GLSLANG_MSG_KEEP_UNCALLED_BIT = (1 << 8),
GLSLANG_MSG_HLSL_OFFSETS_BIT = (1 << 9),
GLSLANG_MSG_DEBUG_INFO_BIT = (1 << 10),
GLSLANG_MSG_HLSL_ENABLE_16BIT_TYPES_BIT = (1 << 11),
GLSLANG_MSG_HLSL_LEGALIZATION_BIT = (1 << 12),
GLSLANG_MSG_HLSL_DX9_COMPATIBLE_BIT = (1 << 13),
GLSLANG_MSG_BUILTIN_SYMBOL_TABLE_BIT = (1 << 14),
GLSLANG_MSG_ENHANCED = (1 << 15),
GLSLANG_MSG_HLSL_LEGALIZATION_BIT = (1 << 12),
GLSLANG_MSG_HLSL_DX9_COMPATIBLE_BIT = (1 << 13),
GLSLANG_MSG_BUILTIN_SYMBOL_TABLE_BIT = (1 << 14),
GLSLANG_MSG_ENHANCED = (1 << 15),
GLSLANG_MSG_ABSOLUTE_PATH = (1 << 16),
LAST_ELEMENT_MARKER(GLSLANG_MSG_COUNT),
} glslang_messages_t;

View File

@@ -1111,6 +1111,12 @@ enum TOperator {
EOpImageBoxFilterQCOM,
EOpImageBlockMatchSADQCOM,
EOpImageBlockMatchSSDQCOM,
// Image processing2
EOpImageBlockMatchWindowSSDQCOM,
EOpImageBlockMatchWindowSADQCOM,
EOpImageBlockMatchGatherSSDQCOM,
EOpImageBlockMatchGatherSADQCOM,
};
enum TLinkType {

View File

@@ -4233,6 +4233,11 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec4 textureBoxFilterQCOM(sampler2D, vec2, vec2);"
"vec4 textureBlockMatchSADQCOM(sampler2D, uvec2, sampler2D, uvec2, uvec2);"
"vec4 textureBlockMatchSSDQCOM(sampler2D, uvec2, sampler2D, uvec2, uvec2);"
"vec4 textureBlockMatchWindowSSDQCOM(sampler2D, uvec2, sampler2D, uvec2, uvec2);"
"vec4 textureBlockMatchWindowSADQCOM(sampler2D, uvec2, sampler2D, uvec2, uvec2);"
"vec4 textureBlockMatchGatherSSDQCOM(sampler2D, uvec2, sampler2D, uvec2, uvec2);"
"vec4 textureBlockMatchGatherSADQCOM(sampler2D, uvec2, sampler2D, uvec2, uvec2);"
"\n");
}
@@ -8909,10 +8914,16 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 140)) {
symbolTable.setFunctionExtensions("textureWeightedQCOM", 1, &E_GL_QCOM_image_processing);
symbolTable.setFunctionExtensions("textureBoxFilterQCOM", 1, &E_GL_QCOM_image_processing);
symbolTable.setFunctionExtensions("textureBlockMatchSADQCOM", 1, &E_GL_QCOM_image_processing);
symbolTable.setFunctionExtensions("textureBlockMatchSSDQCOM", 1, &E_GL_QCOM_image_processing);
symbolTable.setFunctionExtensions("textureBlockMatchWindowSSDQCOM", 1, &E_GL_QCOM_image_processing2);
symbolTable.setFunctionExtensions("textureBlockMatchWindowSADQCOM", 1, &E_GL_QCOM_image_processing2);
symbolTable.setFunctionExtensions("textureBlockMatchGatherSSDQCOM", 1, &E_GL_QCOM_image_processing2);
symbolTable.setFunctionExtensions("textureBlockMatchGatherSADQCOM", 1, &E_GL_QCOM_image_processing2);
}
break;
@@ -10117,6 +10128,11 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.relateToOperator("textureBoxFilterQCOM", EOpImageBoxFilterQCOM);
symbolTable.relateToOperator("textureBlockMatchSADQCOM", EOpImageBlockMatchSADQCOM);
symbolTable.relateToOperator("textureBlockMatchSSDQCOM", EOpImageBlockMatchSSDQCOM);
symbolTable.relateToOperator("textureBlockMatchWindowSSDQCOM", EOpImageBlockMatchWindowSSDQCOM);
symbolTable.relateToOperator("textureBlockMatchWindowSADQCOM", EOpImageBlockMatchWindowSADQCOM);
symbolTable.relateToOperator("textureBlockMatchGatherSSDQCOM", EOpImageBlockMatchGatherSSDQCOM);
symbolTable.relateToOperator("textureBlockMatchGatherSADQCOM", EOpImageBlockMatchGatherSADQCOM);
}
if (profile != EEsProfile && spvVersion.spv == 0) {

View File

@@ -59,7 +59,7 @@ void TParseContextBase::outputMessage(const TSourceLoc& loc, const char* szReaso
safe_vsprintf(szExtraInfo, maxSize, szExtraInfoFormat, args);
infoSink.info.prefix(prefix);
infoSink.info.location(loc);
infoSink.info.location(loc, messages & EShMsgAbsolutePath);
infoSink.info << "'" << szToken << "' : " << szReason << " " << szExtraInfo << "\n";
if (prefix == EPrefixError) {

View File

@@ -7413,6 +7413,7 @@ void TParseContext::coopMatTypeParametersCheck(const TSourceLoc& loc, const TPub
case EbtUint:
case EbtUint8:
case EbtUint16:
case EbtSpirvType:
break;
default:
error(loc, "coopmat invalid basic type", TType::getBasicString(publicType.typeParameters->basicType), "");
@@ -7636,6 +7637,7 @@ struct AccessChainTraverser : public TIntermTraverser {
{}
TString path = "";
TStorageQualifier topLevelStorageQualifier = TStorageQualifier::EvqLast;
bool visitBinary(TVisit, TIntermBinary* binary) override {
if (binary->getOp() == EOpIndexDirectStruct)
@@ -7666,6 +7668,8 @@ struct AccessChainTraverser : public TIntermTraverser {
}
void visitSymbol(TIntermSymbol* symbol) override {
if (symbol->getType().isOpaque())
topLevelStorageQualifier = symbol->getQualifier().storage;
if (!IsAnonymous(symbol->getName()))
path.append(symbol->getName());
}
@@ -7676,6 +7680,15 @@ TIntermNode* TParseContext::vkRelaxedRemapFunctionArgument(const TSourceLoc& loc
AccessChainTraverser accessChainTraverser{};
intermTyped->traverse(&accessChainTraverser);
if (accessChainTraverser.topLevelStorageQualifier == TStorageQualifier::EvqUniform)
{
TParameter param = { 0, new TType, {} };
param.type->shallowCopy(intermTyped->getType());
function->addParameter(param);
return intermTyped;
}
TParameter param = { NewPoolTString(accessChainTraverser.path.c_str()), new TType, {} };
param.type->shallowCopy(intermTyped->getType());
@@ -7795,7 +7808,8 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
error(loc, "unexpected number type parameters", identifier.c_str(), "");
}
if (publicType.typeParameters) {
if (!isTypeFloat(publicType.typeParameters->basicType) && !isTypeInt(publicType.typeParameters->basicType)) {
if (!isTypeFloat(publicType.typeParameters->basicType) &&
!isTypeInt(publicType.typeParameters->basicType) && publicType.typeParameters->basicType != EbtSpirvType) {
error(loc, "expected 8, 16, 32, or 64 bit signed or unsigned integer or 16, 32, or 64 bit float type", identifier.c_str(), "");
}
}

View File

@@ -1434,7 +1434,8 @@ int ShCompile(
int /*debugOptions*/,
int defaultVersion, // use 100 for ES environment, 110 for desktop
bool forwardCompatible, // give errors for use of deprecated features
EShMessages messages // warnings/errors/AST; things to print out
EShMessages messages, // warnings/errors/AST; things to print out,
const char *shaderFileName // the filename
)
{
// Map the generic handle to the C++ object
@@ -1450,6 +1451,9 @@ int ShCompile(
compiler->infoSink.info.erase();
compiler->infoSink.debug.erase();
compiler->infoSink.info.setShaderFileName(shaderFileName);
compiler->infoSink.debug.setShaderFileName(shaderFileName);
TIntermediate intermediate(compiler->getLanguage());
TShader::ForbidIncluder includer;

View File

@@ -264,11 +264,14 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_fragment_shader_barycentric] = EBhDisable;
extensionBehavior[E_GL_EXT_expect_assume] = EBhDisable;
extensionBehavior[E_GL_EXT_control_flow_attributes2] = EBhDisable;
extensionBehavior[E_GL_KHR_cooperative_matrix] = EBhDisable;
// #line and #include
extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable;
extensionBehavior[E_GL_GOOGLE_include_directive] = EBhDisable;
extensionBehavior[E_GL_ARB_shading_language_include] = EBhDisable;
extensionBehavior[E_GL_AMD_shader_ballot] = EBhDisable;
extensionBehavior[E_GL_AMD_shader_trinary_minmax] = EBhDisable;
@@ -312,6 +315,7 @@ void TParseVersions::initializeExtensionBehavior()
// QCOM
extensionBehavior[E_GL_QCOM_image_processing] = EBhDisable;
extensionBehavior[E_GL_QCOM_image_processing2] = EBhDisable;
// AEP
extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisable;
@@ -443,6 +447,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
"#define GL_QCOM_image_processing 1\n"
"#define GL_QCOM_image_processing2 1\n"
;
if (version >= 300) {
@@ -569,6 +574,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_NV_shader_invocation_reorder 1\n"
"#define GL_QCOM_image_processing 1\n"
"#define GL_QCOM_image_processing2 1\n"
"#define GL_EXT_shader_explicit_arithmetic_types 1\n"
"#define GL_EXT_shader_explicit_arithmetic_types_int8 1\n"
@@ -590,6 +596,8 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_EXT_fragment_shader_barycentric 1\n"
"#define GL_EXT_shader_quad_control 1\n"
"#define GL_EXT_texture_array 1\n"
"#define GL_EXT_control_flow_attributes2 1\n"
;
if (spvVersion.spv == 0) {
@@ -983,6 +991,8 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co
updateExtensionBehavior(line, "GL_OES_shader_io_blocks", behaviorString);
else if (strcmp(extension, "GL_GOOGLE_include_directive") == 0)
updateExtensionBehavior(line, "GL_GOOGLE_cpp_style_line_directive", behaviorString);
else if (strcmp(extension, "GL_ARB_shading_language_include") == 0)
updateExtensionBehavior(line, "GL_GOOGLE_cpp_style_line_directive", behaviorString);
// subgroup_* to subgroup_basic
else if (strcmp(extension, "GL_KHR_shader_subgroup_vote") == 0)
updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString);

View File

@@ -221,6 +221,7 @@ const char* const E_GL_EXT_draw_instanced = "GL_EXT_draw_insta
const char* const E_GL_EXT_texture_array = "GL_EXT_texture_array";
const char* const E_GL_EXT_maximal_reconvergence = "GL_EXT_maximal_reconvergence";
const char* const E_GL_EXT_expect_assume = "GL_EXT_expect_assume";
const char* const E_GL_EXT_control_flow_attributes2 = "GL_EXT_control_flow_attributes2";
// Arrays of extensions for the above viewportEXTs duplications
@@ -241,6 +242,7 @@ const int Num_OVR_multiview_EXTs = sizeof(OVR_multiview_EXTs) / sizeof(OVR_multi
// #line and #include
const char* const E_GL_GOOGLE_cpp_style_line_directive = "GL_GOOGLE_cpp_style_line_directive";
const char* const E_GL_GOOGLE_include_directive = "GL_GOOGLE_include_directive";
const char* const E_GL_ARB_shading_language_include = "GL_ARB_shading_language_include";
const char* const E_GL_AMD_shader_ballot = "GL_AMD_shader_ballot";
const char* const E_GL_AMD_shader_trinary_minmax = "GL_AMD_shader_trinary_minmax";
@@ -290,6 +292,7 @@ const int Num_viewportEXTs = sizeof(viewportEXTs) / sizeof(viewportEXTs[0]);
const char* const E_GL_QCOM_image_processing = "GL_QCOM_image_processing";
const char* const E_GL_QCOM_image_processing2 = "GL_QCOM_image_processing2";
// AEP
const char* const E_GL_ANDROID_extension_pack_es31a = "GL_ANDROID_extension_pack_es31a";

View File

@@ -508,7 +508,10 @@ function_call_header_with_parameters
&& $3->getType().containsOpaque())
{
TIntermNode* remappedNode = parseContext.vkRelaxedRemapFunctionArgument($2.loc, $1.function, $3);
$$.intermNode = parseContext.intermediate.mergeAggregate($1.intermNode, remappedNode, $2.loc);
if (remappedNode == $3)
$$.intermNode = parseContext.intermediate.growAggregate($1.intermNode, $3, $2.loc);
else
$$.intermNode = parseContext.intermediate.mergeAggregate($1.intermNode, remappedNode, $2.loc);
$$.function = $1.function;
}
else
@@ -1756,6 +1759,7 @@ type_parameter_specifier_list
: type_specifier {
$$ = new TTypeParameters;
$$->arraySizes = new TArraySizes;
$$->spirvType = $1.spirvType;
$$->basicType = $1.basicType;
}
| unary_expression {
@@ -3950,7 +3954,8 @@ iteration_statement
$$ = $1;
}
| attribute iteration_statement_nonattributed {
parseContext.requireExtensions($2->getLoc(), 1, &E_GL_EXT_control_flow_attributes, "attribute");
const char * extensions[2] = { E_GL_EXT_control_flow_attributes, E_GL_EXT_control_flow_attributes2 };
parseContext.requireExtensions($2->getLoc(), 2, extensions, "attribute");
parseContext.handleLoopAttributes(*$1, $2);
$$ = $2;
}

File diff suppressed because it is too large Load Diff

View File

@@ -83,6 +83,11 @@ public:
const char* featureDesc);
virtual void ppRequireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[],
const char* featureDesc);
template<typename Container>
constexpr void ppRequireExtensions(const TSourceLoc& loc, Container extensions, const char* featureDesc) {
ppRequireExtensions(loc, static_cast<int>(extensions.size()), extensions.data(), featureDesc);
}
virtual TExtensionBehavior getExtensionBehavior(const char*);
virtual bool extensionTurnedOn(const char* const extension);
virtual bool extensionsTurnedOn(int numExtensions, const char* const extensions[]);

View File

@@ -973,7 +973,8 @@ int TPpContext::readCPPline(TPpToken* ppToken)
break;
case PpAtomInclude:
if(!parseContext.isReadingHLSL()) {
parseContext.ppRequireExtensions(ppToken->loc, 1, &E_GL_GOOGLE_include_directive, "#include");
const std::array exts = { E_GL_GOOGLE_include_directive, E_GL_ARB_shading_language_include };
parseContext.ppRequireExtensions(ppToken->loc, exts, "#include");
}
token = CPPinclude(ppToken);
break;

View File

@@ -220,7 +220,9 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
}
if (ch >= '0' && ch <= '9') {
while (ch >= '0' && ch <= '9') {
exponent = exponent * 10 + (ch - '0');
if (exponent < 500) {
exponent = exponent * 10 + (ch - '0');
}
saveName(ch);
ch = getChar();
}

View File

@@ -252,23 +252,24 @@ typedef enum {
// Message choices for what errors and warnings are given.
//
enum EShMessages : unsigned {
EShMsgDefault = 0, // default is to give all required errors and extra warnings
EShMsgRelaxedErrors = (1 << 0), // be liberal in accepting input
EShMsgSuppressWarnings = (1 << 1), // suppress all warnings, except those required by the specification
EShMsgAST = (1 << 2), // print the AST intermediate representation
EShMsgSpvRules = (1 << 3), // issue messages for SPIR-V generation
EShMsgVulkanRules = (1 << 4), // issue messages for Vulkan-requirements of GLSL for SPIR-V
EShMsgOnlyPreprocessor = (1 << 5), // only print out errors produced by the preprocessor
EShMsgReadHlsl = (1 << 6), // use HLSL parsing rules and semantics
EShMsgCascadingErrors = (1 << 7), // get cascading errors; risks error-recovery issues, instead of an early exit
EShMsgKeepUncalled = (1 << 8), // for testing, don't eliminate uncalled functions
EShMsgHlslOffsets = (1 << 9), // allow block offsets to follow HLSL rules instead of GLSL rules
EShMsgDebugInfo = (1 << 10), // save debug information
EShMsgHlslEnable16BitTypes = (1 << 11), // enable use of 16-bit types in SPIR-V for HLSL
EShMsgHlslLegalization = (1 << 12), // enable HLSL Legalization messages
EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (for samplers and semantics)
EShMsgBuiltinSymbolTable = (1 << 14), // print the builtin symbol table
EShMsgEnhanced = (1 << 15), // enhanced message readability
EShMsgDefault = 0, // default is to give all required errors and extra warnings
EShMsgRelaxedErrors = (1 << 0), // be liberal in accepting input
EShMsgSuppressWarnings = (1 << 1), // suppress all warnings, except those required by the specification
EShMsgAST = (1 << 2), // print the AST intermediate representation
EShMsgSpvRules = (1 << 3), // issue messages for SPIR-V generation
EShMsgVulkanRules = (1 << 4), // issue messages for Vulkan-requirements of GLSL for SPIR-V
EShMsgOnlyPreprocessor = (1 << 5), // only print out errors produced by the preprocessor
EShMsgReadHlsl = (1 << 6), // use HLSL parsing rules and semantics
EShMsgCascadingErrors = (1 << 7), // get cascading errors; risks error-recovery issues, instead of an early exit
EShMsgKeepUncalled = (1 << 8), // for testing, don't eliminate uncalled functions
EShMsgHlslOffsets = (1 << 9), // allow block offsets to follow HLSL rules instead of GLSL rules
EShMsgDebugInfo = (1 << 10), // save debug information
EShMsgHlslEnable16BitTypes = (1 << 11), // enable use of 16-bit types in SPIR-V for HLSL
EShMsgHlslLegalization = (1 << 12), // enable HLSL Legalization messages
EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (for samplers and semantics)
EShMsgBuiltinSymbolTable = (1 << 14), // print the builtin symbol table
EShMsgEnhanced = (1 << 15), // enhanced message readability
EShMsgAbsolutePath = (1 << 16), // Output Absolute path for messages
LAST_ELEMENT_MARKER(EShMsgCount),
};
@@ -335,7 +336,8 @@ GLSLANG_EXPORT int ShCompile(const ShHandle, const char* const shaderStrings[],
int, // debugOptions unused
int defaultVersion = 110, // use 100 for ES environment, overridden by #version in shader
bool forwardCompatible = false, // give errors for use of deprecated features
EShMessages messages = EShMsgDefault // warnings and errors
EShMessages messages = EShMsgDefault, // warnings and errors
const char* fileName = nullptr
);
GLSLANG_EXPORT int ShLinkExt(