microsoft / microsoft/DirectXShaderCompiler
No error emitted when declaring RayQuery object in constant buffer
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
The compiler should emit an error diagnostic if you declare a RayQuery in a cbuffer, since it makes no sense to have a RayQuery in a constant buffer.
Steps to Reproduce
https://godbolt.org/z/bvEK7bWvT
Actual Behavior
The compiler actually puts the object with the fake handle in the constant buffer that looks like:
; cbuffer $Globals
; {
;
; struct $Globals
; {
;
; struct class.RayQuery<0>
; {
;
; uint h; ; Offset: 0
;
; } rq; ; Offset: 0
;
; uint j; ; Offset: 4
;
; } $Globals; ; Offset: 0 Size: 8
;
; }
If you try to use the RayQuery object, the compiler will crash.
Environment
- DXC version: latest main
- Host Operating System: any
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
Reproduce the declaration and use of a RayQuery in a constant buffer with the linked Godbolt example using the DirectX Shader Compiler. Trace how the compiler represents RayQuery objects in constant buffers, then make the invalid declaration produce an error and confirm that using such an object no longer reaches a crash.
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
- 42/100