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:-cpu -compute -shaderobj -output-using-type 2//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj -output-using-type 3//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type 4//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type 5 6// No 16-bit and 64-bit integer support on DX11. 7//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type -xslang -DDX11 8 9//TEST(compute, vulkan):SIMPLE(filecheck=CHECK_SPV): -stage compute -entry computeMain -target spirv 10 11//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 12RWStructuredBuffer<int> outputBuffer; 13 14[numthreads(1, 1, 1)] 15void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 16{ 17 int index = int(dispatchThreadID.x); 18 uint outIndex = 0; 19 20 // CHECK_SPV: OpSDot 21 int3 a = { index - 1, index - 2, index - 3}; 22 int3 b = { 1, 2, 3}; 23 outputBuffer[outIndex++] = dot(a, b); 24 25 // CHECK_SPV: OpUDot 26 uint3 c = { index + 1, index + 2, index + 3}; 27 uint3 d = { 2, 4, 6}; 28 outputBuffer[outIndex++] = int(dot(c, d)); 29 30#if !defined(DX11) 31 // CHECK_SPV: OpUDot 32 uint64_t2 e = { index + 1, index + 2}; 33 uint64_t2 f = { 4, 8}; 34 outputBuffer[outIndex++] = int(dot(e, f)); 35 36 // CHECK_SPV: OpSDot 37 int16_t4 g = { int16_t(index + 1), int16_t(index + 2), int16_t(index + 3), int16_t(index + 4)}; 38 int16_t4 h = { -1, 2, 2, -1}; 39 outputBuffer[outIndex++] = int(dot(g, h)); 40#else 41 outputBuffer[outIndex++] = 20; 42 outputBuffer[outIndex++] = 5; 43#endif 44}