• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Mesa 3-D graphics library
4  *
5  * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23  * 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  */
TAG(dotprod_vec2)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 
TAG(dotprod_vec3)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 
TAG(dotprod_vec4)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 
TAG(init_dotprod)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 }
103