yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Yong HeMake `-no-mangle` option work, add `-no-hlsl-binding`. (#3817)a23adc221

master
816 B29 linesraw
1//TEST:COMPARE_HLSL: -profile cs_5_0 -entry main
2
3// Confirm that we get the typing of literal suffixes correct
4
5// A type created to cause type-checking failures downstream
6struct Bad { int bad; };
7
8// We define two overloads for `foo()`. The "right" one takes
9// an unsigned integer, and returns it. The "wrong" one takes
10// a signed integer and returns a `Bad`.
11
12uint foo(uint x) { return x; }
13Bad foo(int x) { Bad b; b.bad = x; return b; }
14
15// The shader entry point will call `foo()` on a literal
16// with a suffix that should make it unsigned, so that
17// we either respect the suffix and call the right overload,
18// or ignore it and call the wrong one.
19
20#ifndef __SLANG__
21#define b b_0
22#endif
23
24RWStructuredBuffer<uint> b;
25[numthreads(32,1,1)]
26void main(uint3 tid : SV_DispatchThreadID)
27{
28	b[tid.x] = foo(99u);
29}