2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/common/math.h>
24 void Dali::Internal::TransformVector3( Vec3 result, const Mat4 m, const Vec3 v )
28 result[0] = v[0] * m[0] + v[1] * m[4] + v[2] * m[8];
29 result[1] = v[0] * m[1] + v[1] * m[5] + v[2] * m[9];
30 result[2] = v[0] * m[2] + v[1] * m[6] + v[2] * m[10];
34 Vec4 temp = { v[0], v[1], v[2], 0.0f };
37 asm volatile ( "VLD1.F32 {q0}, [%1] \n\t" //Load "temp" from memory to register q0
38 "VLD1.F32 {q1}, [%0]! \n\t" //Load first row of the matrix from memory to register q1
39 "VMUL.F32 q2, q1, d0[0] \n\t" //q2 = (m[0..3] * v.x)
40 "VLD1.F32 {q1}, [%0]! \n\t" //Load second row of the matrix from memory
41 "VMLA.F32 q2, q1, d0[1] \n\t" //q2 = (m[0..3] * v.x) + (m[4..7] * v.y)
42 "VLD1.F32 {q1}, [%0]! \n\t" //Load third row of the matrix from memory
43 "VMLA.F32 q2, q1, d1[0] \n\t" //q2 = (m[0..3] * v.x) + (m[4..7] * v.y) + (m[8...11] * v.z)
44 "VST1.F32 {q2}, [%2] \n\t" //Write the result back to memory
46 : "r"(m), "r"(temp), "r"(tempResult)
47 : "q0", "q1", "q2", "memory" );
49 result[0] = tempResult[0];
50 result[1] = tempResult[1];
51 result[2] = tempResult[2];
56 float Dali::Internal::Length( const Vec3 v )
58 return sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);