]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/3d-matrix-vector/3d-matrix-vector.factor
factor: trim using lists
[factor.git] / extra / benchmark / 3d-matrix-vector / 3d-matrix-vector.factor
1 USING: kernel math math.matrices.simd math.vectors
2 math.vectors.simd prettyprint typed ;
3 QUALIFIED-WITH: alien.c-types c
4 IN: benchmark.3d-matrix-vector
5
6 : v2min ( xy -- xx )
7     dup { 1 0 2 3 } vshuffle vmin ; inline
8
9 TYPED:: p-matrix ( dim: float-4 fov: float near: float far: float -- matrix: matrix4 )
10     dim dup v2min v/ fov v*n near v*n
11     near far frustum-matrix4 ;
12
13 TYPED:: mv-matrix ( pitch: float yaw: float location: float-4 -- matrix: matrix4 )
14     float-4{ 1.0 0.0 0.0 0.0 } pitch rotation-matrix4
15     float-4{ 0.0 1.0 0.0 0.0 } yaw   rotation-matrix4
16     location vneg translation-matrix4 m4. m4. ;
17
18 :: 3d-matrix-vector-benchmark ( -- )
19     f :> result!
20     100000 [
21         float-4{ 1024.0 768.0 0.0 0.0 } 0.7 0.25 1024.0 p-matrix :> p
22         3.0 1.0 float-4{ 10.0 -0.0 2.0 0.0 } mv-matrix :> mv
23         mv p m4. result!
24     ] times
25     result . ;
26
27 MAIN: 3d-matrix-vector-benchmark