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 2// No support for uint64_t on DX11 3//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 4// No support for uint64_t on fxc - we need SM6.0 and dxil 5// https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/hlsl-shader-model-6-0-features-for-direct3d-12 6//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj 7//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -shaderobj -render-feature hardware-device 8//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -render-feature int64 9//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj 10//TEST(compute, metal):COMPARE_COMPUTE_EX:-slang -compute -mtl 11 12//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 13RWStructuredBuffer<int> outputBuffer; 14 15[numthreads(4, 1, 1)] 16void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 17{ 18 uint64_t idx = dispatchThreadID.x; 19 20 uint64_t ti = 0; 21 22 ti += max(2, idx); 23 ti += min(idx, 1ull); 24 ti += clamp(idx * 10, 11, 23); 25 26 ti += countbits(uint(idx * 13)); 27 28 // Math 29 ti = ti - idx; 30 ti = ti + (ti % (idx + 5)); 31 ti = ti + (ti / (idx + 20)); 32 33 // Logical ops 34 ti = ti | idx; 35 ti = ti ^ (idx & (idx + 1)); 36 37 // Shift 38 ti = ti + (idx >> 1); 39 ti = ti + (idx << 2); 40 41 uint64_t v = uint64_t(ti) * 0x8000100354354354ull; 42 // Let's check all the bits make it 43 uint64_t u = v | 0x8000000000000000ull; 44 45 v = max(u, v); 46 47 outputBuffer[dispatchThreadID.x] = int(v) ^ int(v >> 32); 48}