summaryrefslogtreecommitdiffstats
path: root/tests/compute/interface-shader-param-legalization.slang
blob: 717e786e3af84d0281456feff4e05dccc32dc265 (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
52
53
54
55
56
57
58
59
60
// interface-shader-param-legalization.slang

// Test case where concrete type implementing
// an interface has resource-type fields nested in it.

//DISABLED_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute

interface IModifier
{
    int modify(int val);
}

// Note: a constant buffer for the global scope gets introduced
// at this point, since `gModifier` introduces uniform storage
// for the RTTI, witness table, and "any value" parts of the
// existential.
//
//TEST_INPUT:cbuffer(data=[1 2 3 4 5 6 7 8], stride=4):
uniform IModifier gModifier;

int test(
    int val)
{
    return gModifier.modify(val);
}


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

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

    let inputVal : int = tid;
    let outputVal = test(inputVal);

    gOutputBuffer[tid] = outputVal;
}

// Now that we've define all the logic of the entry point,
// we will define some concrete types that we can plug
// in for the interface-type parameters.

struct ConcreteData
{
    int offset;
}

struct ConcreteModifier : IModifier
{
    ConstantBuffer<ConcreteData> data;

    int modify(int val) { return val + data.offset; }
}

//TEST_INPUT: globalExistentialType ConcreteModifier
//TEST_INPUT:cbuffer(data=[256], stride=4):out