yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Anders LeinoWGSL: Support isnan, isinf, etc.. (#5609)ed123a9ca

master
915 B28 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
2//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
4//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
5//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
6
7// inf, -inf, nan, finite
8//TEST_INPUT:ubuffer(data=[ 0x7f800000 0xff800000 0x7fffffff 1 ], stride=4):name inputBuffer
9RWStructuredBuffer<float> inputBuffer;
10
11//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
12RWStructuredBuffer<int> outputBuffer;
13
14[numthreads(4, 1, 1)]
15void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
16{
17    int idx = int(dispatchThreadID.x);
18
19    float v = inputBuffer[idx];
20    
21    int flags = 0;
22    
23    flags |= isnan(v) ? 1 : 0;
24    flags |= isfinite(v) ? 2 : 0;
25    flags |= isinf(v) ? 4 : 0;
26    
27    outputBuffer[idx] = flags;
28}