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
850 B33 linesraw
1//TEST:COMPARE_HLSL: -profile ps_5_0 -entry main
2
3// Render target outputs (`SV_Target`) and UAVs are treated
4// as sharing the same binding slots in HLSL, so we need to
5// make sure that any `u` registers we allocate don't
6// interfere with render targets.
7
8#ifdef __SLANG__
9#define R(X) /**/
10#else
11#define R(X) X
12
13#define Foo Foo_0
14#define v v_0
15#define fooBuffer fooBuffer_0
16
17#endif
18
19float4 use(float  val) { return val; };
20float4 use(float2 val) { return float4(val,0.0,0.0); };
21float4 use(float3 val) { return float4(val,0.0); };
22float4 use(float4 val) { return val; };
23float4 use(Texture2D t, SamplerState s) { return t.Sample(s, 0.0); }
24
25struct Foo { float2 v; };
26
27// This should be allocated a register *after* the render target
28RWStructuredBuffer<Foo> fooBuffer R(: register(u1));
29
30float4 main() : SV_TARGET
31{
32	return use(fooBuffer[12].v);
33}