yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
9261c7a23
master
1// It doesn't look like fxc, dxc, vk support double versions of many of the intrinsics, so they are disabled here. 2 3// TODO(JS): 4// NOTE! war-double-host-callable category is a work around for issues with x86 & host-callable 5 6//TEST(compute, war-double-host-callable):COMPARE_COMPUTE_EX:-cpu -compute 7//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute 8//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 9//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -render-feature double 10//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute 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 int idx = int(dispatchThreadID.x); 19 20 double f = idx * (1.0f / (4.0f)); 21 22 int it = 0; 23 double ft = 0.0l; 24 25 // fmod 26 ft += int(((f % 0.11l) * 100) + 0.5l); 27 28 ft += sin(f); 29 ft += cos(f); 30 ft += tan(f); 31 32 ft += asin(f); 33 ft += acos(f); 34 ft += atan(f); 35 36 ft += atan2(f, 2.0l); 37 38 { 39 double sf, cf; 40 sincos(f, sf, cf); 41 42 ft += sf; 43 ft += cf; 44 } 45 46 ft += rcp(1.0l + f); 47 ft += sign(f - 0.5l); 48 49 ft += saturate(f * 4 - 2.0l); 50 51 ft += sqrt(f); 52 ft += rsqrt(1.0l + f); 53 54 ft += exp2(f); 55 ft += exp(f); 56 57 58 ft += frac(f * 3); 59 ft += ceil(f * 5 - 3); 60 61 ft += floor(f * 10 - 7); 62 ft += trunc(f * 7); 63 64 ft += log(f + 10.0l); 65 ft += log2(f * 3 + 2); 66 67 { 68 double v[] = { 1, 10, 100, 1000 }; 69 ft += int(log10(v[idx]) + 0.5l); 70 } 71 72 ft += abs(f * 4 - 2.0l); 73 74 ft += min(0.5l, f); 75 ft += max(f, 0.75l); 76 77 ft += pow(0.5l, f); 78 79 ft += smoothstep(0.2l, 0.7l, f); 80 ft += lerp(-100.0l, 100.0l, f); 81 82 ft += clamp(f, 0.1l, 0.3l); 83 84 ft += step(f, 0.5l); 85 86 { 87 uint low, high; 88 asuint(f * 2.0l, low, high); 89 ft += asdouble(low, high); 90 } 91 92 ft += ldexp(23.2, f); 93 94 outputBuffer[idx] = int(ft * 16); 95}