Move the transform and lighting code to two new directories
[mesa.git] / src / mesa / math / m_dotprod_tmp.h
1 /* $Id: m_dotprod_tmp.h,v 1.1 2000/11/16 21:05:41 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)( GLvector4f *out_vec,
35 GLuint elt,
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 outstride = out_vec->stride;
45 GLfloat *out = out_vec->start + elt;
46 GLuint i;
47
48 const GLfloat plane0 = plane[0], plane1 = plane[1], plane3 = plane[3];
49
50 (void) mask;
51
52 for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) {
53 CULL_CHECK {
54 *out = (coord[0] * plane0 +
55 coord[1] * plane1 +
56 plane3);
57 }
58 }
59 out_vec->count = coord_vec->count;
60 }
61
62 static void TAG(dotprod_vec3)( GLvector4f *out_vec,
63 GLuint elt,
64 const GLvector4f *coord_vec,
65 const GLfloat plane[4],
66 const GLubyte mask[])
67 {
68 GLuint stride = coord_vec->stride;
69 GLfloat *coord = coord_vec->start;
70 GLuint count = coord_vec->count;
71
72 GLuint outstride = out_vec->stride;
73 GLfloat *out = out_vec->start + elt;
74 GLuint i;
75
76 const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2];
77 const GLfloat plane3 = plane[3];
78
79 (void) mask;
80
81 for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) {
82 CULL_CHECK {
83 *out = (coord[0] * plane0 +
84 coord[1] * plane1 +
85 coord[2] * plane2 +
86 plane3);
87 }
88 }
89 out_vec->count = coord_vec->count;
90 }
91
92 static void TAG(dotprod_vec4)( GLvector4f *out_vec,
93 GLuint elt,
94 const GLvector4f *coord_vec,
95 const GLfloat plane[4],
96 const GLubyte mask[])
97 {
98 GLuint stride = coord_vec->stride;
99 GLfloat *coord = coord_vec->start;
100 GLuint count = coord_vec->count;
101
102 GLuint outstride = out_vec->stride;
103 GLfloat *out = out_vec->start + elt;
104 GLuint i;
105
106 const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2];
107 const GLfloat plane3 = plane[3];
108
109 (void) mask;
110
111 for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) {
112 CULL_CHECK {
113 *out = (coord[0] * plane0 +
114 coord[1] * plane1 +
115 coord[2] * plane2 +
116 coord[3] * plane3);
117 }
118 }
119 out_vec->count = coord_vec->count;
120 }
121
122
123 static void TAG(init_dotprod)( void )
124 {
125 gl_dotprod_tab[IDX&1][2] = TAG(dotprod_vec2);
126 gl_dotprod_tab[IDX&1][3] = TAG(dotprod_vec3);
127 gl_dotprod_tab[IDX&1][4] = TAG(dotprod_vec4);
128 }