-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Source code not embeded in spirv #6092
Comments
Not sure if this is related to the same bug, but I see a validation error with the latest Vulkan SDK 1.4.304
|
This behavior of the compilation API is the same using tagged version 2024.17 and 2025.2 of the slang repo |
@EtienneParmentier, do you know by any chance a way to avoid this issue?
|
@mklefrancois I am not aware of any fixes. |
I found a temporary solution. |
@mklefrancois This doesn't help at all: my goal is to embed slang source code into the spirv file to help me debug shader code in renderdoc, and doing the embeding using the compilation API, not slangc. I guess slangc producing broken files with debug options is another subject entirely, please submit another issue that references this one to keep the discussion focused. |
I've reproduced the issue. The diff between the SPIR-V from It looks like the SPIR-V from the API has been optimized. |
@EtienneParmentier I found after some debugging that adding the lines
to your sample program will cause SPV_KHR_non_semantic_info + source to be generated. I need to read up on the API docs, but it feels like a bug that the per-target options are seemingly being ignored. |
https://shader-slang.org/slang/user-guide/compiling.html#compiler-options
This makes it sound like the original sample here should just work without making the options session-wide. |
Here is the call that adds the source when you specify session-wide that you want debug info: slang/source/slang/slang-lower-to-ir.cpp Line 11363 in ac174d2
I guess we're just missing a similar place for per-target output. |
Alternatively we change the logic around slang/source/slang/slang-lower-to-ir.cpp Line 11363 in ac174d2
Then we need to add a check during SPIR-V emit whether or not the particular target we're emitting for should actually emit |
That would be perfect ! Having to create 2 sessions would nullify the advantages of using the cpp api, since at that point invoking slangc twice would achieve the same results. Are there other options that are 'forgotten' when they are target specific ? I believe all compiler options should behave in the same way, whether they are specified at the target level or at the session level. |
I find it a bug that causes us to ignore everything you set through targetDesc.compilerOptionEntries. Can you try and see if #6178 fixes your problem? I think this may simply be caused by that option set through targetDesc being ignored. |
No it doesn't fix my issue. The source code is still missing from the assembly. |
It appears that debug info option affects IR generation so it has to be set on the session desc in order to for the ir lowering logic to emit the necessary debug info into IR. |
Here's a summary of the issue and a possible solution. The problem is that in order to generate debug info, we need the front-end to produce debug instructions when lowering to IR. When the backend sees these debug instructions, it will translate them to SPIRV debug info accordingly. Since this is an option for the front-end, it has to be set in session desc, and not in target desc, because target desc only affects the backend. The ask here is the ability to parse and check a module once, and generate both code with and without debug info in two separate target requests. We can enable such use by:
By doing so, we can ensure we always emit debug insts when lowering to IR, and these debug insts will be removed when compiling for a target that disables debug info during backend process, and will be respected when compiling for a target that does not disable debug info. |
@aleino-nv Note that the front-end will not have access to any compiler options set on a target, and it shouldn't access them. Instead of saying "enable debug source lowering when any target specifies debug info", we should just let the front-end emit debug info if the session desc enables debug info. But then we also allow target desc to disable debug info by including an entry that sets DebugInfo to |
So the user will need to do the following if they want debug info only for specific targets?
In particular, if they want debug info anywhere they need to realize to enable it in session options? I was thinking it would be more natural if it worked like this:
What do you think about the latter alternative? |
@csyonghe It's not clear to me how to do this properly. Is this supposed to produce code that is identical to what you'd get if you specified |
This helps to address shader-slang#6092.
@EtienneParmentier I believe the latest version of #6193 should fix the problem you encountered. |
This helps to address shader-slang#6092.
I initially posted this on the discord server, but I think it's easier to track progress here. I also updated my reproducer to remove unimportant stuff.
I am trying to use the compilation API to create spirv from slang source code. When I use the slangc tool, I can use the folowing command line to embed source code into the generated spirV:
which produces the folowing sprirv assembly:
I am trying to do the same using the compilation API.
Here is my reproducer, it also contains the test.slang file inside the raw string:
it produces the folowing assembly:
I think the spirv extension "SPV_KHR_non_semantic_info" is lacking in my cpp code, but I didn't found a way to activate it. I tried to debug slangc without success. Is their a way to activate this extension using the compilation API ?
The text was updated successfully, but these errors were encountered: