yum-mirror/slang

Making it easier to work with shaders

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

Yong HeVarious Fixes to gfx, reflection and emit. (#1867)e67af5b1a

master
1.3 KiB35 linesraw
1// default-major.slang
2
3// The default layout should be column. 
4// This test is disabled because `gfx` layer always initializes Slang to use row-major layout.
5// To test this behavior we need to find a way to make `gfx` use Slang default instead.
6// Unfortunately CPU and CUDA only work with row layout, so they have to be disabled here.
7
8//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -compile-arg -O3 -shaderobj
9//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -shaderobj
10//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -dx12 -shaderobj
11//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj
12//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj
13
14// This data is in column major layout order.... 
15//TEST_INPUT:cbuffer(data=[1.0 0.0 0.0 10.0  0.0 1.0 0.0 20.0  0.0 0.0 1.0 30.0  0.0 0.0 0.0 1.0]):name matrixBuffer
16
17ConstantBuffer<float4x4> matrixBuffer;
18
19//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name output
20RWStructuredBuffer<float> output;
21
22[numthreads(1, 1, 1)]
23void computeMain(uint3 tid : SV_DispatchThreadID)
24{
25    float4 v = float4(1, 2, 3, 1);
26
27    float4x4 M = matrixBuffer;
28    
29    float4 r = mul(v, M);
30
31    output[0] = r.x;
32    output[1] = r.y;
33    output[2] = r.z;
34    output[3] = r.w;
35}