summaryrefslogtreecommitdiff
path: root/tests/compute/global-type-param3.slang
blob: 05793dce4b3a3f1052d6248ff68e623185f67a2f (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
//TEST(smoke,compute):COMPARE_COMPUTE:-xslang -use-ir
//TEST_INPUT: cbuffer(data=[1.0], stride=4):dxbinding(0),glbinding(0)
//TEST_INPUT: ubuffer(data=[0], stride=4):dxbinding(0),glbinding(0),out
//TEST_INPUT: type Impl

RWStructuredBuffer<float> outputBuffer;

interface IBase
{
    float compute();
}

struct Impl : IBase
{
    float base;  // = 1.0
    float compute()
    {
        return 1.0;
    }
};

__generic_param TImpl : IBase;

ParameterBlock<TImpl> impl;

float doCompute<T:IBase>(T t)
{
    return t.compute();
}

[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
	uint tid = dispatchThreadID.x;
	float outVal = doCompute<TImpl>(impl); 
	outputBuffer[tid] = outVal;
}