Add correct line number to OpDebugFunction and OpDebugScope for function:
1. Pull OpDebugFunction, OpDebugScope and OpDebugVariable for params out of makeFunctionEntry. 2. Put above in a separate function called setupDebugFunctionEntry, which also accept line number and set it correctly in builder. 3. Call setupDebugFunctionEntry in makeFunction. Also special case handle entry function since it's created ealier elsewhere.
This commit is contained in:
parent
a2fb1ba2ad
commit
979423d84f
19 changed files with 9076 additions and 9016 deletions
|
|
@ -5403,9 +5403,17 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
|
|||
|
||||
for (int f = 0; f < (int)glslFunctions.size(); ++f) {
|
||||
glslang::TIntermAggregate* glslFunction = glslFunctions[f]->getAsAggregate();
|
||||
if (! glslFunction || glslFunction->getOp() != glslang::EOpFunction || isShaderEntryPoint(glslFunction))
|
||||
if (! glslFunction || glslFunction->getOp() != glslang::EOpFunction)
|
||||
continue;
|
||||
|
||||
if (isShaderEntryPoint(glslFunction)) {
|
||||
if (glslangIntermediate->getSource() != glslang::EShSourceHlsl) {
|
||||
builder.setupDebugFunctionEntry(shaderEntry, glslangIntermediate->getEntryPointMangledName().c_str(),
|
||||
glslFunction->getLoc().line,
|
||||
std::vector<spv::Id>(), // main function has no param
|
||||
std::vector<char const*>());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// We're on a user function. Set up the basic interface for the function now,
|
||||
// so that it's available to call. Translating the body will happen later.
|
||||
//
|
||||
|
|
@ -5455,6 +5463,8 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
|
|||
TranslatePrecisionDecoration(glslFunction->getType()), convertGlslangToSpvType(glslFunction->getType()),
|
||||
glslFunction->getName().c_str(), convertGlslangLinkageToSpv(glslFunction->getLinkType()), paramTypes,
|
||||
paramNames, paramDecorations, &functionBlock);
|
||||
builder.setupDebugFunctionEntry(function, glslFunction->getName().c_str(), glslFunction->getLoc().line,
|
||||
paramTypes, paramNames);
|
||||
if (implicitThis)
|
||||
function->setImplicitThis();
|
||||
|
||||
|
|
|
|||
|
|
@ -2101,12 +2101,8 @@ Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const
|
|||
}
|
||||
}
|
||||
|
||||
// Make the debug function instruction
|
||||
// reset last debug scope
|
||||
if (emitNonSemanticShaderDebugInfo) {
|
||||
Id nameId = getStringId(unmangleFunctionName(name));
|
||||
Id debugFuncId = makeDebugFunction(function, nameId, typeId);
|
||||
debugId[funcId] = debugFuncId;
|
||||
currentDebugScopeId.push(debugFuncId);
|
||||
lastDebugScopeId = NoResult;
|
||||
}
|
||||
|
||||
|
|
@ -2116,41 +2112,62 @@ Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const
|
|||
function->addBlock(*entry);
|
||||
setBuildPoint(*entry);
|
||||
|
||||
// DebugScope and DebugLine for parameter DebugDeclares
|
||||
if (emitNonSemanticShaderDebugInfo && (int)paramTypes.size() > 0) {
|
||||
addDebugScopeAndLine(currentFileId, currentLine, 0);
|
||||
}
|
||||
if (name)
|
||||
addName(function->getId(), name);
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo) {
|
||||
assert(paramTypes.size() == paramNames.size());
|
||||
for(size_t p = 0; p < paramTypes.size(); ++p)
|
||||
{
|
||||
functions.push_back(std::unique_ptr<Function>(function));
|
||||
|
||||
return function;
|
||||
}
|
||||
|
||||
void Builder::setupDebugFunctionEntry(Function* function, const char* name, int line, const std::vector<Id>& paramTypes,
|
||||
const std::vector<char const*>& paramNames)
|
||||
{
|
||||
|
||||
if (!emitNonSemanticShaderDebugInfo)
|
||||
return;
|
||||
|
||||
currentLine = line;
|
||||
Id nameId = getStringId(unmangleFunctionName(name));
|
||||
Id funcTypeId = function->getFuncTypeId();
|
||||
assert(debugId[funcTypeId] != 0);
|
||||
Id funcId = function->getId();
|
||||
|
||||
assert(funcId != 0);
|
||||
|
||||
// Make the debug function instruction
|
||||
Id debugFuncId = makeDebugFunction(function, nameId, funcTypeId);
|
||||
debugId[funcId] = debugFuncId;
|
||||
currentDebugScopeId.push(debugFuncId);
|
||||
|
||||
// DebugScope and DebugLine for parameter DebugDeclares
|
||||
assert(paramTypes.size() == paramNames.size());
|
||||
if ((int)paramTypes.size() > 0) {
|
||||
addDebugScopeAndLine(currentFileId, currentLine, 0);
|
||||
|
||||
Id firstParamId = function->getParamId(0);
|
||||
|
||||
for (size_t p = 0; p < paramTypes.size(); ++p) {
|
||||
auto getParamTypeId = [this](Id const& typeId) {
|
||||
if (isPointerType(typeId) || isArrayType(typeId)) {
|
||||
return getContainedTypeId(typeId);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return typeId;
|
||||
}
|
||||
};
|
||||
auto const& paramName = paramNames[p];
|
||||
auto const debugLocalVariableId = createDebugLocalVariable(debugId[getParamTypeId(paramTypes[p])], paramName, p+1);
|
||||
auto const debugLocalVariableId =
|
||||
createDebugLocalVariable(debugId[getParamTypeId(paramTypes[p])], paramName, p + 1);
|
||||
|
||||
debugId[firstParamId + p] = debugLocalVariableId;
|
||||
|
||||
makeDebugDeclare(debugLocalVariableId, firstParamId + p);
|
||||
}
|
||||
}
|
||||
|
||||
if (name)
|
||||
addName(function->getId(), name);
|
||||
|
||||
functions.push_back(std::unique_ptr<Function>(function));
|
||||
|
||||
// Clear debug scope stack
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
currentDebugScopeId.pop();
|
||||
|
||||
return function;
|
||||
}
|
||||
|
||||
Id Builder::makeDebugFunction([[maybe_unused]] Function* function, Id nameId, Id funcTypeId)
|
||||
|
|
@ -2166,13 +2183,13 @@ Id Builder::makeDebugFunction([[maybe_unused]] Function* function, Id nameId, Id
|
|||
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugFunction);
|
||||
type->addIdOperand(nameId);
|
||||
type->addIdOperand(debugId[funcTypeId]);
|
||||
type->addIdOperand(makeDebugSource(currentFileId)); // Will be fixed later when true filename available
|
||||
type->addIdOperand(makeUintConstant(currentLine)); // Will be fixed later when true line available
|
||||
type->addIdOperand(makeDebugSource(currentFileId)); // TODO: This points to file of definition instead of declaration
|
||||
type->addIdOperand(makeUintConstant(currentLine)); // TODO: This points to line of definition instead of declaration
|
||||
type->addIdOperand(makeUintConstant(0)); // column
|
||||
type->addIdOperand(makeDebugCompilationUnit()); // scope
|
||||
type->addIdOperand(nameId); // linkage name
|
||||
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic));
|
||||
type->addIdOperand(makeUintConstant(currentLine)); // TODO(greg-lunarg): correct scope line
|
||||
type->addIdOperand(makeUintConstant(currentLine));
|
||||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
return funcId;
|
||||
|
|
|
|||
|
|
@ -237,6 +237,9 @@ public:
|
|||
Id makeDebugFunction(Function* function, Id nameId, Id funcTypeId);
|
||||
Id makeDebugLexicalBlock(uint32_t line);
|
||||
std::string unmangleFunctionName(std::string const& name) const;
|
||||
void setupDebugFunctionEntry(Function* function, const char* name, int line,
|
||||
const std::vector<Id>& paramTypes,
|
||||
const std::vector<char const*>& paramNames);
|
||||
|
||||
// accelerationStructureNV type
|
||||
Id makeAccelerationStructureType();
|
||||
|
|
|
|||
|
|
@ -352,6 +352,7 @@ public:
|
|||
void addLocalVariable(std::unique_ptr<Instruction> inst);
|
||||
Id getReturnType() const { return functionInstruction.getTypeId(); }
|
||||
Id getFuncId() const { return functionInstruction.getResultId(); }
|
||||
Id getFuncTypeId() const { return functionInstruction.getIdOperand(1); }
|
||||
void setReturnPrecision(Decoration precision)
|
||||
{
|
||||
if (precision == DecorationRelaxedPrecision)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue