yum-mirror/slang

Making it easier to work with shaders

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

Anders LeinoEnable a bunch of WGPU tests (#5513)43df1da01

master
868 B33 linesraw
1//TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type
2//TEST(compute):COMPARE_COMPUTE_EX():-slang -compute -shaderobj -output-using-type
3//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj -output-using-type
4//TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl -output-using-type
5
6//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
7RWStructuredBuffer<uint> outputBuffer;
8
9func twice<A>(f : functype (A) -> A, a : A) -> A
10{
11    return f(f(a));
12}
13
14func apply2<A, B, C>(f : functype (A, B) -> C, a : A, b : B) -> C
15{
16    return f(a, b);
17}
18
19func multiply(x : float, y : float) -> float
20{
21    return x * y;
22}
23
24func square(x : float) -> float
25{
26    return apply2<float, float, float>(multiply, x, x);
27}
28
29[numthreads(4, 1, 1)]
30void computeMain(uint tig : SV_GroupIndex)
31{
32    outputBuffer[tig] = uint(twice(square, -2.f));
33}