cf9c99bbd4d11bdde7e17e59dc468cd4d1e8c7eb
[mesa.git] / src / mesa / drivers / dri / unichrome / via_tris.c
1 /*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25 #include <stdio.h>
26 #include <math.h>
27
28 #include "glheader.h"
29 #include "context.h"
30 #include "mtypes.h"
31 #include "macros.h"
32 #include "colormac.h"
33
34 #include "swrast/swrast.h"
35 #include "swrast_setup/swrast_setup.h"
36 #include "tnl/t_context.h"
37 #include "tnl/t_pipeline.h"
38
39 #include "via_context.h"
40 #include "via_tris.h"
41 #include "via_state.h"
42 #include "via_vb.h"
43 #include "via_ioctl.h"
44
45 static void viaRenderPrimitive(GLcontext *ctx, GLenum prim);
46 GLuint RasterCounter = 0;
47 extern GLuint idle;
48 extern GLuint busy;
49 /***********************************************************************
50 * Emit primitives as inline vertices *
51 ***********************************************************************/
52
53 #if defined(USE_X86_ASM)
54 #define COPY_DWORDS(j, vb, vertsize, v) \
55 do { \
56 int __tmp; \
57 __asm__ __volatile__("rep ; movsl" \
58 : "=%c" (j), "=D" (vb), "=S" (__tmp) \
59 : "0" (vertsize), \
60 "D" ((long)vb), \
61 "S" ((long)v)); \
62 } while (0)
63 #else
64 #define COPY_DWORDS(j, vb, vertsize, v) \
65 do { \
66 for (j = 0; j < vertsize; j++) \
67 vb[j] = ((GLuint *)v)[j]; \
68 vb += vertsize; \
69 } while (0)
70 #endif
71
72 static void __inline__ via_draw_triangle(viaContextPtr vmesa,
73 viaVertexPtr v0,
74 viaVertexPtr v1,
75 viaVertexPtr v2)
76 {
77 GLuint vertsize = vmesa->vertexSize;
78 GLuint *vb = viaCheckDma(vmesa, 3 * 4 * vertsize);
79 int j;
80
81 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
82 #ifdef PERFORMANCE_MEASURE
83 if (VIA_PERFORMANCE) P_M;
84 #endif
85 COPY_DWORDS(j, vb, vertsize, v0);
86 COPY_DWORDS(j, vb, vertsize, v1);
87 COPY_DWORDS(j, vb, vertsize, v2);
88 vmesa->dmaLow += 3 * 4 * vertsize;
89 vmesa->primitiveRendered = GL_TRUE;
90 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
91 }
92
93
94 static void __inline__ via_draw_quad(viaContextPtr vmesa,
95 viaVertexPtr v0,
96 viaVertexPtr v1,
97 viaVertexPtr v2,
98 viaVertexPtr v3)
99 {
100 GLuint vertsize = vmesa->vertexSize;
101 GLuint *vb = viaCheckDma(vmesa, 6 * 4 * vertsize);
102 int j;
103 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
104 #ifdef PERFORMANCE_MEASURE
105 if (VIA_PERFORMANCE) P_M;
106 #endif
107 COPY_DWORDS(j, vb, vertsize, v0);
108 COPY_DWORDS(j, vb, vertsize, v1);
109 COPY_DWORDS(j, vb, vertsize, v3);
110 COPY_DWORDS(j, vb, vertsize, v1);
111 COPY_DWORDS(j, vb, vertsize, v2);
112 COPY_DWORDS(j, vb, vertsize, v3);
113 vmesa->dmaLow += 6 * 4 * vertsize;
114 vmesa->primitiveRendered = GL_TRUE;
115 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
116 }
117
118
119 static __inline__ void via_draw_point(viaContextPtr vmesa,
120 viaVertexPtr v0)
121 {
122 /*GLfloat sz = vmesa->glCtx->Point._Size * .5;*/
123 int vertsize = vmesa->vertexSize;
124 /*GLuint *vb = viaCheckDma(vmesa, 2 * 4 * vertsize);*/
125 GLuint *vb = viaCheckDma(vmesa, 4 * vertsize);
126 int j;
127 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
128 #ifdef PERFORMANCE_MEASURE
129 if (VIA_PERFORMANCE) P_M;
130 #endif
131 COPY_DWORDS(j, vb, vertsize, v0);
132 vmesa->dmaLow += 4 * vertsize;
133 vmesa->primitiveRendered = GL_TRUE;
134 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
135 }
136
137
138 /*
139 * Draw line in hardware.
140 * Checked out - AC.
141 */
142 static __inline__ void via_draw_line(viaContextPtr vmesa,
143 viaVertexPtr v0,
144 viaVertexPtr v1)
145 {
146 GLuint vertsize = vmesa->vertexSize;
147 GLuint *vb = viaCheckDma(vmesa, 2 * 4 * vertsize);
148 int j;
149 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
150 #ifdef PERFORMANCE_MEASURE
151 if (VIA_PERFORMANCE) P_M;
152 #endif
153 COPY_DWORDS(j, vb, vertsize, v0);
154 COPY_DWORDS(j, vb, vertsize, v1);
155 vmesa->dmaLow += 2 * 4 * vertsize;
156 vmesa->primitiveRendered = GL_TRUE;
157 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
158 }
159
160
161 /***********************************************************************
162 * Macros for via_dd_tritmp.h to draw basic primitives *
163 ***********************************************************************/
164
165 #define TRI(a, b, c) \
166 do { \
167 if (VIA_DEBUG) fprintf(stderr, "hw TRI\n"); \
168 if (DO_FALLBACK) \
169 vmesa->drawTri(vmesa, a, b, c); \
170 else \
171 via_draw_triangle(vmesa, a, b, c); \
172 } while (0)
173
174 #define QUAD(a, b, c, d) \
175 do { \
176 if (VIA_DEBUG) fprintf(stderr, "hw QUAD\n");\
177 if (DO_FALLBACK) { \
178 vmesa->drawTri(vmesa, a, b, d); \
179 vmesa->drawTri(vmesa, b, c, d); \
180 } \
181 else \
182 via_draw_quad(vmesa, a, b, c, d); \
183 } while (0)
184
185 #define LINE(v0, v1) \
186 do { \
187 if(VIA_DEBUG) fprintf(stderr, "hw LINE\n");\
188 if (DO_FALLBACK) \
189 vmesa->drawLine(vmesa, v0, v1); \
190 else \
191 via_draw_line(vmesa, v0, v1); \
192 } while (0)
193
194 #define POINT(v0) \
195 do { \
196 if (VIA_DEBUG) fprintf(stderr, "hw POINT\n");\
197 if (DO_FALLBACK) \
198 vmesa->drawPoint(vmesa, v0); \
199 else \
200 via_draw_point(vmesa, v0); \
201 } while (0)
202
203
204 /***********************************************************************
205 * Build render functions from dd templates *
206 ***********************************************************************/
207
208 #define VIA_OFFSET_BIT 0x01
209 #define VIA_TWOSIDE_BIT 0x02
210 #define VIA_UNFILLED_BIT 0x04
211 #define VIA_FALLBACK_BIT 0x08
212 #define VIA_MAX_TRIFUNC 0x10
213
214
215 static struct {
216 tnl_points_func points;
217 tnl_line_func line;
218 tnl_triangle_func triangle;
219 tnl_quad_func quad;
220 } rast_tab[VIA_MAX_TRIFUNC];
221
222
223 #define DO_FALLBACK (IND & VIA_FALLBACK_BIT)
224 #define DO_OFFSET (IND & VIA_OFFSET_BIT)
225 #define DO_UNFILLED (IND & VIA_UNFILLED_BIT)
226 #define DO_TWOSIDE (IND & VIA_TWOSIDE_BIT)
227 #define DO_FLAT 0
228 #define DO_TRI 1
229 #define DO_QUAD 1
230 #define DO_LINE 1
231 #define DO_POINTS 1
232 #define DO_FULL_QUAD 1
233
234 #define HAVE_RGBA 1
235 #define HAVE_SPEC 1
236 #define HAVE_BACK_COLORS 0
237 #define HAVE_HW_FLATSHADE 1
238 #define VERTEX viaVertex
239 #define TAB rast_tab
240
241 /* Only used to pull back colors into vertices (ie, we know color is
242 * floating point).
243 */
244 #define VIA_COLOR(dst, src) \
245 do { \
246 dst[0] = src[2]; \
247 dst[1] = src[1]; \
248 dst[2] = src[0]; \
249 dst[3] = src[3]; \
250 } while (0)
251
252 #define VIA_SPEC(dst, src) \
253 do { \
254 dst[0] = src[2]; \
255 dst[1] = src[1]; \
256 dst[2] = src[0]; \
257 } while (0)
258
259
260 #define DEPTH_SCALE (1.0 / 0xffff)
261 #define UNFILLED_TRI unfilled_tri
262 #define UNFILLED_QUAD unfilled_quad
263 #define VERT_X(_v) _v->v.x
264 #define VERT_Y(_v) _v->v.y
265 #define VERT_Z(_v) _v->v.z
266 #define AREA_IS_CCW(a) (a > 0)
267 #define GET_VERTEX(e) (vmesa->verts + (e<<vmesa->vertexStrideShift))
268
269 #define VERT_SET_RGBA(v, c) VIA_COLOR(v->ub4[coloroffset], c)
270 #define VERT_COPY_RGBA(v0, v1) v0->ui[coloroffset] = v1->ui[coloroffset]
271 #define VERT_SAVE_RGBA(idx) color[idx] = v[idx]->ui[coloroffset]
272 #define VERT_RESTORE_RGBA(idx) v[idx]->ui[coloroffset] = color[idx]
273 #define VERT_SET_SPEC(v, c) if (havespec) VIA_SPEC(v->ub4[5], c)
274 #define VERT_COPY_SPEC(v0, v1) if (havespec) COPY_3V(v0->ub4[5], v1->ub4[5])
275 #define VERT_SAVE_SPEC(idx) if (havespec) spec[idx] = v[idx]->ui[5]
276 #define VERT_RESTORE_SPEC(idx) if (havespec) v[idx]->ui[5] = spec[idx]
277
278 #define SET_PRIMITIVE_RENDERED vmesa->primitiveRendered = GL_TRUE;
279
280 #define LOCAL_VARS(n) \
281 viaContextPtr vmesa = VIA_CONTEXT(ctx); \
282 GLuint color[n], spec[n]; \
283 GLuint coloroffset = (vmesa->vertexSize == 4 ? 3 : 4); \
284 GLboolean havespec = (vmesa->vertexSize > 4); \
285 (void)color; (void)spec; (void)coloroffset; (void)havespec;
286
287
288 /***********************************************************************
289 * Helpers for rendering unfilled primitives *
290 ***********************************************************************/
291 /*
292 static const GLuint hwPrim[GL_POLYGON + 1] = {
293 PR_LINES,
294 PR_LINES,
295 PR_LINES,
296 PR_LINES,
297 PR_TRIANGLES,
298 PR_TRIANGLES,
299 PR_TRIANGLES,
300 PR_TRIANGLES,
301 PR_TRIANGLES,
302 PR_TRIANGLES
303 };
304 */
305
306 #define RASTERIZE(x) \
307 if (vmesa->hwPrimitive != x) { \
308 viaRasterPrimitiveFinish(ctx); \
309 viaRasterPrimitive(ctx, x, x); \
310 }
311
312 #define RENDER_PRIMITIVE vmesa->renderPrimitive
313 #define TAG(x) x
314 #define IND VIA_FALLBACK_BIT
315 #include "tnl_dd/t_dd_unfilled.h"
316 #undef IND
317 #undef RASTERIZE
318
319 /***********************************************************************
320 * Generate GL render functions *
321 ***********************************************************************/
322 #define RASTERIZE(x)
323
324 #define IND (0)
325 #define TAG(x) x
326 #include "via_dd_tritmp.h"
327
328 #define IND (VIA_OFFSET_BIT)
329 #define TAG(x) x##_offset
330 #include "via_dd_tritmp.h"
331
332 #define IND (VIA_TWOSIDE_BIT)
333 #define TAG(x) x##_twoside
334 #include "via_dd_tritmp.h"
335
336 #define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT)
337 #define TAG(x) x##_twoside_offset
338 #include "via_dd_tritmp.h"
339
340 #define IND (VIA_UNFILLED_BIT)
341 #define TAG(x) x##_unfilled
342 #include "via_dd_tritmp.h"
343
344 #define IND (VIA_OFFSET_BIT|VIA_UNFILLED_BIT)
345 #define TAG(x) x##_offset_unfilled
346 #include "via_dd_tritmp.h"
347
348 #define IND (VIA_TWOSIDE_BIT|VIA_UNFILLED_BIT)
349 #define TAG(x) x##_twoside_unfilled
350 #include "via_dd_tritmp.h"
351
352 #define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT|VIA_UNFILLED_BIT)
353 #define TAG(x) x##_twoside_offset_unfilled
354 #include "via_dd_tritmp.h"
355
356 #define IND (VIA_FALLBACK_BIT)
357 #define TAG(x) x##_fallback
358 #include "via_dd_tritmp.h"
359
360 #define IND (VIA_OFFSET_BIT|VIA_FALLBACK_BIT)
361 #define TAG(x) x##_offset_fallback
362 #include "via_dd_tritmp.h"
363
364 #define IND (VIA_TWOSIDE_BIT|VIA_FALLBACK_BIT)
365 #define TAG(x) x##_twoside_fallback
366 #include "via_dd_tritmp.h"
367
368 #define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT|VIA_FALLBACK_BIT)
369 #define TAG(x) x##_twoside_offset_fallback
370 #include "via_dd_tritmp.h"
371
372 #define IND (VIA_UNFILLED_BIT|VIA_FALLBACK_BIT)
373 #define TAG(x) x##_unfilled_fallback
374 #include "via_dd_tritmp.h"
375
376 #define IND (VIA_OFFSET_BIT|VIA_UNFILLED_BIT|VIA_FALLBACK_BIT)
377 #define TAG(x) x##_offset_unfilled_fallback
378 #include "via_dd_tritmp.h"
379
380 #define IND (VIA_TWOSIDE_BIT|VIA_UNFILLED_BIT|VIA_FALLBACK_BIT)
381 #define TAG(x) x##_twoside_unfilled_fallback
382 #include "via_dd_tritmp.h"
383
384 #define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT|VIA_UNFILLED_BIT| \
385 VIA_FALLBACK_BIT)
386 #define TAG(x) x##_twoside_offset_unfilled_fallback
387 #include "via_dd_tritmp.h"
388
389
390 static void init_rast_tab(void)
391 {
392 init();
393 init_offset();
394 init_twoside();
395 init_twoside_offset();
396 init_unfilled();
397 init_offset_unfilled();
398 init_twoside_unfilled();
399 init_twoside_offset_unfilled();
400 init_fallback();
401 init_offset_fallback();
402 init_twoside_fallback();
403 init_twoside_offset_fallback();
404 init_unfilled_fallback();
405 init_offset_unfilled_fallback();
406 init_twoside_unfilled_fallback();
407 init_twoside_offset_unfilled_fallback();
408 }
409
410
411 /***********************************************************************
412 * Rasterization fallback helpers *
413 ***********************************************************************/
414
415
416 /* This code is hit only when a mix of accelerated and unaccelerated
417 * primitives are being drawn, and only for the unaccelerated
418 * primitives.
419 */
420 static void
421 via_fallback_tri(viaContextPtr vmesa,
422 viaVertex *v0,
423 viaVertex *v1,
424 viaVertex *v2)
425 {
426 GLcontext *ctx = vmesa->glCtx;
427 SWvertex v[3];
428 #ifdef PERFORMANCE_MEASURE
429 if (VIA_PERFORMANCE) P_M;
430 #endif
431 via_translate_vertex(ctx, v0, &v[0]);
432 via_translate_vertex(ctx, v1, &v[1]);
433 via_translate_vertex(ctx, v2, &v[2]);
434 _swrast_Triangle(ctx, &v[0], &v[1], &v[2]);
435 }
436
437
438 static void
439 via_fallback_line(viaContextPtr vmesa,
440 viaVertex *v0,
441 viaVertex *v1)
442 {
443 GLcontext *ctx = vmesa->glCtx;
444 SWvertex v[2];
445 #ifdef PERFORMANCE_MEASURE
446 if (VIA_PERFORMANCE) P_M;
447 #endif
448 via_translate_vertex(ctx, v0, &v[0]);
449 via_translate_vertex(ctx, v1, &v[1]);
450 _swrast_Line(ctx, &v[0], &v[1]);
451 }
452
453
454 static void
455 via_fallback_point(viaContextPtr vmesa,
456 viaVertex *v0)
457 {
458 GLcontext *ctx = vmesa->glCtx;
459 SWvertex v[1];
460 #ifdef PERFORMANCE_MEASURE
461 if (VIA_PERFORMANCE) P_M;
462 #endif
463 via_translate_vertex(ctx, v0, &v[0]);
464 _swrast_Point(ctx, &v[0]);
465 }
466
467 /**********************************************************************/
468 /* Render unclipped begin/end objects */
469 /* (No Twoside / Offset / Unfilled) */
470 /**********************************************************************/
471 #define IND 0
472 #define V(x) (viaVertex *)(vertptr + ((x) << vertshift))
473 #define RENDER_POINTS(start, count) \
474 for (; start < count; start++) POINT(V(ELT(start)));
475 #define RENDER_LINE(v0, v1) LINE(V(v0), V(v1))
476
477 #define RENDER_TRI( v0, v1, v2) \
478 if (VIA_DEBUG) fprintf(stderr, "RENDER_TRI - simple\n"); \
479 TRI( V(v0), V(v1), V(v2))
480
481 #define RENDER_QUAD(v0, v1, v2, v3) QUAD(V(v0), V(v1), V(v2), V(v3))
482
483 #define INIT(x) viaRasterPrimitive(ctx, x, x)
484
485 #undef LOCAL_VARS
486 #define LOCAL_VARS \
487 viaContextPtr vmesa = VIA_CONTEXT(ctx); \
488 GLubyte *vertptr = (GLubyte *)vmesa->verts; \
489 const GLuint vertshift = vmesa->vertexStrideShift; \
490 const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
491 (void)elt;
492 #define POSTFIX \
493 viaRasterPrimitiveFinish(ctx)
494 #define RESET_STIPPLE
495 #define RESET_OCCLUSION
496 #define PRESERVE_VB_DEFS
497 #define ELT(x) x
498 #define TAG(x) via_fast##x##_verts
499 #include "via_vb_rendertmp.h"
500 #undef ELT
501 #undef TAG
502 #define TAG(x) via_fast##x##_elts
503 #define ELT(x) elt[x]
504 #include "via_vb_rendertmp.h"
505 #undef ELT
506 #undef TAG
507 #undef NEED_EDGEFLAG_SETUP
508 #undef EDGEFLAG_GET
509 #undef EDGEFLAG_SET
510 #undef RESET_OCCLUSION
511
512 /**********************************************************************/
513 /* Render unclipped begin/end objects */
514 /* (Can handle Twoside / Offset / Unfilled */
515 /**********************************************************************/
516 #define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
517 #define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
518 #define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
519
520 #define RENDER_POINTS(start, count) \
521 tnl->Driver.Render.Points(ctx, start, count)
522
523 #define RENDER_LINE(v1, v2) \
524 LineFunc(ctx, v1, v2)
525
526 #define RENDER_TRI(v1, v2, v3) \
527 if (VIA_DEBUG) fprintf(stderr, "RENDER_TRI - complex\n"); \
528 if (VIA_DEBUG) fprintf(stderr, "TriangleFunc = %x\n", (unsigned int)TriangleFunc); \
529 TriangleFunc(ctx, v1, v2, v3)
530
531 #define RENDER_QUAD(v1, v2, v3, v4) \
532 QuadFunc(ctx, v1, v2, v3, v4)
533
534 #define LOCAL_VARS \
535 TNLcontext *tnl = TNL_CONTEXT(ctx); \
536 struct vertex_buffer *VB = &tnl->vb; \
537 const GLuint * const elt = VB->Elts; \
538 const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
539 const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
540 const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
541 const GLboolean stipple = ctx->Line.StippleFlag; \
542 (void) (LineFunc && TriangleFunc && QuadFunc); \
543 (void) elt; (void) stipple;
544
545 #define POSTFIX \
546 viaRasterPrimitiveFinish(ctx)
547 #define ELT(x) x
548 #define TAG(x) via_##x##_verts
549 /*#define INIT(x) tnl->Driver.Render.PrimitiveNotify(ctx, x)*/
550 #define INIT(x) viaRasterPrimitive(ctx, x, x)
551 #define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple(ctx)
552 #define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
553 #define PRESERVE_VB_DEFS
554 #include "via_vb_rendertmp.h"
555 #undef ELT
556 #undef TAG
557 #define ELT(x) elt[x]
558 #define TAG(x) via_##x##_elts
559 #include "via_vb_rendertmp.h"
560
561 /**********************************************************************/
562 /* Render clipped primitives */
563 /**********************************************************************/
564
565
566
567 static void viaRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
568 GLuint n)
569 {
570 TNLcontext *tnl = TNL_CONTEXT(ctx);
571 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
572 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
573 #ifdef PERFORMANCE_MEASURE
574 if (VIA_PERFORMANCE) P_M;
575 #endif
576 /* Render the new vertices as an unclipped polygon.
577 */
578 {
579 GLuint *tmp = VB->Elts;
580 VB->Elts = (GLuint *)elts;
581 tnl->Driver.Render.PrimTabElts[GL_POLYGON](ctx, 0, n,
582 PRIM_BEGIN|PRIM_END);
583 VB->Elts = tmp;
584 }
585 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
586 }
587
588 static void viaRenderClippedLine(GLcontext *ctx, GLuint ii, GLuint jj)
589 {
590 viaContextPtr vmesa = VIA_CONTEXT(ctx);
591 TNLcontext *tnl = TNL_CONTEXT(ctx);
592 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
593 #ifdef PERFORMANCE_MEASURE
594 if (VIA_PERFORMANCE) P_M;
595 #endif
596 vmesa->primitiveRendered = GL_TRUE;
597
598 tnl->Driver.Render.Line(ctx, ii, jj);
599 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
600 }
601
602 static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
603 GLuint n)
604 {
605 viaContextPtr vmesa = VIA_CONTEXT(ctx);
606 GLuint vertsize = vmesa->vertexSize;
607 GLuint *vb = viaCheckDma(vmesa, (n - 2) * 3 * 4 * vertsize);
608 GLubyte *vertptr = (GLubyte *)vmesa->verts;
609 const GLuint vertshift = vmesa->vertexStrideShift;
610 const GLuint *start = (const GLuint *)V(elts[0]);
611 GLuint *temp1;
612 GLuint *temp2;
613 int i,j;
614 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
615 #ifdef PERFORMANCE_MEASURE
616 if (VIA_PERFORMANCE) P_M;
617 #endif
618 vmesa->primitiveRendered = GL_TRUE;
619
620 for (i = 2; i < n; i++) {
621 /*=* [DBG] exy : fix flat-shading + clipping error *=*/
622 /*COPY_DWORDS(j, vb, vertsize, start);
623 COPY_DWORDS(j, vb, vertsize, V(elts[i - 1]));
624 temp1 = (GLuint *)V(elts[i - 1]);
625 COPY_DWORDS(j, vb, vertsize, V(elts[i]));
626 temp2 = (GLuint *)V(elts[i]);*/
627 COPY_DWORDS(j, vb, vertsize, V(elts[i - 1]));
628 COPY_DWORDS(j, vb, vertsize, V(elts[i]));
629 temp1 = (GLuint *)V(elts[i - 1]);
630 COPY_DWORDS(j, vb, vertsize, start);
631 temp2 = (GLuint *)V(elts[i]);
632 if (VIA_DEBUG) fprintf(stderr, "start = %d - x = %f, y = %f, z = %f, w = %f, u = %f, v = %f\n", elts[0], *(GLfloat *)&start[0], *(GLfloat *)&start[1], *(GLfloat *)&start[2], *(GLfloat *)&start[3], *(GLfloat *)&start[6], *(GLfloat *)&start[7]);
633 if (VIA_DEBUG) fprintf(stderr, "%d - x = %f, y = %f, z = %f, w = %f, u = %f, v = %f\n", elts[i - 1], *(GLfloat *)&temp1[0], *(GLfloat *)&temp1[1], *(GLfloat *)&temp1[2], *(GLfloat *)&temp1[3], *(GLfloat *)&temp1[6], *(GLfloat *)&temp1[7]);
634 if (VIA_DEBUG) fprintf(stderr, "%d - x = %f, y = %f, z = %f, w = %f, u = %f, v = %f\n", elts[i], *(GLfloat *)&temp2[0], *(GLfloat *)&temp2[1], *(GLfloat *)&temp2[2], *(GLfloat *)&temp2[3], *(GLfloat *)&temp2[6], *(GLfloat *)&temp2[7]);
635 }
636 vmesa->dmaLow += (n - 2) * 3 * 4 * vertsize;
637 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
638 }
639
640 /**********************************************************************/
641 /* Choose render functions */
642 /**********************************************************************/
643
644
645
646 #define _VIA_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE | \
647 _DD_NEW_TRI_UNFILLED | \
648 _DD_NEW_TRI_LIGHT_TWOSIDE | \
649 _DD_NEW_TRI_OFFSET | \
650 _DD_NEW_TRI_STIPPLE | \
651 _NEW_POLYGONSTIPPLE)
652
653 #define POINT_FALLBACK (0)
654 /*#define LINE_FALLBACK (DD_LINE_STIPPLE)
655 */
656 #define LINE_FALLBACK (0)
657 #define TRI_FALLBACK (0)
658 #define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
659 #define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
660
661 static void viaChooseRenderState(GLcontext *ctx)
662 {
663 TNLcontext *tnl = TNL_CONTEXT(ctx);
664 viaContextPtr vmesa = VIA_CONTEXT(ctx);
665 GLuint flags = ctx->_TriangleCaps;
666 GLuint index = 0;
667 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
668
669 if (VIA_DEBUG) fprintf(stderr, "_TriangleCaps = %x\n", flags);
670 if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
671 if (flags & ANY_RASTER_FLAGS) {
672 if (flags & DD_TRI_LIGHT_TWOSIDE) index |= VIA_TWOSIDE_BIT;
673 if (flags & DD_TRI_OFFSET) index |= VIA_OFFSET_BIT;
674 if (flags & DD_TRI_UNFILLED) index |= VIA_UNFILLED_BIT;
675 }
676
677 vmesa->drawPoint = via_draw_point;
678 vmesa->drawLine = via_draw_line;
679 vmesa->drawTri = via_draw_triangle;
680
681 /* Hook in fallbacks for specific primitives.
682 */
683 if (flags & ANY_FALLBACK_FLAGS) {
684 if (flags & POINT_FALLBACK)
685 vmesa->drawPoint = via_fallback_point;
686
687 if (flags & LINE_FALLBACK)
688 vmesa->drawLine = via_fallback_line;
689
690 if (flags & TRI_FALLBACK)
691 vmesa->drawTri = via_fallback_tri;
692
693 index |= VIA_FALLBACK_BIT;
694 }
695 }
696 if (VIA_DEBUG) {
697 fprintf(stderr, "index = %x\n", index);
698 fprintf(stderr, "renderIndex = %x\n", vmesa->renderIndex);
699 }
700 if (vmesa->renderIndex != index) {
701 vmesa->renderIndex = index;
702
703 tnl->Driver.Render.Points = rast_tab[index].points;
704 tnl->Driver.Render.Line = rast_tab[index].line;
705 tnl->Driver.Render.Triangle = rast_tab[index].triangle;
706 if (VIA_DEBUG) fprintf(stderr, "tnl->Driver.Render.xxx = rast_tab[index].xxx = %x\n", (unsigned int)tnl->Driver.Render.Triangle);
707 tnl->Driver.Render.Quad = rast_tab[index].quad;
708
709 if (index == 0) {
710 tnl->Driver.Render.PrimTabVerts = via_fastrender_tab_verts;
711 tnl->Driver.Render.PrimTabElts = via_fastrender_tab_elts;
712 tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
713 tnl->Driver.Render.ClippedPolygon = viaFastRenderClippedPoly;
714 }
715 else {
716 tnl->Driver.Render.PrimTabVerts = via_render_tab_verts;
717 tnl->Driver.Render.PrimTabElts = via_render_tab_elts;
718 tnl->Driver.Render.ClippedLine = viaRenderClippedLine;
719 tnl->Driver.Render.ClippedPolygon = viaRenderClippedPoly;
720 }
721 }
722 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
723 }
724
725 static const GLenum reducedPrim[GL_POLYGON + 1] = {
726 GL_POINTS,
727 GL_LINES,
728 GL_LINES,
729 GL_LINES,
730 GL_TRIANGLES,
731 GL_TRIANGLES,
732 GL_TRIANGLES,
733 GL_TRIANGLES,
734 GL_TRIANGLES,
735 GL_TRIANGLES
736 };
737
738
739 static void emit_all_state(viaContextPtr vmesa)
740 {
741 GLcontext *ctx = vmesa->glCtx;
742 GLuint *vb = viaCheckDma(vmesa, 0x110);
743 GLuint i = 0;
744 GLuint j = 0;
745 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
746 #ifdef PERFORMANCE_MEASURE
747 if (VIA_PERFORMANCE) P_M;
748 #endif
749
750 *vb++ = HC_HEADER2;
751 *vb++ = (HC_ParaType_NotTex << 16);
752 *vb++ = ((HC_SubA_HEnable << 24) | vmesa->regEnable);
753 *vb++ = ((HC_SubA_HFBBMSKL << 24) | vmesa->regHFBBMSKL);
754 *vb++ = ((HC_SubA_HROP << 24) | vmesa->regHROP);
755 i += 5;
756
757 if (vmesa->hasDepth && vmesa->hasStencil) {
758 GLuint pitch, format, offset;
759
760 format = HC_HZWBFM_24;
761
762 offset = vmesa->depth.offset;
763 pitch = vmesa->depth.pitch;
764
765 *vb++ = ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF));
766
767 *vb++ = ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24));
768 *vb++ = ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK |
769 format | pitch);
770 *vb++ = ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD);
771 /* set stencil */
772 *vb++ = ((HC_SubA_HSTREF << 24) | vmesa->regHSTREF);
773 *vb++ = ((HC_SubA_HSTMD << 24) | vmesa->regHSTMD);
774
775 i += 6;
776 }
777 else if (vmesa->hasDepth) {
778 GLuint pitch, format, offset;
779
780 if (vmesa->depthBits == 16) {
781 /* We haven't support 16bit depth yet */
782 format = HC_HZWBFM_16;
783 /*format = HC_HZWBFM_32;*/
784 if (VIA_DEBUG) fprintf(stderr, "z format = 16\n");
785 }
786 else {
787 format = HC_HZWBFM_32;
788 if (VIA_DEBUG) fprintf(stderr, "z format = 32\n");
789 }
790
791
792 offset = vmesa->depth.offset;
793 pitch = vmesa->depth.pitch;
794
795 *vb++ = ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF));
796
797 *vb++ = ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24));
798 *vb++ = ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK |
799 format | pitch);
800 *vb++ = ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD);
801 i += 4;
802 }
803 else if (vmesa->hasStencil) {
804 GLuint pitch, format, offset;
805
806 format = HC_HZWBFM_24;
807
808 offset = vmesa->depth.offset;
809 pitch = vmesa->depth.pitch;
810
811 *vb++ = ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF));
812
813 *vb++ = ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24));
814 *vb++ = ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK |
815 format | pitch);
816 *vb++ = ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD);
817 /* set stencil */
818 *vb++ = ((HC_SubA_HSTREF << 24) | vmesa->regHSTREF);
819 *vb++ = ((HC_SubA_HSTMD << 24) | vmesa->regHSTMD);
820
821 i += 6;
822 }
823
824 if (ctx->Color.AlphaEnabled) {
825 *vb++ = ((HC_SubA_HATMD << 24) | vmesa->regHATMD);
826 i++;
827 }
828
829 if (ctx->Color.BlendEnabled) {
830 *vb++ = ((HC_SubA_HABLCsat << 24) | vmesa->regHABLCsat);
831 *vb++ = ((HC_SubA_HABLCop << 24) | vmesa->regHABLCop);
832 *vb++ = ((HC_SubA_HABLAsat << 24) | vmesa->regHABLAsat);
833 *vb++ = ((HC_SubA_HABLAop << 24) | vmesa->regHABLAop);
834 *vb++ = ((HC_SubA_HABLRCa << 24) | vmesa->regHABLRCa);
835 *vb++ = ((HC_SubA_HABLRFCa << 24) | vmesa->regHABLRFCa);
836 *vb++ = ((HC_SubA_HABLRCbias << 24) | vmesa->regHABLRCbias);
837 *vb++ = ((HC_SubA_HABLRCb << 24) | vmesa->regHABLRCb);
838 *vb++ = ((HC_SubA_HABLRFCb << 24) | vmesa->regHABLRFCb);
839 *vb++ = ((HC_SubA_HABLRAa << 24) | vmesa->regHABLRAa);
840 *vb++ = ((HC_SubA_HABLRAb << 24) | vmesa->regHABLRAb);
841 i += 11;
842 }
843
844 if (ctx->Fog.Enabled) {
845 *vb++ = ((HC_SubA_HFogLF << 24) | vmesa->regHFogLF);
846 *vb++ = ((HC_SubA_HFogCL << 24) | vmesa->regHFogCL);
847 *vb++ = ((HC_SubA_HFogCH << 24) | vmesa->regHFogCH);
848 i += 3;
849 }
850
851 if (ctx->Line.StippleFlag) {
852 *vb++ = ((HC_SubA_HLP << 24) | ctx->Line.StipplePattern);
853 *vb++ = ((HC_SubA_HLPRF << 24) | ctx->Line.StippleFactor);
854 }
855 else {
856 *vb++ = ((HC_SubA_HLP << 24) | 0xFFFF);
857 *vb++ = ((HC_SubA_HLPRF << 24) | 0x1);
858 }
859
860 i += 2;
861
862 *vb++ = ((HC_SubA_HPixGC << 24) | 0x0);
863 i++;
864
865 if (i & 0x1) {
866 *vb++ = HC_DUMMY;
867 i++;
868 }
869
870 if (ctx->Texture._EnabledUnits) {
871
872 struct gl_texture_unit *texUnit0 = &ctx->Texture.Unit[0];
873 struct gl_texture_unit *texUnit1 = &ctx->Texture.Unit[1];
874
875 {
876 viaTextureObjectPtr t = (viaTextureObjectPtr)texUnit0->_Current->DriverData;
877 GLuint nDummyValue = 0;
878
879 *vb++ = HC_HEADER2;
880 *vb++ = (HC_ParaType_Tex << 16) | (HC_SubType_TexGeneral << 24);
881
882 if (ctx->Texture._EnabledUnits > 1) {
883 if (VIA_DEBUG) fprintf(stderr, "multi texture\n");
884 nDummyValue = (HC_SubA_HTXSMD << 24) | (1 << 3);
885
886 if (t && t->needClearCache) {
887 *vb++ = nDummyValue | HC_HTXCHCLR_MASK;
888 *vb++ = nDummyValue;
889 }
890 else {
891 *vb++ = nDummyValue;
892 *vb++ = nDummyValue;
893 }
894 }
895 else {
896 if (VIA_DEBUG) fprintf(stderr, "single texture\n");
897 nDummyValue = (HC_SubA_HTXSMD << 24) | 0;
898
899 if (t && t->needClearCache) {
900 *vb++ = nDummyValue | HC_HTXCHCLR_MASK;
901 *vb++ = nDummyValue;
902 }
903 else {
904 *vb++ = nDummyValue;
905 *vb++ = nDummyValue;
906 }
907 }
908 *vb++ = HC_HEADER2;
909 *vb++ = HC_ParaType_NotTex << 16;
910 *vb++ = (HC_SubA_HEnable << 24) | vmesa->regEnable;
911 *vb++ = (HC_SubA_HEnable << 24) | vmesa->regEnable;
912 i += 8;
913 }
914
915 if (texUnit0->Enabled) {
916 struct gl_texture_object *texObj = texUnit0->_Current;
917 viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData;
918 GLuint numLevels = t->lastLevel - t->firstLevel + 1;
919 GLuint nDummyValue = 0;
920 if (VIA_DEBUG) {
921 fprintf(stderr, "texture0 enabled\n");
922 fprintf(stderr, "texture level %d\n", t->actualLevel);
923 }
924 if (numLevels == 8) {
925 nDummyValue = t->regTexFM;
926 *vb++ = HC_HEADER2;
927 *vb++ = (HC_ParaType_Tex << 16) | (0 << 24);
928 *vb++ = t->regTexFM;
929 *vb++ = (HC_SubA_HTXnL0OS << 24) |
930 ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel;
931 *vb++ = t->regTexWidthLog2[0];
932 *vb++ = t->regTexWidthLog2[1];
933 *vb++ = t->regTexHeightLog2[0];
934 *vb++ = t->regTexHeightLog2[1];
935 *vb++ = t->regTexBaseH[0];
936 *vb++ = t->regTexBaseH[1];
937 *vb++ = t->regTexBaseH[2];
938
939 *vb++ = t->regTexBaseAndPitch[0].baseL;
940 *vb++ = t->regTexBaseAndPitch[0].pitchLog2;
941 *vb++ = t->regTexBaseAndPitch[1].baseL;
942 *vb++ = t->regTexBaseAndPitch[1].pitchLog2;
943 *vb++ = t->regTexBaseAndPitch[2].baseL;
944 *vb++ = t->regTexBaseAndPitch[2].pitchLog2;
945 *vb++ = t->regTexBaseAndPitch[3].baseL;
946 *vb++ = t->regTexBaseAndPitch[3].pitchLog2;
947 *vb++ = t->regTexBaseAndPitch[4].baseL;
948 *vb++ = t->regTexBaseAndPitch[4].pitchLog2;
949 *vb++ = t->regTexBaseAndPitch[5].baseL;
950 *vb++ = t->regTexBaseAndPitch[5].pitchLog2;
951 *vb++ = t->regTexBaseAndPitch[6].baseL;
952 *vb++ = t->regTexBaseAndPitch[6].pitchLog2;
953 *vb++ = t->regTexBaseAndPitch[7].baseL;
954 *vb++ = t->regTexBaseAndPitch[7].pitchLog2;
955 i += 27;
956 }
957 else if (numLevels > 1) {
958 nDummyValue = t->regTexFM;
959 *vb++ = HC_HEADER2;
960 *vb++ = (HC_ParaType_Tex << 16) | (0 << 24);
961 *vb++ = t->regTexFM;
962 *vb++ = (HC_SubA_HTXnL0OS << 24) |
963 ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel;
964 *vb++ = t->regTexWidthLog2[0];
965 *vb++ = t->regTexHeightLog2[0];
966
967 if (numLevels > 6) {
968 *vb++ = t->regTexWidthLog2[1];
969 *vb++ = t->regTexHeightLog2[1];
970 i += 2;
971 }
972
973 *vb++ = t->regTexBaseH[0];
974
975 if (numLevels > 3) {
976 *vb++ = t->regTexBaseH[1];
977 i++;
978 }
979 if (numLevels > 6) {
980 *vb++ = t->regTexBaseH[2];
981 i++;
982 }
983 if (numLevels > 9) {
984 *vb++ = t->regTexBaseH[3];
985 i++;
986 }
987
988 i += 7;
989
990 for (j = 0; j < numLevels; j++) {
991 *vb++ = t->regTexBaseAndPitch[j].baseL;
992 *vb++ = t->regTexBaseAndPitch[j].pitchLog2;
993 i += 2;
994 }
995 }
996 else {
997 nDummyValue = t->regTexFM;
998 *vb++ = HC_HEADER2;
999 *vb++ = (HC_ParaType_Tex << 16) | (0 << 24);
1000 *vb++ = t->regTexFM;
1001 *vb++ = (HC_SubA_HTXnL0OS << 24) |
1002 ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel;
1003 *vb++ = t->regTexWidthLog2[0];
1004 *vb++ = t->regTexHeightLog2[0];
1005 *vb++ = t->regTexBaseH[0];
1006 *vb++ = t->regTexBaseAndPitch[0].baseL;
1007 *vb++ = t->regTexBaseAndPitch[0].pitchLog2;
1008 i += 9;
1009 }
1010
1011 *vb++ = (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB_0;
1012 *vb++ = (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD_0;
1013 *vb++ = (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat_0;
1014 *vb++ = (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop_0;
1015 *vb++ = (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog_0;
1016 *vb++ = (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat_0;
1017 *vb++ = (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb_0;
1018 *vb++ = (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa_0;
1019 *vb++ = (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog_0;
1020 i += 9;
1021 /*=* John Sheng [2003.7.18] texture combine */
1022 *vb++ = (HC_SubA_HTXnTBLRCa << 24) | vmesa->regHTXnTBLRCa_0;
1023 *vb++ = (HC_SubA_HTXnTBLRCc << 24) | vmesa->regHTXnTBLRCc_0;
1024 *vb++ = (HC_SubA_HTXnTBLRCbias << 24) | vmesa->regHTXnTBLRCbias_0;
1025 i += 3;
1026
1027 if (t->regTexFM == HC_HTXnFM_Index8) {
1028 struct gl_color_table *table = &texObj->Palette;
1029 GLfloat *tableF = (GLfloat *)table->Table;
1030
1031 *vb++ = HC_HEADER2;
1032 *vb++ = (HC_ParaType_Palette << 16) | (0 << 24);
1033 i += 2;
1034 for (j = 0; j < table->Size; j++) {
1035 *vb++ = tableF[j];
1036 i++;
1037 }
1038 }
1039 if (i & 0x1) {
1040 *vb++ = HC_DUMMY;
1041 i++;
1042 }
1043 }
1044
1045 if (texUnit1->Enabled) {
1046 struct gl_texture_object *texObj = texUnit1->_Current;
1047 viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData;
1048 GLuint numLevels = t->lastLevel - t->firstLevel + 1;
1049 GLuint nDummyValue = 0;
1050 if (VIA_DEBUG) {
1051 fprintf(stderr, "texture1 enabled\n");
1052 fprintf(stderr, "texture level %d\n", t->actualLevel);
1053 }
1054 if (numLevels == 8) {
1055 nDummyValue = t->regTexFM;
1056 *vb++ = HC_HEADER2;
1057 *vb++ = (HC_ParaType_Tex << 16) | (1 << 24);
1058 *vb++ = t->regTexFM;
1059 *vb++ = (HC_SubA_HTXnL0OS << 24) |
1060 ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel;
1061 *vb++ = t->regTexWidthLog2[0];
1062 *vb++ = t->regTexWidthLog2[1];
1063 *vb++ = t->regTexHeightLog2[0];
1064 *vb++ = t->regTexHeightLog2[1];
1065 *vb++ = t->regTexBaseH[0];
1066 *vb++ = t->regTexBaseH[1];
1067 *vb++ = t->regTexBaseH[2];
1068
1069 *vb++ = t->regTexBaseAndPitch[0].baseL;
1070 *vb++ = t->regTexBaseAndPitch[0].pitchLog2;
1071 *vb++ = t->regTexBaseAndPitch[1].baseL;
1072 *vb++ = t->regTexBaseAndPitch[1].pitchLog2;
1073 *vb++ = t->regTexBaseAndPitch[2].baseL;
1074 *vb++ = t->regTexBaseAndPitch[2].pitchLog2;
1075 *vb++ = t->regTexBaseAndPitch[3].baseL;
1076 *vb++ = t->regTexBaseAndPitch[3].pitchLog2;
1077 *vb++ = t->regTexBaseAndPitch[4].baseL;
1078 *vb++ = t->regTexBaseAndPitch[4].pitchLog2;
1079 *vb++ = t->regTexBaseAndPitch[5].baseL;
1080 *vb++ = t->regTexBaseAndPitch[5].pitchLog2;
1081 *vb++ = t->regTexBaseAndPitch[6].baseL;
1082 *vb++ = t->regTexBaseAndPitch[6].pitchLog2;
1083 *vb++ = t->regTexBaseAndPitch[7].baseL;
1084 *vb++ = t->regTexBaseAndPitch[7].pitchLog2;
1085 i += 27;
1086 }
1087 else if (numLevels > 1) {
1088 nDummyValue = t->regTexFM;
1089 *vb++ = HC_HEADER2;
1090 *vb++ = (HC_ParaType_Tex << 16) | (1 << 24);
1091 *vb++ = t->regTexFM;
1092 *vb++ = (HC_SubA_HTXnL0OS << 24) |
1093 ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel;
1094 *vb++ = t->regTexWidthLog2[0];
1095 *vb++ = t->regTexHeightLog2[0];
1096
1097 if (numLevels > 6) {
1098 *vb++ = t->regTexWidthLog2[1];
1099 *vb++ = t->regTexHeightLog2[1];
1100 i += 2;
1101 }
1102
1103 *vb++ = t->regTexBaseH[0];
1104
1105 if (numLevels > 3) {
1106 *vb++ = t->regTexBaseH[1];
1107 i++;
1108 }
1109 if (numLevels > 6) {
1110 *vb++ = t->regTexBaseH[2];
1111 i++;
1112 }
1113 if (numLevels > 9) {
1114 *vb++ = t->regTexBaseH[3];
1115 i++;
1116 }
1117
1118 i += 7;
1119
1120 for (j = 0; j < numLevels; j++) {
1121 *vb++ = t->regTexBaseAndPitch[j].baseL;
1122 *vb++ = t->regTexBaseAndPitch[j].pitchLog2;
1123 i += 2;
1124 }
1125 }
1126 else {
1127 nDummyValue = t->regTexFM;
1128 *vb++ = HC_HEADER2;
1129 *vb++ = (HC_ParaType_Tex << 16) | (1 << 24);
1130 *vb++ = t->regTexFM;
1131 *vb++ = (HC_SubA_HTXnL0OS << 24) |
1132 ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel;
1133 *vb++ = t->regTexWidthLog2[0];
1134 *vb++ = t->regTexHeightLog2[0];
1135 *vb++ = t->regTexBaseH[0];
1136 *vb++ = t->regTexBaseAndPitch[0].baseL;
1137 *vb++ = t->regTexBaseAndPitch[0].pitchLog2;
1138 i += 9;
1139 }
1140
1141 *vb++ = (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB_1;
1142 *vb++ = (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD_1;
1143 *vb++ = (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat_1;
1144 *vb++ = (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop_1;
1145 *vb++ = (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog_1;
1146 *vb++ = (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat_1;
1147 *vb++ = (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb_1;
1148 *vb++ = (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa_1;
1149 *vb++ = (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog_1;
1150 i += 9;
1151
1152 if (t->regTexFM == HC_HTXnFM_Index8) {
1153 struct gl_color_table *table = &texObj->Palette;
1154 GLfloat *tableF = (GLfloat *)table->Table;
1155
1156 *vb++ = HC_HEADER2;
1157 *vb++ = (HC_ParaType_Palette << 16) | (1 << 24);
1158 i += 2;
1159 for (j = 0; j < table->Size; j++) {
1160 *vb++ = tableF[j];
1161 i++;
1162 }
1163 }
1164 if (i & 0x1) {
1165 *vb++ = HC_DUMMY;
1166 i++;
1167 }
1168 }
1169 }
1170
1171
1172 if (ctx->Polygon.StippleFlag) {
1173 GLuint *stipple = &ctx->PolygonStipple[0];
1174
1175 *vb++ = HC_HEADER2;
1176 *vb++ = ((HC_ParaType_Palette << 16) | (HC_SubType_Stipple << 24));
1177
1178 *vb++ = stipple[31];
1179 *vb++ = stipple[30];
1180 *vb++ = stipple[29];
1181 *vb++ = stipple[28];
1182 *vb++ = stipple[27];
1183 *vb++ = stipple[26];
1184 *vb++ = stipple[25];
1185 *vb++ = stipple[24];
1186 *vb++ = stipple[23];
1187 *vb++ = stipple[22];
1188 *vb++ = stipple[21];
1189 *vb++ = stipple[20];
1190 *vb++ = stipple[19];
1191 *vb++ = stipple[18];
1192 *vb++ = stipple[17];
1193 *vb++ = stipple[16];
1194 *vb++ = stipple[15];
1195 *vb++ = stipple[14];
1196 *vb++ = stipple[13];
1197 *vb++ = stipple[12];
1198 *vb++ = stipple[11];
1199 *vb++ = stipple[10];
1200 *vb++ = stipple[9];
1201 *vb++ = stipple[8];
1202 *vb++ = stipple[7];
1203 *vb++ = stipple[6];
1204 *vb++ = stipple[5];
1205 *vb++ = stipple[4];
1206 *vb++ = stipple[3];
1207 *vb++ = stipple[2];
1208 *vb++ = stipple[1];
1209 *vb++ = stipple[0];
1210
1211 *vb++ = HC_HEADER2;
1212 *vb++ = (HC_ParaType_NotTex << 16);
1213 *vb++ = ((HC_SubA_HSPXYOS << 24) | (0x20 - (vmesa->driDrawable->h & 0x1F)));
1214 *vb++ = ((HC_SubA_HSPXYOS << 24) | (0x20 - (vmesa->driDrawable->h & 0x1F)));
1215 i += 38;
1216 }
1217
1218 vmesa->dmaLow += (i << 2);
1219
1220 vmesa->dirty = 0;
1221 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
1222 }
1223
1224
1225 static void emit_partial_state(viaContextPtr vmesa)
1226 {
1227 GLcontext *ctx = vmesa->glCtx;
1228 GLuint dirty = vmesa->dirty;
1229 GLuint *vb = viaCheckDma(vmesa, 0x110);
1230 GLuint i = 0;
1231
1232 if( VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
1233
1234 #ifdef PERFORMANCE_MEASURE
1235 if (VIA_PERFORMANCE) P_M;
1236 #endif
1237 vb = vb;
1238
1239 *vb++ = HC_HEADER2;
1240 *vb++ = (HC_ParaType_NotTex << 16);
1241 *vb++ = ((HC_SubA_HEnable << 24) | vmesa->regEnable);
1242 *vb++ = ((HC_SubA_HFBBMSKL << 24) | vmesa->regHFBBMSKL);
1243 *vb++ = ((HC_SubA_HROP << 24) | vmesa->regHROP);
1244 i += 5;
1245
1246 if (dirty & VIA_UPLOAD_DESTBUFFER) {
1247 }
1248
1249 if (dirty & VIA_UPLOAD_DEPTHBUFFER) {
1250 }
1251
1252 if (dirty * VIA_UPLOAD_DEPTH) {
1253 *vb++ = ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD);
1254 i++;
1255 }
1256
1257 if (dirty * VIA_UPLOAD_ALPHATEST) {
1258 *vb++ = ((HC_SubA_HATMD << 24) | vmesa->regHATMD);
1259 i++;
1260 }
1261
1262
1263 if (dirty & VIA_UPLOAD_BLEND) {
1264 *vb++ = ((HC_SubA_HABLCsat << 24) | vmesa->regHABLCsat);
1265 *vb++ = ((HC_SubA_HABLCop << 24) | vmesa->regHABLCop);
1266 *vb++ = ((HC_SubA_HABLAsat << 24) | vmesa->regHABLAsat);
1267 *vb++ = ((HC_SubA_HABLAop << 24) | vmesa->regHABLAop);
1268 *vb++ = ((HC_SubA_HABLRCa << 24) | vmesa->regHABLRCa);
1269 *vb++ = ((HC_SubA_HABLRFCa << 24) | vmesa->regHABLRFCa);
1270 *vb++ = ((HC_SubA_HABLRCbias << 24) | vmesa->regHABLRCbias);
1271 *vb++ = ((HC_SubA_HABLRCb << 24) | vmesa->regHABLRCb);
1272 *vb++ = ((HC_SubA_HABLRFCb << 24) | vmesa->regHABLRFCb);
1273 *vb++ = ((HC_SubA_HABLRAa << 24) | vmesa->regHABLRAa);
1274 *vb++ = ((HC_SubA_HABLRAb << 24) | vmesa->regHABLRAb);
1275 i += 11;
1276 }
1277
1278 if (dirty & VIA_UPLOAD_FOG) {
1279 *vb++ = ((HC_SubA_HFogLF << 24) | vmesa->regHFogLF);
1280 *vb++ = ((HC_SubA_HFogCL << 24) | vmesa->regHFogCL);
1281 *vb++ = ((HC_SubA_HFogCH << 24) | vmesa->regHFogCH);
1282 i += 3;
1283 }
1284
1285 if (dirty & VIA_UPLOAD_LINESTIPPLE) {
1286 *vb++ = ((HC_SubA_HLP << 24) | ctx->Line.StipplePattern);
1287 *vb++ = ((HC_SubA_HLPRF << 24) | ctx->Line.StippleFactor);
1288 }
1289 else {
1290 *vb++ = ((HC_SubA_HLP << 24) | 0xFFFF);
1291 *vb++ = ((HC_SubA_HLPRF << 24) | 0x1);
1292 }
1293 i += 2;
1294
1295 *vb++ = ((HC_SubA_HPixGC << 24) | 0x0);
1296 i++;
1297
1298 if (i & 0x1) {
1299 *vb++ = HC_DUMMY;
1300 i++;
1301 }
1302
1303 if (dirty & VIA_UPLOAD_TEXTURE) {
1304
1305 }
1306
1307 if (dirty & VIA_UPLOAD_POLYGONSTIPPLE) {
1308
1309 }
1310
1311 vmesa->dmaLow += (i << 2);
1312
1313 vmesa->dirty = 0;
1314 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
1315 }
1316
1317 /**********************************************************************/
1318 /* High level hooks for t_vb_render.c */
1319 /**********************************************************************/
1320
1321 /* Determine the rasterized primitive when not drawing unfilled
1322 * polygons.
1323 *
1324 * Used only for the default render stage which always decomposes
1325 * primitives to trianges/lines/points. For the accelerated stage,
1326 * which renders strips as strips, the equivalent calculations are
1327 * performed in via_render.c.
1328 */
1329 static void viaRenderPrimitive(GLcontext *ctx, GLenum prim)
1330 {
1331 viaContextPtr vmesa = VIA_CONTEXT(ctx);
1332 GLuint rprim = reducedPrim[prim];
1333 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
1334 vmesa->renderPrimitive = prim;
1335 viaRasterPrimitive(ctx, rprim, rprim);
1336 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
1337 }
1338
1339 static void viaRunPipeline(GLcontext *ctx)
1340 {
1341 viaContextPtr vmesa = VIA_CONTEXT(ctx);
1342 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
1343
1344 if (VIA_DEBUG) fprintf(stderr, "newState = %x\n", vmesa->newState);
1345
1346 if (vmesa->newState) {
1347 if (vmesa->newState & _NEW_TEXTURE)
1348 viaUpdateTextureState(ctx); /* may modify vmesa->newState */
1349
1350 viaChooseVertexState(ctx);
1351 viaChooseRenderState(ctx);
1352 vmesa->newState = 0;
1353 }
1354
1355 if (vmesa->needUploadAllState)
1356 emit_all_state(vmesa);
1357 else
1358 emit_partial_state(vmesa);
1359
1360 _tnl_run_pipeline(ctx);
1361 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
1362 }
1363
1364 static void viaRenderStart(GLcontext *ctx)
1365 {
1366 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
1367
1368 /* Check for projective texturing. Make sure all texcoord
1369 * pointers point to something. (fix in mesa?)
1370 */
1371 viaCheckTexSizes(ctx);
1372 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
1373 }
1374
1375 static void viaRenderFinish(GLcontext *ctx)
1376 {
1377 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
1378 if (VIA_CONTEXT(ctx)->renderIndex & VIA_FALLBACK_BIT)
1379 _swrast_flush(ctx);
1380 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
1381 }
1382
1383
1384 /* System to flush dma and emit state changes based on the rasterized
1385 * primitive.
1386 */
1387 void viaRasterPrimitive(GLcontext *ctx,
1388 GLenum rprim,
1389 GLuint hwprim)
1390 {
1391 viaContextPtr vmesa = VIA_CONTEXT(ctx);
1392 GLuint *vb = viaCheckDma(vmesa, 32);
1393 GLuint regCmdB;
1394 if (VIA_DEBUG) {
1395 fprintf(stderr, "%s - in\n", __FUNCTION__);
1396 fprintf(stderr, "hwprim = %x\n", hwprim);
1397 }
1398 /*=* [DBG] exy : fix wireframe + clipping error *=*/
1399 if (((rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)))) {
1400 hwprim = GL_LINES;
1401 }
1402
1403 if (RasterCounter > 0) {
1404
1405 if (VIA_DEBUG) fprintf(stderr, "enter twice:%d\n",RasterCounter);
1406 RasterCounter++;
1407 return;
1408 }
1409 RasterCounter++;
1410
1411 vmesa->primitiveRendered = GL_FALSE;
1412 regCmdB = vmesa->regCmdB;
1413
1414 switch (hwprim) {
1415 case GL_POINTS:
1416 if (VIA_DEBUG) fprintf(stderr, "Points\n");
1417 vmesa->regCmdA_End = vmesa->regCmdA | HC_HPMType_Point | HC_HVCycle_Full;
1418 if (ctx->Light.ShadeModel == GL_FLAT)
1419 vmesa->regCmdA_End |= HC_HShading_FlatA;
1420 break;
1421 case GL_LINES:
1422 if (VIA_DEBUG) fprintf(stderr, "Lines\n");
1423 vmesa->regCmdA_End = vmesa->regCmdA | HC_HPMType_Line | HC_HVCycle_Full;
1424 if (ctx->Light.ShadeModel == GL_FLAT)
1425 vmesa->regCmdA_End |= HC_HShading_FlatB;
1426 break;
1427 case GL_LINE_LOOP:
1428 case GL_LINE_STRIP:
1429 if (VIA_DEBUG) fprintf(stderr, "Line Loop / Line Strip\n");
1430 vmesa->regCmdA_End = vmesa->regCmdA | HC_HPMType_Line | HC_HVCycle_AFP |
1431 HC_HVCycle_AB | HC_HVCycle_NewB;
1432 regCmdB |= HC_HVCycle_AB | HC_HVCycle_NewB | HC_HLPrst_MASK;
1433 if (ctx->Light.ShadeModel == GL_FLAT)
1434 vmesa->regCmdA_End |= HC_HShading_FlatB;
1435 break;
1436 case GL_TRIANGLES:
1437 if (VIA_DEBUG) fprintf(stderr, "Triangles\n");
1438 vmesa->regCmdA_End = vmesa->regCmdA | HC_HPMType_Tri | HC_HVCycle_Full;
1439 if (ctx->Light.ShadeModel == GL_FLAT)
1440 vmesa->regCmdA_End |= HC_HShading_FlatC;
1441 break;
1442 case GL_TRIANGLE_STRIP:
1443 if (VIA_DEBUG) fprintf(stderr, "Triangle Strip\n");
1444 vmesa->regCmdA_End = vmesa->regCmdA | HC_HPMType_Tri | HC_HVCycle_AFP |
1445 HC_HVCycle_AC | HC_HVCycle_BB | HC_HVCycle_NewC;
1446 regCmdB |= HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC;
1447 if (ctx->Light.ShadeModel == GL_FLAT)
1448 vmesa->regCmdA_End |= HC_HShading_FlatB;
1449 break;
1450 case GL_TRIANGLE_FAN:
1451 if (VIA_DEBUG) fprintf(stderr, "Triangle Fan\n");
1452 vmesa->regCmdA_End = vmesa->regCmdA | HC_HPMType_Tri | HC_HVCycle_AFP |
1453 HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC;
1454 regCmdB |= HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC;
1455 if (ctx->Light.ShadeModel == GL_FLAT)
1456 vmesa->regCmdA_End |= HC_HShading_FlatC;
1457 break;
1458 case GL_QUADS:
1459 if (VIA_DEBUG) fprintf(stderr, "No HW Quads\n");
1460 return;
1461 case GL_QUAD_STRIP:
1462 if (VIA_DEBUG) fprintf(stderr, "No HW Quad Strip\n");
1463 return;
1464 case GL_POLYGON:
1465 if (VIA_DEBUG) fprintf(stderr, "Polygon\n");
1466 vmesa->regCmdA_End = vmesa->regCmdA | HC_HPMType_Tri | HC_HVCycle_AFP |
1467 HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC;
1468 regCmdB |= HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC;
1469 if (ctx->Light.ShadeModel == GL_FLAT)
1470 vmesa->regCmdA_End |= HC_HShading_FlatC;
1471 break;
1472 default:
1473 if (VIA_DEBUG) fprintf(stderr, "Unknow\n");
1474 return;
1475 }
1476
1477 *vb++ = HC_HEADER2;
1478 *vb++ = (HC_ParaType_NotTex << 16);
1479 *vb++ = 0xCCCCCCCC;
1480 *vb++ = 0xDDDDDDDD;
1481
1482 *vb++ = HC_HEADER2;
1483 *vb++ = (HC_ParaType_CmdVdata << 16);
1484 *vb++ = regCmdB;
1485 *vb++ = vmesa->regCmdA_End;
1486 vmesa->dmaLow += 32;
1487
1488 vmesa->reducedPrimitive = rprim;
1489 vmesa->hwPrimitive = rprim;
1490 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
1491 }
1492
1493 void viaRasterPrimitiveFinish(GLcontext *ctx)
1494 {
1495 viaContextPtr vmesa = VIA_CONTEXT(ctx);
1496 if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
1497
1498 if (VIA_DEBUG) fprintf(stderr, "primitiveRendered = %x\n", vmesa->primitiveRendered);
1499 if (RasterCounter > 1) {
1500 RasterCounter--;
1501 if (VIA_DEBUG) fprintf(stderr, "finish enter twice: %d\n",RasterCounter);
1502 return;
1503 }
1504 RasterCounter = 0;
1505
1506
1507 if (vmesa->primitiveRendered) {
1508 GLuint *vb = viaCheckDma(vmesa, 0);
1509 GLuint cmdA = vmesa->regCmdA_End | HC_HPLEND_MASK | HC_HPMValidN_MASK | HC_HE3Fire_MASK;
1510
1511 /*=* John Sheng [2003.6.20] fix pci *=*/
1512 /*if (vmesa->dmaLow & 0x1) {*/
1513 if (vmesa->dmaLow & 0x1 || !vmesa->useAgp) {
1514 *vb++ = cmdA ;
1515 vmesa->dmaLow += 4;
1516 }
1517 else {
1518 *vb++ = cmdA;
1519 *vb++ = cmdA;
1520 vmesa->dmaLow += 8;
1521 }
1522 }
1523 else {
1524 if (vmesa->dmaLow >= (32 + DMA_OFFSET))
1525 vmesa->dmaLow -= 32;
1526 }
1527
1528 if (0) viaFlushPrimsLocked(vmesa);
1529 if (0) {
1530 volatile GLuint *pnMMIOBase = vmesa->regMMIOBase;
1531 volatile GLuint *pnEngBase = (volatile GLuint *)((GLuint)pnMMIOBase + 0x400);
1532 int nStatus = *pnEngBase;
1533 if (((nStatus & 0xFFFEFFFF) == 0x00020000)) {
1534 #ifdef PERFORMANCE_MEASURE
1535 idle++;
1536 #endif
1537 viaFlushPrims(vmesa);
1538 }
1539 #ifdef PERFORMANCE_MEASURE
1540 else {
1541 busy++;
1542 }
1543 #endif
1544 }
1545 if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
1546 }
1547
1548
1549 /**********************************************************************/
1550 /* Transition to/from hardware rasterization. */
1551 /**********************************************************************/
1552
1553
1554 void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode)
1555 {
1556 GLcontext *ctx = vmesa->glCtx;
1557 TNLcontext *tnl = TNL_CONTEXT(ctx);
1558 GLuint oldfallback = vmesa->Fallback;
1559 if (VIA_DEBUG) fprintf(stderr, "%s old %x bit %x mode %d\n", __FUNCTION__,
1560 vmesa->Fallback, bit, mode);
1561
1562 if (mode) {
1563 vmesa->Fallback |= bit;
1564 if (oldfallback == 0) {
1565 if (VIA_DEBUG) fprintf(stderr, "ENTER FALLBACK\n");
1566 VIA_FIREVERTICES(vmesa);
1567 _swsetup_Wakeup(ctx);
1568 vmesa->renderIndex = ~0;
1569 }
1570 }
1571 else {
1572 vmesa->Fallback &= ~bit;
1573 if (oldfallback == bit) {
1574 if (VIA_DEBUG) fprintf(stderr, "LEAVE FALLBACK\n");
1575 tnl->Driver.Render.Start = viaRenderStart;
1576 tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive;
1577 tnl->Driver.Render.Finish = viaRenderFinish;
1578 tnl->Driver.Render.BuildVertices = viaBuildVertices;
1579 vmesa->newState |= (_VIA_NEW_RENDERSTATE|_VIA_NEW_VERTEX);
1580 }
1581 }
1582
1583 }
1584
1585
1586 /**********************************************************************/
1587 /* Initialization. */
1588 /**********************************************************************/
1589
1590
1591 void viaInitTriFuncs(GLcontext *ctx)
1592 {
1593 TNLcontext *tnl = TNL_CONTEXT(ctx);
1594 static int firsttime = 1;
1595
1596 if (firsttime) {
1597 init_rast_tab();
1598 firsttime = 0;
1599 }
1600
1601 tnl->Driver.RunPipeline = viaRunPipeline;
1602 tnl->Driver.Render.Start = viaRenderStart;
1603 tnl->Driver.Render.Finish = viaRenderFinish;
1604 tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive;
1605 tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
1606 tnl->Driver.Render.BuildVertices = viaBuildVertices;
1607 }