Updated glslang.

This commit is contained in:
Бранимир Караџић
2024-02-24 19:46:21 -08:00
parent 2e9c28f436
commit 854602a008
28 changed files with 357 additions and 144 deletions

View File

@@ -95,6 +95,8 @@ GLSLANG_EXPORT void glslang_program_SPIRV_generate_with_options(glslang_program_
const glslang::TIntermediate* intermediate = program->program->getIntermediate(c_shader_stage(stage));
program->spirv.clear();
glslang::GlslangToSpv(*intermediate, program->spirv, &logger, reinterpret_cast<glslang::SpvOptions*>(spv_options));
program->loggerMessages = logger.getAllMessages();

View File

@@ -60,5 +60,6 @@ static const char* const E_SPV_KHR_ray_tracing_position_fetch = "SPV_KHR_ray_t
static const char* const E_SPV_KHR_cooperative_matrix = "SPV_KHR_cooperative_matrix";
static const char* const E_SPV_KHR_maximal_reconvergence = "SPV_KHR_maximal_reconvergence";
static const char* const E_SPV_KHR_subgroup_rotate = "SPV_KHR_subgroup_rotate";
static const char* const E_SPV_KHR_expect_assume = "SPV_KHR_expect_assume";
#endif // #ifndef GLSLextKHR_H

View File

@@ -87,4 +87,7 @@ const char* const E_SPV_NV_shader_invocation_reorder = "SPV_NV_shader_invocation
//SPV_NV_displacement_micromap
const char* const E_SPV_NV_displacement_micromap = "SPV_NV_displacement_micromap";
//SPV_NV_shader_atomic_fp16_vector
const char* const E_SPV_NV_shader_atomic_fp16_vector = "SPV_NV_shader_atomic_fp16_vector";
#endif // #ifndef GLSLextNV_H

View File

@@ -204,7 +204,8 @@ protected:
spv::Id createBinaryMatrixOperation(spv::Op, OpDecorations&, spv::Id typeId, spv::Id left, spv::Id right);
spv::Id createUnaryOperation(glslang::TOperator op, OpDecorations&, spv::Id typeId, spv::Id operand,
glslang::TBasicType typeProxy,
const spv::Builder::AccessChain::CoherentFlags &lvalueCoherentFlags);
const spv::Builder::AccessChain::CoherentFlags &lvalueCoherentFlags,
const glslang::TType &opType);
spv::Id createUnaryMatrixOperation(spv::Op op, OpDecorations&, spv::Id typeId, spv::Id operand,
glslang::TBasicType typeProxy);
spv::Id createConversion(glslang::TOperator op, OpDecorations&, spv::Id destTypeId, spv::Id operand,
@@ -213,7 +214,8 @@ protected:
spv::Id makeSmearedConstant(spv::Id constant, int vectorSize);
spv::Id createAtomicOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId,
std::vector<spv::Id>& operands, glslang::TBasicType typeProxy,
const spv::Builder::AccessChain::CoherentFlags &lvalueCoherentFlags);
const spv::Builder::AccessChain::CoherentFlags &lvalueCoherentFlags,
const glslang::TType &opType);
spv::Id createInvocationsOperation(glslang::TOperator op, spv::Id typeId, std::vector<spv::Id>& operands,
glslang::TBasicType typeProxy);
spv::Id CreateInvocationsVectorOperation(spv::Op op, spv::GroupOperation groupOperation,
@@ -1163,6 +1165,7 @@ spv::ImageFormat TGlslangToSpvTraverser::TranslateImageFormat(const glslang::TTy
case glslang::ElfR64i:
builder.addExtension(spv::E_SPV_EXT_shader_image_int64);
builder.addCapability(spv::CapabilityInt64ImageEXT);
break;
default:
break;
}
@@ -2692,7 +2695,7 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
// if not, then possibly an operation
if (! result)
result = createUnaryOperation(node->getOp(), decorations, resultType(), operand,
node->getOperand()->getBasicType(), lvalueCoherentFlags);
node->getOperand()->getBasicType(), lvalueCoherentFlags, node->getType());
// it could be attached to a SPIR-V intruction
if (!result) {
@@ -2785,6 +2788,11 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
return false;
case glslang::EOpAssumeEXT:
builder.addCapability(spv::CapabilityExpectAssumeKHR);
builder.addExtension(spv::E_SPV_KHR_expect_assume);
builder.createNoResultOp(spv::OpAssumeTrueKHR, operand);
return false;
case glslang::EOpEmitStreamVertex:
builder.createNoResultOp(spv::OpEmitStreamVertex, operand);
return false;
@@ -3045,7 +3053,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
case glslang::EOpConstructF16Mat4x3:
case glslang::EOpConstructF16Mat4x4:
isMatrix = true;
// fall through
[[fallthrough]];
case glslang::EOpConstructFloat:
case glslang::EOpConstructVec2:
case glslang::EOpConstructVec3:
@@ -3216,7 +3224,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
case glslang::EOpAtomicStore:
noReturnValue = true;
// fallthrough
[[fallthrough]];
case glslang::EOpAtomicLoad:
atomic = true;
break;
@@ -3246,6 +3254,12 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
binOp = node->getOp();
break;
case glslang::EOpExpectEXT:
builder.addCapability(spv::CapabilityExpectAssumeKHR);
builder.addExtension(spv::E_SPV_KHR_expect_assume);
binOp = node->getOp();
break;
case glslang::EOpIgnoreIntersectionNV:
case glslang::EOpTerminateRayNV:
case glslang::EOpTraceNV:
@@ -3313,7 +3327,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
case glslang::EOpHitObjectRecordHitWithIndexMotionNV:
case glslang::EOpReorderThreadNV:
noReturnValue = true;
//Fallthrough
[[fallthrough]];
case glslang::EOpHitObjectIsEmptyNV:
case glslang::EOpHitObjectIsMissNV:
case glslang::EOpHitObjectIsHitNV:
@@ -3764,7 +3778,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
glslang::TBasicType typeProxy = (node->getOp() == glslang::EOpAtomicStore)
? node->getSequence()[0]->getAsTyped()->getBasicType() : node->getBasicType();
result = createAtomicOperation(node->getOp(), precision, resultType(), operands, typeProxy,
lvalueCoherentFlags);
lvalueCoherentFlags, node->getType());
} else if (node->getOp() == glslang::EOpSpirvInst) {
const auto& spirvInst = node->getSpirvInstruction();
if (spirvInst.set == "") {
@@ -3811,7 +3825,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
result = createUnaryOperation(
node->getOp(), decorations,
resultType(), operands.front(),
glslangOperands[0]->getAsTyped()->getBasicType(), lvalueCoherentFlags);
glslangOperands[0]->getAsTyped()->getBasicType(), lvalueCoherentFlags, node->getType());
}
break;
default:
@@ -6066,7 +6080,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
operands.push_back(*opIt);
return createAtomicOperation(node->getOp(), precision, resultType(), operands, typeProxy,
lvalueCoherentFlags);
lvalueCoherentFlags, node->getType());
}
}
@@ -6591,6 +6605,10 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, OpD
binOp = isUnsigned ? spv::OpUMul32x16INTEL : spv::OpIMul32x16INTEL;
break;
case glslang::EOpExpectEXT:
binOp = spv::OpExpectKHR;
break;
case glslang::EOpLessThan:
case glslang::EOpGreaterThan:
case glslang::EOpLessThanEqual:
@@ -6813,7 +6831,8 @@ spv::Id TGlslangToSpvTraverser::createBinaryMatrixOperation(spv::Op op, OpDecora
}
spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, OpDecorations& decorations, spv::Id typeId,
spv::Id operand, glslang::TBasicType typeProxy, const spv::Builder::AccessChain::CoherentFlags &lvalueCoherentFlags)
spv::Id operand, glslang::TBasicType typeProxy, const spv::Builder::AccessChain::CoherentFlags &lvalueCoherentFlags,
const glslang::TType &opType)
{
spv::Op unaryOp = spv::OpNop;
int extBuiltins = -1;
@@ -7101,7 +7120,7 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, OpDe
// Handle all of the atomics in one place, in createAtomicOperation()
std::vector<spv::Id> operands;
operands.push_back(operand);
return createAtomicOperation(op, decorations.precision, typeId, operands, typeProxy, lvalueCoherentFlags);
return createAtomicOperation(op, decorations.precision, typeId, operands, typeProxy, lvalueCoherentFlags, opType);
}
case glslang::EOpBitFieldReverse:
@@ -7819,7 +7838,7 @@ spv::Id TGlslangToSpvTraverser::makeSmearedConstant(spv::Id constant, int vector
// For glslang ops that map to SPV atomic opCodes
spv::Id TGlslangToSpvTraverser::createAtomicOperation(glslang::TOperator op, spv::Decoration /*precision*/,
spv::Id typeId, std::vector<spv::Id>& operands, glslang::TBasicType typeProxy,
const spv::Builder::AccessChain::CoherentFlags &lvalueCoherentFlags)
const spv::Builder::AccessChain::CoherentFlags &lvalueCoherentFlags, const glslang::TType &opType)
{
spv::Op opCode = spv::OpNop;
@@ -7830,14 +7849,20 @@ spv::Id TGlslangToSpvTraverser::createAtomicOperation(glslang::TOperator op, spv
opCode = spv::OpAtomicIAdd;
if (typeProxy == glslang::EbtFloat16 || typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble) {
opCode = spv::OpAtomicFAddEXT;
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float_add);
if (typeProxy == glslang::EbtFloat16) {
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float16_add);
builder.addCapability(spv::CapabilityAtomicFloat16AddEXT);
} else if (typeProxy == glslang::EbtFloat) {
builder.addCapability(spv::CapabilityAtomicFloat32AddEXT);
if (typeProxy == glslang::EbtFloat16 &&
(opType.getVectorSize() == 2 || opType.getVectorSize() == 4)) {
builder.addExtension(spv::E_SPV_NV_shader_atomic_fp16_vector);
builder.addCapability(spv::CapabilityAtomicFloat16VectorNV);
} else {
builder.addCapability(spv::CapabilityAtomicFloat64AddEXT);
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float_add);
if (typeProxy == glslang::EbtFloat16) {
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float16_add);
builder.addCapability(spv::CapabilityAtomicFloat16AddEXT);
} else if (typeProxy == glslang::EbtFloat) {
builder.addCapability(spv::CapabilityAtomicFloat32AddEXT);
} else {
builder.addCapability(spv::CapabilityAtomicFloat64AddEXT);
}
}
}
break;
@@ -7850,13 +7875,19 @@ spv::Id TGlslangToSpvTraverser::createAtomicOperation(glslang::TOperator op, spv
case glslang::EOpAtomicCounterMin:
if (typeProxy == glslang::EbtFloat16 || typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble) {
opCode = spv::OpAtomicFMinEXT;
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float_min_max);
if (typeProxy == glslang::EbtFloat16)
builder.addCapability(spv::CapabilityAtomicFloat16MinMaxEXT);
else if (typeProxy == glslang::EbtFloat)
builder.addCapability(spv::CapabilityAtomicFloat32MinMaxEXT);
else
builder.addCapability(spv::CapabilityAtomicFloat64MinMaxEXT);
if (typeProxy == glslang::EbtFloat16 &&
(opType.getVectorSize() == 2 || opType.getVectorSize() == 4)) {
builder.addExtension(spv::E_SPV_NV_shader_atomic_fp16_vector);
builder.addCapability(spv::CapabilityAtomicFloat16VectorNV);
} else {
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float_min_max);
if (typeProxy == glslang::EbtFloat16)
builder.addCapability(spv::CapabilityAtomicFloat16MinMaxEXT);
else if (typeProxy == glslang::EbtFloat)
builder.addCapability(spv::CapabilityAtomicFloat32MinMaxEXT);
else
builder.addCapability(spv::CapabilityAtomicFloat64MinMaxEXT);
}
} else if (typeProxy == glslang::EbtUint || typeProxy == glslang::EbtUint64) {
opCode = spv::OpAtomicUMin;
} else {
@@ -7868,13 +7899,19 @@ spv::Id TGlslangToSpvTraverser::createAtomicOperation(glslang::TOperator op, spv
case glslang::EOpAtomicCounterMax:
if (typeProxy == glslang::EbtFloat16 || typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble) {
opCode = spv::OpAtomicFMaxEXT;
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float_min_max);
if (typeProxy == glslang::EbtFloat16)
builder.addCapability(spv::CapabilityAtomicFloat16MinMaxEXT);
else if (typeProxy == glslang::EbtFloat)
builder.addCapability(spv::CapabilityAtomicFloat32MinMaxEXT);
else
builder.addCapability(spv::CapabilityAtomicFloat64MinMaxEXT);
if (typeProxy == glslang::EbtFloat16 &&
(opType.getVectorSize() == 2 || opType.getVectorSize() == 4)) {
builder.addExtension(spv::E_SPV_NV_shader_atomic_fp16_vector);
builder.addCapability(spv::CapabilityAtomicFloat16VectorNV);
} else {
builder.addExtension(spv::E_SPV_EXT_shader_atomic_float_min_max);
if (typeProxy == glslang::EbtFloat16)
builder.addCapability(spv::CapabilityAtomicFloat16MinMaxEXT);
else if (typeProxy == glslang::EbtFloat)
builder.addCapability(spv::CapabilityAtomicFloat32MinMaxEXT);
else
builder.addCapability(spv::CapabilityAtomicFloat64MinMaxEXT);
}
} else if (typeProxy == glslang::EbtUint || typeProxy == glslang::EbtUint64) {
opCode = spv::OpAtomicUMax;
} else {
@@ -7899,6 +7936,12 @@ spv::Id TGlslangToSpvTraverser::createAtomicOperation(glslang::TOperator op, spv
case glslang::EOpAtomicExchange:
case glslang::EOpImageAtomicExchange:
case glslang::EOpAtomicCounterExchange:
if ((typeProxy == glslang::EbtFloat16) &&
(opType.getVectorSize() == 2 || opType.getVectorSize() == 4)) {
builder.addExtension(spv::E_SPV_NV_shader_atomic_fp16_vector);
builder.addCapability(spv::CapabilityAtomicFloat16VectorNV);
}
opCode = spv::OpAtomicExchange;
break;
case glslang::EOpAtomicCompSwap:
@@ -8305,7 +8348,7 @@ spv::Id TGlslangToSpvTraverser::createSubgroupOperation(glslang::TOperator op, s
case glslang::EOpSubgroupQuadAny:
builder.addExtension(spv::E_SPV_KHR_quad_control);
builder.addCapability(spv::CapabilityQuadControlKHR);
// pass through
[[fallthrough]];
case glslang::EOpSubgroupAll:
case glslang::EOpSubgroupAny:
case glslang::EOpSubgroupAllEqual:

View File

@@ -1176,6 +1176,10 @@ Id Builder::makeAccelerationStructureType()
groupedTypes[OpTypeAccelerationStructureKHR].push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
if (emitNonSemanticShaderDebugInfo) {
spv::Id debugType = makeCompositeDebugType({}, "accelerationStructure", NonSemanticShaderDebugInfo100Structure, true);
debugId[type->getResultId()] = debugType;
}
} else {
type = groupedTypes[OpTypeAccelerationStructureKHR].back();
}
@@ -1191,6 +1195,10 @@ Id Builder::makeRayQueryType()
groupedTypes[OpTypeRayQueryKHR].push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
if (emitNonSemanticShaderDebugInfo) {
spv::Id debugType = makeCompositeDebugType({}, "rayQuery", NonSemanticShaderDebugInfo100Structure, true);
debugId[type->getResultId()] = debugType;
}
} else {
type = groupedTypes[OpTypeRayQueryKHR].back();
}
@@ -1476,17 +1484,6 @@ bool Builder::isSpecConstantOpCode(Op opcode) const
}
}
bool Builder::isRayTracingOpCode(Op opcode) const
{
switch (opcode) {
case OpTypeAccelerationStructureKHR:
case OpTypeRayQueryKHR:
return true;
default:
return false;
}
}
Id Builder::makeNullConstant(Id typeId)
{
Instruction* constant;
@@ -2368,7 +2365,7 @@ Id Builder::createVariable(Decoration precision, StorageClass storageClass, Id t
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(inst));
module.mapInstruction(inst);
if (emitNonSemanticShaderDebugInfo && !isRayTracingOpCode(getOpCode(type)))
if (emitNonSemanticShaderDebugInfo)
{
auto const debugResultId = createDebugGlobalVariable(debugId[type], name, inst->getResultId());
debugId[inst->getResultId()] = debugResultId;

View File

@@ -326,8 +326,6 @@ public:
// See if a resultId is valid for use as an initializer.
bool isValidInitializer(Id resultId) const { return isConstant(resultId) || isGlobalVariable(resultId); }
bool isRayTracingOpCode(Op opcode) const;
int getScalarTypeWidth(Id typeId) const
{
Id scalarTypeId = getScalarTypeId(typeId);

View File

@@ -181,6 +181,7 @@ void Builder::postProcessType(const Instruction& inst, Id typeId)
else if (width == 8)
addCapability(CapabilityInt8);
}
break;
default:
if (basicTypeOp == OpTypeInt) {
if (width == 16)

View File

@@ -360,7 +360,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
switch (stream[word]) {
case 8: idDescriptor[resultId] = "int8_t"; break;
case 16: idDescriptor[resultId] = "int16_t"; break;
default: assert(0); // fallthrough
default: assert(0); [[fallthrough]];
case 32: idDescriptor[resultId] = "int"; break;
case 64: idDescriptor[resultId] = "int64_t"; break;
}
@@ -368,7 +368,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
case OpTypeFloat:
switch (stream[word]) {
case 16: idDescriptor[resultId] = "float16_t"; break;
default: assert(0); // fallthrough
default: assert(0); [[fallthrough]];
case 32: idDescriptor[resultId] = "float"; break;
case 64: idDescriptor[resultId] = "float64_t"; break;
}

View File

@@ -1037,12 +1037,15 @@ const char* CapabilityString(int info)
case CapabilityFragmentShadingRateKHR: return "FragmentShadingRateKHR";
case CapabilityDemoteToHelperInvocationEXT: return "DemoteToHelperInvocationEXT";
case CapabilityAtomicFloat16VectorNV: return "AtomicFloat16VectorNV";
case CapabilityShaderClockKHR: return "ShaderClockKHR";
case CapabilityQuadControlKHR: return "QuadControlKHR";
case CapabilityInt64ImageEXT: return "Int64ImageEXT";
case CapabilityIntegerFunctions2INTEL: return "CapabilityIntegerFunctions2INTEL";
case CapabilityExpectAssumeKHR: return "ExpectAssumeKHR";
case CapabilityAtomicFloat16AddEXT: return "AtomicFloat16AddEXT";
case CapabilityAtomicFloat32AddEXT: return "AtomicFloat32AddEXT";
case CapabilityAtomicFloat64AddEXT: return "AtomicFloat64AddEXT";

View File

@@ -1108,6 +1108,7 @@ enum Capability {
CapabilityShaderInvocationReorderNV = 5383,
CapabilityBindlessTextureNV = 5390,
CapabilityRayQueryPositionFetchKHR = 5391,
CapabilityAtomicFloat16VectorNV = 5404,
CapabilitySubgroupShuffleINTEL = 5568,
CapabilitySubgroupBufferBlockIOINTEL = 5569,
CapabilitySubgroupImageBlockIOINTEL = 5570,

View File

@@ -391,6 +391,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
case EvqOut:
case EvqInOut:
parseContext.error(token.loc, "in/out qualifiers are only valid on parameters", token.string->c_str(), "");
break;
default:
break;
}

View File

@@ -402,7 +402,7 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char*
case EOpLeftShiftAssign:
case EOpRightShiftAssign:
isModifyOp = true;
// fall through...
[[fallthrough]];
case EOpAssign:
{
// Since this is an lvalue, we'll convert an image load to a sequence like this
@@ -4507,13 +4507,13 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
int cmpValues = 0; // 1 if there is a compare value (handier than a bool below)
switch (op) {
case EOpMethodGatherCmpRed: cmpValues = 1; // fall through
case EOpMethodGatherCmpRed: cmpValues = 1; [[fallthrough]];
case EOpMethodGatherRed: channel = 0; break;
case EOpMethodGatherCmpGreen: cmpValues = 1; // fall through
case EOpMethodGatherCmpGreen: cmpValues = 1; [[fallthrough]];
case EOpMethodGatherGreen: channel = 1; break;
case EOpMethodGatherCmpBlue: cmpValues = 1; // fall through
case EOpMethodGatherCmpBlue: cmpValues = 1; [[fallthrough]];
case EOpMethodGatherBlue: channel = 2; break;
case EOpMethodGatherCmpAlpha: cmpValues = 1; // fall through
case EOpMethodGatherCmpAlpha: cmpValues = 1; [[fallthrough]];
case EOpMethodGatherAlpha: channel = 3; break;
default: assert(0); break;
}

View File

@@ -161,6 +161,11 @@ template<class T> inline T* NewPoolObject(T, int instances)
return new(GetThreadPoolAllocator().allocate(instances * sizeof(T))) T[instances];
}
inline bool StartsWith(TString const &str, const char *prefix)
{
return str.compare(0, strlen(prefix), prefix) == 0;
}
//
// Pool allocator versions of vectors, lists, and maps
//

View File

@@ -1091,6 +1091,10 @@ enum TOperator {
EOpWaveActiveCountBits, // Will decompose to subgroupBallotBitCount(subgroupBallot()).
EOpWavePrefixCountBits, // Will decompose to subgroupBallotInclusiveBitCount(subgroupBallot()).
// GL_EXT_expect_assume
EOpAssumeEXT,
EOpExpectEXT,
// Shader Clock Ops
EOpReadClockSubgroupKHR,
EOpReadClockDeviceKHR,

View File

@@ -1465,6 +1465,20 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
// NV_shader_atomic_fp16_vector
if (profile != EEsProfile && version >= 430) {
commonBuiltins.append(
"f16vec2 atomicAdd(coherent volatile inout f16vec2, f16vec2);"
"f16vec4 atomicAdd(coherent volatile inout f16vec4, f16vec4);"
"f16vec2 atomicMin(coherent volatile inout f16vec2, f16vec2);"
"f16vec4 atomicMin(coherent volatile inout f16vec4, f16vec4);"
"f16vec2 atomicMax(coherent volatile inout f16vec2, f16vec2);"
"f16vec4 atomicMax(coherent volatile inout f16vec4, f16vec4);"
"f16vec2 atomicExchange(coherent volatile inout f16vec2, f16vec2);"
"f16vec4 atomicExchange(coherent volatile inout f16vec4, f16vec4);"
"\n");
}
if ((profile == EEsProfile && version >= 300) ||
(profile != EEsProfile && version >= 150)) { // GL_ARB_shader_bit_encoding
commonBuiltins.append(
@@ -4118,6 +4132,37 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"u16vec4 unpack16(uint64_t);"
"i32vec2 unpack32(int64_t);"
"u32vec2 unpack32(uint64_t);"
// GL_EXT_expect_assume
"int8_t expectEXT(int8_t, int8_t);"
"i8vec2 expectEXT(i8vec2, i8vec2);"
"i8vec3 expectEXT(i8vec3, i8vec3);"
"i8vec4 expectEXT(i8vec4, i8vec4);"
"uint8_t expectEXT(uint8_t, uint8_t);"
"u8vec2 expectEXT(u8vec2, u8vec2);"
"u8vec3 expectEXT(u8vec3, u8vec3);"
"u8vec4 expectEXT(u8vec4, u8vec4);"
"int16_t expectEXT(int16_t, int16_t);"
"i16vec2 expectEXT(i16vec2, i16vec2);"
"i16vec3 expectEXT(i16vec3, i16vec3);"
"i16vec4 expectEXT(i16vec4, i16vec4);"
"uint16_t expectEXT(uint16_t, uint16_t);"
"u16vec2 expectEXT(u16vec2, u16vec2);"
"u16vec3 expectEXT(u16vec3, u16vec3);"
"u16vec4 expectEXT(u16vec4, u16vec4);"
"int64_t expectEXT(int64_t, int64_t);"
"i64vec2 expectEXT(i64vec2, i64vec2);"
"i64vec3 expectEXT(i64vec3, i64vec3);"
"i64vec4 expectEXT(i64vec4, i64vec4);"
"uint64_t expectEXT(uint64_t, uint64_t);"
"u64vec2 expectEXT(u64vec2, u64vec2);"
"u64vec3 expectEXT(u64vec3, u64vec3);"
"u64vec4 expectEXT(u64vec4, u64vec4);"
"\n");
}
@@ -4156,6 +4201,29 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
}
// GL_EXT_expect_assume
if ((profile == EEsProfile && version >= 310) ||
((profile != EEsProfile && version >= 140))) {
commonBuiltins.append(
"void assumeEXT(bool);"
"bool expectEXT(bool, bool);"
"bvec2 expectEXT(bvec2, bvec2);"
"bvec3 expectEXT(bvec3, bvec3);"
"bvec4 expectEXT(bvec4, bvec4);"
"int expectEXT(int, int);"
"ivec2 expectEXT(ivec2, ivec2);"
"ivec3 expectEXT(ivec3, ivec3);"
"ivec4 expectEXT(ivec4, ivec4);"
"uint expectEXT(uint, uint);"
"uvec2 expectEXT(uvec2, uvec2);"
"uvec3 expectEXT(uvec3, uvec3);"
"uvec4 expectEXT(uvec4, uvec4);"
"\n");
}
// QCOM_image_processing
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 140)) {
@@ -6624,6 +6692,34 @@ void TBuiltIns::addImageFunctions(TSampler sampler, const TString& typeName, int
commonBuiltins.append(imageParams);
commonBuiltins.append(", float);\n");
}
// GL_NV_shader_atomic_fp16_vector
if (profile != EEsProfile && version >= 430) {
const int numFp16Builtins = 4;
const char* atomicFp16Func[numFp16Builtins] = {
" imageAtomicAdd(volatile coherent ",
" imageAtomicMin(volatile coherent ",
" imageAtomicMax(volatile coherent ",
" imageAtomicExchange(volatile coherent "
};
const int numFp16DataTypes = 2;
const char* atomicFp16DataTypes[numFp16DataTypes] = {
"f16vec2",
"f16vec4"
};
// Loop twice to add prototypes with/without scope/semantics
for (int j = 0; j < numFp16DataTypes; ++j) {
for (int i = 0; i < numFp16Builtins; ++i) {
commonBuiltins.append(atomicFp16DataTypes[j]);
commonBuiltins.append(atomicFp16Func[i]);
commonBuiltins.append(imageParams);
commonBuiltins.append(", ");
commonBuiltins.append(atomicFp16DataTypes[j]);
commonBuiltins.append(");\n");
}
}
}
if (profile != EEsProfile && version >= 450) {
commonBuiltins.append("float imageAtomicAdd(volatile coherent ");
commonBuiltins.append(imageParams);
@@ -8030,7 +8126,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setFunctionExtensions("texture2DArrayLod", 1, &E_GL_EXT_texture_array);
symbolTable.setFunctionExtensions("shadow1DArrayLod", 1, &E_GL_EXT_texture_array);
}
// Fall through
[[fallthrough]];
case EShLangTessControl:
if (profile == EEsProfile && version >= 310) {
@@ -8045,7 +8141,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
BuiltInVariable("gl_BoundingBox", EbvBoundingBox, symbolTable);
}
}
// Fall through
[[fallthrough]];
case EShLangTessEvaluation:
case EShLangGeometry:
@@ -8631,6 +8727,13 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
}
// GL_EXT_expect_assume
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 140)) {
symbolTable.setFunctionExtensions("assumeEXT", 1, &E_GL_EXT_expect_assume);
symbolTable.setFunctionExtensions("expectEXT", 1, &E_GL_EXT_expect_assume);
}
// GL_KHR_shader_subgroup
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 140)) {
@@ -9732,6 +9835,8 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.relateToOperator("averageRounded", EOpAverageRounded);
symbolTable.relateToOperator("multiply32x16", EOpMul32x16);
symbolTable.relateToOperator("debugPrintfEXT", EOpDebugPrintf);
symbolTable.relateToOperator("assumeEXT", EOpAssumeEXT);
symbolTable.relateToOperator("expectEXT", EOpExpectEXT);
if (PureOperatorBuiltins) {
@@ -10126,7 +10231,8 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
if (profile != EEsProfile && version >= 460) {
symbolTable.relateToOperator("fetchMicroTriangleVertexPositionNV", EOpFetchMicroTriangleVertexPositionNV);
symbolTable.relateToOperator("fetchMicroTriangleVertexBarycentricNV", EOpFetchMicroTriangleVertexBarycentricNV);
} // fallthrough
}
[[fallthrough]];
case EShLangClosestHit:
case EShLangMiss:
if (profile != EEsProfile && version >= 460) {

View File

@@ -376,6 +376,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child,
case EOpNegative:
if (child->getType().getBasicType() == EbtStruct || child->getType().isArray())
return nullptr;
break;
default: break; // some compilers want this
}
@@ -1277,6 +1278,7 @@ void TIntermediate::addBiShapeConversion(TOperator op, TIntermTyped*& lhsNode, T
// matrix multiply does not change shapes
if (lhsNode->isMatrix() && rhsNode->isMatrix())
return;
[[fallthrough]];
case EOpAdd:
case EOpSub:
case EOpDiv:
@@ -3489,6 +3491,7 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
// check for non-Boolean operands
if (left->getBasicType() == EbtBool || right->getBasicType() == EbtBool)
return false;
break;
default:
break;
@@ -3532,13 +3535,14 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
if (left->getType() == right->getType())
return true;
// Fall through
[[fallthrough]];
case EOpMul:
case EOpMulAssign:
// At least the basic type has to match
if (left->getBasicType() != right->getBasicType())
return false;
break;
default:
break;
@@ -3681,7 +3685,7 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
case EOpAssign:
if (left->getVectorSize() != right->getVectorSize() || left->getMatrixCols() != right->getMatrixCols() || left->getMatrixRows() != right->getMatrixRows())
return false;
// fall through
[[fallthrough]];
case EOpAdd:
case EOpSub:

View File

@@ -257,6 +257,7 @@ void TParseContextBase::rValueErrorCheck(const TSourceLoc& loc, const char* op,
case EOpVectorSwizzle:
case EOpMatrixSwizzle:
rValueErrorCheck(loc, op, binaryNode->getLeft());
break;
default:
break;
}

View File

@@ -2524,15 +2524,26 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
error(loc, "only supported on image with format r64i", fnCandidate.getName().c_str(), "");
else if (callNode.getType().getBasicType() == EbtUint64 && imageType.getQualifier().getFormat() != ElfR64ui)
error(loc, "only supported on image with format r64ui", fnCandidate.getName().c_str(), "");
} else if(callNode.getType().getBasicType() == EbtFloat16 &&
((callNode.getType().getVectorSize() == 2 && arg0->getType().getQualifier().getFormat() == ElfRg16f) ||
(callNode.getType().getVectorSize() == 4 && arg0->getType().getQualifier().getFormat() == ElfRgba16f))) {
if (StartsWith(fnCandidate.getName(), "imageAtomicAdd") ||
StartsWith(fnCandidate.getName(), "imageAtomicExchange") ||
StartsWith(fnCandidate.getName(), "imageAtomicMin") ||
StartsWith(fnCandidate.getName(), "imageAtomicMax")) {
requireExtensions(loc, 1, &E_GL_NV_shader_atomic_fp16_vector, fnCandidate.getName().c_str());
} else {
error(loc, "f16vec2/4 operation not supported on: ", fnCandidate.getName().c_str(), "");
}
} else if (imageType.getSampler().type == EbtFloat) {
if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") == 0) {
if (StartsWith(fnCandidate.getName(), "imageAtomicExchange")) {
// imageAtomicExchange doesn't require an extension
} else if ((fnCandidate.getName().compare(0, 14, "imageAtomicAdd") == 0) ||
(fnCandidate.getName().compare(0, 15, "imageAtomicLoad") == 0) ||
(fnCandidate.getName().compare(0, 16, "imageAtomicStore") == 0)) {
} else if (StartsWith(fnCandidate.getName(), "imageAtomicAdd") ||
StartsWith(fnCandidate.getName(), "imageAtomicLoad") ||
StartsWith(fnCandidate.getName(), "imageAtomicStore")) {
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float, fnCandidate.getName().c_str());
} else if ((fnCandidate.getName().compare(0, 14, "imageAtomicMin") == 0) ||
(fnCandidate.getName().compare(0, 14, "imageAtomicMax") == 0)) {
} else if (StartsWith(fnCandidate.getName(), "imageAtomicMin") ||
StartsWith(fnCandidate.getName(), "imageAtomicMax")) {
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float2, fnCandidate.getName().c_str());
} else {
error(loc, "only supported on integer images", fnCandidate.getName().c_str(), "");
@@ -2582,6 +2593,11 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
const char* const extensions[2] = { E_GL_NV_shader_atomic_int64,
E_GL_EXT_shader_atomic_int64 };
requireExtensions(loc, 2, extensions, fnCandidate.getName().c_str());
} else if ((callNode.getOp() == EOpAtomicAdd || callNode.getOp() == EOpAtomicExchange ||
callNode.getOp() == EOpAtomicMin || callNode.getOp() == EOpAtomicMax) &&
arg0->getType().getBasicType() == EbtFloat16 &&
(arg0->getType().getVectorSize() == 2 || arg0->getType().getVectorSize() == 4 )) {
requireExtensions(loc, 1, &E_GL_NV_shader_atomic_fp16_vector, fnCandidate.getName().c_str());
} else if ((callNode.getOp() == EOpAtomicAdd || callNode.getOp() == EOpAtomicExchange) &&
(arg0->getType().getBasicType() == EbtFloat ||
arg0->getType().getBasicType() == EbtDouble)) {
@@ -6244,7 +6260,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
error(loc, "needs a literal integer", "max_primitives", "");
return;
}
// Fall through
[[fallthrough]];
case EShLangTask:
// Fall through
@@ -7320,7 +7336,7 @@ TIntermTyped* TParseContext::vkRelaxedRemapFunctionCall(const TSourceLoc& loc, T
realFunc.addParameter(TParameter().copyParam((*function)[i]));
}
TParameter tmpP = { nullptr, &uintType };
TParameter tmpP = { nullptr, &uintType, {} };
realFunc.addParameter(TParameter().copyParam(tmpP));
arguments = intermediate.growAggregate(arguments, intermediate.addConstantUnion(1, loc, true));
@@ -7337,7 +7353,7 @@ TIntermTyped* TParseContext::vkRelaxedRemapFunctionCall(const TSourceLoc& loc, T
realFunc.addParameter(TParameter().copyParam((*function)[i]));
}
TParameter tmpP = { nullptr, &uintType };
TParameter tmpP = { nullptr, &uintType, {} };
realFunc.addParameter(TParameter().copyParam(tmpP));
arguments = intermediate.growAggregate(arguments, intermediate.addConstantUnion(-1, loc, true));
@@ -7660,7 +7676,7 @@ TIntermNode* TParseContext::vkRelaxedRemapFunctionArgument(const TSourceLoc& loc
AccessChainTraverser accessChainTraverser{};
intermTyped->traverse(&accessChainTraverser);
TParameter param = { NewPoolTString(accessChainTraverser.path.c_str()), new TType };
TParameter param = { NewPoolTString(accessChainTraverser.path.c_str()), new TType, {} };
param.type->shallowCopy(intermTyped->getType());
std::vector<int> newParams = {};
@@ -8418,6 +8434,7 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
intermediate.addBuiltInFunctionCall(node->getLoc(), EOpConstructUVec2, false, newSrcNode, type);
return newNode;
}
[[fallthrough]];
case EOpConstructUVec3:
case EOpConstructUVec4:
case EOpConstructUint:
@@ -8439,6 +8456,7 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
intermediate.addBuiltInFunctionCall(node->getLoc(), EOpPackUint2x32, true, node, type);
return newNode;
}
[[fallthrough]];
case EOpConstructDVec2:
case EOpConstructDVec3:
case EOpConstructDVec4:
@@ -8591,7 +8609,7 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
TIntermTyped* newNode = intermediate.addBuiltInFunctionCall(node->getLoc(), EOpConvPtrToUint64, true, node, type);
return newNode;
}
// fall through
[[fallthrough]];
case EOpConstructU64Vec2:
case EOpConstructU64Vec3:
case EOpConstructU64Vec4:
@@ -9656,7 +9674,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
error(loc, "cannot apply to 'out'", TQualifier::getGeometryString(publicType.shaderQualifiers.geometry), "");
break;
}
// Fall through
[[fallthrough]];
case ElgPoints:
case ElgLineStrip:
case ElgTriangleStrip:

