yum-mirror/slang

Making it easier to work with shaders

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

aidanfnvAdd slang-test check for D3D11 double support (#6761)28006e36d

master
1.2 KiB31 linesraw
1//TEST(compute):COMPARE_COMPUTE:-cuda -output-using-type -shaderobj
2//TEST(compute):COMPARE_COMPUTE:-cpu -output-using-type -shaderobj
3//TEST(compute):COMPARE_COMPUTE: -output-using-type -shaderobj -render-feature double
4
5// Cos values are all 0 on D3d12(!)
6//DISABLE_TEST(compute):COMPARE_COMPUTE: -dx12 -output-using-type -shaderobj
7// When using double on vulkan the values are incorrect(!)
8//DISABLE_TEST(compute,vulkan):COMPARE_COMPUTE:-vk -output-using-type -shaderobj
9//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
10// Not supported in WGSL: Double and other unsupported scalar types
11//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -wgpu
12
13//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
14RWStructuredBuffer<float> outputBuffer;
15
16float quantize(double value)
17{
18    return int(value * 256) * 1.0f / 256.0f;
19}
20
21[numthreads(4, 1, 1)]
22void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
23{
24    float values[] = { -9, 9, -3, 3 };
25
26	int tid = int(dispatchThreadID.x);
27    float value = values[tid];
28    
29    outputBuffer[tid * 2 + 0] = quantize(sin(double(value)));
30    outputBuffer[tid * 2 + 1] = quantize(cos(double(value)));
31}