blob: 4dc1ae61ab3bf6e4ea977338a89129e543c313c5 (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
//TEST(compute):COMPARE_COMPUTE_EX(filecheck=CHK):-cpu -compute -shaderobj
// No support for int64_t on D3D11 (no sm 6.0)
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX(filecheck=CHK):-slang -compute -shaderobj
// No support with Dx12 with dxbc. Needs SM6.0 + dxil
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX(filecheck=CHK):-slang -compute -dx12 -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX(filecheck=CHK):-slang -compute -profile cs_6_0 -dx12 -shaderobj -render-feature hardware-device
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck=CHK):-vk -compute -shaderobj -render-feature int64
//TEST(compute):COMPARE_COMPUTE_EX(filecheck=CHK):-cuda -compute -shaderobj
// The expected behavior is that the literal type is the first from the following list
// in which the value can fit:
// - For decimal bases:
// - `int`
// - `int64_t`
// - For non-decimal bases:
// - `int`
// - `uint`
// - `int64_t`
// - `uint64_t`
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<uint64_t> outputBuffer;
[numthreads(10, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
int idx = int(int64_t(dispatchThreadID.x));
uint64_t v = 0;
if (idx == 0)
{
// Should be 0xffffffffffffffff
v = -1;
}
else if (idx == 1)
{
// Should be 0x00000000ffffffff
v = -1u;
}
else if (idx == 2)
{
// Should be 0x0000000080000000
v = 0x80000000u;
}
else if (idx == 3)
{
// Should be 0x0000000080000000
int64_t v0 = 0x80000000;
v = v0;
}
else if (idx == 4)
{
// Should be 0x0000000080000000. Shows hexadecimal literals can represent unsigned 32-bit integers.
v = 0x80000000;
}
else if (idx == 5)
{
// Should be 0xffffffffffffffff
v = ~0;
}
else if (idx == 6)
{
// Should be 0xffffffffffffffff
v = ~0LL;
}
else if (idx == 7)
{
// Should be 0x7fffffffffffffff. Shows decimal literals can represent 64-bit integers.
v = 9223372036854775807;
}
else if (idx == 8)
{
// Should be 1. Shows decimal literals can represent INT64_MIN or 0x8000000000000000.
// Warning will be emitted as negative(-) is scanned separately in the lexer, and the positive
// literal portion will emit a warning.
// The final value must be correctly set as INT64_MIN and must be negative.
if (-9223372036854775808 < 0L)
{
v = 1;
}
else
{
v = 0;
}
//CHK: warning 39999: integer literal is too large to be represented in a signed integer type, interpreting as unsigned
}
else
{
// Shoud be 0xfaaaaaaabaaaaaaa. Shows hexadecimal literals can represent unsigned 64-bit integers.
v = 0xfaaaaaaabaaaaaaa;
}
outputBuffer[idx] = v;
}
|