1617a3babSopenharmony_ci
2617a3babSopenharmony_ci// Test v*v, v*m, m*v, and m*m argument clamping.
3617a3babSopenharmony_ci
4617a3babSopenharmony_cicbuffer Matrix
5617a3babSopenharmony_ci{
6617a3babSopenharmony_ci    float4x4  m44;
7617a3babSopenharmony_ci    float4x3  m43;
8617a3babSopenharmony_ci    float3x4  m34;
9617a3babSopenharmony_ci    float3x3  m33;
10617a3babSopenharmony_ci    float2x4  m24;
11617a3babSopenharmony_ci    float4x2  m42;
12617a3babSopenharmony_ci    float4    v4;
13617a3babSopenharmony_ci    float3    v3;
14617a3babSopenharmony_ci    float2    v2;
15617a3babSopenharmony_ci}
16617a3babSopenharmony_ci
17617a3babSopenharmony_cifloat4 main() : SV_Target0
18617a3babSopenharmony_ci{
19617a3babSopenharmony_ci    // v*v:
20617a3babSopenharmony_ci    float  r00 = mul(v2, v3);  // float = float2*float3; // clamp to float2 dot product
21617a3babSopenharmony_ci    float  r01 = mul(v4, v2);  // float = float4*float2; // clamp to float2 dot product
22617a3babSopenharmony_ci
23617a3babSopenharmony_ci    // v*m
24617a3babSopenharmony_ci    float4 r10 = mul(v3, m44); // float4 = float3 * float4x4;  // clamp mat to float3x4;
25617a3babSopenharmony_ci    float4 r11 = mul(v4, m34); // truncate vector to vec3
26617a3babSopenharmony_ci
27617a3babSopenharmony_ci    // m*v
28617a3babSopenharmony_ci    float4 r20 = mul(m44, v3); // float4 = float4x4 * float3;  // clamp mat to float4x3;
29617a3babSopenharmony_ci    float4 r21 = mul(m43, v4); // truncate vector to vec3
30617a3babSopenharmony_ci
31617a3babSopenharmony_ci    // m*m
32617a3babSopenharmony_ci    float2x3 r30 = mul(m24, m33);  // float2x3 = float2x4 * float3x3;
33617a3babSopenharmony_ci    float3x4 r31 = mul(m33, m24);  // float3x4 = float3x3 * float2x4;
34617a3babSopenharmony_ci    float3x2 r32 = mul(m33, m42);  // float3x2 = float3x3 * float4x2;
35617a3babSopenharmony_ci    float4x3 r33 = mul(m42, m33);  // float4x3 = float4x2 * float3x3;
36617a3babSopenharmony_ci
37617a3babSopenharmony_ci    return r10 + r11 + r20 + r21 + r00 + r01 + r30[0].x + r31[0] + r32[0].x + transpose(r33)[0];
38617a3babSopenharmony_ci}
39