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
920 B41 linesraw
1//TEST(smoke):COMPARE_HLSL: -profile ps_5_0 -entry main
2
3// Handle the case where the fragment shader output is
4// defined a structure, and the semantics are on the sub-fields
5
6#ifdef __SLANG__
7#define R(X) /**/
8#else
9#define R(X) X
10
11#define Foo Foo_0
12#define v v_0
13#define fooBuffer fooBuffer_0
14
15#endif
16
17float4 use(float  val) { return val; };
18float4 use(float2 val) { return float4(val,0.0,0.0); };
19float4 use(float3 val) { return float4(val,0.0); };
20float4 use(float4 val) { return val; };
21float4 use(Texture2D t, SamplerState s) { return t.Sample(s, 0.0); }
22
23struct Foo { float2 v; };
24
25// This should be allocated a register *after* the render targets
26RWStructuredBuffer<Foo> fooBuffer R(: register(u2));
27
28struct Fragment
29{
30	float4 color : SV_Target0;
31	float4 extra : SV_Target1;
32	
33};
34
35Fragment main()
36{
37	Fragment output;
38	output.color = use(fooBuffer[42].v);
39	output.extra = use(fooBuffer[999].v);
40	return output;
41}