summaryrefslogtreecommitdiffstats
path: root/tests/compute/dynamic-dispatch-bindless-texture.slang
blob: d3d40b2c5d7571b7f3291bba4ef676d71bf238cb (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
40
// 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: Texture2D(size=8, content = one):name t2D,bindless
//TEST_INPUT:ubuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) handle(t2D) 0 0], stride=4):name=gCb
StructuredBuffer<IInterface> gCb;

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

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

//TEST_INPUT: globalExistentialType __Dynamic

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