KhronosGroup / KhronosGroup/glslang
AMD & NVidia Extension Issues
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
I have been using glslang for Vulkan shader compilation and reflection, recently we have enabled linking to distributed glslang and SPIRV dlls, this caused segfaults in the application.
To try and find what options caused errors I created a test application with simple reflection, I found `ENABLE_AMD_EXTENSIONS`, and `ENABLE_NV_EXTENSIONS` to be the culprits, and the results are interesting.
The default build configuration has `ENABLE_AMD_EXTENSIONS=OFF` `ENABLE_NV_EXTENSIONS=OFF` `ENABLE_OPT=OFF`, each issue listed below describes which one was changed to generate the issue.
1. I was getting SIGSEGV out of `glslang::TSmallArrayVector::size` by calling `program.getUniformTType(i)->computeNumComponents()` at https://github.com/KhronosGroup/glslang/blob/master/glslang/Include/arrays.h#L103 with just `ENABLE_NV_EXTENSIONS=ON`. adding `ENABLE_AMD_EXTENSIONS=ON` appears fix the crash, the array size is then not multiplied into the result (something I added in my main.cpp).
With this point I would like to ask how to properly find the byte size of a uniform, we can get the byte size of a uniform block with `program.getUniformBlockSize(i)` but not of each individual uniform in the block or on its own.
2. `program.getUniformBlockTType(i)->getQualifier().layoutPushConstant` will always have a integer value of 31 instead of 0 or 1 with `ENABLE_AMD_EXTENSIONS=ON`.
This point and the next are very similar with the value set to a strange constant number, I checked and the qualifier pointer in the TProgram reflection and the one returned are to the same address but with some values altered (no process was run between checking the pointers).
3. `program.getAttributeTType(i)->getQualifier().layoutLocation` will give a value of 4095, expected values range between 0-3 in my tests cases with `ENABLE_AMD_EXTENSIONS=ON` and `ENABLE_NV_EXTENSIONS=ON`. If I were to create a method in TProgram to fetch the values they are returned correctly: `int TProgram::getAttributeLocation(int index) const { return reflection->getAttribute(index).getType()->getQualifier().layoutPushConstant; }`
I ran my tests on Windows 10 in CLion, and with Ubuntu 18.10 using GCC7, I am including all of these findings in one issue as many relate to each other. My tests can be found here: https://github.com/mattparks/glsltest. debug/debug.cpp was used to create the outputs in debug that show the exact outputs seen.
There were more issues found with just these three build options, I found workarounds to the other issues with the three listed here being severe.
Contributor guide
Research direction
Start with debug/debug.cpp and the reported build combinations for ENABLE_AMD_EXTENSIONS, ENABLE_NV_EXTENSIONS, and ENABLE_OPT. Inspect glslang/Include/arrays.h and the TProgram reflection accessors while reproducing the crashes and incorrect qualifier values on the supplied Windows or Ubuntu setups. Done means identifying and fixing the reflection or extension interaction, with the uniform sizing and qualifier results matching the expected values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100