OSDN Git Service

Merge branch 'mesa_7_7_branch'
[android-x86/external-mesa.git] / src / mesa / drivers / dri / i915 / intel_tris.c
1 /**************************************************************************
2  * 
3  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4  * All Rights Reserved.
5  * 
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  * 
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  * 
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  * 
26  **************************************************************************/
27
28 /** @file intel_tris.c
29  *
30  * This file contains functions for managing the vertex buffer and emitting
31  * primitives into it.
32  */
33
34 #include "main/glheader.h"
35 #include "main/context.h"
36 #include "main/macros.h"
37 #include "main/enums.h"
38 #include "main/texobj.h"
39 #include "main/state.h"
40 #include "main/dd.h"
41
42 #include "swrast/swrast.h"
43 #include "swrast_setup/swrast_setup.h"
44 #include "tnl/t_context.h"
45 #include "tnl/t_pipeline.h"
46 #include "tnl/t_vertex.h"
47
48 #include "intel_screen.h"
49 #include "intel_context.h"
50 #include "intel_tris.h"
51 #include "intel_batchbuffer.h"
52 #include "intel_buffers.h"
53 #include "intel_reg.h"
54 #include "intel_span.h"
55 #include "intel_chipset.h"
56 #include "i830_context.h"
57 #include "i830_reg.h"
58
59 static void intelRenderPrimitive(GLcontext * ctx, GLenum prim);
60 static void intelRasterPrimitive(GLcontext * ctx, GLenum rprim,
61                                  GLuint hwprim);
62
63 static void
64 intel_flush_inline_primitive(struct intel_context *intel)
65 {
66    GLuint used = intel->batch->ptr - intel->prim.start_ptr;
67
68    assert(intel->prim.primitive != ~0);
69
70 /*    _mesa_printf("/\n"); */
71
72    if (used < 8)
73       goto do_discard;
74
75    *(int *) intel->prim.start_ptr = (_3DPRIMITIVE |
76                                      intel->prim.primitive | (used / 4 - 2));
77
78    goto finished;
79
80  do_discard:
81    intel->batch->ptr -= used;
82
83  finished:
84    intel->prim.primitive = ~0;
85    intel->prim.start_ptr = 0;
86    intel->prim.flush = 0;
87 }
88
89 static void intel_start_inline(struct intel_context *intel, uint32_t prim)
90 {
91    BATCH_LOCALS;
92
93    intel->vtbl.emit_state(intel);
94
95    intel->no_batch_wrap = GL_TRUE;
96
97    /*_mesa_printf("%s *", __progname);*/
98
99    /* Emit a slot which will be filled with the inline primitive
100     * command later.
101     */
102    BEGIN_BATCH(2);
103    OUT_BATCH(0);
104
105    assert((intel->batch->dirty_state & (1<<1)) == 0);
106
107    intel->prim.start_ptr = intel->batch->ptr;
108    intel->prim.primitive = prim;
109    intel->prim.flush = intel_flush_inline_primitive;
110
111    OUT_BATCH(0);
112    ADVANCE_BATCH();
113
114    intel->no_batch_wrap = GL_FALSE;
115 /*    _mesa_printf(">"); */
116 }
117
118 static void intel_wrap_inline(struct intel_context *intel)
119 {
120    GLuint prim = intel->prim.primitive;
121
122    intel_flush_inline_primitive(intel);
123    intel_batchbuffer_flush(intel->batch);
124    intel_start_inline(intel, prim);  /* ??? */
125 }
126
127 static GLuint *intel_extend_inline(struct intel_context *intel, GLuint dwords)
128 {
129    GLuint sz = dwords * sizeof(GLuint);
130    GLuint *ptr;
131
132    assert(intel->prim.flush == intel_flush_inline_primitive);
133
134    if (intel_batchbuffer_space(intel->batch) < sz)
135       intel_wrap_inline(intel);
136
137 /*    _mesa_printf("."); */
138
139    intel->vtbl.assert_not_dirty(intel);
140
141    ptr = (GLuint *) intel->batch->ptr;
142    intel->batch->ptr += sz;
143
144    return ptr;
145 }
146
147 /** Sets the primitive type for a primitive sequence, flushing as needed. */
148 void intel_set_prim(struct intel_context *intel, uint32_t prim)
149 {
150    /* if we have no VBOs */
151
152    if (intel->intelScreen->no_vbo) {
153       intel_start_inline(intel, prim);
154       return;
155    }
156    if (prim != intel->prim.primitive) {
157       INTEL_FIREVERTICES(intel);
158       intel->prim.primitive = prim;
159    }
160 }
161
162 /** Returns mapped VB space for the given number of vertices */
163 uint32_t *intel_get_prim_space(struct intel_context *intel, unsigned int count)
164 {
165    uint32_t *addr;
166
167    if (intel->intelScreen->no_vbo) {
168       return intel_extend_inline(intel, count * intel->vertex_size);
169    }
170
171    /* Check for space in the existing VB */
172    if (intel->prim.vb_bo == NULL ||
173        (intel->prim.current_offset +
174         count * intel->vertex_size * 4) > INTEL_VB_SIZE ||
175        (intel->prim.count + count) >= (1 << 16)) {
176       /* Flush existing prim if any */
177       INTEL_FIREVERTICES(intel);
178
179       intel_finish_vb(intel);
180
181       /* Start a new VB */
182       if (intel->prim.vb == NULL)
183          intel->prim.vb = malloc(INTEL_VB_SIZE);
184       intel->prim.vb_bo = dri_bo_alloc(intel->bufmgr, "vb",
185                                        INTEL_VB_SIZE, 4);
186       intel->prim.start_offset = 0;
187       intel->prim.current_offset = 0;
188    }
189
190    intel->prim.flush = intel_flush_prim;
191
192    addr = (uint32_t *)(intel->prim.vb + intel->prim.current_offset);
193    intel->prim.current_offset += intel->vertex_size * 4 * count;
194    intel->prim.count += count;
195
196    return addr;
197 }
198
199 /** Dispatches the accumulated primitive to the batchbuffer. */
200 void intel_flush_prim(struct intel_context *intel)
201 {
202    dri_bo *aper_array[2];
203    dri_bo *vb_bo;
204    unsigned int offset, count;
205    BATCH_LOCALS;
206
207    /* Must be called after an intel_start_prim. */
208    assert(intel->prim.primitive != ~0);
209
210    if (intel->prim.count == 0)
211       return;
212
213    /* Clear the current prims out of the context state so that a batch flush
214     * flush triggered by emit_state doesn't loop back to flush_prim again.
215     */
216    vb_bo = intel->prim.vb_bo;
217    dri_bo_reference(vb_bo);
218    count = intel->prim.count;
219    intel->prim.count = 0;
220    offset = intel->prim.start_offset;
221    intel->prim.start_offset = intel->prim.current_offset;
222    if (!intel->gen >= 3)
223       intel->prim.start_offset = ALIGN(intel->prim.start_offset, 128);
224    intel->prim.flush = NULL;
225
226    intel->vtbl.emit_state(intel);
227
228    aper_array[0] = intel->batch->buf;
229    aper_array[1] = vb_bo;
230    if (dri_bufmgr_check_aperture_space(aper_array, 2)) {
231       intel_batchbuffer_flush(intel->batch);
232       intel->vtbl.emit_state(intel);
233    }
234
235    /* Ensure that we don't start a new batch for the following emit, which
236     * depends on the state just emitted. emit_state should be making sure we
237     * have the space for this.
238     */
239    intel->no_batch_wrap = GL_TRUE;
240
241    /* Check that we actually emitted the state into this batch, using the
242     * UPLOAD_CTX bit as the signal.
243     */
244    assert((intel->batch->dirty_state & (1<<1)) == 0);
245
246 #if 0
247    printf("emitting %d..%d=%d vertices size %d\n", offset,
248           intel->prim.current_offset, count,
249           intel->vertex_size * 4);
250 #endif
251
252    if (intel->gen >= 3) {
253       BEGIN_BATCH(5);
254       OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
255                 I1_LOAD_S(0) | I1_LOAD_S(1) | 1);
256       assert((offset & !S0_VB_OFFSET_MASK) == 0);
257       OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0, offset);
258       OUT_BATCH((intel->vertex_size << S1_VERTEX_WIDTH_SHIFT) |
259                 (intel->vertex_size << S1_VERTEX_PITCH_SHIFT));
260
261       OUT_BATCH(_3DPRIMITIVE |
262                 PRIM_INDIRECT |
263                 PRIM_INDIRECT_SEQUENTIAL |
264                 intel->prim.primitive |
265                 count);
266       OUT_BATCH(0); /* Beginning vertex index */
267       ADVANCE_BATCH();
268    } else {
269       struct i830_context *i830 = i830_context(&intel->ctx);
270
271       BEGIN_BATCH(5);
272       OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
273                 I1_LOAD_S(0) | I1_LOAD_S(2) | 1);
274       /* S0 */
275       assert((offset & !S0_VB_OFFSET_MASK_830) == 0);
276       OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0,
277                 offset | (intel->vertex_size << S0_VB_PITCH_SHIFT_830) |
278                 S0_VB_ENABLE_830);
279       /* S2
280        * This is somewhat unfortunate -- VB width is tied up with
281        * vertex format data that we've already uploaded through
282        * _3DSTATE_VFT[01]_CMD.  We may want to replace emits of VFT state with
283        * STATE_IMMEDIATE_1 like this to avoid duplication.
284        */
285       OUT_BATCH((i830->state.Ctx[I830_CTXREG_VF] & VFT0_TEX_COUNT_MASK) >>
286                 VFT0_TEX_COUNT_SHIFT << S2_TEX_COUNT_SHIFT_830 |
287                 (i830->state.Ctx[I830_CTXREG_VF2] << 16) |
288                 intel->vertex_size << S2_VERTEX_0_WIDTH_SHIFT_830);
289
290       OUT_BATCH(_3DPRIMITIVE |
291                 PRIM_INDIRECT |
292                 PRIM_INDIRECT_SEQUENTIAL |
293                 intel->prim.primitive |
294                 count);
295       OUT_BATCH(0); /* Beginning vertex index */
296       ADVANCE_BATCH();
297    }
298
299    intel->no_batch_wrap = GL_FALSE;
300
301    dri_bo_unreference(vb_bo);
302 }
303
304 /**
305  * Uploads the locally-accumulated VB into the buffer object.
306  *
307  * This avoids us thrashing the cachelines in and out as the buffer gets
308  * filled, dispatched, then reused as the hardware completes rendering from it,
309  * and also lets us clflush less if we dispatch with a partially-filled VB.
310  *
311  * This is called normally from get_space when we're finishing a BO, but also
312  * at batch flush time so that we don't try accessing the contents of a
313  * just-dispatched buffer.
314  */
315 void intel_finish_vb(struct intel_context *intel)
316 {
317    if (intel->prim.vb_bo == NULL)
318       return;
319
320    dri_bo_subdata(intel->prim.vb_bo, 0, intel->prim.start_offset,
321                   intel->prim.vb);
322    dri_bo_unreference(intel->prim.vb_bo);
323    intel->prim.vb_bo = NULL;
324 }
325
326 /***********************************************************************
327  *                    Emit primitives as inline vertices               *
328  ***********************************************************************/
329
330 #ifdef __i386__
331 #define COPY_DWORDS( j, vb, vertsize, v )                       \
332 do {                                                            \
333    int __tmp;                                                   \
334    __asm__ __volatile__( "rep ; movsl"                          \
335                          : "=%c" (j), "=D" (vb), "=S" (__tmp)   \
336                          : "0" (vertsize),                      \
337                          "D" ((long)vb),                        \
338                          "S" ((long)v) );                       \
339 } while (0)
340 #else
341 #define COPY_DWORDS( j, vb, vertsize, v )       \
342 do {                                            \
343    for ( j = 0 ; j < vertsize ; j++ ) {         \
344       vb[j] = ((GLuint *)v)[j];                 \
345    }                                            \
346    vb += vertsize;                              \
347 } while (0)
348 #endif
349
350 static void
351 intel_draw_quad(struct intel_context *intel,
352                 intelVertexPtr v0,
353                 intelVertexPtr v1, intelVertexPtr v2, intelVertexPtr v3)
354 {
355    GLuint vertsize = intel->vertex_size;
356    GLuint *vb = intel_get_prim_space(intel, 6);
357    int j;
358
359    COPY_DWORDS(j, vb, vertsize, v0);
360    COPY_DWORDS(j, vb, vertsize, v1);
361
362    /* If smooth shading, draw like a trifan which gives better
363     * rasterization.  Otherwise draw as two triangles with provoking
364     * vertex in third position as required for flat shading.
365     */
366    if (intel->ctx.Light.ShadeModel == GL_FLAT) {
367       COPY_DWORDS(j, vb, vertsize, v3);
368       COPY_DWORDS(j, vb, vertsize, v1);
369    }
370    else {
371       COPY_DWORDS(j, vb, vertsize, v2);
372       COPY_DWORDS(j, vb, vertsize, v0);
373    }
374
375    COPY_DWORDS(j, vb, vertsize, v2);
376    COPY_DWORDS(j, vb, vertsize, v3);
377 }
378
379 static void
380 intel_draw_triangle(struct intel_context *intel,
381                     intelVertexPtr v0, intelVertexPtr v1, intelVertexPtr v2)
382 {
383    GLuint vertsize = intel->vertex_size;
384    GLuint *vb = intel_get_prim_space(intel, 3);
385    int j;
386
387    COPY_DWORDS(j, vb, vertsize, v0);
388    COPY_DWORDS(j, vb, vertsize, v1);
389    COPY_DWORDS(j, vb, vertsize, v2);
390 }
391
392
393 static void
394 intel_draw_line(struct intel_context *intel,
395                 intelVertexPtr v0, intelVertexPtr v1)
396 {
397    GLuint vertsize = intel->vertex_size;
398    GLuint *vb = intel_get_prim_space(intel, 2);
399    int j;
400
401    COPY_DWORDS(j, vb, vertsize, v0);
402    COPY_DWORDS(j, vb, vertsize, v1);
403 }
404
405
406 static void
407 intel_draw_point(struct intel_context *intel, intelVertexPtr v0)
408 {
409    GLuint vertsize = intel->vertex_size;
410    GLuint *vb = intel_get_prim_space(intel, 1);
411    int j;
412
413    /* Adjust for sub pixel position -- still required for conform. */
414    *(float *) &vb[0] = v0->v.x;
415    *(float *) &vb[1] = v0->v.y;
416    for (j = 2; j < vertsize; j++)
417       vb[j] = v0->ui[j];
418 }
419
420
421
422 /***********************************************************************
423  *                Fixup for ARB_point_parameters                       *
424  ***********************************************************************/
425
426 /* Currently not working - VERT_ATTRIB_POINTSIZE isn't correctly
427  * represented in the fragment program InputsRead field.
428  */
429 static void
430 intel_atten_point(struct intel_context *intel, intelVertexPtr v0)
431 {
432    GLcontext *ctx = &intel->ctx;
433    GLfloat psz[4], col[4], restore_psz, restore_alpha;
434
435    _tnl_get_attr(ctx, v0, _TNL_ATTRIB_POINTSIZE, psz);
436    _tnl_get_attr(ctx, v0, _TNL_ATTRIB_COLOR0, col);
437
438    restore_psz = psz[0];
439    restore_alpha = col[3];
440
441    if (psz[0] >= ctx->Point.Threshold) {
442       psz[0] = MIN2(psz[0], ctx->Point.MaxSize);
443    }
444    else {
445       GLfloat dsize = psz[0] / ctx->Point.Threshold;
446       psz[0] = MAX2(ctx->Point.Threshold, ctx->Point.MinSize);
447       col[3] *= dsize * dsize;
448    }
449
450    if (psz[0] < 1.0)
451       psz[0] = 1.0;
452
453    if (restore_psz != psz[0] || restore_alpha != col[3]) {
454       _tnl_set_attr(ctx, v0, _TNL_ATTRIB_POINTSIZE, psz);
455       _tnl_set_attr(ctx, v0, _TNL_ATTRIB_COLOR0, col);
456
457       intel_draw_point(intel, v0);
458
459       psz[0] = restore_psz;
460       col[3] = restore_alpha;
461
462       _tnl_set_attr(ctx, v0, _TNL_ATTRIB_POINTSIZE, psz);
463       _tnl_set_attr(ctx, v0, _TNL_ATTRIB_COLOR0, col);
464    }
465    else
466       intel_draw_point(intel, v0);
467 }
468
469
470
471
472
473 /***********************************************************************
474  *                Fixup for I915 WPOS texture coordinate                *
475  ***********************************************************************/
476
477
478
479 static void
480 intel_wpos_triangle(struct intel_context *intel,
481                     intelVertexPtr v0, intelVertexPtr v1, intelVertexPtr v2)
482 {
483    GLuint offset = intel->wpos_offset;
484    GLuint size = intel->wpos_size;
485    GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
486    GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset);
487    GLfloat *v2_wpos = (GLfloat *)((char *)v2 + offset);
488
489    __memcpy(v0_wpos, v0, size);
490    __memcpy(v1_wpos, v1, size);
491    __memcpy(v2_wpos, v2, size);
492
493    v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
494    v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h;
495    v2_wpos[1] = -v2_wpos[1] + intel->driDrawable->h;
496
497
498    intel_draw_triangle(intel, v0, v1, v2);
499 }
500
501
502 static void
503 intel_wpos_line(struct intel_context *intel,
504                 intelVertexPtr v0, intelVertexPtr v1)
505 {
506    GLuint offset = intel->wpos_offset;
507    GLuint size = intel->wpos_size;
508    GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
509    GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset);
510
511    __memcpy(v0_wpos, v0, size);
512    __memcpy(v1_wpos, v1, size);
513
514    v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
515    v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h;
516
517    intel_draw_line(intel, v0, v1);
518 }
519
520
521 static void
522 intel_wpos_point(struct intel_context *intel, intelVertexPtr v0)
523 {
524    GLuint offset = intel->wpos_offset;
525    GLuint size = intel->wpos_size;
526    GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
527
528    __memcpy(v0_wpos, v0, size);
529    v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
530
531    intel_draw_point(intel, v0);
532 }
533
534
535
536
537
538
539 /***********************************************************************
540  *          Macros for t_dd_tritmp.h to draw basic primitives          *
541  ***********************************************************************/
542
543 #define TRI( a, b, c )                          \
544 do {                                            \
545    if (DO_FALLBACK)                             \
546       intel->draw_tri( intel, a, b, c );        \
547    else                                         \
548       intel_draw_triangle( intel, a, b, c );    \
549 } while (0)
550
551 #define QUAD( a, b, c, d )                      \
552 do {                                            \
553    if (DO_FALLBACK) {                           \
554       intel->draw_tri( intel, a, b, d );        \
555       intel->draw_tri( intel, b, c, d );        \
556    } else                                       \
557       intel_draw_quad( intel, a, b, c, d );     \
558 } while (0)
559
560 #define LINE( v0, v1 )                          \
561 do {                                            \
562    if (DO_FALLBACK)                             \
563       intel->draw_line( intel, v0, v1 );        \
564    else                                         \
565       intel_draw_line( intel, v0, v1 );         \
566 } while (0)
567
568 #define POINT( v0 )                             \
569 do {                                            \
570    if (DO_FALLBACK)                             \
571       intel->draw_point( intel, v0 );           \
572    else                                         \
573       intel_draw_point( intel, v0 );            \
574 } while (0)
575
576
577 /***********************************************************************
578  *              Build render functions from dd templates               *
579  ***********************************************************************/
580
581 #define INTEL_OFFSET_BIT        0x01
582 #define INTEL_TWOSIDE_BIT       0x02
583 #define INTEL_UNFILLED_BIT      0x04
584 #define INTEL_FALLBACK_BIT      0x08
585 #define INTEL_MAX_TRIFUNC       0x10
586
587
588 static struct
589 {
590    tnl_points_func points;
591    tnl_line_func line;
592    tnl_triangle_func triangle;
593    tnl_quad_func quad;
594 } rast_tab[INTEL_MAX_TRIFUNC];
595
596
597 #define DO_FALLBACK (IND & INTEL_FALLBACK_BIT)
598 #define DO_OFFSET   (IND & INTEL_OFFSET_BIT)
599 #define DO_UNFILLED (IND & INTEL_UNFILLED_BIT)
600 #define DO_TWOSIDE  (IND & INTEL_TWOSIDE_BIT)
601 #define DO_FLAT      0
602 #define DO_TRI       1
603 #define DO_QUAD      1
604 #define DO_LINE      1
605 #define DO_POINTS    1
606 #define DO_FULL_QUAD 1
607
608 #define HAVE_RGBA         1
609 #define HAVE_SPEC         1
610 #define HAVE_BACK_COLORS  0
611 #define HAVE_HW_FLATSHADE 1
612 #define VERTEX            intelVertex
613 #define TAB               rast_tab
614
615 /* Only used to pull back colors into vertices (ie, we know color is
616  * floating point).
617  */
618 #define INTEL_COLOR( dst, src )                         \
619 do {                                                    \
620    UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]);        \
621    UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]);        \
622    UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]);        \
623    UNCLAMPED_FLOAT_TO_UBYTE((dst)[3], (src)[3]);        \
624 } while (0)
625
626 #define INTEL_SPEC( dst, src )                          \
627 do {                                                    \
628    UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]);        \
629    UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]);        \
630    UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]);        \
631 } while (0)
632
633
634 #define DEPTH_SCALE intel->polygon_offset_scale
635 #define UNFILLED_TRI unfilled_tri
636 #define UNFILLED_QUAD unfilled_quad
637 #define VERT_X(_v) _v->v.x
638 #define VERT_Y(_v) _v->v.y
639 #define VERT_Z(_v) _v->v.z
640 #define AREA_IS_CCW( a ) (a > 0)
641 #define GET_VERTEX(e) (intel->verts + (e * intel->vertex_size * sizeof(GLuint)))
642
643 #define VERT_SET_RGBA( v, c )    if (coloroffset) INTEL_COLOR( v->ub4[coloroffset], c )
644 #define VERT_COPY_RGBA( v0, v1 ) if (coloroffset) v0->ui[coloroffset] = v1->ui[coloroffset]
645 #define VERT_SAVE_RGBA( idx )    if (coloroffset) color[idx] = v[idx]->ui[coloroffset]
646 #define VERT_RESTORE_RGBA( idx ) if (coloroffset) v[idx]->ui[coloroffset] = color[idx]
647
648 #define VERT_SET_SPEC( v, c )    if (specoffset) INTEL_SPEC( v->ub4[specoffset], c )
649 #define VERT_COPY_SPEC( v0, v1 ) if (specoffset) COPY_3V(v0->ub4[specoffset], v1->ub4[specoffset])
650 #define VERT_SAVE_SPEC( idx )    if (specoffset) spec[idx] = v[idx]->ui[specoffset]
651 #define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx]
652
653 #define LOCAL_VARS(n)                                                   \
654    struct intel_context *intel = intel_context(ctx);                    \
655    GLuint color[n] = { 0, }, spec[n] = { 0, };                          \
656    GLuint coloroffset = intel->coloroffset;                             \
657    GLboolean specoffset = intel->specoffset;                            \
658    (void) color; (void) spec; (void) coloroffset; (void) specoffset;
659
660
661 /***********************************************************************
662  *                Helpers for rendering unfilled primitives            *
663  ***********************************************************************/
664
665 static const GLuint hw_prim[GL_POLYGON + 1] = {
666    PRIM3D_POINTLIST,
667    PRIM3D_LINELIST,
668    PRIM3D_LINELIST,
669    PRIM3D_LINELIST,
670    PRIM3D_TRILIST,
671    PRIM3D_TRILIST,
672    PRIM3D_TRILIST,
673    PRIM3D_TRILIST,
674    PRIM3D_TRILIST,
675    PRIM3D_TRILIST
676 };
677
678 #define RASTERIZE(x) intelRasterPrimitive( ctx, x, hw_prim[x] )
679 #define RENDER_PRIMITIVE intel->render_primitive
680 #define TAG(x) x
681 #define IND INTEL_FALLBACK_BIT
682 #include "tnl_dd/t_dd_unfilled.h"
683 #undef IND
684
685 /***********************************************************************
686  *                      Generate GL render functions                   *
687  ***********************************************************************/
688
689 #define IND (0)
690 #define TAG(x) x
691 #include "tnl_dd/t_dd_tritmp.h"
692
693 #define IND (INTEL_OFFSET_BIT)
694 #define TAG(x) x##_offset
695 #include "tnl_dd/t_dd_tritmp.h"
696
697 #define IND (INTEL_TWOSIDE_BIT)
698 #define TAG(x) x##_twoside
699 #include "tnl_dd/t_dd_tritmp.h"
700
701 #define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT)
702 #define TAG(x) x##_twoside_offset
703 #include "tnl_dd/t_dd_tritmp.h"
704
705 #define IND (INTEL_UNFILLED_BIT)
706 #define TAG(x) x##_unfilled
707 #include "tnl_dd/t_dd_tritmp.h"
708
709 #define IND (INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT)
710 #define TAG(x) x##_offset_unfilled
711 #include "tnl_dd/t_dd_tritmp.h"
712
713 #define IND (INTEL_TWOSIDE_BIT|INTEL_UNFILLED_BIT)
714 #define TAG(x) x##_twoside_unfilled
715 #include "tnl_dd/t_dd_tritmp.h"
716
717 #define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT)
718 #define TAG(x) x##_twoside_offset_unfilled
719 #include "tnl_dd/t_dd_tritmp.h"
720
721 #define IND (INTEL_FALLBACK_BIT)
722 #define TAG(x) x##_fallback
723 #include "tnl_dd/t_dd_tritmp.h"
724
725 #define IND (INTEL_OFFSET_BIT|INTEL_FALLBACK_BIT)
726 #define TAG(x) x##_offset_fallback
727 #include "tnl_dd/t_dd_tritmp.h"
728
729 #define IND (INTEL_TWOSIDE_BIT|INTEL_FALLBACK_BIT)
730 #define TAG(x) x##_twoside_fallback
731 #include "tnl_dd/t_dd_tritmp.h"
732
733 #define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT|INTEL_FALLBACK_BIT)
734 #define TAG(x) x##_twoside_offset_fallback
735 #include "tnl_dd/t_dd_tritmp.h"
736
737 #define IND (INTEL_UNFILLED_BIT|INTEL_FALLBACK_BIT)
738 #define TAG(x) x##_unfilled_fallback
739 #include "tnl_dd/t_dd_tritmp.h"
740
741 #define IND (INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT|INTEL_FALLBACK_BIT)
742 #define TAG(x) x##_offset_unfilled_fallback
743 #include "tnl_dd/t_dd_tritmp.h"
744
745 #define IND (INTEL_TWOSIDE_BIT|INTEL_UNFILLED_BIT|INTEL_FALLBACK_BIT)
746 #define TAG(x) x##_twoside_unfilled_fallback
747 #include "tnl_dd/t_dd_tritmp.h"
748
749 #define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT| \
750              INTEL_FALLBACK_BIT)
751 #define TAG(x) x##_twoside_offset_unfilled_fallback
752 #include "tnl_dd/t_dd_tritmp.h"
753
754
755 static void
756 init_rast_tab(void)
757 {
758    init();
759    init_offset();
760    init_twoside();
761    init_twoside_offset();
762    init_unfilled();
763    init_offset_unfilled();
764    init_twoside_unfilled();
765    init_twoside_offset_unfilled();
766    init_fallback();
767    init_offset_fallback();
768    init_twoside_fallback();
769    init_twoside_offset_fallback();
770    init_unfilled_fallback();
771    init_offset_unfilled_fallback();
772    init_twoside_unfilled_fallback();
773    init_twoside_offset_unfilled_fallback();
774 }
775
776
777 /***********************************************************************
778  *                    Rasterization fallback helpers                   *
779  ***********************************************************************/
780
781
782 /* This code is hit only when a mix of accelerated and unaccelerated
783  * primitives are being drawn, and only for the unaccelerated
784  * primitives.
785  */
786 static void
787 intel_fallback_tri(struct intel_context *intel,
788                    intelVertex * v0, intelVertex * v1, intelVertex * v2)
789 {
790    GLcontext *ctx = &intel->ctx;
791    SWvertex v[3];
792
793    if (0)
794       fprintf(stderr, "\n%s\n", __FUNCTION__);
795
796    INTEL_FIREVERTICES(intel);
797
798    _swsetup_Translate(ctx, v0, &v[0]);
799    _swsetup_Translate(ctx, v1, &v[1]);
800    _swsetup_Translate(ctx, v2, &v[2]);
801    intelSpanRenderStart(ctx);
802    _swrast_Triangle(ctx, &v[0], &v[1], &v[2]);
803    intelSpanRenderFinish(ctx);
804 }
805
806
807 static void
808 intel_fallback_line(struct intel_context *intel,
809                     intelVertex * v0, intelVertex * v1)
810 {
811    GLcontext *ctx = &intel->ctx;
812    SWvertex v[2];
813
814    if (0)
815       fprintf(stderr, "\n%s\n", __FUNCTION__);
816
817    INTEL_FIREVERTICES(intel);
818
819    _swsetup_Translate(ctx, v0, &v[0]);
820    _swsetup_Translate(ctx, v1, &v[1]);
821    intelSpanRenderStart(ctx);
822    _swrast_Line(ctx, &v[0], &v[1]);
823    intelSpanRenderFinish(ctx);
824 }
825
826 static void
827 intel_fallback_point(struct intel_context *intel,
828                      intelVertex * v0)
829 {
830    GLcontext *ctx = &intel->ctx;
831    SWvertex v[1];
832
833    if (0)
834       fprintf(stderr, "\n%s\n", __FUNCTION__);
835
836    INTEL_FIREVERTICES(intel);
837
838    _swsetup_Translate(ctx, v0, &v[0]);
839    intelSpanRenderStart(ctx);
840    _swrast_Point(ctx, &v[0]);
841    intelSpanRenderFinish(ctx);
842 }
843
844
845 /**********************************************************************/
846 /*               Render unclipped begin/end objects                   */
847 /**********************************************************************/
848
849 #define IND 0
850 #define V(x) (intelVertex *)(vertptr + ((x)*vertsize*sizeof(GLuint)))
851 #define RENDER_POINTS( start, count )   \
852    for ( ; start < count ; start++) POINT( V(ELT(start)) );
853 #define RENDER_LINE( v0, v1 )         LINE( V(v0), V(v1) )
854 #define RENDER_TRI(  v0, v1, v2 )     TRI(  V(v0), V(v1), V(v2) )
855 #define RENDER_QUAD( v0, v1, v2, v3 ) QUAD( V(v0), V(v1), V(v2), V(v3) )
856 #define INIT(x) intelRenderPrimitive( ctx, x )
857 #undef LOCAL_VARS
858 #define LOCAL_VARS                                              \
859     struct intel_context *intel = intel_context(ctx);                   \
860     GLubyte *vertptr = (GLubyte *)intel->verts;                 \
861     const GLuint vertsize = intel->vertex_size;         \
862     const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;       \
863     (void) elt;
864 #define RESET_STIPPLE
865 #define RESET_OCCLUSION
866 #define PRESERVE_VB_DEFS
867 #define ELT(x) x
868 #define TAG(x) intel_##x##_verts
869 #include "tnl/t_vb_rendertmp.h"
870 #undef ELT
871 #undef TAG
872 #define TAG(x) intel_##x##_elts
873 #define ELT(x) elt[x]
874 #include "tnl/t_vb_rendertmp.h"
875
876 /**********************************************************************/
877 /*                   Render clipped primitives                        */
878 /**********************************************************************/
879
880
881
882 static void
883 intelRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n)
884 {
885    struct intel_context *intel = intel_context(ctx);
886    TNLcontext *tnl = TNL_CONTEXT(ctx);
887    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
888    GLuint prim = intel->render_primitive;
889
890    /* Render the new vertices as an unclipped polygon.
891     */
892    {
893       GLuint *tmp = VB->Elts;
894       VB->Elts = (GLuint *) elts;
895       tnl->Driver.Render.PrimTabElts[GL_POLYGON] (ctx, 0, n,
896                                                   PRIM_BEGIN | PRIM_END);
897       VB->Elts = tmp;
898    }
899
900    /* Restore the render primitive
901     */
902    if (prim != GL_POLYGON)
903       tnl->Driver.Render.PrimitiveNotify(ctx, prim);
904 }
905
906 static void
907 intelRenderClippedLine(GLcontext * ctx, GLuint ii, GLuint jj)
908 {
909    TNLcontext *tnl = TNL_CONTEXT(ctx);
910
911    tnl->Driver.Render.Line(ctx, ii, jj);
912 }
913
914 static void
915 intelFastRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n)
916 {
917    struct intel_context *intel = intel_context(ctx);
918    const GLuint vertsize = intel->vertex_size;
919    GLuint *vb = intel_get_prim_space(intel, (n - 2) * 3);
920    GLubyte *vertptr = (GLubyte *) intel->verts;
921    const GLuint *start = (const GLuint *) V(elts[0]);
922    int i, j;
923
924    for (i = 2; i < n; i++) {
925       COPY_DWORDS(j, vb, vertsize, V(elts[i - 1]));
926       COPY_DWORDS(j, vb, vertsize, V(elts[i]));
927       COPY_DWORDS(j, vb, vertsize, start);
928    }
929 }
930
931 /**********************************************************************/
932 /*                    Choose render functions                         */
933 /**********************************************************************/
934
935
936
937
938 #define ANY_FALLBACK_FLAGS (DD_LINE_STIPPLE | DD_TRI_STIPPLE | DD_POINT_ATTEN | DD_POINT_SMOOTH | DD_TRI_SMOOTH)
939 #define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET | DD_TRI_UNFILLED)
940
941 void
942 intelChooseRenderState(GLcontext * ctx)
943 {
944    TNLcontext *tnl = TNL_CONTEXT(ctx);
945    struct intel_context *intel = intel_context(ctx);
946    GLuint flags = ctx->_TriangleCaps;
947    const struct gl_fragment_program *fprog = ctx->FragmentProgram._Current;
948    GLboolean have_wpos = (fprog && (fprog->Base.InputsRead & FRAG_BIT_WPOS));
949    GLuint index = 0;
950
951    if (INTEL_DEBUG & DEBUG_STATE)
952       fprintf(stderr, "\n%s\n", __FUNCTION__);
953
954    if ((flags & (ANY_FALLBACK_FLAGS | ANY_RASTER_FLAGS)) || have_wpos) {
955
956       if (flags & ANY_RASTER_FLAGS) {
957          if (flags & DD_TRI_LIGHT_TWOSIDE)
958             index |= INTEL_TWOSIDE_BIT;
959          if (flags & DD_TRI_OFFSET)
960             index |= INTEL_OFFSET_BIT;
961          if (flags & DD_TRI_UNFILLED)
962             index |= INTEL_UNFILLED_BIT;
963       }
964
965       if (have_wpos) {
966          intel->draw_point = intel_wpos_point;
967          intel->draw_line = intel_wpos_line;
968          intel->draw_tri = intel_wpos_triangle;
969
970          /* Make sure these get called:
971           */
972          index |= INTEL_FALLBACK_BIT;
973       }
974       else {
975          intel->draw_point = intel_draw_point;
976          intel->draw_line = intel_draw_line;
977          intel->draw_tri = intel_draw_triangle;
978       }
979
980       /* Hook in fallbacks for specific primitives.
981        */
982       if (flags & ANY_FALLBACK_FLAGS) {
983          if (flags & DD_LINE_STIPPLE)
984             intel->draw_line = intel_fallback_line;
985
986          if ((flags & DD_TRI_STIPPLE) && !intel->hw_stipple)
987             intel->draw_tri = intel_fallback_tri;
988
989          if (flags & DD_TRI_SMOOTH) {
990             if (intel->conformance_mode > 0)
991                intel->draw_tri = intel_fallback_tri;
992          }
993
994          if (flags & DD_POINT_ATTEN) {
995             if (0)
996                intel->draw_point = intel_atten_point;
997             else
998                intel->draw_point = intel_fallback_point;
999          }
1000
1001          if (flags & DD_POINT_SMOOTH) {
1002             if (intel->conformance_mode > 0)
1003                intel->draw_point = intel_fallback_point;
1004          }
1005
1006          index |= INTEL_FALLBACK_BIT;
1007       }
1008    }
1009
1010    if (intel->RenderIndex != index) {
1011       intel->RenderIndex = index;
1012
1013       tnl->Driver.Render.Points = rast_tab[index].points;
1014       tnl->Driver.Render.Line = rast_tab[index].line;
1015       tnl->Driver.Render.Triangle = rast_tab[index].triangle;
1016       tnl->Driver.Render.Quad = rast_tab[index].quad;
1017
1018       if (index == 0) {
1019          tnl->Driver.Render.PrimTabVerts = intel_render_tab_verts;
1020          tnl->Driver.Render.PrimTabElts = intel_render_tab_elts;
1021          tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
1022          tnl->Driver.Render.ClippedPolygon = intelFastRenderClippedPoly;
1023       }
1024       else {
1025          tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
1026          tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
1027          tnl->Driver.Render.ClippedLine = intelRenderClippedLine;
1028          tnl->Driver.Render.ClippedPolygon = intelRenderClippedPoly;
1029       }
1030    }
1031 }
1032
1033 static const GLenum reduced_prim[GL_POLYGON + 1] = {
1034    GL_POINTS,
1035    GL_LINES,
1036    GL_LINES,
1037    GL_LINES,
1038    GL_TRIANGLES,
1039    GL_TRIANGLES,
1040    GL_TRIANGLES,
1041    GL_TRIANGLES,
1042    GL_TRIANGLES,
1043    GL_TRIANGLES
1044 };
1045
1046
1047 /**********************************************************************/
1048 /*                 High level hooks for t_vb_render.c                 */
1049 /**********************************************************************/
1050
1051
1052
1053
1054 static void
1055 intelRunPipeline(GLcontext * ctx)
1056 {
1057    struct intel_context *intel = intel_context(ctx);
1058
1059    _mesa_lock_context_textures(ctx);
1060    
1061    if (ctx->NewState)
1062       _mesa_update_state_locked(ctx);
1063
1064    if (intel->NewGLState) {
1065       if (intel->NewGLState & _NEW_TEXTURE) {
1066          intel->vtbl.update_texture_state(intel);
1067       }
1068
1069       if (!intel->Fallback) {
1070          if (intel->NewGLState & _INTEL_NEW_RENDERSTATE)
1071             intelChooseRenderState(ctx);
1072       }
1073
1074       intel->NewGLState = 0;
1075    }
1076
1077    intel_map_vertex_shader_textures(ctx);
1078    _tnl_run_pipeline(ctx);
1079    intel_unmap_vertex_shader_textures(ctx);
1080
1081    _mesa_unlock_context_textures(ctx);
1082 }
1083
1084 static void
1085 intelRenderStart(GLcontext * ctx)
1086 {
1087    struct intel_context *intel = intel_context(ctx);
1088
1089    intel_check_front_buffer_rendering(intel);
1090    intel->vtbl.render_start(intel_context(ctx));
1091    intel->vtbl.emit_state(intel);
1092 }
1093
1094 static void
1095 intelRenderFinish(GLcontext * ctx)
1096 {
1097    struct intel_context *intel = intel_context(ctx);
1098
1099    if (intel->RenderIndex & INTEL_FALLBACK_BIT)
1100       _swrast_flush(ctx);
1101
1102    INTEL_FIREVERTICES(intel);
1103 }
1104
1105
1106
1107
1108  /* System to flush dma and emit state changes based on the rasterized
1109   * primitive.
1110   */
1111 static void
1112 intelRasterPrimitive(GLcontext * ctx, GLenum rprim, GLuint hwprim)
1113 {
1114    struct intel_context *intel = intel_context(ctx);
1115
1116    if (0)
1117       fprintf(stderr, "%s %s %x\n", __FUNCTION__,
1118               _mesa_lookup_enum_by_nr(rprim), hwprim);
1119
1120    intel->vtbl.reduced_primitive_state(intel, rprim);
1121
1122    /* Start a new primitive.  Arrange to have it flushed later on.
1123     */
1124    if (hwprim != intel->prim.primitive) {
1125       INTEL_FIREVERTICES(intel);
1126
1127       intel_set_prim(intel, hwprim);
1128    }
1129 }
1130
1131
1132  /* 
1133   */
1134 static void
1135 intelRenderPrimitive(GLcontext * ctx, GLenum prim)
1136 {
1137    struct intel_context *intel = intel_context(ctx);
1138
1139    if (0)
1140       fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim));
1141
1142    /* Let some clipping routines know which primitive they're dealing
1143     * with.
1144     */
1145    intel->render_primitive = prim;
1146
1147    /* Shortcircuit this when called from t_dd_rendertmp.h for unfilled
1148     * triangles.  The rasterized primitive will always be reset by
1149     * lower level functions in that case, potentially pingponging the
1150     * state:
1151     */
1152    if (reduced_prim[prim] == GL_TRIANGLES &&
1153        (ctx->_TriangleCaps & DD_TRI_UNFILLED))
1154       return;
1155
1156    /* Set some primitive-dependent state and Start? a new primitive.
1157     */
1158    intelRasterPrimitive(ctx, reduced_prim[prim], hw_prim[prim]);
1159 }
1160
1161
1162  /**********************************************************************/
1163  /*           Transition to/from hardware rasterization.               */
1164  /**********************************************************************/
1165
1166 static char *fallbackStrings[] = {
1167    [0] = "Draw buffer",
1168    [1] = "Read buffer",
1169    [2] = "Depth buffer",
1170    [3] = "Stencil buffer",
1171    [4] = "User disable",
1172    [5] = "Render mode",
1173
1174    [12] = "Texture",
1175    [13] = "Color mask",
1176    [14] = "Stencil",
1177    [15] = "Stipple",
1178    [16] = "Program",
1179    [17] = "Logic op",
1180    [18] = "Smooth polygon",
1181    [19] = "Smooth point",
1182 };
1183
1184
1185 static char *
1186 getFallbackString(GLuint bit)
1187 {
1188    int i = 0;
1189    while (bit > 1) {
1190       i++;
1191       bit >>= 1;
1192    }
1193    return fallbackStrings[i];
1194 }
1195
1196
1197
1198 /**
1199  * Enable/disable a fallback flag.
1200  * \param bit  one of INTEL_FALLBACK_x flags.
1201  */
1202 void
1203 intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode)
1204 {
1205    GLcontext *ctx = &intel->ctx;
1206    TNLcontext *tnl = TNL_CONTEXT(ctx);
1207    const GLbitfield oldfallback = intel->Fallback;
1208
1209    if (mode) {
1210       intel->Fallback |= bit;
1211       if (oldfallback == 0) {
1212          intelFlush(ctx);
1213          if (INTEL_DEBUG & DEBUG_FALLBACKS)
1214             fprintf(stderr, "ENTER FALLBACK %x: %s\n",
1215                     bit, getFallbackString(bit));
1216          _swsetup_Wakeup(ctx);
1217          intel->RenderIndex = ~0;
1218       }
1219    }
1220    else {
1221       intel->Fallback &= ~bit;
1222       if (oldfallback == bit) {
1223          _swrast_flush(ctx);
1224          if (INTEL_DEBUG & DEBUG_FALLBACKS)
1225             fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString(bit));
1226          tnl->Driver.Render.Start = intelRenderStart;
1227          tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive;
1228          tnl->Driver.Render.Finish = intelRenderFinish;
1229          tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
1230          tnl->Driver.Render.CopyPV = _tnl_copy_pv;
1231          tnl->Driver.Render.Interp = _tnl_interp;
1232
1233          _tnl_invalidate_vertex_state(ctx, ~0);
1234          _tnl_invalidate_vertices(ctx, ~0);
1235          _tnl_install_attrs(ctx,
1236                             intel->vertex_attrs,
1237                             intel->vertex_attr_count,
1238                             intel->ViewportMatrix.m, 0);
1239
1240          intel->NewGLState |= _INTEL_NEW_RENDERSTATE;
1241       }
1242    }
1243 }
1244
1245 union fi
1246 {
1247    GLfloat f;
1248    GLint i;
1249 };
1250
1251 /**********************************************************************/
1252 /*                            Initialization.                         */
1253 /**********************************************************************/
1254
1255
1256 void
1257 intelInitTriFuncs(GLcontext * ctx)
1258 {
1259    TNLcontext *tnl = TNL_CONTEXT(ctx);
1260    static int firsttime = 1;
1261
1262    if (firsttime) {
1263       init_rast_tab();
1264       firsttime = 0;
1265    }
1266
1267    tnl->Driver.RunPipeline = intelRunPipeline;
1268    tnl->Driver.Render.Start = intelRenderStart;
1269    tnl->Driver.Render.Finish = intelRenderFinish;
1270    tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive;
1271    tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
1272    tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
1273    tnl->Driver.Render.CopyPV = _tnl_copy_pv;
1274    tnl->Driver.Render.Interp = _tnl_interp;
1275 }