summaryrefslogtreecommitdiffstats
path: root/tests/compute/dynamic-dispatch-bindless-texture.slang
blob: 34ef67d1e398c700435c750875720d5ff80f8304 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Test using interface typed shader parameters with texture typed fields.
//TEST(compute):COMPARE_COMPUTE:-cpu
//TEST(compute):COMPARE_COMPUTE:-cuda

[anyValueSize(16)]
interface IInterface
{
    float run();
}

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
RWStructuredBuffer<uint> gOutputBuffer;
//TEST_INPUT: set gCb = new StructuredBuffer<IInterface>{new MyImpl{Texture2D(size=8, content = one), Sampler}}
StructuredBuffer<IInterface> gCb;

[numthreads(4, 1, 1)]
void computeMain(int3       dispatchThreadID : SV_DispatchThreadID)
{
    let tid = dispatchThreadID.x;

    let inputVal : int = tid;
    IInterface v0 = gCb.Load(0);
    SamplerState sampler;
    let outputVal = v0.run();
    gOutputBuffer[tid] = uint(trunc(outputVal));
}

//TEST_INPUT: globalExistentialType __Dynamic

// Type must be marked `public` to ensure it is visible in the generated DLL.
export struct MyImpl : IInterface
{
    Texture2D tex;
    SamplerState sampler;
    float run()
    {
        return tex.Sample(sampler, float2(0.0, 0.0)).x;
    }
};