View File

@@ -633,6 +633,7 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
infoSink.info.message(EPrefixError, "#version: mesh/task shaders require es profile with version 320 or above, or non-es profile with version 450 or above");
version = profile == EEsProfile ? 320 : 450;
}
break;
default:
break;
}

View File

@@ -149,6 +149,7 @@ void TType::buildMangledName(TString& mangledName) const
mangledName += '-';
(*structure)[i].type->buildMangledName(mangledName);
}
break;
default:
break;
}

View File

@@ -262,6 +262,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_maximal_reconvergence] = EBhDisable;
extensionBehavior[E_GL_EXT_fragment_shader_barycentric] = EBhDisable;
extensionBehavior[E_GL_EXT_expect_assume] = EBhDisable;
extensionBehavior[E_GL_KHR_cooperative_matrix] = EBhDisable;
@@ -304,6 +305,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_NV_integer_cooperative_matrix] = EBhDisable;
extensionBehavior[E_GL_NV_shader_invocation_reorder] = EBhDisable;
extensionBehavior[E_GL_NV_displacement_micromap] = EBhDisable;
extensionBehavior[E_GL_NV_shader_atomic_fp16_vector] = EBhDisable;
// ARM
extensionBehavior[E_GL_ARM_shader_core_builtins] = EBhDisable;
@@ -764,7 +766,7 @@ void TParseVersions::profileRequires(const TSourceLoc& loc, int profileMask, int
switch (getExtensionBehavior(extensions[i])) {
case EBhWarn:
infoSink.info.message(EPrefixWarning, ("extension " + TString(extensions[i]) + " is being used for " + featureDesc).c_str(), loc);
// fall through
[[fallthrough]];
case EBhRequire:
case EBhEnable:
okay = true;

View File

@@ -220,6 +220,7 @@ const char* const E_GL_EXT_shader_quad_control = "GL_EXT_shader_qua
const char* const E_GL_EXT_draw_instanced = "GL_EXT_draw_instanced";
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";
// Arrays of extensions for the above viewportEXTs duplications
@@ -277,6 +278,7 @@ const char* const E_GL_NV_integer_cooperative_matrix = "GL_NV_integer
const char* const E_GL_NV_shader_invocation_reorder = "GL_NV_shader_invocation_reorder";
const char* const E_GL_EXT_ray_tracing_position_fetch = "GL_EXT_ray_tracing_position_fetch";
const char* const E_GL_NV_displacement_micromap = "GL_NV_displacement_micromap";
const char* const E_GL_NV_shader_atomic_fp16_vector = "GL_NV_shader_atomic_fp16_vector";
// ARM
const char* const E_GL_ARM_shader_core_builtins = "GL_ARM_shader_core_builtins";

View File

@@ -494,7 +494,7 @@ function_call_header_with_parameters
}
else
{
TParameter param = { 0, new TType };
TParameter param = { 0, new TType, {} };
param.type->shallowCopy($2->getType());
$1.function->addParameter(param);
@@ -513,7 +513,7 @@ function_call_header_with_parameters
}
else
{
TParameter param = { 0, new TType };
TParameter param = { 0, new TType, {} };
param.type->shallowCopy($3->getType());
$1.function->addParameter(param);
@@ -1068,7 +1068,7 @@ parameter_declarator
}
parseContext.reservedErrorCheck($2.loc, *$2.string);
TParameter param = {$2.string, new TType($1)};
TParameter param = {$2.string, new TType($1), {}};
$$.loc = $2.loc;
$$.param = param;
}
@@ -1086,7 +1086,7 @@ parameter_declarator
parseContext.arraySizeRequiredCheck($3.loc, *$3.arraySizes);
parseContext.reservedErrorCheck($2.loc, *$2.string);
TParameter param = { $2.string, type };
TParameter param = { $2.string, type, {} };
$$.loc = $2.loc;
$$.param = param;
@@ -1139,7 +1139,7 @@ parameter_declaration
parameter_type_specifier
: type_specifier {
TParameter param = { 0, new TType($1) };
TParameter param = { 0, new TType($1), {} };
$$.param = param;
if ($1.arraySizes)
parseContext.arraySizeRequiredCheck($1.loc, *$1.arraySizes);

View File

@@ -5467,7 +5467,7 @@ yyreduce:
}
else
{
TParameter param = { 0, new TType };
TParameter param = { 0, new TType, {} };
param.type->shallowCopy((yyvsp[0].interm.intermTypedNode)->getType());
(yyvsp[-1].interm).function->addParameter(param);
@@ -5491,7 +5491,7 @@ yyreduce:
}
else
{
TParameter param = { 0, new TType };
TParameter param = { 0, new TType, {} };
param.type->shallowCopy((yyvsp[0].interm.intermTypedNode)->getType());
(yyvsp[-2].interm).function->addParameter(param);
@@ -6388,7 +6388,7 @@ yyreduce:
}
parseContext.reservedErrorCheck((yyvsp[0].lex).loc, *(yyvsp[0].lex).string);
TParameter param = {(yyvsp[0].lex).string, new TType((yyvsp[-1].interm.type))};
TParameter param = {(yyvsp[0].lex).string, new TType((yyvsp[-1].interm.type)), {}};
(yyval.interm).loc = (yyvsp[0].lex).loc;
(yyval.interm).param = param;
}
@@ -6411,7 +6411,7 @@ yyreduce:
parseContext.arraySizeRequiredCheck((yyvsp[0].interm).loc, *(yyvsp[0].interm).arraySizes);
parseContext.reservedErrorCheck((yyvsp[-1].lex).loc, *(yyvsp[-1].lex).string);
TParameter param = { (yyvsp[-1].lex).string, type };
TParameter param = { (yyvsp[-1].lex).string, type, {} };
(yyval.interm).loc = (yyvsp[-1].lex).loc;
(yyval.interm).param = param;
@@ -6477,7 +6477,7 @@ yyreduce:
case 124: /* parameter_type_specifier: type_specifier */
#line 1141 "MachineIndependent/glslang.y"
{
TParameter param = { 0, new TType((yyvsp[0].interm.type)) };
TParameter param = { 0, new TType((yyvsp[0].interm.type)), {} };
(yyval.interm).param = param;
if ((yyvsp[0].interm.type).arraySizes)
parseContext.arraySizeRequiredCheck((yyvsp[0].interm.type).loc, *(yyvsp[0].interm.type).arraySizes);

View File

@@ -1587,7 +1587,7 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
infoSink.debug << "max_vertices = " << vertices << "\n";
infoSink.debug << "max_primitives = " << primitives << "\n";
infoSink.debug << "output primitive = " << TQualifier::getGeometryString(outputPrimitive) << "\n";
// Fall through
[[fallthrough]];
case EShLangTask:
// Fall through
case EShLangCompute:

View File

@@ -85,7 +85,7 @@ public:
addGlobalReference(base->getAccessName());
if (target) {
TVarEntryInfo ent = {base->getId(), base, ! traverseAll};
TVarEntryInfo ent = {base->getId(), base, ! traverseAll, {}, {}, {}, {}, {}, {}, {}};
ent.stage = intermediate.getStage();
TVarLiveMap::iterator at = target->find(
ent.symbol->getAccessName()); // std::lower_bound(target->begin(), target->end(), ent, TVarEntryInfo::TOrderById());
@@ -124,7 +124,7 @@ public:
else
return;
TVarEntryInfo ent = { base->getId() };
TVarEntryInfo ent = { base->getId(), {}, {}, {}, {}, {}, {}, {}, {}, {} };
// Fix a defect, when block has no instance name, we need to find its block name
TVarLiveMap::const_iterator at = source->find(base->getAccessName());
if (at == source->end())

View File

@@ -1350,7 +1350,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
error(infoSink, "At least one shader must specify a layout(max_vertices = value)");
if (primitives == TQualifier::layoutNotSet)
error(infoSink, "At least one shader must specify a layout(max_primitives = value)");
// fall through
[[fallthrough]];
case EShLangTask:
if (numTaskNVBlocks > 1)
error(infoSink, "Only one taskNV interface block is allowed per shader");

View File

@@ -704,69 +704,73 @@ public:
case EbtFloat:
switch ((int)sampler.dim) {
case Esd1D:
switch ((int)sampler.shadow) {
case false: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY : GL_SAMPLER_1D;
case true: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY_SHADOW : GL_SAMPLER_1D_SHADOW;
}
if (sampler.shadow)
return sampler.arrayed ? GL_SAMPLER_1D_ARRAY_SHADOW : GL_SAMPLER_1D_SHADOW;
else
return sampler.arrayed ? GL_SAMPLER_1D_ARRAY : GL_SAMPLER_1D;
case Esd2D:
switch ((int)sampler.ms) {
case false:
switch ((int)sampler.shadow) {
case false: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY : GL_SAMPLER_2D;
case true: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY_SHADOW : GL_SAMPLER_2D_SHADOW;
}
case true: return sampler.arrayed ? GL_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_SAMPLER_2D_MULTISAMPLE;
if (sampler.ms) {
return sampler.arrayed ? GL_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_SAMPLER_2D_MULTISAMPLE;
} else {
if (sampler.shadow)
return sampler.arrayed ? GL_SAMPLER_2D_ARRAY_SHADOW : GL_SAMPLER_2D_SHADOW;
else
return sampler.arrayed ? GL_SAMPLER_2D_ARRAY : GL_SAMPLER_2D;
}
case Esd3D:
return GL_SAMPLER_3D;
case EsdCube:
switch ((int)sampler.shadow) {
case false: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY : GL_SAMPLER_CUBE;
case true: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW : GL_SAMPLER_CUBE_SHADOW;
}
if (sampler.shadow)
return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW : GL_SAMPLER_CUBE_SHADOW;
else
return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY : GL_SAMPLER_CUBE;
case EsdRect:
return sampler.shadow ? GL_SAMPLER_2D_RECT_SHADOW : GL_SAMPLER_2D_RECT;
case EsdBuffer:
return GL_SAMPLER_BUFFER;
default:
return 0;
}
case EbtFloat16:
switch ((int)sampler.dim) {
case Esd1D:
switch ((int)sampler.shadow) {
case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_AMD : GL_FLOAT16_SAMPLER_1D_AMD;
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_1D_SHADOW_AMD;
}
if (sampler.shadow)
return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_1D_SHADOW_AMD;
else
return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_AMD : GL_FLOAT16_SAMPLER_1D_AMD;
case Esd2D:
switch ((int)sampler.ms) {
case false:
switch ((int)sampler.shadow) {
case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_AMD;
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_SHADOW_AMD;
}
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_AMD;
if (sampler.ms) {
return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_AMD;
} else {
if (sampler.shadow)
return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_SHADOW_AMD;
else
return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_AMD;
}
case Esd3D:
return GL_FLOAT16_SAMPLER_3D_AMD;
case EsdCube:
switch ((int)sampler.shadow) {
case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_AMD : GL_FLOAT16_SAMPLER_CUBE_AMD;
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_CUBE_SHADOW_AMD;
}
if (sampler.shadow)
return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_CUBE_SHADOW_AMD;
else
return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_AMD : GL_FLOAT16_SAMPLER_CUBE_AMD;
case EsdRect:
return sampler.shadow ? GL_FLOAT16_SAMPLER_2D_RECT_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_RECT_AMD;
case EsdBuffer:
return GL_FLOAT16_SAMPLER_BUFFER_AMD;
default:
return 0;
}
case EbtInt:
switch ((int)sampler.dim) {
case Esd1D:
return sampler.arrayed ? GL_INT_SAMPLER_1D_ARRAY : GL_INT_SAMPLER_1D;
case Esd2D:
switch ((int)sampler.ms) {
case false: return sampler.arrayed ? GL_INT_SAMPLER_2D_ARRAY : GL_INT_SAMPLER_2D;
case true: return sampler.arrayed ? GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
: GL_INT_SAMPLER_2D_MULTISAMPLE;
}
if (sampler.ms)
return sampler.arrayed ? GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
: GL_INT_SAMPLER_2D_MULTISAMPLE;
else
return sampler.arrayed ? GL_INT_SAMPLER_2D_ARRAY : GL_INT_SAMPLER_2D;
case Esd3D:
return GL_INT_SAMPLER_3D;
case EsdCube:
@@ -775,17 +779,19 @@ public:
return GL_INT_SAMPLER_2D_RECT;
case EsdBuffer:
return GL_INT_SAMPLER_BUFFER;
default:
return 0;
}
case EbtUint:
switch ((int)sampler.dim) {
case Esd1D:
return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_1D_ARRAY : GL_UNSIGNED_INT_SAMPLER_1D;
case Esd2D:
switch ((int)sampler.ms) {
case false: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D;
case true: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
: GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE;
}
if (sampler.ms)
return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
: GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE;
else
return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D;
case Esd3D:
return GL_UNSIGNED_INT_SAMPLER_3D;
case EsdCube:
@@ -794,6 +800,8 @@ public:
return GL_UNSIGNED_INT_SAMPLER_2D_RECT;
case EsdBuffer:
return GL_UNSIGNED_INT_SAMPLER_BUFFER;
default:
return 0;
}
default:
return 0;
@@ -806,10 +814,10 @@ public:
case Esd1D:
return sampler.arrayed ? GL_IMAGE_1D_ARRAY : GL_IMAGE_1D;
case Esd2D:
switch ((int)sampler.ms) {
case false: return sampler.arrayed ? GL_IMAGE_2D_ARRAY : GL_IMAGE_2D;
case true: return sampler.arrayed ? GL_IMAGE_2D_MULTISAMPLE_ARRAY : GL_IMAGE_2D_MULTISAMPLE;
}
if (sampler.ms)
return sampler.arrayed ? GL_IMAGE_2D_MULTISAMPLE_ARRAY : GL_IMAGE_2D_MULTISAMPLE;
else
return sampler.arrayed ? GL_IMAGE_2D_ARRAY : GL_IMAGE_2D;
case Esd3D:
return GL_IMAGE_3D;
case EsdCube:
@@ -818,16 +826,18 @@ public:
return GL_IMAGE_2D_RECT;
case EsdBuffer:
return GL_IMAGE_BUFFER;
default:
return 0;
}
case EbtFloat16:
switch ((int)sampler.dim) {
case Esd1D:
return sampler.arrayed ? GL_FLOAT16_IMAGE_1D_ARRAY_AMD : GL_FLOAT16_IMAGE_1D_AMD;
case Esd2D:
switch ((int)sampler.ms) {
case false: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_AMD;
case true: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_MULTISAMPLE_AMD;
}
if (sampler.ms)
return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_MULTISAMPLE_AMD;
else
return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_AMD;
case Esd3D:
return GL_FLOAT16_IMAGE_3D_AMD;
case EsdCube:
@@ -836,16 +846,18 @@ public:
return GL_FLOAT16_IMAGE_2D_RECT_AMD;
case EsdBuffer:
return GL_FLOAT16_IMAGE_BUFFER_AMD;
default:
return 0;
}
case EbtInt:
switch ((int)sampler.dim) {
case Esd1D:
return sampler.arrayed ? GL_INT_IMAGE_1D_ARRAY : GL_INT_IMAGE_1D;
case Esd2D:
switch ((int)sampler.ms) {
case false: return sampler.arrayed ? GL_INT_IMAGE_2D_ARRAY : GL_INT_IMAGE_2D;
case true: return sampler.arrayed ? GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_INT_IMAGE_2D_MULTISAMPLE;
}
if (sampler.ms)
return sampler.arrayed ? GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_INT_IMAGE_2D_MULTISAMPLE;
else
return sampler.arrayed ? GL_INT_IMAGE_2D_ARRAY : GL_INT_IMAGE_2D;
case Esd3D:
return GL_INT_IMAGE_3D;
case EsdCube:
@@ -854,17 +866,19 @@ public:
return GL_INT_IMAGE_2D_RECT;
case EsdBuffer:
return GL_INT_IMAGE_BUFFER;
default:
return 0;
}
case EbtUint:
switch ((int)sampler.dim) {
case Esd1D:
return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_1D_ARRAY : GL_UNSIGNED_INT_IMAGE_1D;
case Esd2D:
switch ((int)sampler.ms) {
case false: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_ARRAY : GL_UNSIGNED_INT_IMAGE_2D;
case true: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY
: GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE;
}
if (sampler.ms)
return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY
: GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE;
else
return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_ARRAY : GL_UNSIGNED_INT_IMAGE_2D;
case Esd3D:
return GL_UNSIGNED_INT_IMAGE_3D;
case EsdCube:
@@ -873,6 +887,8 @@ public:
return GL_UNSIGNED_INT_IMAGE_2D_RECT;
case EsdBuffer:
return GL_UNSIGNED_INT_IMAGE_BUFFER;
default:
return 0;
}
default:
return 0;
@@ -937,6 +953,7 @@ public:
case 4: return GL_FLOAT_MAT4;
default: return 0;
}
default: return 0;
}
case EbtDouble:
switch (type.getMatrixCols()) {
@@ -961,6 +978,7 @@ public:
case 4: return GL_DOUBLE_MAT4;
default: return 0;
}
default: return 0;
}
case EbtFloat16:
switch (type.getMatrixCols()) {
@@ -985,6 +1003,7 @@ public:
case 4: return GL_FLOAT16_MAT4_AMD;
default: return 0;
}
default: return 0;
}
default:
return 0;