yum-mirror/slang

Making it easier to work with shaders

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

ArielG-NVInitial `dyn` keyword support & `-lang 2026` compiler option (#7172)27c6e9b01

master
842 B30 linesraw
1// Test using interface typed shader parameters with texture typed fields.
2//TEST(compute):COMPARE_COMPUTE:-cpu
3//TEST(compute):COMPARE_COMPUTE:-cuda
4
5// Type must be marked `public` to ensure it is visible in the generated DLL.
6
7export struct MyImpl
8{
9    Texture2D tex;
10    float run()
11    {
12        return tex.Load({0, 0, 0}).x;
13    }
14};
15
16//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
17RWStructuredBuffer<uint> gOutputBuffer;
18//TEST_INPUT: set gCb = new StructuredBuffer<MyImpl>{new MyImpl{Texture2D(size=8, content = one)}}
19StructuredBuffer<MyImpl> gCb;
20
21[numthreads(4, 1, 1)]
22void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
23{
24    let tid = dispatchThreadID.x;
25
26    let inputVal : int = tid;
27    MyImpl v0 = gCb.Load(0);
28    let outputVal = v0.run();
29    gOutputBuffer[tid] = uint(trunc(outputVal));
30}