KhronosGroup / KhronosGroup/SPIRV-Cross
Invalid GLSL produced from valid SPIRV
Nobody has claimed this yet.
- Dominant language
- GLSL
- Stars
- 2.5k
- Forks
- 713
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 16
Description
Decompiling valid SPIRV results in invalid GLSL.
```
$ spirv-cross --stage comp --version 460 --vulkan-semantics lumen.spirv --output out.glsl
$ glslangValidator -g -V -S comp --target-env spirv1.6 out.glsl
out.glsl
ERROR: out.glsl:317: 'ShadowTraces' : undeclared identifier
ERROR: out.glsl:317: '_m0' : unknown swizzle selection
ERROR: out.glsl:317: '_m0' : unknown swizzle selection
ERROR: out.glsl:317: '_m0' : unknown swizzle selection
ERROR: out.glsl:317: '=' : cannot convert from ' temp float' to ' temp highp uint'
ERROR: out.glsl:317: '' : compilation terminated
ERROR: 6 compilation errors. No code generated.
SPIR-V is not generated for failed compile or link
```
Tested on
```
$ ./glslangValidator --version
Glslang Version: 11:15.0.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 15.0.0
GLSL Version: 4.60 glslang Khronos. 15.0.0
SPIR-V Version 0x00010600, Revision 1
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 11
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100
$ ./spirv-cross --version
Git commit: vulkan-sdk-1.3.296.0-10-g36e54568 Timestamp: 2024-10-14T16:18:23
```
[lumen_spirv.txt](https://github.com/user-attachments/files/17366129/lumen_spirv.txt)
[out_glsl.txt](https://github.com/user-attachments/files/17366141/out_glsl.txt)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the report with lumen_spirv.txt, the spirv-cross command, and glslangValidator, then compare the generated out.glsl at line 317 with the validator errors. Trace how the invalid ShadowTraces expression is produced and verify that the corrected output compiles successfully with the reported validation command.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100