yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
e0c20a076
master
1// This test is to see what intrinsics are available on VK 2 3//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj 4//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj -render-feature double 5 6//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type 7 8//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer 9RWStructuredBuffer<double> outputBuffer; 10 11[numthreads(4, 1, 1)] 12void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 13{ 14 int idx = int(dispatchThreadID.x); 15 16 double f = idx * (1.0f / (4.0f)); 17 18 double ft = 0.0l; 19 20 // fmod 21 ft += int(((f % 0.11l) * 100) + 0.5l); 22 23 ft += rcp(1.0l + f); 24 ft += sign(f - 0.5l); 25 26 ft += saturate(f * 4 - 2.0l); 27 28 ft += sqrt(f); 29 ft += rsqrt(1.0l + f); 30 31 ft += frac(f * 3); 32 ft += ceil(f * 5 - 3); 33 34 ft += floor(f * 10 - 7); 35 ft += trunc(f * 7); 36 37 ft += abs(f * 4 - 2.0l); 38 39 ft += min(0.5l, f); 40 ft += max(f, 0.75l); 41 42 ft += smoothstep(0.2l, 0.7l, f); 43 ft += lerp(-100.0l, 100.0l, f); 44 45 ft += clamp(f, 0.1l, 0.3l); 46 47 ft += step(f, 0.5l); 48 49 { 50 uint low, high; 51 asuint(f * 2.0l, low, high); 52 ft += asdouble(low, high); 53 } 54 55 outputBuffer[idx] = ft; 56}