summaryrefslogtreecommitdiffstats
path: root/tests/compute/assoctype-lookup.slang
blob: 8a032528bc70e40247ef959931c27d3a4eb59cc1 (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
// assoctype-nested.slang

// Confirm that an associated type can be correctly looked up.

//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj

interface IBoneWeightSet
{
    associatedtype PackedType;
};

struct StandardBoneWeightSet : IBoneWeightSet
{
    struct PackedType
    {
        uint boneIds;
        uint boneWeights;
    };
    PackedType field;
};

interface IVertexFormat
{
    associatedtype BoneWeightSet : IBoneWeightSet;
};

struct VertexFormat<TBoneWeightSet : IBoneWeightSet> : IVertexFormat
{
    typedef TBoneWeightSet BoneWeightSet;
    TBoneWeightSet.PackedType weightSet;
};

struct OutputType
{
    VertexFormat<StandardBoneWeightSet>.BoneWeightSet.PackedType field;
};

int test(int val)
{
    OutputType rs;
    rs.field.boneIds = 256;
    return int(rs.field.boneIds);
}

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

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    uint tid = dispatchThreadID.x;
    int inputVal = int(tid);
    int outputVal = test(inputVal);
    gOutputBuffer[tid] = outputVal;
}