yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1// Here we are going to do a very simple calculation with double. 2// For simplicity we are not going to use any intrinsics, and not use any resources that use double 3 4//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj 5//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -render-feature double 6//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj 7//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -shaderobj 8//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -render-feature double 9//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj 10//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl 11// Not supported in WGSL: Double and other unsupported scalar types 12//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu 13 14//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer 15RWStructuredBuffer<uint> outputBuffer; 16 17[numthreads(4, 1, 1)] 18void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 19{ 20 int idx = int(dispatchThreadID.x); 21 22 double f = idx * (1.0l / (4.0l)); 23 24 f = 1.0l / f; 25 26 { 27 uint low, high; 28 asuint(f * 2.0l, low, high); 29 outputBuffer[idx * 2 + 0] = low; 30 outputBuffer[idx * 2 + 1] = high; 31 } 32}