Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / mesa / math / m_dotprod_tmp.h
1
2 /*
3  * Mesa 3-D graphics library
4  * Version:  3.5
5  *
6  * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included
16  * in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25
26 /*
27  * New (3.1) transformation code written by Keith Whitwell.
28  */
29
30
31 /* Note - respects the stride of the output vector.
32  */
33 static void TAG(dotprod_vec2)( GLfloat *out,
34                                GLuint outstride,
35                                const GLvector4f *coord_vec,
36                                const GLfloat plane[4] )
37 {
38    GLuint stride = coord_vec->stride;
39    GLfloat *coord = coord_vec->start;
40    GLuint count = coord_vec->count;
41
42    GLuint i;
43
44    const GLfloat plane0 = plane[0], plane1 = plane[1], plane3 = plane[3];
45
46    for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) {
47       *out = (coord[0] * plane0 +
48               coord[1] * plane1 +
49               plane3);
50    }
51 }
52
53 static void TAG(dotprod_vec3)( GLfloat *out,
54                                GLuint outstride,
55                                const GLvector4f *coord_vec,
56                                const GLfloat plane[4] )
57 {
58    GLuint stride = coord_vec->stride;
59    GLfloat *coord = coord_vec->start;
60    GLuint count = coord_vec->count;
61
62    GLuint i;
63
64    const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2];
65    const GLfloat plane3 = plane[3];
66
67    for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) {
68       *out = (coord[0] * plane0 +
69               coord[1] * plane1 +
70               coord[2] * plane2 +
71               plane3);
72    }
73 }
74
75 static void TAG(dotprod_vec4)( GLfloat *out,
76                                GLuint outstride,
77                                const GLvector4f *coord_vec,
78                                const GLfloat plane[4] )
79 {
80    GLuint stride = coord_vec->stride;
81    GLfloat *coord = coord_vec->start;
82    GLuint count = coord_vec->count;
83    GLuint i;
84
85    const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2];
86    const GLfloat plane3 = plane[3];
87
88    for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) {
89       *out = (coord[0] * plane0 +
90               coord[1] * plane1 +
91               coord[2] * plane2 +
92               coord[3] * plane3);
93    }
94 }
95
96
97 static void TAG(init_dotprod)( void )
98 {
99    _mesa_dotprod_tab[2] = TAG(dotprod_vec2);
100    _mesa_dotprod_tab[3] = TAG(dotprod_vec3);
101    _mesa_dotprod_tab[4] = TAG(dotprod_vec4);
102 }