microsoft / microsoft/DirectXShaderCompiler
[SPIR-V] Reading a ConstantBuffer from the ResourceDescriptorHeap in the global scope crashes in hit shaders
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
Declaring a static const ConstantBuffer in the global scope and assigning it from the resource heap causes a crash for closest/any hit shaders (cannot repro for pixel or compute shaders). The crash seems to occur from a null pointer in getParent...
Removing the declaration from the global scope and reading the ConstantBuffer from the entrypoint's body avoids the crash (https://godbolt.org/z/a1KKc5rqa).
Steps to Reproduce
Here is an example of the crash: https://godbolt.org/z/nWM76YMce
(FWIW, I later discovered that you don't even need to reference the ConstantBuffer in the body of the entrypoint, remove that line and it still crashes)
Contributor guide
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 running the two Godbolt reproductions linked in the issue and compare the closest/any hit shader behavior with pixel or compute shaders. Trace the SPIR-V compilation path for a static const ConstantBuffer initialized from the ResourceDescriptorHeap in global scope, focusing on the reported null pointer in getParent. Done means the reproducer no longer crashes, including when the ConstantBuffer is not referenced in the entrypoint body.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100