yum-mirror/slang

Making it easier to work with shaders

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

skallweitNVenable more metal tests (#4326)712ce653d

master
987 B34 linesraw
1// matrix-swizzle.slang
2
3//TEST(compute):COMPARE_COMPUTE: -shaderobj
4
5// Test that matrix swizzle works correctly
6// Matrix swizzles can either be one or zero indexed
7// Reference: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-per-component-math
8
9int test(int val)
10{
11    float2x2 worldMatrix = float2x2(val + 0, val + 1, val + 2, val + 3);
12    float2 tempVector1;
13    float2 tempVector2;
14
15    // TODO: make left-hand side matrix swizzles work
16    tempVector1 = worldMatrix._m00_m11;
17    tempVector2 = worldMatrix._12_21;
18
19    // return tempMatrix[0][0] + tempMatrix[0][1] = val + 0 + val + 1
20    return int(tempVector1.x + tempVector2.x);
21}
22
23
24//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
25RWStructuredBuffer<int> outputBuffer;
26
27[numthreads(4, 1, 1)]
28void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
29{
30    int tid = dispatchThreadID.x;
31    int inVal = tid;
32    int outVal = test(inVal);
33    outputBuffer[tid] = outVal;
34}