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