|
|
@@ -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:
|