source: trunk/src/opengl/mesa/vertices.c

Last change on this file was 3598, checked in by jeroen, 25 years ago

* empty log message *

File size: 5.3 KB
Line 
1/* $Id: vertices.c,v 1.3 2000-05-23 20:41:04 jeroen Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version: 3.3
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#include "glheader.h"
28#include "types.h"
29#include "vertices.h"
30
31#if defined(USE_X86_ASM)
32#include "common_x86asm.h"
33#endif
34
35/* The start of a bunch of vertex oriented geometry routines. These
36 * are expected to support the production of driver-specific fast paths
37 * for CVA and eventually normal processing.
38 *
39 * These have been taken from fxfastpath.c, and are now also used in
40 * the mga driver.
41 *
42 * These should grow to include:
43 * - choice of 8/16 dword vertices
44 * - ??
45 * - use of portable assembly layouts.
46 *
47 * More tentatively:
48 * - more (all?) matrix types
49 * - more (?) vertex sizes
50 *
51 * -- Keith Whitwell.
52 */
53
54/* The inline 3dnow code seems to give problems with some peoples
55 * compiler/binutils.
56 */
57/* #undef USE_3DNOW_ASM */
58
59
60#if defined(USE_X86_ASM) && defined(__GNUC__)
61
62
63#endif
64
65
66static void _PROJAPI transform_v16(GLfloat *f,
67 const GLfloat *m,
68 const GLfloat *obj,
69 GLuint obj_stride,
70 GLuint count )
71{
72 GLuint i;
73
74 for (i = 0 ; i < count ; i++, STRIDE_F(obj, obj_stride), f+=16)
75 {
76 const GLfloat ox = obj[0], oy = obj[1], oz = obj[2];
77 f[0] = m[0] * ox + m[4] * oy + m[8] * oz + m[12];
78 f[1] = m[1] * ox + m[5] * oy + m[9] * oz + m[13];
79 f[2] = m[2] * ox + m[6] * oy + m[10] * oz + m[14];
80 f[3] = m[3] * ox + m[7] * oy + m[11] * oz + m[15];
81 }
82}
83
84/* Project all vertices upto but not including last. Guarenteed to be
85 * at least one such vertex.
86 */
87static void _PROJAPI project_verts(GLfloat *first,
88 GLfloat *last,
89 const GLfloat *m,
90 GLuint stride )
91{
92 const GLfloat sx = m[0], sy = m[5], sz = m[10];
93 const GLfloat tx = m[12], ty = m[13], tz = m[14];
94 GLfloat *f;
95
96 for ( f = first ; f != last ; STRIDE_F(f,stride))
97 {
98 const GLfloat oow = 1.0F / f[3];
99 f[0] = sx * f[0] * oow + tx;
100 f[1] = sy * f[1] * oow + ty;
101 f[2] = sz * f[2] * oow + tz;
102 f[3] = oow;
103 }
104}
105
106static void _PROJAPI project_clipped_verts(GLfloat *first,
107 GLfloat *last,
108 const GLfloat *m,
109 GLuint stride,
110 const GLubyte *clipmask )
111{
112 const GLfloat sx = m[0], sy = m[5], sz = m[10];
113 const GLfloat tx = m[12], ty = m[13], tz = m[14];
114 GLfloat *f;
115
116 for ( f = first ; f != last ; STRIDE_F(f,stride), clipmask++)
117 {
118 if (!*clipmask) {
119 const GLfloat oow = 1.0F / f[3];
120 f[0] = sx * f[0] * oow + tx;
121 f[1] = sy * f[1] * oow + ty;
122 f[2] = sz * f[2] * oow + tz;
123 f[3] = oow;
124 }
125 }
126}
127
128
129
130
131static void _PROJAPI cliptest_v16( GLfloat *first,
132 GLfloat *last,
133 GLubyte *p_clipOr,
134 GLubyte *p_clipAnd,
135 GLubyte *clipmask )
136{
137 GLubyte clipAnd = (GLubyte) ~0;
138 GLubyte clipOr = 0;
139 GLfloat *f = first;
140 static int i;
141 i = 0;
142
143 for ( ; f != last ; f+=16, clipmask++, i++)
144 {
145 const GLfloat cx = f[0];
146 const GLfloat cy = f[1];
147 const GLfloat cz = f[2];
148 const GLfloat cw = f[3];
149 GLubyte mask = 0;
150
151 if (cx > cw) mask |= CLIP_RIGHT_BIT;
152 if (cx < -cw) mask |= CLIP_LEFT_BIT;
153 if (cy > cw) mask |= CLIP_TOP_BIT;
154 if (cy < -cw) mask |= CLIP_BOTTOM_BIT;
155 if (cz > cw) mask |= CLIP_FAR_BIT;
156 if (cz < -cw) mask |= CLIP_NEAR_BIT;
157
158 *clipmask = mask;
159 clipAnd &= mask;
160 clipOr |= mask;
161 }
162
163 (*p_clipOr) |= clipOr;
164 (*p_clipAnd) &= clipAnd;
165}
166
167
168
169GLenum gl_reduce_prim[GL_POLYGON+1] = {
170 GL_POINTS,
171 GL_LINES,
172 GL_LINES,
173 GL_LINES,
174 GL_TRIANGLES,
175 GL_TRIANGLES,
176 GL_TRIANGLES,
177 GL_TRIANGLES,
178 GL_TRIANGLES,
179 GL_TRIANGLES,
180};
181
182gl_transform_func gl_xform_points3_v16_general = transform_v16;
183gl_cliptest_func gl_cliptest_points4_v16 = cliptest_v16;
184gl_project_clipped_func gl_project_clipped_v16 = project_clipped_verts;
185gl_project_func gl_project_v16 = project_verts;
186
187void gl_init_vertices()
188{
189}
Note: See TracBrowser for help on using the repository browser.