Revert SpvBuilder.* to master versions.
This commit is contained in:
parent
e592652665
commit
738314fe82
File diff suppressed because it is too large
Load Diff
@ -79,8 +79,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addCapability(spv::Capability cap) { capabilities.insert(cap); }
|
void addCapability(spv::Capability cap) { capabilities.insert(cap); }
|
||||||
|
|
||||||
// To get a new <id> for anything needing a new one.
|
// To get a new <id> for anything needing a new one.
|
||||||
Id getUniqueId() { return ++uniqueId; }
|
Id getUniqueId() { return ++uniqueId; }
|
||||||
|
|
||||||
// To get a set of new <id>s, e.g., for a set of function parameters
|
// To get a set of new <id>s, e.g., for a set of function parameters
|
||||||
Id getUniqueIds(int numIds)
|
Id getUniqueIds(int numIds)
|
||||||
{
|
{
|
||||||
@ -104,8 +106,7 @@ public:
|
|||||||
Id makeArrayType(Id element, Id sizeId, int stride); // 0 stride means no stride decoration
|
Id makeArrayType(Id element, Id sizeId, int stride); // 0 stride means no stride decoration
|
||||||
Id makeRuntimeArray(Id element);
|
Id makeRuntimeArray(Id element);
|
||||||
Id makeFunctionType(Id returnType, const std::vector<Id>& paramTypes);
|
Id makeFunctionType(Id returnType, const std::vector<Id>& paramTypes);
|
||||||
Id makeImageType(Id sampledType, Dim, bool depth, bool arrayed, bool ms, unsigned sampled,
|
Id makeImageType(Id sampledType, Dim, bool depth, bool arrayed, bool ms, unsigned sampled, ImageFormat format);
|
||||||
ImageFormat format);
|
|
||||||
Id makeSamplerType();
|
Id makeSamplerType();
|
||||||
Id makeSampledImageType(Id imageType);
|
Id makeSampledImageType(Id imageType);
|
||||||
|
|
||||||
@ -122,10 +123,7 @@ public:
|
|||||||
Id getContainedTypeId(Id typeId) const;
|
Id getContainedTypeId(Id typeId) const;
|
||||||
Id getContainedTypeId(Id typeId, int) const;
|
Id getContainedTypeId(Id typeId, int) const;
|
||||||
StorageClass getTypeStorageClass(Id typeId) const { return module.getStorageClass(typeId); }
|
StorageClass getTypeStorageClass(Id typeId) const { return module.getStorageClass(typeId); }
|
||||||
ImageFormat getImageTypeFormat(Id typeId) const
|
ImageFormat getImageTypeFormat(Id typeId) const { return (ImageFormat)module.getInstruction(typeId)->getImmediateOperand(6); }
|
||||||
{
|
|
||||||
return (ImageFormat)module.getInstruction(typeId)->getImmediateOperand(6);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isPointer(Id resultId) const { return isPointerType(getTypeId(resultId)); }
|
bool isPointer(Id resultId) const { return isPointerType(getTypeId(resultId)); }
|
||||||
bool isScalar(Id resultId) const { return isScalarType(getTypeId(resultId)); }
|
bool isScalar(Id resultId) const { return isScalarType(getTypeId(resultId)); }
|
||||||
@ -133,17 +131,10 @@ public:
|
|||||||
bool isMatrix(Id resultId) const { return isMatrixType(getTypeId(resultId)); }
|
bool isMatrix(Id resultId) const { return isMatrixType(getTypeId(resultId)); }
|
||||||
bool isAggregate(Id resultId) const { return isAggregateType(getTypeId(resultId)); }
|
bool isAggregate(Id resultId) const { return isAggregateType(getTypeId(resultId)); }
|
||||||
bool isSampledImage(Id resultId) const { return isSampledImageType(getTypeId(resultId)); }
|
bool isSampledImage(Id resultId) const { return isSampledImageType(getTypeId(resultId)); }
|
||||||
bool isBoolType(Id typeId) const
|
|
||||||
{
|
bool isBoolType(Id typeId) const { return groupedTypes[OpTypeBool].size() > 0 && typeId == groupedTypes[OpTypeBool].back()->getResultId(); }
|
||||||
return groupedTypes[OpTypeBool].size() > 0 &&
|
|
||||||
typeId == groupedTypes[OpTypeBool].back()->getResultId();
|
|
||||||
}
|
|
||||||
bool isPointerType(Id typeId) const { return getTypeClass(typeId) == OpTypePointer; }
|
bool isPointerType(Id typeId) const { return getTypeClass(typeId) == OpTypePointer; }
|
||||||
bool isScalarType(Id typeId) const
|
bool isScalarType(Id typeId) const { return getTypeClass(typeId) == OpTypeFloat || getTypeClass(typeId) == OpTypeInt || getTypeClass(typeId) == OpTypeBool; }
|
||||||
{
|
|
||||||
return getTypeClass(typeId) == OpTypeFloat || getTypeClass(typeId) == OpTypeInt ||
|
|
||||||
getTypeClass(typeId) == OpTypeBool;
|
|
||||||
}
|
|
||||||
bool isVectorType(Id typeId) const { return getTypeClass(typeId) == OpTypeVector; }
|
bool isVectorType(Id typeId) const { return getTypeClass(typeId) == OpTypeVector; }
|
||||||
bool isMatrixType(Id typeId) const { return getTypeClass(typeId) == OpTypeMatrix; }
|
bool isMatrixType(Id typeId) const { return getTypeClass(typeId) == OpTypeMatrix; }
|
||||||
bool isStructType(Id typeId) const { return getTypeClass(typeId) == OpTypeStruct; }
|
bool isStructType(Id typeId) const { return getTypeClass(typeId) == OpTypeStruct; }
|
||||||
@ -152,6 +143,7 @@ public:
|
|||||||
bool isImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeImage; }
|
bool isImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeImage; }
|
||||||
bool isSamplerType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampler; }
|
bool isSamplerType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampler; }
|
||||||
bool isSampledImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampledImage; }
|
bool isSampledImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampledImage; }
|
||||||
|
|
||||||
bool isConstantOpCode(Op opcode) const;
|
bool isConstantOpCode(Op opcode) const;
|
||||||
bool isSpecConstantOpCode(Op opcode) const;
|
bool isSpecConstantOpCode(Op opcode) const;
|
||||||
bool isConstant(Id resultId) const { return isConstantOpCode(getOpCode(resultId)); }
|
bool isConstant(Id resultId) const { return isConstantOpCode(getOpCode(resultId)); }
|
||||||
@ -172,6 +164,7 @@ public:
|
|||||||
return getNumTypeComponents(getContainedTypeId(typeId));
|
return getNumTypeComponents(getContainedTypeId(typeId));
|
||||||
}
|
}
|
||||||
int getNumRows(Id resultId) const { return getTypeNumRows(getTypeId(resultId)); }
|
int getNumRows(Id resultId) const { return getTypeNumRows(getTypeId(resultId)); }
|
||||||
|
|
||||||
Dim getTypeDimensionality(Id typeId) const
|
Dim getTypeDimensionality(Id typeId) const
|
||||||
{
|
{
|
||||||
assert(isImageType(typeId));
|
assert(isImageType(typeId));
|
||||||
@ -203,8 +196,7 @@ public:
|
|||||||
|
|
||||||
// Methods for adding information outside the CFG.
|
// Methods for adding information outside the CFG.
|
||||||
Instruction* addEntryPoint(ExecutionModel, Function*, const char* name);
|
Instruction* addEntryPoint(ExecutionModel, Function*, const char* name);
|
||||||
void addExecutionMode(Function*, ExecutionMode mode, int value1 = -1, int value2 = -1,
|
void addExecutionMode(Function*, ExecutionMode mode, int value1 = -1, int value2 = -1, int value3 = -1);
|
||||||
int value3 = -1);
|
|
||||||
void addName(Id, const char* name);
|
void addName(Id, const char* name);
|
||||||
void addMemberName(Id, int member, const char* name);
|
void addMemberName(Id, int member, const char* name);
|
||||||
void addLine(Id target, Id fileName, int line, int column);
|
void addLine(Id target, Id fileName, int line, int column);
|
||||||
@ -222,9 +214,8 @@ public:
|
|||||||
// Make a shader-style function, and create its entry block if entry is non-zero.
|
// Make a shader-style function, and create its entry block if entry is non-zero.
|
||||||
// Return the function, pass back the entry.
|
// Return the function, pass back the entry.
|
||||||
// The returned pointer is only valid for the lifetime of this builder.
|
// The returned pointer is only valid for the lifetime of this builder.
|
||||||
Function* makeFunctionEntry(Decoration precision, Id returnType, const char* name,
|
Function* makeFunctionEntry(Decoration precision, Id returnType, const char* name, const std::vector<Id>& paramTypes,
|
||||||
const std::vector<Id>& paramTypes,
|
const std::vector<Decoration>& precisions, Block **entry = 0);
|
||||||
const std::vector<Decoration>& precisions, Block** entry = 0);
|
|
||||||
|
|
||||||
// Create a return. An 'implicit' return is one not appearing in the source
|
// Create a return. An 'implicit' return is one not appearing in the source
|
||||||
// code. In the case of an implicit return, no post-return block is inserted.
|
// code. In the case of an implicit return, no post-return block is inserted.
|
||||||
@ -277,8 +268,7 @@ public:
|
|||||||
|
|
||||||
// Take an rvalue (source) and a set of channels to extract from it to
|
// Take an rvalue (source) and a set of channels to extract from it to
|
||||||
// make a new rvalue, which is returned.
|
// make a new rvalue, which is returned.
|
||||||
Id createRvalueSwizzle(Decoration precision, Id typeId, Id source,
|
Id createRvalueSwizzle(Decoration precision, Id typeId, Id source, std::vector<unsigned>& channels);
|
||||||
std::vector<unsigned>& channels);
|
|
||||||
|
|
||||||
// Take a copy of an lvalue (target) and a source of components, and set the
|
// Take a copy of an lvalue (target) and a source of components, and set the
|
||||||
// source components into the lvalue where the 'channels' say to put them.
|
// source components into the lvalue where the 'channels' say to put them.
|
||||||
@ -304,8 +294,7 @@ public:
|
|||||||
// - promoteScalar(scalar, scalar) // do nothing
|
// - promoteScalar(scalar, scalar) // do nothing
|
||||||
// Other forms are not allowed.
|
// Other forms are not allowed.
|
||||||
//
|
//
|
||||||
// Generally, the type of 'scalar' does not need to be the same type as the components in
|
// Generally, the type of 'scalar' does not need to be the same type as the components in 'vector'.
|
||||||
// 'vector'.
|
|
||||||
// The type of the created vector is a vector of components of the same type as the scalar.
|
// The type of the created vector is a vector of components of the same type as the scalar.
|
||||||
//
|
//
|
||||||
// Note: One of the arguments will change, with the result coming back that way rather than
|
// Note: One of the arguments will change, with the result coming back that way rather than
|
||||||
@ -338,8 +327,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Select the correct texture operation based on all inputs, and emit the correct instruction
|
// Select the correct texture operation based on all inputs, and emit the correct instruction
|
||||||
Id createTextureCall(Decoration precision, Id resultType, bool sparse, bool fetch, bool proj,
|
Id createTextureCall(Decoration precision, Id resultType, bool sparse, bool fetch, bool proj, bool gather, bool noImplicit, const TextureParameters&);
|
||||||
bool gather, bool noImplicit, const TextureParameters&);
|
|
||||||
|
|
||||||
// Emit the OpTextureQuery* instruction that was passed in.
|
// Emit the OpTextureQuery* instruction that was passed in.
|
||||||
// Figure out the right return value and type, and return it.
|
// Figure out the right return value and type, and return it.
|
||||||
@ -351,8 +339,7 @@ public:
|
|||||||
Id createBitFieldInsertCall(Decoration precision, Id, Id, Id, Id);
|
Id createBitFieldInsertCall(Decoration precision, Id, Id, Id, Id);
|
||||||
|
|
||||||
// Reduction comparison for composites: For equal and not-equal resulting in a scalar.
|
// Reduction comparison for composites: For equal and not-equal resulting in a scalar.
|
||||||
Id createCompositeCompare(Decoration precision, Id, Id,
|
Id createCompositeCompare(Decoration precision, Id, Id, bool /* true if for equal, false if for not-equal */);
|
||||||
bool /* true if for equal, false if for not-equal */);
|
|
||||||
|
|
||||||
// OpCompositeConstruct
|
// OpCompositeConstruct
|
||||||
Id createCompositeConstruct(Id typeId, std::vector<Id>& constituents);
|
Id createCompositeConstruct(Id typeId, std::vector<Id>& constituents);
|
||||||
@ -361,14 +348,14 @@ public:
|
|||||||
Id createConstructor(Decoration precision, const std::vector<Id>& sources, Id resultTypeId);
|
Id createConstructor(Decoration precision, const std::vector<Id>& sources, Id resultTypeId);
|
||||||
|
|
||||||
// matrix constructor
|
// matrix constructor
|
||||||
Id createMatrixConstructor(Decoration precision, const std::vector<Id>& sources,
|
Id createMatrixConstructor(Decoration precision, const std::vector<Id>& sources, Id constructee);
|
||||||
Id constructee);
|
|
||||||
|
|
||||||
// Helper to use for building nested control flow with if-then-else.
|
// Helper to use for building nested control flow with if-then-else.
|
||||||
class If {
|
class If {
|
||||||
public:
|
public:
|
||||||
If(Id condition, Builder& builder);
|
If(Id condition, Builder& builder);
|
||||||
~If() {}
|
~If() {}
|
||||||
|
|
||||||
void makeBeginElse();
|
void makeBeginElse();
|
||||||
void makeEndIf();
|
void makeEndIf();
|
||||||
|
|
||||||
@ -397,8 +384,7 @@ public:
|
|||||||
// Returns the right set of basic blocks to start each code segment with, so that the caller's
|
// Returns the right set of basic blocks to start each code segment with, so that the caller's
|
||||||
// recursion stack can hold the memory for it.
|
// recursion stack can hold the memory for it.
|
||||||
//
|
//
|
||||||
void makeSwitch(Id condition, int numSegments, std::vector<int>& caseValues,
|
void makeSwitch(Id condition, int numSegments, std::vector<int>& caseValues, std::vector<int>& valueToSegment, int defaultSegment,
|
||||||
std::vector<int>& valueToSegment, int defaultSegment,
|
|
||||||
std::vector<Block*>& segmentBB); // return argument
|
std::vector<Block*>& segmentBB); // return argument
|
||||||
|
|
||||||
// Add a branch to the innermost switch's merge block.
|
// Add a branch to the innermost switch's merge block.
|
||||||
@ -467,12 +453,9 @@ public:
|
|||||||
Id base; // for l-values, pointer to the base object, for r-values, the base object
|
Id base; // for l-values, pointer to the base object, for r-values, the base object
|
||||||
std::vector<Id> indexChain;
|
std::vector<Id> indexChain;
|
||||||
Id instr; // cache the instruction that generates this access chain
|
Id instr; // cache the instruction that generates this access chain
|
||||||
std::vector<unsigned>
|
std::vector<unsigned> swizzle; // each std::vector element selects the next GLSL component number
|
||||||
swizzle; // each std::vector element selects the next GLSL component number
|
Id component; // a dynamic component index, can coexist with a swizzle, done after the swizzle, NoResult if not present
|
||||||
Id component; // a dynamic component index, can coexist with a swizzle, done after the
|
Id preSwizzleBaseType; // dereferenced type, before swizzle or component is applied; NoType unless a swizzle or component is present
|
||||||
// swizzle, NoResult if not present
|
|
||||||
Id preSwizzleBaseType; // dereferenced type, before swizzle or component is applied; NoType
|
|
||||||
// unless a swizzle or component is present
|
|
||||||
bool isRValue; // true if 'base' is an r-value, otherwise, base is an l-value
|
bool isRValue; // true if 'base' is an r-value, otherwise, base is an l-value
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -484,6 +467,7 @@ public:
|
|||||||
// for external save and restore
|
// for external save and restore
|
||||||
AccessChain getAccessChain() { return accessChain; }
|
AccessChain getAccessChain() { return accessChain; }
|
||||||
void setAccessChain(AccessChain newChain) { accessChain = newChain; }
|
void setAccessChain(AccessChain newChain) { accessChain = newChain; }
|
||||||
|
|
||||||
// clear accessChain
|
// clear accessChain
|
||||||
void clearAccessChain();
|
void clearAccessChain();
|
||||||
|
|
||||||
@ -502,7 +486,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// push offset onto the end of the chain
|
// push offset onto the end of the chain
|
||||||
void accessChainPush(Id offset) { accessChain.indexChain.push_back(offset); }
|
void accessChainPush(Id offset)
|
||||||
|
{
|
||||||
|
accessChain.indexChain.push_back(offset);
|
||||||
|
}
|
||||||
|
|
||||||
// push new swizzle onto the end of any existing swizzle, merging into a single swizzle
|
// push new swizzle onto the end of any existing swizzle, merging into a single swizzle
|
||||||
void accessChainPushSwizzle(std::vector<unsigned>& swizzle, Id preSwizzleBaseType);
|
void accessChainPushSwizzle(std::vector<unsigned>& swizzle, Id preSwizzleBaseType);
|
||||||
|
|
||||||
@ -554,8 +542,7 @@ public:
|
|||||||
void simplifyAccessChainSwizzle();
|
void simplifyAccessChainSwizzle();
|
||||||
void createAndSetNoPredecessorBlock(const char*);
|
void createAndSetNoPredecessorBlock(const char*);
|
||||||
void createSelectionMerge(Block* mergeBlock, unsigned int control);
|
void createSelectionMerge(Block* mergeBlock, unsigned int control);
|
||||||
void dumpInstructions(std::vector<unsigned int>&,
|
void dumpInstructions(std::vector<unsigned int>&, const std::vector<std::unique_ptr<Instruction> >&) const;
|
||||||
const std::vector<std::unique_ptr<Instruction> >&) const;
|
|
||||||
|
|
||||||
SourceLanguage source;
|
SourceLanguage source;
|
||||||
int sourceVersion;
|
int sourceVersion;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user