Open preetishkakkar opened 1 year ago
looks like removing tshader.setDebugInfo(true); makes it works
setting it after parse also works fine, I guess may be it's not useful to tshader.setDebugInfo before parsing?
I don't think glslang ought to be crashing even if you are passing the incorrect options. I'm going to take a look and see if I can reproduce this and get a backtrace. I've also reformatted your comment so the code doesn't get mangled, for future reference you can enclose code between triple-backticks to keep it from getting mangled by the HTML parser, or you can just attach the file as an attachment.
Hi. How is this going? I've been experiencing the same issue.
[...]
spv::SpvBuildLogger logger;
glslang::SpvOptions spv_options{};
spv_options.generateDebugInfo = true; <-- make it crash
std::vector<u32> spv;
glslang::GlslangToSpv(*intermediary, spv, &logger, &spv_options);
This is the error that I got:
Assertion failed: !currentDebugScopeId.empty(), file C:\dev\utils\vcpkg\buildtrees\glslang\src\12.2.0-7aaf2a2782.clean\SPIRV\SpvBuilder.cpp, line 2131
I hope it'll be fixed soon. Cheers!
If we're using glslang::TShader::setDebugInfo
with true
, we seem to need to to set glslang::SpvOptions::emitNonSemanticShaderDebugInfo
to true
in order for the crash not to manifest itself.
I would have liked to tackle this further but I think an interface design decision needs to be made here.
When glslang::TShader::setDebugInfo
is called with true
,
on glslang::TShader::parse
, EOpScope
instead of EOpSequence
is emitted for LEFT_BRACE statement_list RIGHT_BRACE
:
https://github.com/KhronosGroup/glslang/blob/a91631b260cba3f22858d6c6827511e636c2458a/glslang/MachineIndependent/glslang.y#L3765-L3769
With glslang::SpvOptions::emitNonSemanticShaderDebugInfo
set to false
(the dafault value),
spv::Builder::enterFunction
doesn't initialize the top level debug scope:
https://github.com/KhronosGroup/glslang/blob/a91631b260cba3f22858d6c6827511e636c2458a/SPIRV/SpvBuilder.cpp#L2272-L2285
So when TGlslangToSpvTraverser::visitAggregate
gets to an EOpScope
and calls spv::Builder::enterScope
:
https://github.com/KhronosGroup/glslang/blob/a91631b260cba3f22858d6c6827511e636c2458a/SPIRV/GlslangToSpv.cpp#L2896-L2897
spv::Builder::enterScope
calls spv::Builder::makeDebugLexicalBlock
, which fails the assertion assert(!currentDebugScopeId.empty())
:
https://github.com/KhronosGroup/glslang/blob/a91631b260cba3f22858d6c6827511e636c2458a/SPIRV/SpvBuilder.cpp#L2213-L2223
Hello, I am using git tag version 11.13.0 and I have below code
As soon as I add if/else to my shader it crashes? Below is my shader code