|
@@ -1312,7 +1312,7 @@ Op Builder::getMostBasicTypeClass(Id typeId) const
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int Builder::getNumTypeConstituents(Id typeId) const
|
|
|
|
|
|
|
+unsigned int Builder::getNumTypeConstituents(Id typeId) const
|
|
|
{
|
|
{
|
|
|
Instruction* instr = module.getInstruction(typeId);
|
|
Instruction* instr = module.getInstruction(typeId);
|
|
|
|
|
|
|
@@ -1979,7 +1979,7 @@ void Builder::addDecoration(Id id, Decoration decoration, int num)
|
|
|
if (num >= 0)
|
|
if (num >= 0)
|
|
|
dec->addImmediateOperand(num);
|
|
dec->addImmediateOperand(num);
|
|
|
|
|
|
|
|
- decorations.push_back(std::unique_ptr<Instruction>(dec));
|
|
|
|
|
|
|
+ decorations.insert(std::unique_ptr<Instruction>(dec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Builder::addDecoration(Id id, Decoration decoration, const char* s)
|
|
void Builder::addDecoration(Id id, Decoration decoration, const char* s)
|
|
@@ -1993,7 +1993,7 @@ void Builder::addDecoration(Id id, Decoration decoration, const char* s)
|
|
|
dec->addImmediateOperand(decoration);
|
|
dec->addImmediateOperand(decoration);
|
|
|
dec->addStringOperand(s);
|
|
dec->addStringOperand(s);
|
|
|
|
|
|
|
|
- decorations.push_back(std::unique_ptr<Instruction>(dec));
|
|
|
|
|
|
|
+ decorations.insert(std::unique_ptr<Instruction>(dec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Builder::addDecoration(Id id, Decoration decoration, const std::vector<unsigned>& literals)
|
|
void Builder::addDecoration(Id id, Decoration decoration, const std::vector<unsigned>& literals)
|
|
@@ -2008,7 +2008,7 @@ void Builder::addDecoration(Id id, Decoration decoration, const std::vector<unsi
|
|
|
for (auto literal : literals)
|
|
for (auto literal : literals)
|
|
|
dec->addImmediateOperand(literal);
|
|
dec->addImmediateOperand(literal);
|
|
|
|
|
|
|
|
- decorations.push_back(std::unique_ptr<Instruction>(dec));
|
|
|
|
|
|
|
+ decorations.insert(std::unique_ptr<Instruction>(dec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Builder::addDecoration(Id id, Decoration decoration, const std::vector<const char*>& strings)
|
|
void Builder::addDecoration(Id id, Decoration decoration, const std::vector<const char*>& strings)
|
|
@@ -2023,7 +2023,7 @@ void Builder::addDecoration(Id id, Decoration decoration, const std::vector<cons
|
|
|
for (auto string : strings)
|
|
for (auto string : strings)
|
|
|
dec->addStringOperand(string);
|
|
dec->addStringOperand(string);
|
|
|
|
|
|
|
|
- decorations.push_back(std::unique_ptr<Instruction>(dec));
|
|
|
|
|
|
|
+ decorations.insert(std::unique_ptr<Instruction>(dec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Builder::addLinkageDecoration(Id id, const char* name, spv::LinkageType linkType) {
|
|
void Builder::addLinkageDecoration(Id id, const char* name, spv::LinkageType linkType) {
|
|
@@ -2034,7 +2034,7 @@ void Builder::addLinkageDecoration(Id id, const char* name, spv::LinkageType lin
|
|
|
dec->addStringOperand(name);
|
|
dec->addStringOperand(name);
|
|
|
dec->addImmediateOperand(linkType);
|
|
dec->addImmediateOperand(linkType);
|
|
|
|
|
|
|
|
- decorations.push_back(std::unique_ptr<Instruction>(dec));
|
|
|
|
|
|
|
+ decorations.insert(std::unique_ptr<Instruction>(dec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Builder::addDecorationId(Id id, Decoration decoration, Id idDecoration)
|
|
void Builder::addDecorationId(Id id, Decoration decoration, Id idDecoration)
|
|
@@ -2048,7 +2048,7 @@ void Builder::addDecorationId(Id id, Decoration decoration, Id idDecoration)
|
|
|
dec->addImmediateOperand(decoration);
|
|
dec->addImmediateOperand(decoration);
|
|
|
dec->addIdOperand(idDecoration);
|
|
dec->addIdOperand(idDecoration);
|
|
|
|
|
|
|
|
- decorations.push_back(std::unique_ptr<Instruction>(dec));
|
|
|
|
|
|
|
+ decorations.insert(std::unique_ptr<Instruction>(dec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Builder::addDecorationId(Id id, Decoration decoration, const std::vector<Id>& operandIds)
|
|
void Builder::addDecorationId(Id id, Decoration decoration, const std::vector<Id>& operandIds)
|
|
@@ -2064,7 +2064,7 @@ void Builder::addDecorationId(Id id, Decoration decoration, const std::vector<Id
|
|
|
for (auto operandId : operandIds)
|
|
for (auto operandId : operandIds)
|
|
|
dec->addIdOperand(operandId);
|
|
dec->addIdOperand(operandId);
|
|
|
|
|
|
|
|
- decorations.push_back(std::unique_ptr<Instruction>(dec));
|
|
|
|
|
|
|
+ decorations.insert(std::unique_ptr<Instruction>(dec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, int num)
|
|
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, int num)
|
|
@@ -2080,7 +2080,7 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
|
|
|
if (num >= 0)
|
|
if (num >= 0)
|
|
|
dec->addImmediateOperand(num);
|
|
dec->addImmediateOperand(num);
|
|
|
|
|
|
|
|
- decorations.push_back(std::unique_ptr<Instruction>(dec));
|
|
|
|
|
|
|
+ decorations.insert(std::unique_ptr<Instruction>(dec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, const char *s)
|
|
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, const char *s)
|
|
@@ -2095,7 +2095,7 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
|
|
|
dec->addImmediateOperand(decoration);
|
|
dec->addImmediateOperand(decoration);
|
|
|
dec->addStringOperand(s);
|
|
dec->addStringOperand(s);
|
|
|
|
|
|
|
|
- decorations.push_back(std::unique_ptr<Instruction>(dec));
|
|
|
|
|
|
|
+ decorations.insert(std::unique_ptr<Instruction>(dec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, const std::vector<unsigned>& literals)
|
|
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, const std::vector<unsigned>& literals)
|
|
@@ -2111,7 +2111,7 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
|
|
|
for (auto literal : literals)
|
|
for (auto literal : literals)
|
|
|
dec->addImmediateOperand(literal);
|
|
dec->addImmediateOperand(literal);
|
|
|
|
|
|
|
|
- decorations.push_back(std::unique_ptr<Instruction>(dec));
|
|
|
|
|
|
|
+ decorations.insert(std::unique_ptr<Instruction>(dec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, const std::vector<const char*>& strings)
|
|
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, const std::vector<const char*>& strings)
|
|
@@ -2127,10 +2127,16 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
|
|
|
for (auto string : strings)
|
|
for (auto string : strings)
|
|
|
dec->addStringOperand(string);
|
|
dec->addStringOperand(string);
|
|
|
|
|
|
|
|
- decorations.push_back(std::unique_ptr<Instruction>(dec));
|
|
|
|
|
|
|
+ decorations.insert(std::unique_ptr<Instruction>(dec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Builder::addInstruction(std::unique_ptr<Instruction> inst) {
|
|
void Builder::addInstruction(std::unique_ptr<Instruction> inst) {
|
|
|
|
|
+ // Phis must appear first in their block, don't insert line tracking instructions
|
|
|
|
|
+ // in front of them, just add the OpPhi and return.
|
|
|
|
|
+ if (inst->getOpCode() == OpPhi) {
|
|
|
|
|
+ buildPoint->addInstruction(std::move(inst));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
// Optionally insert OpDebugScope
|
|
// Optionally insert OpDebugScope
|
|
|
if (emitNonSemanticShaderDebugInfo && dirtyScopeTracker) {
|
|
if (emitNonSemanticShaderDebugInfo && dirtyScopeTracker) {
|
|
|
if (buildPoint->updateDebugScope(currentDebugScopeId.top())) {
|
|
if (buildPoint->updateDebugScope(currentDebugScopeId.top())) {
|
|
@@ -2236,14 +2242,13 @@ Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const
|
|
|
return function;
|
|
return function;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void Builder::setupDebugFunctionEntry(Function* function, const char* name, int line, const std::vector<Id>& paramTypes,
|
|
|
|
|
- const std::vector<char const*>& paramNames)
|
|
|
|
|
|
|
+void Builder::setupFunctionDebugInfo(Function* function, const char* name, const std::vector<Id>& paramTypes,
|
|
|
|
|
+ const std::vector<char const*>& paramNames)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
if (!emitNonSemanticShaderDebugInfo)
|
|
if (!emitNonSemanticShaderDebugInfo)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- currentLine = line;
|
|
|
|
|
Id nameId = getStringId(unmangleFunctionName(name));
|
|
Id nameId = getStringId(unmangleFunctionName(name));
|
|
|
Id funcTypeId = function->getFuncTypeId();
|
|
Id funcTypeId = function->getFuncTypeId();
|
|
|
assert(debugId[funcTypeId] != 0);
|
|
assert(debugId[funcTypeId] != 0);
|
|
@@ -2924,7 +2929,7 @@ Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, const std::vect
|
|
|
swizzle->reserveOperands(2);
|
|
swizzle->reserveOperands(2);
|
|
|
swizzle->addIdOperand(target);
|
|
swizzle->addIdOperand(target);
|
|
|
|
|
|
|
|
- assert(getNumComponents(source) == (int)channels.size());
|
|
|
|
|
|
|
+ assert(getNumComponents(source) == channels.size());
|
|
|
assert(isVector(source));
|
|
assert(isVector(source));
|
|
|
swizzle->addIdOperand(source);
|
|
swizzle->addIdOperand(source);
|
|
|
|
|
|
|
@@ -3371,7 +3376,7 @@ Id Builder::createCompositeCompare(Decoration precision, Id value1, Id value2, b
|
|
|
Id Builder::createCompositeConstruct(Id typeId, const std::vector<Id>& constituents)
|
|
Id Builder::createCompositeConstruct(Id typeId, const std::vector<Id>& constituents)
|
|
|
{
|
|
{
|
|
|
assert(isAggregateType(typeId) || (getNumTypeConstituents(typeId) > 1 &&
|
|
assert(isAggregateType(typeId) || (getNumTypeConstituents(typeId) > 1 &&
|
|
|
- getNumTypeConstituents(typeId) == (int)constituents.size()));
|
|
|
|
|
|
|
+ getNumTypeConstituents(typeId) == constituents.size()));
|
|
|
|
|
|
|
|
if (generatingOpCodeForSpecConst) {
|
|
if (generatingOpCodeForSpecConst) {
|
|
|
// Sometime, even in spec-constant-op mode, the constant composite to be
|
|
// Sometime, even in spec-constant-op mode, the constant composite to be
|
|
@@ -3424,6 +3429,12 @@ Id Builder::createConstructor(Decoration precision, const std::vector<Id>& sourc
|
|
|
if (sources.size() == 1 && isScalar(sources[0]) && numTargetComponents > 1)
|
|
if (sources.size() == 1 && isScalar(sources[0]) && numTargetComponents > 1)
|
|
|
return smearScalar(precision, sources[0], resultTypeId);
|
|
return smearScalar(precision, sources[0], resultTypeId);
|
|
|
|
|
|
|
|
|
|
+ // Special case: 2 vectors of equal size
|
|
|
|
|
+ if (sources.size() == 1 && isVector(sources[0]) && numTargetComponents == getNumComponents(sources[0])) {
|
|
|
|
|
+ assert(resultTypeId == getTypeId(sources[0]));
|
|
|
|
|
+ return sources[0];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// accumulate the arguments for OpCompositeConstruct
|
|
// accumulate the arguments for OpCompositeConstruct
|
|
|
std::vector<Id> constituents;
|
|
std::vector<Id> constituents;
|
|
|
Id scalarTypeId = getScalarTypeId(resultTypeId);
|
|
Id scalarTypeId = getScalarTypeId(resultTypeId);
|
|
@@ -3458,8 +3469,8 @@ Id Builder::createConstructor(Decoration precision, const std::vector<Id>& sourc
|
|
|
if (sourcesToUse + targetComponent > numTargetComponents)
|
|
if (sourcesToUse + targetComponent > numTargetComponents)
|
|
|
sourcesToUse = numTargetComponents - targetComponent;
|
|
sourcesToUse = numTargetComponents - targetComponent;
|
|
|
|
|
|
|
|
- int col = 0;
|
|
|
|
|
- int row = 0;
|
|
|
|
|
|
|
+ unsigned int col = 0;
|
|
|
|
|
+ unsigned int row = 0;
|
|
|
for (unsigned int s = 0; s < sourcesToUse; ++s) {
|
|
for (unsigned int s = 0; s < sourcesToUse; ++s) {
|
|
|
if (row >= getNumRows(sourceArg)) {
|
|
if (row >= getNumRows(sourceArg)) {
|
|
|
row = 0;
|
|
row = 0;
|
|
@@ -3504,8 +3515,8 @@ Id Builder::createConstructor(Decoration precision, const std::vector<Id>& sourc
|
|
|
Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>& sources, Id resultTypeId)
|
|
Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>& sources, Id resultTypeId)
|
|
|
{
|
|
{
|
|
|
Id componentTypeId = getScalarTypeId(resultTypeId);
|
|
Id componentTypeId = getScalarTypeId(resultTypeId);
|
|
|
- int numCols = getTypeNumColumns(resultTypeId);
|
|
|
|
|
- int numRows = getTypeNumRows(resultTypeId);
|
|
|
|
|
|
|
+ unsigned int numCols = getTypeNumColumns(resultTypeId);
|
|
|
|
|
+ unsigned int numRows = getTypeNumRows(resultTypeId);
|
|
|
|
|
|
|
|
Instruction* instr = module.getInstruction(componentTypeId);
|
|
Instruction* instr = module.getInstruction(componentTypeId);
|
|
|
const unsigned bitCount = instr->getImmediateOperand(0);
|
|
const unsigned bitCount = instr->getImmediateOperand(0);
|
|
@@ -3520,11 +3531,11 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
|
|
|
Id sourceColumnTypeId = getContainedTypeId(getTypeId(matrix));
|
|
Id sourceColumnTypeId = getContainedTypeId(getTypeId(matrix));
|
|
|
|
|
|
|
|
std::vector<unsigned> channels;
|
|
std::vector<unsigned> channels;
|
|
|
- for (int row = 0; row < numRows; ++row)
|
|
|
|
|
|
|
+ for (unsigned int row = 0; row < numRows; ++row)
|
|
|
channels.push_back(row);
|
|
channels.push_back(row);
|
|
|
|
|
|
|
|
std::vector<Id> matrixColumns;
|
|
std::vector<Id> matrixColumns;
|
|
|
- for (int col = 0; col < numCols; ++col) {
|
|
|
|
|
|
|
+ for (unsigned int col = 0; col < numCols; ++col) {
|
|
|
std::vector<unsigned> indexes;
|
|
std::vector<unsigned> indexes;
|
|
|
indexes.push_back(col);
|
|
indexes.push_back(col);
|
|
|
Id colv = createCompositeExtract(matrix, sourceColumnTypeId, indexes);
|
|
Id colv = createCompositeExtract(matrix, sourceColumnTypeId, indexes);
|
|
@@ -3542,7 +3553,7 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
|
|
|
|
|
|
|
|
// Detect a matrix being constructed from a repeated vector of the correct size.
|
|
// Detect a matrix being constructed from a repeated vector of the correct size.
|
|
|
// Create the composite directly from it.
|
|
// Create the composite directly from it.
|
|
|
- if ((int)sources.size() == numCols && isVector(sources[0]) && getNumComponents(sources[0]) == numRows &&
|
|
|
|
|
|
|
+ if (sources.size() == numCols && isVector(sources[0]) && getNumComponents(sources[0]) == numRows &&
|
|
|
std::equal(sources.begin() + 1, sources.end(), sources.begin())) {
|
|
std::equal(sources.begin() + 1, sources.end(), sources.begin())) {
|
|
|
return setPrecision(createCompositeConstruct(resultTypeId, sources), precision);
|
|
return setPrecision(createCompositeConstruct(resultTypeId, sources), precision);
|
|
|
}
|
|
}
|
|
@@ -3574,12 +3585,12 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
|
|
|
} else if (isMatrix(sources[0])) {
|
|
} else if (isMatrix(sources[0])) {
|
|
|
// constructing from another matrix; copy over the parts that exist in both the argument and constructee
|
|
// constructing from another matrix; copy over the parts that exist in both the argument and constructee
|
|
|
Id matrix = sources[0];
|
|
Id matrix = sources[0];
|
|
|
- int minCols = std::min(numCols, getNumColumns(matrix));
|
|
|
|
|
- int minRows = std::min(numRows, getNumRows(matrix));
|
|
|
|
|
- for (int col = 0; col < minCols; ++col) {
|
|
|
|
|
|
|
+ unsigned int minCols = std::min(numCols, getNumColumns(matrix));
|
|
|
|
|
+ unsigned int minRows = std::min(numRows, getNumRows(matrix));
|
|
|
|
|
+ for (unsigned int col = 0; col < minCols; ++col) {
|
|
|
std::vector<unsigned> indexes;
|
|
std::vector<unsigned> indexes;
|
|
|
indexes.push_back(col);
|
|
indexes.push_back(col);
|
|
|
- for (int row = 0; row < minRows; ++row) {
|
|
|
|
|
|
|
+ for (unsigned int row = 0; row < minRows; ++row) {
|
|
|
indexes.push_back(row);
|
|
indexes.push_back(row);
|
|
|
ids[col][row] = createCompositeExtract(matrix, componentTypeId, indexes);
|
|
ids[col][row] = createCompositeExtract(matrix, componentTypeId, indexes);
|
|
|
indexes.pop_back();
|
|
indexes.pop_back();
|
|
@@ -3588,12 +3599,12 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// fill in the matrix in column-major order with whatever argument components are available
|
|
// fill in the matrix in column-major order with whatever argument components are available
|
|
|
- int row = 0;
|
|
|
|
|
- int col = 0;
|
|
|
|
|
|
|
+ unsigned int row = 0;
|
|
|
|
|
+ unsigned int col = 0;
|
|
|
|
|
|
|
|
- for (int arg = 0; arg < (int)sources.size() && col < numCols; ++arg) {
|
|
|
|
|
|
|
+ for (unsigned int arg = 0; arg < sources.size() && col < numCols; ++arg) {
|
|
|
Id argComp = sources[arg];
|
|
Id argComp = sources[arg];
|
|
|
- for (int comp = 0; comp < getNumComponents(sources[arg]); ++comp) {
|
|
|
|
|
|
|
+ for (unsigned int comp = 0; comp < getNumComponents(sources[arg]); ++comp) {
|
|
|
if (getNumComponents(sources[arg]) > 1) {
|
|
if (getNumComponents(sources[arg]) > 1) {
|
|
|
argComp = createCompositeExtract(sources[arg], componentTypeId, comp);
|
|
argComp = createCompositeExtract(sources[arg], componentTypeId, comp);
|
|
|
setPrecision(argComp, precision);
|
|
setPrecision(argComp, precision);
|
|
@@ -3617,9 +3628,9 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
|
|
|
// make the column vectors
|
|
// make the column vectors
|
|
|
Id columnTypeId = getContainedTypeId(resultTypeId);
|
|
Id columnTypeId = getContainedTypeId(resultTypeId);
|
|
|
std::vector<Id> matrixColumns;
|
|
std::vector<Id> matrixColumns;
|
|
|
- for (int col = 0; col < numCols; ++col) {
|
|
|
|
|
|
|
+ for (unsigned int col = 0; col < numCols; ++col) {
|
|
|
std::vector<Id> vectorComponents;
|
|
std::vector<Id> vectorComponents;
|
|
|
- for (int row = 0; row < numRows; ++row)
|
|
|
|
|
|
|
+ for (unsigned int row = 0; row < numRows; ++row)
|
|
|
vectorComponents.push_back(ids[col][row]);
|
|
vectorComponents.push_back(ids[col][row]);
|
|
|
Id column = createCompositeConstruct(columnTypeId, vectorComponents);
|
|
Id column = createCompositeConstruct(columnTypeId, vectorComponents);
|
|
|
setPrecision(column, precision);
|
|
setPrecision(column, precision);
|
|
@@ -3846,7 +3857,7 @@ void Builder::accessChainStore(Id rvalue, Decoration nonUniform, spv::MemoryAcce
|
|
|
|
|
|
|
|
// If a swizzle exists and is not full and is not dynamic, then the swizzle will be broken into individual stores.
|
|
// If a swizzle exists and is not full and is not dynamic, then the swizzle will be broken into individual stores.
|
|
|
if (accessChain.swizzle.size() > 0 &&
|
|
if (accessChain.swizzle.size() > 0 &&
|
|
|
- getNumTypeComponents(getResultingAccessChainType()) != (int)accessChain.swizzle.size() &&
|
|
|
|
|
|
|
+ getNumTypeComponents(getResultingAccessChainType()) != accessChain.swizzle.size() &&
|
|
|
accessChain.component == NoResult) {
|
|
accessChain.component == NoResult) {
|
|
|
for (unsigned int i = 0; i < accessChain.swizzle.size(); ++i) {
|
|
for (unsigned int i = 0; i < accessChain.swizzle.size(); ++i) {
|
|
|
accessChain.indexChain.push_back(makeUintConstant(accessChain.swizzle[i]));
|
|
accessChain.indexChain.push_back(makeUintConstant(accessChain.swizzle[i]));
|
|
@@ -4166,7 +4177,7 @@ void Builder::simplifyAccessChainSwizzle()
|
|
|
{
|
|
{
|
|
|
// If the swizzle has fewer components than the vector, it is subsetting, and must stay
|
|
// If the swizzle has fewer components than the vector, it is subsetting, and must stay
|
|
|
// to preserve that fact.
|
|
// to preserve that fact.
|
|
|
- if (getNumTypeComponents(accessChain.preSwizzleBaseType) > (int)accessChain.swizzle.size())
|
|
|
|
|
|
|
+ if (getNumTypeComponents(accessChain.preSwizzleBaseType) > accessChain.swizzle.size())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
// if components are out of order, it is a swizzle
|
|
// if components are out of order, it is a swizzle
|
|
@@ -4324,11 +4335,10 @@ void Builder::dumpSourceInstructions(std::vector<unsigned int>& out) const
|
|
|
dumpSourceInstructions(iItr->first, *iItr->second, out);
|
|
dumpSourceInstructions(iItr->first, *iItr->second, out);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void Builder::dumpInstructions(std::vector<unsigned int>& out,
|
|
|
|
|
- const std::vector<std::unique_ptr<Instruction> >& instructions) const
|
|
|
|
|
|
|
+template <class Range> void Builder::dumpInstructions(std::vector<unsigned int>& out, const Range& instructions) const
|
|
|
{
|
|
{
|
|
|
- for (int i = 0; i < (int)instructions.size(); ++i) {
|
|
|
|
|
- instructions[i]->dump(out);
|
|
|
|
|
|
|
+ for (const auto& inst : instructions) {
|
|
|
|
|
+ inst->dump(out);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -4341,4 +4351,40 @@ void Builder::dumpModuleProcesses(std::vector<unsigned int>& out) const
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+bool Builder::DecorationInstructionLessThan::operator()(const std::unique_ptr<Instruction>& lhs,
|
|
|
|
|
+ const std::unique_ptr<Instruction>& rhs) const
|
|
|
|
|
+{
|
|
|
|
|
+ // Order by the id to which the decoration applies first. This is more intuitive.
|
|
|
|
|
+ assert(lhs->isIdOperand(0) && rhs->isIdOperand(0));
|
|
|
|
|
+ if (lhs->getIdOperand(0) != rhs->getIdOperand(0)) {
|
|
|
|
|
+ return lhs->getIdOperand(0) < rhs->getIdOperand(0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (lhs->getOpCode() != rhs->getOpCode())
|
|
|
|
|
+ return lhs->getOpCode() < rhs->getOpCode();
|
|
|
|
|
+
|
|
|
|
|
+ // Now compare the operands.
|
|
|
|
|
+ int minSize = std::min(lhs->getNumOperands(), rhs->getNumOperands());
|
|
|
|
|
+ for (int i = 1; i < minSize; ++i) {
|
|
|
|
|
+ if (lhs->isIdOperand(i) != rhs->isIdOperand(i)) {
|
|
|
|
|
+ return lhs->isIdOperand(i) < rhs->isIdOperand(i);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (lhs->isIdOperand(i)) {
|
|
|
|
|
+ if (lhs->getIdOperand(i) != rhs->getIdOperand(i)) {
|
|
|
|
|
+ return lhs->getIdOperand(i) < rhs->getIdOperand(i);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (lhs->getImmediateOperand(i) != rhs->getImmediateOperand(i)) {
|
|
|
|
|
+ return lhs->getImmediateOperand(i) < rhs->getImmediateOperand(i);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (lhs->getNumOperands() != rhs->getNumOperands())
|
|
|
|
|
+ return lhs->getNumOperands() < rhs->getNumOperands();
|
|
|
|
|
+
|
|
|
|
|
+ // In this case they are equal.
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
} // end spv namespace
|
|
} // end spv namespace
|