commit
e4d253fdfa
30 changed files with 9763 additions and 9456 deletions
|
|
@ -61,5 +61,6 @@ static const char* const E_SPV_KHR_cooperative_matrix = "SPV_KHR_coope
|
|||
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";
|
||||
static const char* const E_SPV_EXT_replicated_composites = "SPV_EXT_replicated_composites";
|
||||
|
||||
#endif // #ifndef GLSLextKHR_H
|
||||
|
|
|
|||
|
|
@ -1583,6 +1583,8 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
|
|||
builder.addInclude(iItr->first, iItr->second);
|
||||
}
|
||||
|
||||
builder.setUseReplicatedComposites(glslangIntermediate->usingReplicatedComposites());
|
||||
|
||||
stdBuiltins = builder.import("GLSL.std.450");
|
||||
|
||||
spv::AddressingModel addressingModel = spv::AddressingModelLogical;
|
||||
|
|
@ -5787,8 +5789,16 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate&
|
|||
lvalueCoherentFlags = builder.getAccessChain().coherentFlags;
|
||||
builder.addDecoration(lvalue_id, TranslateNonUniformDecoration(lvalueCoherentFlags));
|
||||
lvalueCoherentFlags |= TranslateCoherent(glslangArguments[i]->getAsTyped()->getType());
|
||||
} else
|
||||
arguments.push_back(accessChainLoad(glslangArguments[i]->getAsTyped()->getType()));
|
||||
} else {
|
||||
if (i > 0 &&
|
||||
glslangArguments[i]->getAsSymbolNode() && glslangArguments[i-1]->getAsSymbolNode() &&
|
||||
glslangArguments[i]->getAsSymbolNode()->getId() == glslangArguments[i-1]->getAsSymbolNode()->getId()) {
|
||||
// Reuse the id if possible
|
||||
arguments.push_back(arguments[i-1]);
|
||||
} else {
|
||||
arguments.push_back(accessChainLoad(glslangArguments[i]->getAsTyped()->getType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1484,12 +1484,14 @@ bool Builder::isConstantOpCode(Op opcode) const
|
|||
case OpConstantFalse:
|
||||
case OpConstant:
|
||||
case OpConstantComposite:
|
||||
case OpConstantCompositeReplicateEXT:
|
||||
case OpConstantSampler:
|
||||
case OpConstantNull:
|
||||
case OpSpecConstantTrue:
|
||||
case OpSpecConstantFalse:
|
||||
case OpSpecConstant:
|
||||
case OpSpecConstantComposite:
|
||||
case OpSpecConstantCompositeReplicateEXT:
|
||||
case OpSpecConstantOp:
|
||||
return true;
|
||||
default:
|
||||
|
|
@ -1506,6 +1508,7 @@ bool Builder::isSpecConstantOpCode(Op opcode) const
|
|||
case OpSpecConstant:
|
||||
case OpSpecConstantComposite:
|
||||
case OpSpecConstantOp:
|
||||
case OpSpecConstantCompositeReplicateEXT:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
@ -1782,10 +1785,27 @@ Id Builder::findStructConstant(Id typeId, const std::vector<Id>& comps)
|
|||
// Comments in header
|
||||
Id Builder::makeCompositeConstant(Id typeId, const std::vector<Id>& members, bool specConstant)
|
||||
{
|
||||
Op opcode = specConstant ? OpSpecConstantComposite : OpConstantComposite;
|
||||
assert(typeId);
|
||||
Op typeClass = getTypeClass(typeId);
|
||||
|
||||
bool replicate = false;
|
||||
size_t numMembers = members.size();
|
||||
if (useReplicatedComposites) {
|
||||
// use replicate if all members are the same
|
||||
replicate = numMembers > 0 &&
|
||||
std::equal(members.begin() + 1, members.end(), members.begin());
|
||||
|
||||
if (replicate) {
|
||||
numMembers = 1;
|
||||
addCapability(spv::CapabilityReplicatedCompositesEXT);
|
||||
addExtension(spv::E_SPV_EXT_replicated_composites);
|
||||
}
|
||||
}
|
||||
|
||||
Op opcode = replicate ?
|
||||
(specConstant ? OpSpecConstantCompositeReplicateEXT : OpConstantCompositeReplicateEXT) :
|
||||
(specConstant ? OpSpecConstantComposite : OpConstantComposite);
|
||||
|
||||
switch (typeClass) {
|
||||
case OpTypeVector:
|
||||
case OpTypeArray:
|
||||
|
|
@ -1812,7 +1832,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)
|
||||
for (size_t op = 0; op < numMembers; ++op)
|
||||
c->addIdOperand(members[op]);
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
|
||||
if (typeClass == OpTypeStruct)
|
||||
|
|
@ -2928,7 +2948,17 @@ Id Builder::smearScalar(Decoration precision, Id scalar, Id vectorType)
|
|||
auto result_id = makeCompositeConstant(vectorType, members, isSpecConstant(scalar));
|
||||
smear = module.getInstruction(result_id);
|
||||
} else {
|
||||
smear = new Instruction(getUniqueId(), vectorType, OpCompositeConstruct);
|
||||
bool replicate = useReplicatedComposites && (numComponents > 0);
|
||||
|
||||
if (replicate) {
|
||||
numComponents = 1;
|
||||
addCapability(spv::CapabilityReplicatedCompositesEXT);
|
||||
addExtension(spv::E_SPV_EXT_replicated_composites);
|
||||
}
|
||||
|
||||
Op opcode = replicate ? OpCompositeConstructReplicateEXT : OpCompositeConstruct;
|
||||
|
||||
smear = new Instruction(getUniqueId(), vectorType, opcode);
|
||||
smear->reserveOperands(numComponents);
|
||||
for (int c = 0; c < numComponents; ++c)
|
||||
smear->addIdOperand(scalar);
|
||||
|
|
@ -3321,9 +3351,25 @@ Id Builder::createCompositeConstruct(Id typeId, const std::vector<Id>& constitue
|
|||
[&](spv::Id id) { return isSpecConstant(id); }));
|
||||
}
|
||||
|
||||
Instruction* op = new Instruction(getUniqueId(), typeId, OpCompositeConstruct);
|
||||
bool replicate = false;
|
||||
size_t numConstituents = constituents.size();
|
||||
|
||||
if (useReplicatedComposites) {
|
||||
replicate = numConstituents > 0 &&
|
||||
std::equal(constituents.begin() + 1, constituents.end(), constituents.begin());
|
||||
}
|
||||
|
||||
if (replicate) {
|
||||
numConstituents = 1;
|
||||
addCapability(spv::CapabilityReplicatedCompositesEXT);
|
||||
addExtension(spv::E_SPV_EXT_replicated_composites);
|
||||
}
|
||||
|
||||
Op opcode = replicate ? OpCompositeConstructReplicateEXT : OpCompositeConstruct;
|
||||
|
||||
Instruction* op = new Instruction(getUniqueId(), typeId, opcode);
|
||||
op->reserveOperands(constituents.size());
|
||||
for (int c = 0; c < (int)constituents.size(); ++c)
|
||||
for (size_t c = 0; c < numConstituents; ++c)
|
||||
op->addIdOperand(constituents[c]);
|
||||
addInstruction(std::unique_ptr<Instruction>(op));
|
||||
|
||||
|
|
@ -3458,6 +3504,13 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
|
|||
return setPrecision(createCompositeConstruct(resultTypeId, matrixColumns), precision);
|
||||
}
|
||||
|
||||
// Detect a matrix being constructed from a repeated vector of the correct size.
|
||||
// Create the composite directly from it.
|
||||
if ((int)sources.size() == numCols && isVector(sources[0]) && getNumComponents(sources[0]) == numRows &&
|
||||
std::equal(sources.begin() + 1, sources.end(), sources.begin())) {
|
||||
return setPrecision(createCompositeConstruct(resultTypeId, sources), precision);
|
||||
}
|
||||
|
||||
// Otherwise, will use a two step process
|
||||
// 1. make a compile-time 2D array of values
|
||||
// 2. construct a matrix from that array
|
||||
|
|
|
|||
|
|
@ -872,6 +872,8 @@ public:
|
|||
// Check if the builder is generating code for spec constants.
|
||||
bool isInSpecConstCodeGenMode() { return generatingOpCodeForSpecConst; }
|
||||
|
||||
void setUseReplicatedComposites(bool use) { useReplicatedComposites = use; }
|
||||
|
||||
protected:
|
||||
Id makeIntConstant(Id typeId, unsigned value, bool specConstant);
|
||||
Id makeInt64Constant(Id typeId, unsigned long long value, bool specConstant);
|
||||
|
|
@ -938,6 +940,7 @@ public:
|
|||
Id uniqueId;
|
||||
Function* entryPointFunction;
|
||||
bool generatingOpCodeForSpecConst;
|
||||
bool useReplicatedComposites { false };
|
||||
AccessChain accessChain;
|
||||
|
||||
// special blocks of instructions for output
|
||||
|
|
|
|||
|
|
@ -1066,6 +1066,8 @@ const char* CapabilityString(int info)
|
|||
case CapabilityTextureBlockMatchQCOM: return "TextureBlockMatchQCOM";
|
||||
case CapabilityTextureBlockMatch2QCOM: return "TextureBlockMatch2QCOM";
|
||||
|
||||
case CapabilityReplicatedCompositesEXT: return "CapabilityReplicatedCompositesEXT";
|
||||
|
||||
default: return "Bad";
|
||||
}
|
||||
}
|
||||
|
|
@ -1584,6 +1586,10 @@ const char* OpcodeString(int op)
|
|||
case OpImageBlockMatchGatherSSDQCOM: return "OpImageBlockMatchGatherSSDQCOM";
|
||||
case OpImageBlockMatchGatherSADQCOM: return "OpImageBlockMatchGatherSADQCOM";
|
||||
|
||||
case OpConstantCompositeReplicateEXT: return "OpConstantCompositeReplicateEXT";
|
||||
case OpSpecConstantCompositeReplicateEXT: return "OpSpecConstantCompositeReplicateEXT";
|
||||
case OpCompositeConstructReplicateEXT: return "OpCompositeConstructReplicateEXT";
|
||||
|
||||
default:
|
||||
return "Bad";
|
||||
}
|
||||
|
|
@ -3471,6 +3477,10 @@ void Parameterize()
|
|||
InstructionDesc[OpImageBlockMatchGatherSADQCOM].operands.push(OperandId, "'block size'");
|
||||
InstructionDesc[OpImageBlockMatchGatherSADQCOM].operands.push(OperandImageOperands, "", true);
|
||||
InstructionDesc[OpImageBlockMatchGatherSADQCOM].setResultAndType(true, true);
|
||||
|
||||
InstructionDesc[OpConstantCompositeReplicateEXT].operands.push(OperandId, "'Value'");
|
||||
InstructionDesc[OpSpecConstantCompositeReplicateEXT].operands.push(OperandId, "'Value'");
|
||||
InstructionDesc[OpCompositeConstructReplicateEXT].operands.push(OperandId, "'Value'");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1162,7 +1162,8 @@ enum Capability {
|
|||
CapabilityDotProduct = 6019,
|
||||
CapabilityDotProductKHR = 6019,
|
||||
CapabilityRayCullMaskKHR = 6020,
|
||||
CapabilityCooperativeMatrixKHR = 6022,
|
||||
CapabilityCooperativeMatrixKHR = 6022,
|
||||
CapabilityReplicatedCompositesEXT = 6024,
|
||||
CapabilityBitInstructions = 6025,
|
||||
CapabilityGroupNonUniformRotateKHR = 6026,
|
||||
CapabilityAtomicFloat32AddEXT = 6033,
|
||||
|
|
@ -1688,7 +1689,10 @@ enum Op {
|
|||
OpCooperativeMatrixLoadKHR = 4457,
|
||||
OpCooperativeMatrixStoreKHR = 4458,
|
||||
OpCooperativeMatrixMulAddKHR = 4459,
|
||||
OpCooperativeMatrixLengthKHR = 4460,
|
||||
OpCooperativeMatrixLengthKHR = 4460,
|
||||
OpConstantCompositeReplicateEXT = 4461,
|
||||
OpSpecConstantCompositeReplicateEXT = 4462,
|
||||
OpCompositeConstructReplicateEXT = 4463,
|
||||
OpTypeRayQueryKHR = 4472,
|
||||
OpRayQueryInitializeKHR = 4473,
|
||||
OpRayQueryTerminateKHR = 4474,
|
||||
|
|
@ -2417,7 +2421,10 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
|
|||
case OpCooperativeMatrixLoadKHR: *hasResult = true; *hasResultType = true; break;
|
||||
case OpCooperativeMatrixStoreKHR: *hasResult = false; *hasResultType = false; break;
|
||||
case OpCooperativeMatrixMulAddKHR: *hasResult = true; *hasResultType = true; break;
|
||||
case OpCooperativeMatrixLengthKHR: *hasResult = true; *hasResultType = true; break;
|
||||
case OpCooperativeMatrixLengthKHR: *hasResult = true; *hasResultType = true; break;
|
||||
case OpConstantCompositeReplicateEXT: *hasResult = true; *hasResultType = true; break;
|
||||
case OpSpecConstantCompositeReplicateEXT: *hasResult = true; *hasResultType = true; break;
|
||||
case OpCompositeConstructReplicateEXT: *hasResult = true; *hasResultType = true; break;
|
||||
case OpTypeRayQueryKHR: *hasResult = true; *hasResultType = false; break;
|
||||
case OpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break;
|
||||
case OpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue