yum-mirror/slang

Making it easier to work with shaders

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

Anders LeinoUpdate Slang-RHI again to get more WGPU fixes (#5475)e1c3c4ae3

master
1.5 KiB37 linesraw
1// non-square-column-major.slang
2
3// Note! This test doesn't work on CUDA or CPU targets, because both these targets ignore
4// row/column major setting, as well as they handle alignment differently.
5
6//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -compile-arg -O3 -xslang -matrix-layout-column-major -shaderobj
7//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -xslang -matrix-layout-column-major -shaderobj
8//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type -xslang -matrix-layout-column-major -shaderobj
9//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -xslang -matrix-layout-column-major -shaderobj
10//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -xslang -matrix-layout-column-major -shaderobj
11//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=METAL):-slang  -output-using-type -shaderobj -mtl
12
13// matrix<R, C>
14//TEST_INPUT:cbuffer(data=[1.0 0.0 10.0 0.0  0.0 1.0 20.0 0.0]):name matrixBuffer
15ConstantBuffer<float3x2> matrixBuffer;
16
17//TEST_INPUT:ubuffer(data=[0 0], stride=4):out,name output
18RWStructuredBuffer<float> output;
19
20[numthreads(1, 1, 1)]
21void computeMain(uint3 tid : SV_DispatchThreadID)
22{
23    float3 v = float3(1, 2, 1);
24
25    float3x2 M = matrixBuffer;
26    
27    float2 r = mul(v, M);
28
29    // Metal always uses scalar layout + row major, so it is computing
30    //              [1  0]
31    // [ 1 2 1]  *  [10 0]  = [ 21 1 ]
32    //              [0  1]
33    // METAL: 21
34    // METAL: 1
35    output[0] = r.x;
36    output[1] = r.y;
37}