Fix DebugCompilationUnit scope

Fix 3167.
This commit is contained in:
Jeremy Hayes 2023-04-03 14:24:00 -06:00 committed by arcady-lunarg
parent 77f7cdfb1e
commit 1aefd184a6
3 changed files with 841 additions and 821 deletions

View File

@ -144,6 +144,7 @@ void Builder::addLine(Id fileName, int lineNum, int column)
void Builder::addDebugScopeAndLine(Id fileName, int lineNum, int column)
{
assert(!currentDebugScopeId.empty());
if (currentDebugScopeId.top() != lastDebugScopeId) {
spv::Id resultId = getUniqueId();
Instruction* scopeInst = new Instruction(resultId, makeVoidType(), OpExtInst);
@ -1071,6 +1072,12 @@ Id Builder::makeDebugCompilationUnit() {
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(sourceInst));
module.mapInstruction(sourceInst);
nonSemanticShaderCompilationUnitId = resultId;
// We can reasonably assume that makeDebugCompilationUnit will be called before any of
// debug-scope stack. Function scopes and lexical scopes will occur afterward.
assert(currentDebugScopeId.empty());
currentDebugScopeId.push(nonSemanticShaderCompilationUnitId);
return resultId;
}
@ -1100,6 +1107,8 @@ Id Builder::createDebugGlobalVariable(Id const type, char const*const name, Id c
Id Builder::createDebugLocalVariable(Id type, char const*const name, size_t const argNumber)
{
assert(name != nullptr);
assert(!currentDebugScopeId.empty());
Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
inst->addIdOperand(nonSemanticShaderDebugInfo);
inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugLocalVariable);
@ -2119,6 +2128,8 @@ Id Builder::makeDebugFunction(Function* function, Id nameId, Id funcTypeId) {
}
Id Builder::makeDebugLexicalBlock(uint32_t line) {
assert(!currentDebugScopeId.empty());
Id lexId = getUniqueId();
auto lex = new Instruction(lexId, makeVoidType(), OpExtInst);
lex->addIdOperand(nonSemanticShaderDebugInfo);

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,8 @@ layout (location = 0) out vec4 outFragColor;
#define AMBIENT_LIGHT 0.1
#define USE_PCF
int global_var = 0;
struct Light
{
vec4 position;