yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
b86703432
master
1// non-square-row-major.slang 2 3// Note! This test doesn't work on CUDA or CPU targets, because both these targets 4// assume matrices are tightly packed, whereas GPU targets align rows to 16 bytes. 5 6//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=ALIGNED):-slang -compute -wgpu -output-using-type -xslang -matrix-layout-row-major -shaderobj 7//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=PACKED):-cpu -compute -output-using-type -compile-arg -O3 -xslang -matrix-layout-row-major -shaderobj 8//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=ALIGNED):-slang -compute -output-using-type -xslang -matrix-layout-row-major -shaderobj 9//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=ALIGNED):-slang -compute -dx12 -output-using-type -xslang -matrix-layout-row-major -shaderobj 10//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=ALIGNED):-vk -compute -output-using-type -xslang -matrix-layout-row-major -shaderobj 11//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=PACKED):-cuda -compute -output-using-type -xslang -matrix-layout-row-major -shaderobj 12//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=PACKED): -slang -output-using-type -shaderobj -mtl 13 14// matrix<R, C> 15//TEST_INPUT:cbuffer(data=[1.0 2.0 3.0 4.0 5.0 6.0 0.0 0.0 10.0 20.0 0.0 0.0 ]):name matrixBuffer 16ConstantBuffer<float3x2> matrixBuffer; 17 18//TEST_INPUT:ubuffer(data=[0 0], stride=4):out,name output 19RWStructuredBuffer<float> output; 20 21[numthreads(1, 1, 1)] 22void computeMain(uint3 tid : SV_DispatchThreadID) 23{ 24 float3 v = float3(1, 2, 1); 25 26 float3x2 M = matrixBuffer; 27 28 float2 r = mul(v, M); 29 30 // ALIGNED: 21 31 // ALIGNED: 34 32 33 // PACKED: 12 34 // PACKED: 16 35 output[0] = r.x; 36 output[1] = r.y; 37}