summaryrefslogtreecommitdiffstats
path: root/tests/compute/interface-param-partial-specialize.slang
blob: 1d09c9f55b440c107ef8f90a70cab3887a06e61b (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
41
42
43
44
45
46
47
48
49
50
51
// Tests generating dynamic dispatch code for a function
// with existential-struct-typed param by specializing it
// with __Dynamic. This verifies that the handling of
// "partially" specializing an existential type is correct.

//DISABLED_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda -shaderobj
//DISABLED_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu -shaderobj

[anyValueSize(8)]
interface IInterface
{
    uint eval();
}

export struct Impl : IInterface
{
    uint val;
    uint eval()
    {
        return val;
    }
};

struct Params
{
    StructuredBuffer<IInterface> obj;
};

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
RWStructuredBuffer<uint> gOutputBuffer;

void compute(uint tid, Params p)
{
    gOutputBuffer[tid] = p.obj[0].eval();
}

//TEST_INPUT: entryPointExistentialType __Dynamic

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID,

//TEST_INPUT:begin_buffer(stride=8):name=params.obj
//TEST_INPUT:begin_object(type=Impl)
//TEST_INPUT:uniform(data=[1]):name=val
//TEST_INPUT:end
//TEST_INPUT:end
    uniform Params params)
{
	uint tid = dispatchThreadID.x;
	compute(tid, params);
}