summaryrefslogtreecommitdiffstats
path: root/tests/compute/int-generic.slang
blob: f5839a6c59b24de4e0a5aae190f7edd7ef1128bf (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
//DISABLED_TEST(compute):COMPARE_COMPUTE: -shaderobj
//TEST(compute):COMPARE_COMPUTE: -shaderobj -cuda

//TEST_INPUT:type Material<1,2>

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

interface IBRDF
{
    int compute();
};

interface IMaterial
{
    associatedtype TBRDF : IBRDF;
    TBRDF getBRDF();
}

struct BRDF<let A:int, let B:int> : IBRDF
{
    int c;
    int compute()
    {
        return A+B;        
    }
};

struct Material<let A:int, let B: int> : IMaterial
{
    typedef BRDF<A,B> TBRDF;
    TBRDF getBRDF() { TBRDF a; a.c = 0; return a; }
};

[numthreads(1, 1, 1)]
void computeMain<M : IMaterial>(
    uniform M material,
    uint3 dispatchThreadID : SV_DispatchThreadID)
{
    M.TBRDF brdf = material.getBRDF();
	int outVal = brdf.compute();
	outputBuffer[dispatchThreadID.x] = outVal;
}