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