blob: efedbb06c8d7933640c0158cad83b6b6f234b772 (
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
|
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -shaderobj -output-using-type
struct Functor : IMutatingFunc<float, float>
{
int context;
[mutating]
float operator()(float p)
{
context += (int)p;
return context;
}
}
float apply<T:IMutatingFunc<float,float>>(inout T f, float p)
{
return f(p);
}
//TEST_INPUT:ubuffer(data=[0 3 2 2], stride=4):out,name=outputBuffer
RWStructuredBuffer<uint> outputBuffer;
[numthreads(1, 1, 1)]
void computeMain(uint tid: SV_DispatchThreadID)
{
Functor f;
f.context = 0;
f(1.0f);
f.operator()(1.0f); // explicit operator () call should also work.
apply(f, 2.0f);
apply(f, 3.0f);
// CHECK: 7
outputBuffer[0] = (uint)f.context;
}
|