yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1//TEST(compute):COMPARE_COMPUTE_EX(filecheck=CHK):-cpu -compute -shaderobj 2// No support for int64_t on D3D11 (no sm 6.0) 3//DISABLE_TEST(compute):COMPARE_COMPUTE_EX(filecheck=CHK):-slang -compute -shaderobj 4// No support with Dx12 with dxbc. Needs SM6.0 + dxil 5//DISABLE_TEST(compute):COMPARE_COMPUTE_EX(filecheck=CHK):-slang -compute -dx12 -shaderobj 6//TEST(compute):COMPARE_COMPUTE_EX(filecheck=CHK):-slang -compute -profile cs_6_0 -dx12 -shaderobj -render-feature hardware-device 7//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck=CHK):-vk -compute -shaderobj -render-feature int64 8//TEST(compute):COMPARE_COMPUTE_EX(filecheck=CHK):-cuda -compute -shaderobj 9 10// The expected behavior is that the literal type is the first from the following list 11// in which the value can fit: 12// - For decimal bases: 13// - `int` 14// - `int64_t` 15// - For non-decimal bases: 16// - `int` 17// - `uint` 18// - `int64_t` 19// - `uint64_t` 20 21//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 22RWStructuredBuffer<uint64_t> outputBuffer; 23 24[numthreads(10, 1, 1)] 25void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 26{ 27 int idx = int(int64_t(dispatchThreadID.x)); 28 29 uint64_t v = 0; 30 31 if (idx == 0) 32 { 33 // Should be 0xffffffffffffffff 34 v = -1; 35 } 36 else if (idx == 1) 37 { 38 // Should be 0x00000000ffffffff 39 v = -1u; 40 } 41 else if (idx == 2) 42 { 43 // Should be 0x0000000080000000 44 v = 0x80000000u; 45 } 46 else if (idx == 3) 47 { 48 // Should be 0x0000000080000000 49 int64_t v0 = 0x80000000; 50 v = v0; 51 } 52 else if (idx == 4) 53 { 54 // Should be 0x0000000080000000. Shows hexadecimal literals can represent unsigned 32-bit integers. 55 v = 0x80000000; 56 } 57 else if (idx == 5) 58 { 59 // Should be 0xffffffffffffffff 60 v = ~0; 61 } 62 else if (idx == 6) 63 { 64 // Should be 0xffffffffffffffff 65 v = ~0LL; 66 } 67 else if (idx == 7) 68 { 69 // Should be 0x7fffffffffffffff. Shows decimal literals can represent 64-bit integers. 70 v = 9223372036854775807; 71 } 72 else if (idx == 8) 73 { 74 // Should be 1. Shows decimal literals can represent INT64_MIN or 0x8000000000000000. 75 // Warning will be emitted as negative(-) is scanned separately in the lexer, and the positive 76 // literal portion will emit a warning. 77 // The final value must be correctly set as INT64_MIN and must be negative. 78 if (-9223372036854775808 < 0L) 79 { 80 v = 1; 81 } 82 else 83 { 84 v = 0; 85 } 86 //CHK: warning 39999: integer literal is too large to be represented in a signed integer type, interpreting as unsigned 87 } 88 else 89 { 90 // Shoud be 0xfaaaaaaabaaaaaaa. Shows hexadecimal literals can represent unsigned 64-bit integers. 91 v = 0xfaaaaaaabaaaaaaa; 92 } 93 94 outputBuffer[idx] = v; 95}