blob: 377ef622dad9ea2d865506efac6126179524e994 (
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
|
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -cpu -shaderobj
// CHECK: 5
// CHECK-NEXT: 1
// CHECK-NEXT: 0
//TEST_INPUT:ubuffer(data=[0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
enum MyError
{
Fail = 1
};
T func<T: __BuiltinFloatingPointType>(T val) throws MyError
{
do
{
if (val >= T(3))
throw MyError.Fail;
return val * T(2);
}
catch(err: MyError)
{
// Just rethrow to test catching inside a generic as well.
throw err;
}
}
[numthreads(1, 1, 1)]
void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
{
int i = 0;
do
{
outputBuffer[i] = int(try func(2.5f));
i+=1;
outputBuffer[i] = int(try func(3.5f));
i+=1;
}
catch(err: MyError)
{
outputBuffer[i] = reinterpret<int>(err);
}
}
|