1 | /* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
|
---|
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 | * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
|
---|
28 | * terms stated above.
|
---|
29 | *
|
---|
30 | * Thank you for your contribution, David!
|
---|
31 | *
|
---|
32 | * Please make note of the above copyright/license statement. If you
|
---|
33 | * contributed code or bug fixes to this code under the previous (GNU
|
---|
34 | * Library) license and object to the new license, your code will be
|
---|
35 | * removed at your request. Please see the Mesa docs/COPYRIGHT file
|
---|
36 | * for more information.
|
---|
37 | *
|
---|
38 | * Additional Mesa/3Dfx driver developers:
|
---|
39 | * Daryll Strauss <daryll@precisioninsight.com>
|
---|
40 | * Keith Whitwell <keith@precisioninsight.com>
|
---|
41 | *
|
---|
42 | * See fxapi.h for more revision/author details.
|
---|
43 | */
|
---|
44 |
|
---|
45 |
|
---|
46 | /* fxrender.c - 3Dfx VooDoo RenderVB driver function support */
|
---|
47 |
|
---|
48 |
|
---|
49 | #ifdef HAVE_CONFIG_H
|
---|
50 | #include "conf.h"
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | #if defined(FX)
|
---|
54 |
|
---|
55 | #include "fxdrv.h"
|
---|
56 | #include "vbcull.h"
|
---|
57 |
|
---|
58 | /*
|
---|
59 | * Render a line segment from VB[v1] to VB[v2] when either one or both
|
---|
60 | * endpoints must be clipped.
|
---|
61 | */
|
---|
62 | //#if !defined(__MWERKS__)
|
---|
63 | //INLINE /* function is accessed in fxcva.c! */
|
---|
64 | //#endif
|
---|
65 | void fxRenderClippedLine( struct vertex_buffer *VB,
|
---|
66 | GLuint v1, GLuint v2 )
|
---|
67 | {
|
---|
68 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
|
---|
69 | GLubyte mask = VB->ClipMask[v1] | VB->ClipMask[v2];
|
---|
70 |
|
---|
71 | if (!mask || (VB->ctx->line_clip_tab[VB->ClipPtr->size])(VB, &v1, &v2, mask))
|
---|
72 | FX_grDrawLine((GrVertex *)gWin[v1].f,(GrVertex *)gWin[v2].f);
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|
78 | /* This is legal for Quads as well as triangles, hence the 'n' parameter.
|
---|
79 | */
|
---|
80 | INLINE void fxRenderClippedTriangle( struct vertex_buffer *VB,
|
---|
81 | GLuint n, GLuint vlist[] )
|
---|
82 | {
|
---|
83 | GLubyte mask = 0;
|
---|
84 | GLuint i;
|
---|
85 |
|
---|
86 | for (i = 0 ; i < n ; i++)
|
---|
87 | mask |= VB->ClipMask[vlist[i]];
|
---|
88 |
|
---|
89 | if (mask & CLIP_USER_BIT) {
|
---|
90 | GLubyte *userclipmask = VB->UserClipMask;
|
---|
91 | if (userclipmask[vlist[0]] & userclipmask[vlist[1]] & userclipmask[vlist[2]])
|
---|
92 | return;
|
---|
93 | }
|
---|
94 |
|
---|
95 | n = (VB->ctx->poly_clip_tab[VB->ClipPtr->size])( VB, n, vlist, mask );
|
---|
96 | if (n >= 3) {
|
---|
97 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
|
---|
98 | GrVertex *i0 = (GrVertex *)gWin[vlist[0]].f;
|
---|
99 | GrVertex *i1 = (GrVertex *)gWin[vlist[1]].f;
|
---|
100 | GrVertex *i2 = (GrVertex *)gWin[vlist[2]].f;
|
---|
101 | GLuint i;
|
---|
102 |
|
---|
103 | for (i=2;i<n;i++, i1 = i2, i2 = (GrVertex *)gWin[vlist[i]].f) {
|
---|
104 | FX_grDrawTriangle(i0,i1,i2);
|
---|
105 | }
|
---|
106 | }
|
---|
107 | }
|
---|
108 |
|
---|
109 |
|
---|
110 |
|
---|
111 |
|
---|
112 |
|
---|
113 | static INLINE void fxSafeClippedLine( struct vertex_buffer *VB,
|
---|
114 | GLuint v1, GLuint v2 )
|
---|
115 | {
|
---|
116 | GLubyte mask = VB->ClipMask[v1] | VB->ClipMask[v2];
|
---|
117 |
|
---|
118 | if (!mask) {
|
---|
119 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
|
---|
120 | FX_grDrawLine((GrVertex *)gWin[v1].f,(GrVertex *)gWin[v2].f);
|
---|
121 | } else {
|
---|
122 | fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx;
|
---|
123 | fxLineClipTab[fxMesa->setupindex & 0x7]( VB, v1, v2, mask );
|
---|
124 | }
|
---|
125 | }
|
---|
126 |
|
---|
127 |
|
---|
128 | static INLINE void fxSafeClippedTriangle( struct vertex_buffer *VB,
|
---|
129 | fxVertex *gWin,
|
---|
130 | tfxTriClipFunc cliptri,
|
---|
131 | GLuint v2, GLuint v1, GLuint v )
|
---|
132 | {
|
---|
133 | GLubyte *clipmask = VB->ClipMask;
|
---|
134 | GLubyte mask = clipmask[v2] | clipmask[v1] | clipmask[v];
|
---|
135 |
|
---|
136 | if (!mask) {
|
---|
137 | FX_grDrawTriangle((GrVertex *)gWin[v2].f,
|
---|
138 | (GrVertex *)gWin[v1].f,
|
---|
139 | (GrVertex *)gWin[v].f);
|
---|
140 | return;
|
---|
141 | }
|
---|
142 |
|
---|
143 | if (!(clipmask[v2] & clipmask[v1] & clipmask[v] & CLIP_ALL_BITS))
|
---|
144 | {
|
---|
145 | GLuint vl[3];
|
---|
146 | GLuint imask = mask;
|
---|
147 |
|
---|
148 | if (imask & CLIP_USER_BIT) {
|
---|
149 | GLubyte *userclipmask = VB->UserClipMask;
|
---|
150 | if (userclipmask[v2] & userclipmask[v1] & userclipmask[v])
|
---|
151 | return;
|
---|
152 | imask |= (userclipmask[v2] | userclipmask[v1] | userclipmask[v]) << 8;
|
---|
153 | }
|
---|
154 |
|
---|
155 | ASSIGN_3V(vl, v2, v1, v );
|
---|
156 | cliptri( VB, vl, imask );
|
---|
157 | }
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 | static INLINE void fxSafeClippedTriangle2( struct vertex_buffer *VB,
|
---|
162 | fxVertex *gWin,
|
---|
163 | tfxTriViewClipFunc cliptri,
|
---|
164 | GLuint v2, GLuint v1, GLuint v )
|
---|
165 | {
|
---|
166 | GLubyte *clipmask = VB->ClipMask;
|
---|
167 | GLubyte mask = clipmask[v2] | clipmask[v1] | clipmask[v];
|
---|
168 |
|
---|
169 | if (!mask) {
|
---|
170 | FX_grDrawTriangle((GrVertex *)gWin[v2].f,(GrVertex *)gWin[v1].f,
|
---|
171 | (GrVertex *)gWin[v].f);
|
---|
172 | } else if (!(clipmask[v2] & clipmask[v1] & clipmask[v])) {
|
---|
173 | GLuint vl[3];
|
---|
174 | ASSIGN_3V(vl, v2, v1, v );
|
---|
175 | cliptri( VB, vl, mask );
|
---|
176 | }
|
---|
177 | }
|
---|
178 |
|
---|
179 |
|
---|
180 | static INLINE void fxSafeClippedTriangle3( struct vertex_buffer *VB,
|
---|
181 | fxVertex *gWin,
|
---|
182 | tfxTriClipFunc cliptri,
|
---|
183 | GLuint v2, GLuint v1, GLuint v )
|
---|
184 | {
|
---|
185 | GLubyte *clipmask = VB->ClipMask;
|
---|
186 | GLubyte mask = clipmask[v2] | clipmask[v1] | clipmask[v];
|
---|
187 | GLuint imask = mask;
|
---|
188 |
|
---|
189 | if (imask & CLIP_USER_BIT) {
|
---|
190 | GLubyte *userclipmask = VB->UserClipMask;
|
---|
191 | if (userclipmask[v2] & userclipmask[v1] & userclipmask[v])
|
---|
192 | return;
|
---|
193 | imask |= (userclipmask[v2] | userclipmask[v1] | userclipmask[v]) << 8;
|
---|
194 | }
|
---|
195 |
|
---|
196 | {
|
---|
197 | GLuint vl[3];
|
---|
198 | ASSIGN_3V(vl, v2, v1, v );
|
---|
199 | cliptri( VB, vl, imask );
|
---|
200 | }
|
---|
201 | }
|
---|
202 |
|
---|
203 |
|
---|
204 |
|
---|
205 |
|
---|
206 |
|
---|
207 | /************************************************************************/
|
---|
208 | /************************ RenderVB functions ****************************/
|
---|
209 | /************************************************************************/
|
---|
210 |
|
---|
211 |
|
---|
212 | /* Render front-facing, non-clipped primitives.
|
---|
213 | */
|
---|
214 |
|
---|
215 | #define RENDER_POINTS( start, count ) \
|
---|
216 | (void) gWin; \
|
---|
217 | (void) VB; \
|
---|
218 | (VB->ctx->Driver.PointsFunc)( VB->ctx, start, count-1 )
|
---|
219 |
|
---|
220 | #define RENDER_LINE( i1, i ) \
|
---|
221 | do { \
|
---|
222 | RVB_COLOR(i); \
|
---|
223 | FX_grDrawLine((GrVertex *)gWin[i1].f, \
|
---|
224 | (GrVertex *)gWin[i].f); \
|
---|
225 | } while (0)
|
---|
226 |
|
---|
227 | #define RENDER_TRI( i2, i1, i, pv, parity ) \
|
---|
228 | do { \
|
---|
229 | RVB_COLOR(pv); \
|
---|
230 | if (parity) { \
|
---|
231 | FX_grDrawTriangle((GrVertex *)gWin[i1].f, \
|
---|
232 | (GrVertex *)gWin[i2].f, \
|
---|
233 | (GrVertex *)gWin[i].f); \
|
---|
234 | } else { \
|
---|
235 | FX_grDrawTriangle((GrVertex *)gWin[i2].f, \
|
---|
236 | (GrVertex *)gWin[i1].f, \
|
---|
237 | (GrVertex *)gWin[i].f); \
|
---|
238 | } \
|
---|
239 | } while (0)
|
---|
240 |
|
---|
241 | #define RENDER_QUAD( i3, i2, i1, i, pv ) \
|
---|
242 | do { \
|
---|
243 | RVB_COLOR(pv); \
|
---|
244 | FX_grDrawTriangle((GrVertex *)gWin[i3].f, \
|
---|
245 | (GrVertex *)gWin[i2].f, \
|
---|
246 | (GrVertex *)gWin[i].f); \
|
---|
247 | FX_grDrawTriangle((GrVertex *)gWin[i2].f, \
|
---|
248 | (GrVertex *)gWin[i1].f, \
|
---|
249 | (GrVertex *)gWin[i].f); \
|
---|
250 | } while (0)
|
---|
251 |
|
---|
252 |
|
---|
253 |
|
---|
254 | #define LOCAL_VARS \
|
---|
255 | fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx; \
|
---|
256 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
|
---|
257 | (void) fxMesa;
|
---|
258 |
|
---|
259 | #define INIT(x)
|
---|
260 |
|
---|
261 | #define TAG(x) x##_fx_flat_raw
|
---|
262 | #undef RVB_COLOR
|
---|
263 | #define RVB_COLOR(pv) FX_VB_COLOR(fxMesa, VB->ColorPtr->data[pv])
|
---|
264 | #define PRESERVE_VB_DEFS
|
---|
265 |
|
---|
266 | #include "render_tmp.h"
|
---|
267 |
|
---|
268 | #define TAG(x) x##_fx_smooth_raw
|
---|
269 | #undef RVB_COLOR
|
---|
270 | #define RVB_COLOR(x)
|
---|
271 |
|
---|
272 | #include "render_tmp.h"
|
---|
273 |
|
---|
274 |
|
---|
275 |
|
---|
276 | /* Render with clipped and/or culled primitives with cullmask information.
|
---|
277 | */
|
---|
278 | #define RENDER_POINTS( start, count ) \
|
---|
279 | (void) gWin; \
|
---|
280 | (void) cullmask; \
|
---|
281 | (VB->ctx->Driver.PointsFunc)( VB->ctx, start, count-1 )
|
---|
282 |
|
---|
283 |
|
---|
284 | #define RENDER_LINE( i1, i ) \
|
---|
285 | do { \
|
---|
286 | const GLubyte flags = cullmask[i]; \
|
---|
287 | \
|
---|
288 | if (!(flags & PRIM_NOT_CULLED)) \
|
---|
289 | continue; \
|
---|
290 | \
|
---|
291 | RVB_COLOR(i); \
|
---|
292 | if (flags & PRIM_ANY_CLIP) \
|
---|
293 | fxRenderClippedLine( VB, i1, i ); \
|
---|
294 | else \
|
---|
295 | FX_grDrawLine( (GrVertex *)gWin[i1].f, (GrVertex *)gWin[i].f ); \
|
---|
296 | } while (0)
|
---|
297 |
|
---|
298 |
|
---|
299 | #define RENDER_TRI( i2, i1, i, pv, parity) \
|
---|
300 | do { \
|
---|
301 | const GLubyte flags = cullmask[i]; \
|
---|
302 | GLuint e2,e1; \
|
---|
303 | \
|
---|
304 | if (!(flags & PRIM_NOT_CULLED)) \
|
---|
305 | continue; \
|
---|
306 | \
|
---|
307 | e2=i2, e1=i1; \
|
---|
308 | if (parity) { e2=i1; e1=i2; } \
|
---|
309 | \
|
---|
310 | RVB_COLOR(pv); \
|
---|
311 | if (flags & PRIM_ANY_CLIP) { \
|
---|
312 | fxSafeClippedTriangle3(VB,gWin,cliptri,e2,e1,i); \
|
---|
313 | } else { \
|
---|
314 | FX_grDrawTriangle((GrVertex *)gWin[e2].f, \
|
---|
315 | (GrVertex *)gWin[e1].f, \
|
---|
316 | (GrVertex *)gWin[i].f); \
|
---|
317 | } \
|
---|
318 | } while (0)
|
---|
319 |
|
---|
320 |
|
---|
321 | #define RENDER_QUAD(i3, i2, i1, i, pv) \
|
---|
322 | do { \
|
---|
323 | const GLubyte flags = cullmask[i]; \
|
---|
324 | \
|
---|
325 | if (!(flags & PRIM_NOT_CULLED)) \
|
---|
326 | continue; \
|
---|
327 | \
|
---|
328 | RVB_COLOR(pv); \
|
---|
329 | if (flags&PRIM_ANY_CLIP) { \
|
---|
330 | fxSafeClippedTriangle3(VB,gWin,cliptri,i3,i2,i); \
|
---|
331 | fxSafeClippedTriangle3(VB,gWin,cliptri,i2,i1,i); \
|
---|
332 | } else { \
|
---|
333 | FX_grDrawTriangle((GrVertex *)gWin[i3].f, \
|
---|
334 | (GrVertex *)gWin[i2].f, \
|
---|
335 | (GrVertex *)gWin[i].f); \
|
---|
336 | FX_grDrawTriangle((GrVertex *)gWin[i2].f, \
|
---|
337 | (GrVertex *)gWin[i1].f, \
|
---|
338 | (GrVertex *)gWin[i].f); \
|
---|
339 | } \
|
---|
340 | } while (0)
|
---|
341 |
|
---|
342 |
|
---|
343 |
|
---|
344 |
|
---|
345 |
|
---|
346 | #define LOCAL_VARS \
|
---|
347 | fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx; \
|
---|
348 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
|
---|
349 | const GLubyte *cullmask = VB->CullMask; \
|
---|
350 | tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
|
---|
351 |
|
---|
352 |
|
---|
353 |
|
---|
354 |
|
---|
355 | #define INIT(x) (void) cliptri; (void) fxMesa;
|
---|
356 |
|
---|
357 | #define TAG(x) x##_fx_smooth_culled
|
---|
358 | #undef RVB_COLOR
|
---|
359 | #define RVB_COLOR(x)
|
---|
360 | #define PRESERVE_VB_DEFS
|
---|
361 | #include "render_tmp.h"
|
---|
362 |
|
---|
363 | #define TAG(x) x##_fx_flat_culled
|
---|
364 | #undef RVB_COLOR
|
---|
365 | #define RVB_COLOR(pv) FX_VB_COLOR(fxMesa, VB->ColorPtr->data[pv])
|
---|
366 |
|
---|
367 | #include "render_tmp.h"
|
---|
368 |
|
---|
369 |
|
---|
370 |
|
---|
371 |
|
---|
372 | /* Direct, with the possibility of clipping.
|
---|
373 | */
|
---|
374 | #define RENDER_POINTS( start, count ) \
|
---|
375 | do { \
|
---|
376 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
|
---|
377 | GLubyte *clipmask = VB->ClipMask; \
|
---|
378 | GLuint i; \
|
---|
379 | for (i = start ; i <= count ; i++) \
|
---|
380 | if (clipmask[i] == 0) { \
|
---|
381 | RVB_COLOR(i); \
|
---|
382 | FX_grDrawPoint( (GrVertex *)gWin[i].f );\
|
---|
383 | } \
|
---|
384 | } while (0)
|
---|
385 |
|
---|
386 | #define RENDER_LINE( i1, i ) \
|
---|
387 | do { \
|
---|
388 | RVB_COLOR(i); \
|
---|
389 | fxSafeClippedLine( VB, i1, i ); \
|
---|
390 | } while (0)
|
---|
391 |
|
---|
392 | #define RENDER_TRI( i2, i1, i, pv, parity) \
|
---|
393 | do { \
|
---|
394 | GLuint e2=i2, e1=i1; \
|
---|
395 | if (parity) { GLuint t=e2; e2=e1; e1=t; } \
|
---|
396 | RVB_COLOR(pv); \
|
---|
397 | fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,i); \
|
---|
398 | } while (0)
|
---|
399 |
|
---|
400 | #define RENDER_QUAD( i3, i2, i1, i, pv) \
|
---|
401 | do { \
|
---|
402 | RVB_COLOR(pv); \
|
---|
403 | fxSafeClippedTriangle(VB,gWin,cliptri,i3,i2,i); \
|
---|
404 | fxSafeClippedTriangle(VB,gWin,cliptri,i2,i1,i); \
|
---|
405 | } while (0)
|
---|
406 |
|
---|
407 | #define LOCAL_VARS \
|
---|
408 | fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx; \
|
---|
409 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
|
---|
410 | tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
|
---|
411 |
|
---|
412 | #define INIT(x) (void) cliptri; (void) gWin;
|
---|
413 |
|
---|
414 | #define TAG(x) x##_fx_smooth_clipped
|
---|
415 | #undef RVB_COLOR
|
---|
416 | #define RVB_COLOR(x)
|
---|
417 | #define PRESERVE_VB_DEFS
|
---|
418 | #include "render_tmp.h"
|
---|
419 |
|
---|
420 |
|
---|
421 | #define TAG(x) x##_fx_flat_clipped
|
---|
422 | #undef RVB_COLOR
|
---|
423 | #define RVB_COLOR(pv) FX_VB_COLOR(fxMesa, VB->ColorPtr->data[pv])
|
---|
424 | #include "render_tmp.h"
|
---|
425 |
|
---|
426 |
|
---|
427 |
|
---|
428 |
|
---|
429 |
|
---|
430 |
|
---|
431 | /* Indirect, with the possibility of clipping.
|
---|
432 | */
|
---|
433 | #define RENDER_POINTS( start, count ) \
|
---|
434 | do { \
|
---|
435 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
|
---|
436 | GLuint e; \
|
---|
437 | GLubyte *clipmask = VB->ClipMask; \
|
---|
438 | for(e=start;e<=count;e++) \
|
---|
439 | if(clipmask[elt[e]]==0) { \
|
---|
440 | FX_grDrawPoint((GrVertex *)gWin[elt[e]].f); \
|
---|
441 | } \
|
---|
442 | } while (0)
|
---|
443 |
|
---|
444 | #define RENDER_LINE( i1, i ) \
|
---|
445 | do { \
|
---|
446 | GLuint e1 = elt[i1], e = elt[i]; \
|
---|
447 | RVB_COLOR(e); \
|
---|
448 | fxSafeClippedLine( VB, e1, e ); \
|
---|
449 | } while (0)
|
---|
450 |
|
---|
451 | #define RENDER_TRI( i2, i1, i, pv, parity) \
|
---|
452 | do { \
|
---|
453 | GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
|
---|
454 | if (parity) { GLuint t=e2; e2=e1; e1=t; } \
|
---|
455 | fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,e); \
|
---|
456 | } while (0)
|
---|
457 |
|
---|
458 | #define RENDER_QUAD( i3, i2, i1, i, pv) \
|
---|
459 | do { \
|
---|
460 | GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
|
---|
461 | fxSafeClippedTriangle(VB,gWin,cliptri,e3,e2,e); \
|
---|
462 | fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,e); \
|
---|
463 | } while (0)
|
---|
464 |
|
---|
465 | #define LOCAL_VARS const GLuint *elt = VB->EltPtr->data; \
|
---|
466 | fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx; \
|
---|
467 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
|
---|
468 | tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
|
---|
469 |
|
---|
470 | #define INIT(x) (void) cliptri; (void) gWin;
|
---|
471 |
|
---|
472 | #define TAG(x) x##_fx_smooth_indirect_clipped
|
---|
473 | #undef RVB_COLOR
|
---|
474 | #define RVB_COLOR(x)
|
---|
475 | #include "render_tmp.h"
|
---|
476 |
|
---|
477 |
|
---|
478 | /* Indirect, clipped, but no user clip.
|
---|
479 | */
|
---|
480 | #define RENDER_POINTS( start, count ) \
|
---|
481 | do { \
|
---|
482 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
|
---|
483 | GLuint e; \
|
---|
484 | GLubyte *clipmask = VB->ClipMask; \
|
---|
485 | for(e=start;e<=count;e++) \
|
---|
486 | if(clipmask[elt[e]]==0) { \
|
---|
487 | FX_grDrawPoint((GrVertex *)gWin[elt[e]].f); \
|
---|
488 | } \
|
---|
489 | } while (0)
|
---|
490 |
|
---|
491 | #define RENDER_LINE( i1, i ) \
|
---|
492 | do { \
|
---|
493 | GLuint e1 = elt[i1], e = elt[i]; \
|
---|
494 | RVB_COLOR(e); \
|
---|
495 | fxSafeClippedLine( VB, e1, e ); \
|
---|
496 | } while (0)
|
---|
497 |
|
---|
498 | #define RENDER_TRI( i2, i1, i, pv, parity) \
|
---|
499 | do { \
|
---|
500 | GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
|
---|
501 | if (parity) { GLuint t=e2; e2=e1; e1=t; } \
|
---|
502 | fxSafeClippedTriangle2(VB,gWin,cliptri,e2,e1,e); \
|
---|
503 | } while (0)
|
---|
504 |
|
---|
505 | #define RENDER_QUAD( i3, i2, i1, i, pv) \
|
---|
506 | do { \
|
---|
507 | GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
|
---|
508 | fxSafeClippedTriangle2(VB,gWin,cliptri,e3,e2,e); \
|
---|
509 | fxSafeClippedTriangle2(VB,gWin,cliptri,e2,e1,e); \
|
---|
510 | } while (0)
|
---|
511 |
|
---|
512 | #define LOCAL_VARS const GLuint *elt = VB->EltPtr->data; \
|
---|
513 | fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx; \
|
---|
514 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
|
---|
515 | tfxTriViewClipFunc cliptri = fxMesa->view_clip_tri;
|
---|
516 |
|
---|
517 | #define INIT(x) (void) cliptri; (void) gWin;
|
---|
518 |
|
---|
519 | #define TAG(x) x##_fx_smooth_indirect_view_clipped
|
---|
520 | #undef RVB_COLOR
|
---|
521 | #define RVB_COLOR(x)
|
---|
522 | #include "render_tmp.h"
|
---|
523 |
|
---|
524 |
|
---|
525 |
|
---|
526 |
|
---|
527 |
|
---|
528 |
|
---|
529 |
|
---|
530 | /* Indirect, and no clipping required.
|
---|
531 | */
|
---|
532 | #define RENDER_POINTS( start, count ) \
|
---|
533 | do { \
|
---|
534 | GLuint e; \
|
---|
535 | for(e=start;e<=count;e++) { \
|
---|
536 | FX_grDrawPoint((GrVertex *)gWin[elt[e]].f); \
|
---|
537 | } \
|
---|
538 | } while (0)
|
---|
539 |
|
---|
540 | #define RENDER_LINE( i1, i ) \
|
---|
541 | do { \
|
---|
542 | GLuint e1 = elt[i1], e = elt[i]; \
|
---|
543 | FX_grDrawLine((GrVertex *)gWin[e1].f, (GrVertex *)gWin[e].f); \
|
---|
544 | } while (0)
|
---|
545 |
|
---|
546 |
|
---|
547 | #define RENDER_TRI( i2, i1, i, pv, parity) \
|
---|
548 | do { \
|
---|
549 | GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
|
---|
550 | if (parity) {GLuint tmp = e2; e2 = e1; e1 = tmp;} \
|
---|
551 | FX_grDrawTriangle((GrVertex *)gWin[e2].f, \
|
---|
552 | (GrVertex *)gWin[e1].f, \
|
---|
553 | (GrVertex *)gWin[e].f); \
|
---|
554 | } while (0)
|
---|
555 |
|
---|
556 |
|
---|
557 | #define RENDER_QUAD( i3, i2, i1, i, pv) \
|
---|
558 | do { \
|
---|
559 | GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
|
---|
560 | FX_grDrawTriangle((GrVertex *)gWin[e3].f, \
|
---|
561 | (GrVertex *)gWin[e2].f, \
|
---|
562 | (GrVertex *)gWin[e].f); \
|
---|
563 | FX_grDrawTriangle((GrVertex *)gWin[e2].f, \
|
---|
564 | (GrVertex *)gWin[e1].f, \
|
---|
565 | (GrVertex *)gWin[e].f); \
|
---|
566 | } while (0)
|
---|
567 |
|
---|
568 | #define LOCAL_VARS \
|
---|
569 | fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
|
---|
570 | const GLuint *elt = VB->EltPtr->data;
|
---|
571 |
|
---|
572 | #define INIT(x)
|
---|
573 |
|
---|
574 | #define TAG(x) x##_fx_smooth_indirect
|
---|
575 | #undef RVB_COLOR
|
---|
576 | #define RVB_COLOR(x)
|
---|
577 | #include "render_tmp.h"
|
---|
578 |
|
---|
579 |
|
---|
580 |
|
---|
581 |
|
---|
582 |
|
---|
583 | /* Direct in this context means that triangles, lines, points can be
|
---|
584 | * rendered simply by calling grDrawTriangle, etc., without any
|
---|
585 | * additional setup (such as calling grConstantColor). We also use a
|
---|
586 | * 'safe' set of clipping routines which don't require write-access to
|
---|
587 | * the arrays in the vertex buffer, and don't care about array
|
---|
588 | * stride.
|
---|
589 | *
|
---|
590 | * Thus there is no call to gl_import_arrays() in this function.
|
---|
591 | *
|
---|
592 | * This safe clipping should be generalized to call driver->trianglefunc
|
---|
593 | * under the appropriate conditions.
|
---|
594 | *
|
---|
595 | * We don't handle texcoord-4 in the safe clip routines - maybe we should.
|
---|
596 | *
|
---|
597 | */
|
---|
598 | void fxDDRenderElementsDirect( struct vertex_buffer *VB )
|
---|
599 | {
|
---|
600 | GLcontext *ctx = VB->ctx;
|
---|
601 | struct vertex_buffer *saved_vb = ctx->VB;
|
---|
602 | GLenum prim = ctx->CVA.elt_mode;
|
---|
603 | GLuint nr = VB->EltPtr->count;
|
---|
604 | render_func func = render_tab_fx_smooth_indirect[prim];
|
---|
605 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
606 | GLuint p = 0;
|
---|
607 |
|
---|
608 | if (!nr)
|
---|
609 | return;
|
---|
610 |
|
---|
611 | if (fxMesa->new_state)
|
---|
612 | fxSetupFXUnits(ctx);
|
---|
613 |
|
---|
614 | if (!nr) return;
|
---|
615 |
|
---|
616 | if (VB->ClipOrMask) {
|
---|
617 | func = render_tab_fx_smooth_indirect_view_clipped[prim];
|
---|
618 | if (VB->ClipOrMask & CLIP_USER_BIT)
|
---|
619 | func = render_tab_fx_smooth_indirect_clipped[prim];
|
---|
620 | }
|
---|
621 |
|
---|
622 | ctx->VB = VB; /* kludge */
|
---|
623 |
|
---|
624 | do {
|
---|
625 | func( VB, 0, nr, 0 );
|
---|
626 | } while (ctx->Driver.MultipassFunc &&
|
---|
627 | ctx->Driver.MultipassFunc( VB, ++p ));
|
---|
628 |
|
---|
629 |
|
---|
630 | ctx->VB = saved_vb;
|
---|
631 | }
|
---|
632 |
|
---|
633 |
|
---|
634 | void fxDDRenderVBIndirectDirect( struct vertex_buffer *VB )
|
---|
635 | {
|
---|
636 | GLcontext *ctx = VB->ctx;
|
---|
637 | struct vertex_buffer *cvaVB = ctx->CVA.VB;
|
---|
638 | struct vertex_buffer *saved_vb = ctx->VB;
|
---|
639 | GLuint i, next, count = VB->Count;
|
---|
640 | render_func *tab = render_tab_fx_smooth_indirect;
|
---|
641 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
642 | GLuint p = 0;
|
---|
643 |
|
---|
644 | if (cvaVB->ClipOrMask)
|
---|
645 | tab = render_tab_fx_smooth_indirect_clipped;
|
---|
646 |
|
---|
647 | if (!VB->CullDone)
|
---|
648 | gl_fast_copy_vb( VB );
|
---|
649 |
|
---|
650 | if (fxMesa->new_state)
|
---|
651 | fxSetupFXUnits( ctx );
|
---|
652 |
|
---|
653 | ctx->VB = cvaVB;
|
---|
654 | cvaVB->EltPtr = VB->EltPtr;
|
---|
655 |
|
---|
656 | do {
|
---|
657 | GLuint parity = VB->Parity;
|
---|
658 |
|
---|
659 | for (i = VB->CopyStart ; i < count ; parity = 0, i = next)
|
---|
660 | {
|
---|
661 | GLuint prim = VB->Primitive[i];
|
---|
662 | next = VB->NextPrimitive[i];
|
---|
663 | tab[prim]( cvaVB, i, next, parity );
|
---|
664 | }
|
---|
665 | /* loop never taken */
|
---|
666 | } while (ctx->Driver.MultipassFunc &&
|
---|
667 | ctx->Driver.MultipassFunc( cvaVB, ++p ));
|
---|
668 |
|
---|
669 | cvaVB->EltPtr = 0;
|
---|
670 | ctx->VB = saved_vb;
|
---|
671 | }
|
---|
672 |
|
---|
673 |
|
---|
674 | static render_func *fxDDRenderVBSmooth_tables[3] = {
|
---|
675 | render_tab_fx_smooth_clipped,
|
---|
676 | render_tab_fx_smooth_culled,
|
---|
677 | render_tab_fx_smooth_raw
|
---|
678 | };
|
---|
679 |
|
---|
680 | static render_func *fxDDRenderVBFlat_tables[3] = {
|
---|
681 | render_tab_fx_flat_clipped,
|
---|
682 | render_tab_fx_flat_culled,
|
---|
683 | render_tab_fx_flat_raw
|
---|
684 | };
|
---|
685 |
|
---|
686 |
|
---|
687 | static render_func *null_tables[3] = {
|
---|
688 | 0,
|
---|
689 | 0,
|
---|
690 | 0
|
---|
691 | };
|
---|
692 |
|
---|
693 | #if defined(FX_GLIDE3)
|
---|
694 | #include "fxstripdet.c"
|
---|
695 | #endif
|
---|
696 |
|
---|
697 | void fxDDRenderInit( GLcontext *ctx )
|
---|
698 | {
|
---|
699 | render_init_fx_smooth_indirect_view_clipped();
|
---|
700 | render_init_fx_smooth_indirect_clipped();
|
---|
701 | render_init_fx_smooth_indirect();
|
---|
702 | render_init_fx_smooth_raw();
|
---|
703 | render_init_fx_smooth_culled();
|
---|
704 | render_init_fx_smooth_clipped();
|
---|
705 | render_init_fx_flat_raw();
|
---|
706 | render_init_fx_flat_culled();
|
---|
707 | render_init_fx_flat_clipped();
|
---|
708 | #if defined(FX_GLIDE3)
|
---|
709 | fxDDRenderInitGlide3(ctx);
|
---|
710 | #endif
|
---|
711 | }
|
---|
712 |
|
---|
713 |
|
---|
714 | /* Now used to set an internal var in fxMesa - we hook out at the
|
---|
715 | * level of gl_render_vb() instead.
|
---|
716 | */
|
---|
717 | render_func **fxDDChooseRenderVBTables(GLcontext *ctx)
|
---|
718 | {
|
---|
719 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
720 |
|
---|
721 | if (ctx->IndirectTriangles & DD_SW_SETUP)
|
---|
722 | return null_tables;
|
---|
723 |
|
---|
724 | switch (fxMesa->render_index) {
|
---|
725 | case FX_FLAT:
|
---|
726 | return fxDDRenderVBFlat_tables;
|
---|
727 | case 0:
|
---|
728 | return fxDDRenderVBSmooth_tables;
|
---|
729 | default:
|
---|
730 | return null_tables;
|
---|
731 | }
|
---|
732 | }
|
---|
733 |
|
---|
734 |
|
---|
735 | void fxDDDoRenderVB( struct vertex_buffer *VB )
|
---|
736 | {
|
---|
737 | GLcontext *ctx = VB->ctx;
|
---|
738 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
739 | GLuint i, next, prim;
|
---|
740 | GLuint parity = VB->Parity;
|
---|
741 | render_func *tab;
|
---|
742 | GLuint count = VB->Count;
|
---|
743 | GLint p = 0;
|
---|
744 |
|
---|
745 | if (fxMesa->new_state)
|
---|
746 | fxSetupFXUnits(ctx);
|
---|
747 |
|
---|
748 | if (VB->Indirect) {
|
---|
749 | return;
|
---|
750 | } else if (VB->CullMode & CLIP_MASK_ACTIVE) {
|
---|
751 | tab = fxMesa->RenderVBClippedTab;
|
---|
752 | } else {
|
---|
753 | tab = fxMesa->RenderVBRawTab;
|
---|
754 | }
|
---|
755 |
|
---|
756 | if (!VB->CullDone)
|
---|
757 | gl_fast_copy_vb( VB );
|
---|
758 |
|
---|
759 | do
|
---|
760 | {
|
---|
761 | for ( i= VB->CopyStart ; i < count ; parity = 0, i = next )
|
---|
762 | {
|
---|
763 | prim = VB->Primitive[i];
|
---|
764 | next = VB->NextPrimitive[i];
|
---|
765 | tab[prim]( VB, i, next, parity );
|
---|
766 | }
|
---|
767 |
|
---|
768 | } while (ctx->Driver.MultipassFunc &&
|
---|
769 | ctx->Driver.MultipassFunc( VB, ++p ));
|
---|
770 | }
|
---|
771 |
|
---|
772 |
|
---|
773 | #else
|
---|
774 |
|
---|
775 |
|
---|
776 | /*
|
---|
777 | * Need this to provide at least one external definition.
|
---|
778 | */
|
---|
779 |
|
---|
780 | int gl_fx_dummy_function_render(void)
|
---|
781 | {
|
---|
782 | return 0;
|
---|
783 | }
|
---|
784 |
|
---|
785 | #endif /* FX */
|
---|