aboutsummaryrefslogtreecommitdiff
path: root/SPIRV/SpvBuilder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SPIRV/SpvBuilder.cpp')
-rw-r--r--SPIRV/SpvBuilder.cpp46
1 files changed, 35 insertions, 11 deletions
diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp
index 7c5ea874..764a8860 100644
--- a/SPIRV/SpvBuilder.cpp
+++ b/SPIRV/SpvBuilder.cpp
@@ -71,9 +71,9 @@ Builder::Builder(unsigned int spvVersion, unsigned int magicNumber, SpvBuildLogg
addressModel(AddressingModelLogical),
memoryModel(MemoryModelGLSL450),
builderNumber(magicNumber),
- buildPoint(0),
+ buildPoint(nullptr),
uniqueId(0),
- entryPointFunction(0),
+ entryPointFunction(nullptr),
generatingOpCodeForSpecConst(false),
logger(buildLogger)
{
@@ -650,8 +650,12 @@ Id Builder::makeDebugFunctionType(Id returnType, const std::vector<Id>& paramTyp
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic));
type->addIdOperand(debugId[returnType]);
for (auto const paramType : paramTypes) {
- assert(isPointerType(paramType) || isArrayType(paramType));
- type->addIdOperand(debugId[getContainedTypeId(paramType)]);
+ if (isPointerType(paramType) || isArrayType(paramType)) {
+ type->addIdOperand(debugId[getContainedTypeId(paramType)]);
+ }
+ else {
+ type->addIdOperand(debugId[paramType]);
+ }
}
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
@@ -1176,6 +1180,21 @@ Id Builder::makeRayQueryType()
return type->getResultId();
}
+
+Id Builder::makeHitObjectNVType()
+{
+ Instruction *type;
+ if (groupedTypes[OpTypeHitObjectNV].size() == 0) {
+ type = new Instruction(getUniqueId(), NoType, OpTypeHitObjectNV);
+ groupedTypes[OpTypeHitObjectNV].push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
+ module.mapInstruction(type);
+ } else {
+ type = groupedTypes[OpTypeHitObjectNV].back();
+ }
+
+ return type->getResultId();
+}
#endif
Id Builder::getDerefTypeId(Id resultId) const
@@ -1675,7 +1694,7 @@ Id Builder::importNonSemanticShaderDebugInfoInstructions()
Id Builder::findCompositeConstant(Op typeClass, Id typeId, const std::vector<Id>& comps)
{
- Instruction* constant = 0;
+ Instruction* constant = nullptr;
bool found = false;
for (int i = 0; i < (int)groupedConstants[typeClass].size(); ++i) {
constant = groupedConstants[typeClass][i];
@@ -1702,7 +1721,7 @@ Id Builder::findCompositeConstant(Op typeClass, Id typeId, const std::vector<Id>
Id Builder::findStructConstant(Id typeId, const std::vector<Id>& comps)
{
- Instruction* constant = 0;
+ Instruction* constant = nullptr;
bool found = false;
for (int i = 0; i < (int)groupedStructConstants[typeId].size(); ++i) {
constant = groupedStructConstants[typeId][i];
@@ -2047,11 +2066,16 @@ Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const
assert(paramTypes.size() == paramNames.size());
for(size_t p = 0; p < paramTypes.size(); ++p)
{
- auto const& paramType = paramTypes[p];
- assert(isPointerType(paramType) || isArrayType(paramType));
- assert(debugId[getContainedTypeId(paramType)] != 0);
+ auto getParamTypeId = [this](Id const& typeId) {
+ if (isPointerType(typeId) || isArrayType(typeId)) {
+ return getContainedTypeId(typeId);
+ }
+ else {
+ return typeId;
+ }
+ };
auto const& paramName = paramNames[p];
- auto const debugLocalVariableId = createDebugLocalVariable(debugId[getContainedTypeId(paramType)], paramName, p+1);
+ auto const debugLocalVariableId = createDebugLocalVariable(debugId[getParamTypeId(paramTypes[p])], paramName, p+1);
debugId[firstParamId + p] = debugLocalVariableId;
makeDebugDeclare(debugLocalVariableId, firstParamId + p);
@@ -3332,7 +3356,7 @@ Builder::If::If(Id cond, unsigned int ctrl, Builder& gb) :
builder(gb),
condition(cond),
control(ctrl),
- elseBlock(0)
+ elseBlock(nullptr)
{
function = &builder.getBuildPoint()->getParent();