yum-mirror/slang

Making it easier to work with shaders

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

Yong Hegfx: support d3d12 root parameters (#2122)0c04885da

master
709 B32 linesraw
1// root-shader-parameter.slang
2
3// Test use of root shader parameters.
4[__AttributeUsage(_AttributeTargets.Var)]
5struct rootAttribute {};
6
7struct S1
8{
9    StructuredBuffer<uint> c0;
10    [root] RWStructuredBuffer<uint> c1;
11    StructuredBuffer<uint> c2;
12}
13
14struct S0
15{
16    StructuredBuffer<uint> b0;
17    [root] StructuredBuffer<uint> b1;
18    ParameterBlock<S1> s1;
19    ConstantBuffer<S1> s2;
20}
21
22ParameterBlock<S0> g;
23[root] RWStructuredBuffer<uint> buffer;
24
25[shader("compute")]
26[numthreads(1,1,1)]
27void computeMain(
28    uint3 sv_dispatchThreadID : SV_DispatchThreadID)
29{
30    buffer[0] = g.b0[0] - g.b1[0] + g.s1.c0[0] - g.s1.c1[0] + g.s1.c2[0] + g.s2.c0[0] - g.s2.c1[0] + g.s2.c2[0];
31    // 10-1+2-3+4+5-6+7
32}