diff options
| author | Gangzheng Tong <tonggangzheng@gmail.com> | 2025-04-09 14:41:41 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-09 14:41:41 -0700 |
| commit | 17d1a2c8c3ff6b357b99faaefff7caa7200be2f8 (patch) | |
| tree | 44bd5d93e7d8f080ba47e73f7a5bd5dd7dc61fa3 /tests/bugs | |
| parent | fd09feaaa19c1ae3441dd687bced1b12ff7c768e (diff) | |
Get real value for typeAdapter (#6762)
* Get real value for typeAdapter
When the type is mismatch and typeAdapter is used, get the real value
from typeAdapter so that we don't get nullptr for irValue.
This fixes the assert if uint is used for SV_VertexID, which is an int
in the system binding semantic.
Fixes: #6525
* Add test case; add nullptr check
Diffstat (limited to 'tests/bugs')
| -rw-r--r-- | tests/bugs/gh-6525.slang | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/bugs/gh-6525.slang b/tests/bugs/gh-6525.slang new file mode 100644 index 000000000..fe57b601c --- /dev/null +++ b/tests/bugs/gh-6525.slang @@ -0,0 +1,16 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv + +//CHECK: OpEntryPoint + +// SV_VertexID is a int in the system binding semantic. +// However, declare it as uint should also work with +// the typeAdapter mechanism in Slang compiler. +in uint gl_VertexIndex : SV_VertexID; + +static const float2 uvs[] = { float2(0.0, 0.0), float2(0.0, 2.0), float2(2.0, 0.0) }; + +[shader("vertex")] +float4 vert_main() : SV_Position{ + const float2 uv = uvs[gl_VertexIndex]; + return float4((uv * 2.0 - 1.0), 0.0, 1.0); +}
\ No newline at end of file |
