Move compiler.h and imports.h/c from src/mesa/main into src/util
[mesa.git] / src / mesa / tnl / t_draw.c
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 1999-2007 Brian Paul 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 "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS 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
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Keith Whitwell <keithw@vmware.com>
26 */
27
28 #include <stdio.h>
29
30 #include "main/glheader.h"
31 #include "main/arrayobj.h"
32 #include "main/bufferobj.h"
33 #include "main/condrender.h"
34 #include "main/context.h"
35 #include "util/imports.h"
36 #include "main/mtypes.h"
37 #include "main/macros.h"
38 #include "main/enums.h"
39 #include "main/varray.h"
40 #include "util/half_float.h"
41
42 #include "t_context.h"
43 #include "t_rebase.h"
44 #include "tnl.h"
45
46
47
48 static GLubyte *get_space(struct gl_context *ctx, GLuint bytes)
49 {
50 TNLcontext *tnl = TNL_CONTEXT(ctx);
51 GLubyte *space = malloc(bytes);
52
53 tnl->block[tnl->nr_blocks++] = space;
54 return space;
55 }
56
57
58 static void free_space(struct gl_context *ctx)
59 {
60 TNLcontext *tnl = TNL_CONTEXT(ctx);
61 GLuint i;
62 for (i = 0; i < tnl->nr_blocks; i++)
63 free(tnl->block[i]);
64 tnl->nr_blocks = 0;
65 }
66
67
68 /* Convert the incoming array to GLfloats. Understands the
69 * array->Normalized flag and selects the correct conversion method.
70 */
71 #define CONVERT( TYPE, MACRO ) do { \
72 GLuint i, j; \
73 if (attrib->Format.Normalized) { \
74 for (i = 0; i < count; i++) { \
75 const TYPE *in = (TYPE *)ptr; \
76 for (j = 0; j < sz; j++) { \
77 *fptr++ = MACRO(*in); \
78 in++; \
79 } \
80 ptr += binding->Stride; \
81 } \
82 } else { \
83 for (i = 0; i < count; i++) { \
84 const TYPE *in = (TYPE *)ptr; \
85 for (j = 0; j < sz; j++) { \
86 *fptr++ = (GLfloat)(*in); \
87 in++; \
88 } \
89 ptr += binding->Stride; \
90 } \
91 } \
92 } while (0)
93
94
95 /**
96 * Convert array of BGRA/GLubyte[4] values to RGBA/float[4]
97 * \param ptr input/ubyte array
98 * \param fptr output/float array
99 */
100 static void
101 convert_bgra_to_float(const struct gl_vertex_buffer_binding *binding,
102 const struct gl_array_attributes *attrib,
103 const GLubyte *ptr, GLfloat *fptr,
104 GLuint count )
105 {
106 GLuint i;
107 assert(attrib->Format.Normalized);
108 assert(attrib->Format.Size == 4);
109 for (i = 0; i < count; i++) {
110 const GLubyte *in = (GLubyte *) ptr; /* in is in BGRA order */
111 *fptr++ = UBYTE_TO_FLOAT(in[2]); /* red */
112 *fptr++ = UBYTE_TO_FLOAT(in[1]); /* green */
113 *fptr++ = UBYTE_TO_FLOAT(in[0]); /* blue */
114 *fptr++ = UBYTE_TO_FLOAT(in[3]); /* alpha */
115 ptr += binding->Stride;
116 }
117 }
118
119 static void
120 convert_half_to_float(const struct gl_vertex_buffer_binding *binding,
121 const struct gl_array_attributes *attrib,
122 const GLubyte *ptr, GLfloat *fptr,
123 GLuint count, GLuint sz)
124 {
125 GLuint i, j;
126
127 for (i = 0; i < count; i++) {
128 GLhalfARB *in = (GLhalfARB *)ptr;
129
130 for (j = 0; j < sz; j++) {
131 *fptr++ = _mesa_half_to_float(in[j]);
132 }
133 ptr += binding->Stride;
134 }
135 }
136
137 /**
138 * \brief Convert fixed-point to floating-point.
139 *
140 * In OpenGL, a fixed-point number is a "signed 2's complement 16.16 scaled
141 * integer" (Table 2.2 of the OpenGL ES 2.0 spec).
142 *
143 * If the buffer has the \c normalized flag set, the formula
144 * \code normalize(x) := (2*x + 1) / (2^16 - 1) \endcode
145 * is used to map the fixed-point numbers into the range [-1, 1].
146 */
147 static void
148 convert_fixed_to_float(const struct gl_vertex_buffer_binding *binding,
149 const struct gl_array_attributes *attrib,
150 const GLubyte *ptr, GLfloat *fptr,
151 GLuint count)
152 {
153 GLuint i;
154 GLint j;
155 const GLint size = attrib->Format.Size;
156
157 if (attrib->Format.Normalized) {
158 for (i = 0; i < count; ++i) {
159 const GLfixed *in = (GLfixed *) ptr;
160 for (j = 0; j < size; ++j) {
161 *fptr++ = (GLfloat) (2 * in[j] + 1) / (GLfloat) ((1 << 16) - 1);
162 }
163 ptr += binding->Stride;
164 }
165 } else {
166 for (i = 0; i < count; ++i) {
167 const GLfixed *in = (GLfixed *) ptr;
168 for (j = 0; j < size; ++j) {
169 *fptr++ = in[j] / (GLfloat) (1 << 16);
170 }
171 ptr += binding->Stride;
172 }
173 }
174 }
175
176 /* Adjust pointer to point at first requested element, convert to
177 * floating point, populate VB->AttribPtr[].
178 */
179 static void _tnl_import_array( struct gl_context *ctx,
180 GLuint attr,
181 GLuint count,
182 const struct gl_vertex_buffer_binding *binding,
183 const struct gl_array_attributes *attrib,
184 const GLubyte *ptr )
185 {
186 TNLcontext *tnl = TNL_CONTEXT(ctx);
187 struct vertex_buffer *VB = &tnl->vb;
188 GLuint stride = binding->Stride;
189
190 if (attrib->Format.Type != GL_FLOAT) {
191 const GLuint sz = attrib->Format.Size;
192 GLubyte *buf = get_space(ctx, count * sz * sizeof(GLfloat));
193 GLfloat *fptr = (GLfloat *)buf;
194
195 switch (attrib->Format.Type) {
196 case GL_BYTE:
197 CONVERT(GLbyte, BYTE_TO_FLOAT);
198 break;
199 case GL_UNSIGNED_BYTE:
200 if (attrib->Format.Format == GL_BGRA) {
201 /* See GL_EXT_vertex_array_bgra */
202 convert_bgra_to_float(binding, attrib, ptr, fptr, count);
203 }
204 else {
205 CONVERT(GLubyte, UBYTE_TO_FLOAT);
206 }
207 break;
208 case GL_SHORT:
209 CONVERT(GLshort, SHORT_TO_FLOAT);
210 break;
211 case GL_UNSIGNED_SHORT:
212 CONVERT(GLushort, USHORT_TO_FLOAT);
213 break;
214 case GL_INT:
215 CONVERT(GLint, INT_TO_FLOAT);
216 break;
217 case GL_UNSIGNED_INT:
218 CONVERT(GLuint, UINT_TO_FLOAT);
219 break;
220 case GL_DOUBLE:
221 CONVERT(GLdouble, (GLfloat));
222 break;
223 case GL_HALF_FLOAT:
224 convert_half_to_float(binding, attrib, ptr, fptr, count, sz);
225 break;
226 case GL_FIXED:
227 convert_fixed_to_float(binding, attrib, ptr, fptr, count);
228 break;
229 default:
230 assert(0);
231 break;
232 }
233
234 ptr = buf;
235 stride = sz * sizeof(GLfloat);
236 }
237
238 VB->AttribPtr[attr] = &tnl->tmp_inputs[attr];
239 VB->AttribPtr[attr]->data = (GLfloat (*)[4])ptr;
240 VB->AttribPtr[attr]->start = (GLfloat *)ptr;
241 VB->AttribPtr[attr]->count = count;
242 VB->AttribPtr[attr]->stride = stride;
243 VB->AttribPtr[attr]->size = attrib->Format.Size;
244
245 /* This should die, but so should the whole GLvector4f concept:
246 */
247 VB->AttribPtr[attr]->flags = (((1<<attrib->Format.Size)-1) |
248 VEC_NOT_WRITEABLE |
249 (stride == 4*sizeof(GLfloat) ? 0 : VEC_BAD_STRIDE));
250
251 VB->AttribPtr[attr]->storage = NULL;
252 }
253
254 #define CLIPVERTS ((6 + MAX_CLIP_PLANES) * 2)
255
256
257 static GLboolean *_tnl_import_edgeflag( struct gl_context *ctx,
258 const GLvector4f *input,
259 GLuint count)
260 {
261 const GLubyte *ptr = (const GLubyte *)input->data;
262 const GLuint stride = input->stride;
263 GLboolean *space = (GLboolean *)get_space(ctx, count + CLIPVERTS);
264 GLboolean *bptr = space;
265 GLuint i;
266
267 for (i = 0; i < count; i++) {
268 *bptr++ = ((GLfloat *)ptr)[0] == 1.0F;
269 ptr += stride;
270 }
271
272 return space;
273 }
274
275
276 static void bind_inputs( struct gl_context *ctx,
277 const struct tnl_vertex_array *inputs,
278 GLint count,
279 struct gl_buffer_object **bo,
280 GLuint *nr_bo )
281 {
282 TNLcontext *tnl = TNL_CONTEXT(ctx);
283 struct vertex_buffer *VB = &tnl->vb;
284 GLuint i;
285
286 /* Map all the VBOs
287 */
288 for (i = 0; i < VERT_ATTRIB_MAX; i++) {
289 const struct tnl_vertex_array *array = &inputs[i];
290 const struct gl_vertex_buffer_binding *binding = array->BufferBinding;
291 const struct gl_array_attributes *attrib = array->VertexAttrib;
292 const void *ptr;
293
294 if (_mesa_is_bufferobj(binding->BufferObj)) {
295 if (!binding->BufferObj->Mappings[MAP_INTERNAL].Pointer) {
296 bo[*nr_bo] = binding->BufferObj;
297 (*nr_bo)++;
298 ctx->Driver.MapBufferRange(ctx, 0, binding->BufferObj->Size,
299 GL_MAP_READ_BIT,
300 binding->BufferObj,
301 MAP_INTERNAL);
302
303 assert(binding->BufferObj->Mappings[MAP_INTERNAL].Pointer);
304 }
305
306 ptr = ADD_POINTERS(binding->BufferObj->Mappings[MAP_INTERNAL].Pointer,
307 binding->Offset + attrib->RelativeOffset);
308 }
309 else
310 ptr = attrib->Ptr;
311
312 /* Just make sure the array is floating point, otherwise convert to
313 * temporary storage.
314 *
315 * XXX: remove the GLvector4f type at some stage and just use
316 * client arrays.
317 */
318 _tnl_import_array(ctx, i, count, binding, attrib, ptr);
319 }
320
321 /* We process only the vertices between min & max index:
322 */
323 VB->Count = count;
324
325 /* These should perhaps be part of _TNL_ATTRIB_* */
326 VB->BackfaceColorPtr = NULL;
327 VB->BackfaceIndexPtr = NULL;
328 VB->BackfaceSecondaryColorPtr = NULL;
329
330 /* Clipping and drawing code still requires this to be a packed
331 * array of ubytes which can be written into. TODO: Fix and
332 * remove.
333 */
334 if (ctx->Polygon.FrontMode != GL_FILL ||
335 ctx->Polygon.BackMode != GL_FILL)
336 {
337 VB->EdgeFlag = _tnl_import_edgeflag( ctx,
338 VB->AttribPtr[_TNL_ATTRIB_EDGEFLAG],
339 VB->Count );
340 }
341 else {
342 /* the data previously pointed to by EdgeFlag may have been freed */
343 VB->EdgeFlag = NULL;
344 }
345 }
346
347
348 /* Translate indices to GLuints and store in VB->Elts.
349 */
350 static void bind_indices( struct gl_context *ctx,
351 const struct _mesa_index_buffer *ib,
352 struct gl_buffer_object **bo,
353 GLuint *nr_bo)
354 {
355 TNLcontext *tnl = TNL_CONTEXT(ctx);
356 struct vertex_buffer *VB = &tnl->vb;
357 GLuint i;
358 const void *ptr;
359
360 if (!ib) {
361 VB->Elts = NULL;
362 return;
363 }
364
365 if (_mesa_is_bufferobj(ib->obj) &&
366 !_mesa_bufferobj_mapped(ib->obj, MAP_INTERNAL)) {
367 /* if the buffer object isn't mapped yet, map it now */
368 bo[*nr_bo] = ib->obj;
369 (*nr_bo)++;
370 ptr = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr,
371 ib->count << ib->index_size_shift,
372 GL_MAP_READ_BIT, ib->obj,
373 MAP_INTERNAL);
374 assert(ib->obj->Mappings[MAP_INTERNAL].Pointer);
375 } else {
376 /* user-space elements, or buffer already mapped */
377 ptr = ADD_POINTERS(ib->obj->Mappings[MAP_INTERNAL].Pointer, ib->ptr);
378 }
379
380 if (ib->index_size_shift == 2 && VB->Primitive[0].basevertex == 0) {
381 VB->Elts = (GLuint *) ptr;
382 }
383 else {
384 GLuint *elts = (GLuint *)get_space(ctx, ib->count * sizeof(GLuint));
385 VB->Elts = elts;
386
387 if (ib->index_size_shift == 2) {
388 const GLuint *in = (GLuint *)ptr;
389 for (i = 0; i < ib->count; i++)
390 *elts++ = (GLuint)(*in++) + VB->Primitive[0].basevertex;
391 }
392 else if (ib->index_size_shift == 1) {
393 const GLushort *in = (GLushort *)ptr;
394 for (i = 0; i < ib->count; i++)
395 *elts++ = (GLuint)(*in++) + VB->Primitive[0].basevertex;
396 }
397 else {
398 const GLubyte *in = (GLubyte *)ptr;
399 for (i = 0; i < ib->count; i++)
400 *elts++ = (GLuint)(*in++) + VB->Primitive[0].basevertex;
401 }
402 }
403 }
404
405 static void bind_prims( struct gl_context *ctx,
406 const struct _mesa_prim *prim,
407 GLuint nr_prims )
408 {
409 TNLcontext *tnl = TNL_CONTEXT(ctx);
410 struct vertex_buffer *VB = &tnl->vb;
411
412 VB->Primitive = prim;
413 VB->PrimitiveCount = nr_prims;
414 }
415
416 static void unmap_vbos( struct gl_context *ctx,
417 struct gl_buffer_object **bo,
418 GLuint nr_bo )
419 {
420 GLuint i;
421 for (i = 0; i < nr_bo; i++) {
422 ctx->Driver.UnmapBuffer(ctx, bo[i], MAP_INTERNAL);
423 }
424 }
425
426
427 /* This is the main workhorse doing all the rendering work.
428 */
429 void _tnl_draw_prims(struct gl_context *ctx,
430 const struct tnl_vertex_array *arrays,
431 const struct _mesa_prim *prim,
432 GLuint nr_prims,
433 const struct _mesa_index_buffer *ib,
434 GLboolean index_bounds_valid,
435 GLuint min_index,
436 GLuint max_index,
437 GLuint num_instances,
438 GLuint base_instance,
439 struct gl_transform_feedback_object *tfb_vertcount,
440 unsigned stream)
441 {
442 TNLcontext *tnl = TNL_CONTEXT(ctx);
443 const GLuint TEST_SPLIT = 0;
444 const GLint max = TEST_SPLIT ? 8 : tnl->vb.Size - MAX_CLIPPED_VERTICES;
445 GLint max_basevertex = prim->basevertex;
446 GLuint i;
447
448 if (!index_bounds_valid)
449 vbo_get_minmax_indices(ctx, prim, ib, &min_index, &max_index, nr_prims);
450
451 /* Mesa core state should have been validated already */
452 assert(ctx->NewState == 0x0);
453
454 if (!_mesa_check_conditional_render(ctx))
455 return; /* don't draw */
456
457 for (i = 1; i < nr_prims; i++)
458 max_basevertex = MAX2(max_basevertex, prim[i].basevertex);
459
460 if (0)
461 {
462 printf("%s %d..%d\n", __func__, min_index, max_index);
463 for (i = 0; i < nr_prims; i++)
464 printf("prim %d: %s start %d count %d\n", i,
465 _mesa_enum_to_string(prim[i].mode),
466 prim[i].start,
467 prim[i].count);
468 }
469
470 if (min_index) {
471 /* We always translate away calls with min_index != 0.
472 */
473 t_rebase_prims( ctx, arrays, prim, nr_prims, ib,
474 min_index, max_index, num_instances, base_instance,
475 _tnl_draw_prims );
476 return;
477 }
478 else if ((GLint)max_index + max_basevertex > max) {
479 /* The software TNL pipeline has a fixed amount of storage for
480 * vertices and it is necessary to split incoming drawing commands
481 * if they exceed that limit.
482 */
483 struct split_limits limits;
484 limits.max_verts = max;
485 limits.max_vb_size = ~0;
486 limits.max_indices = ~0;
487
488 /* This will split the buffers one way or another and
489 * recursively call back into this function.
490 */
491 _tnl_split_prims( ctx, arrays, prim, nr_prims, ib,
492 0, max_index + prim->basevertex,
493 num_instances, base_instance,
494 _tnl_draw_prims,
495 &limits );
496 }
497 else {
498 /* May need to map a vertex buffer object for every attribute plus
499 * one for the index buffer.
500 */
501 struct gl_buffer_object *bo[VERT_ATTRIB_MAX + 1];
502 GLuint nr_bo = 0;
503 GLuint inst;
504
505 assert(num_instances > 0);
506
507 for (i = 0; i < nr_prims;) {
508 GLuint this_nr_prims;
509
510 /* Our SW TNL pipeline doesn't handle basevertex yet, so bind_indices
511 * will rebase the elements to the basevertex, and we'll only
512 * emit strings of prims with the same basevertex in one draw call.
513 */
514 for (this_nr_prims = 1; i + this_nr_prims < nr_prims;
515 this_nr_prims++) {
516 if (prim[i].basevertex != prim[i + this_nr_prims].basevertex)
517 break;
518 }
519
520 /* Binding inputs may imply mapping some vertex buffer objects.
521 * They will need to be unmapped below.
522 */
523 for (inst = 0; inst < num_instances; inst++) {
524
525 bind_prims(ctx, &prim[i], this_nr_prims);
526 bind_inputs(ctx, arrays, max_index + prim[i].basevertex + 1,
527 bo, &nr_bo);
528 bind_indices(ctx, ib, bo, &nr_bo);
529
530 tnl->CurInstance = inst;
531 TNL_CONTEXT(ctx)->Driver.RunPipeline(ctx);
532
533 unmap_vbos(ctx, bo, nr_bo);
534 free_space(ctx);
535 }
536
537 i += this_nr_prims;
538 }
539 }
540 }
541
542
543 void
544 _tnl_init_inputs(struct tnl_inputs *inputs)
545 {
546 inputs->current = 0;
547 inputs->vertex_processing_mode = VP_MODE_FF;
548 }
549
550
551 /**
552 * Update the tnl_inputs's arrays to point to the vao->_VertexArray arrays
553 * according to the 'enable' bitmask.
554 * \param enable bitfield of VERT_BIT_x flags.
555 */
556 static inline void
557 update_vao_inputs(struct gl_context *ctx,
558 struct tnl_inputs *inputs, GLbitfield enable)
559 {
560 const struct gl_vertex_array_object *vao = ctx->Array._DrawVAO;
561
562 /* Make sure we process only arrays enabled in the VAO */
563 assert((enable & ~_mesa_get_vao_vp_inputs(vao)) == 0);
564
565 /* Fill in the client arrays from the VAO */
566 const struct gl_vertex_buffer_binding *bindings = &vao->BufferBinding[0];
567 while (enable) {
568 const int attr = u_bit_scan(&enable);
569 struct tnl_vertex_array *input = &inputs->inputs[attr];
570 const struct gl_array_attributes *attrib;
571 attrib = _mesa_draw_array_attrib(vao, attr);
572 input->VertexAttrib = attrib;
573 input->BufferBinding = &bindings[attrib->BufferBindingIndex];
574 }
575 }
576
577
578 /**
579 * Update the tnl_inputs's arrays to point to the vbo->currval arrays
580 * according to the 'current' bitmask.
581 * \param current bitfield of VERT_BIT_x flags.
582 */
583 static inline void
584 update_current_inputs(struct gl_context *ctx,
585 struct tnl_inputs *inputs, GLbitfield current)
586 {
587 gl_vertex_processing_mode mode = ctx->VertexProgram._VPMode;
588
589 /* All previously non current array pointers need update. */
590 GLbitfield mask = current & ~inputs->current;
591 /* On mode change, the slots aliasing with materials need update too */
592 if (mode != inputs->vertex_processing_mode)
593 mask |= current & VERT_BIT_MAT_ALL;
594
595 while (mask) {
596 const int attr = u_bit_scan(&mask);
597 struct tnl_vertex_array *input = &inputs->inputs[attr];
598 input->VertexAttrib = _vbo_current_attrib(ctx, attr);
599 input->BufferBinding = _vbo_current_binding(ctx);
600 }
601
602 inputs->current = current;
603 inputs->vertex_processing_mode = mode;
604 }
605
606
607 /**
608 * Update the tnl_inputs's arrays to point to the vao->_VertexArray and
609 * vbo->currval arrays according to Array._DrawVAO and
610 * Array._DrawVAOEnableAttribs.
611 */
612 void
613 _tnl_update_inputs(struct gl_context *ctx, struct tnl_inputs *inputs)
614 {
615 const GLbitfield enable = ctx->Array._DrawVAOEnabledAttribs;
616
617 /* Update array input pointers */
618 update_vao_inputs(ctx, inputs, enable);
619
620 /* The rest must be current inputs. */
621 update_current_inputs(ctx, inputs, ~enable & VERT_BIT_ALL);
622 }
623
624
625 const struct tnl_vertex_array*
626 _tnl_bind_inputs( struct gl_context *ctx )
627 {
628 TNLcontext *tnl = TNL_CONTEXT(ctx);
629 _tnl_update_inputs(ctx, &tnl->draw_arrays);
630 return tnl->draw_arrays.inputs;
631 }
632
633
634 /* This is the main entrypoint into the slimmed-down software tnl
635 * module. In a regular swtnl driver, this can be plugged straight
636 * into the ctx->Driver.Draw() callback.
637 */
638 void
639 _tnl_draw(struct gl_context *ctx,
640 const struct _mesa_prim *prim, GLuint nr_prims,
641 const struct _mesa_index_buffer *ib,
642 GLboolean index_bounds_valid, GLuint min_index, GLuint max_index,
643 GLuint num_instances, GLuint base_instance,
644 struct gl_transform_feedback_object *tfb_vertcount,
645 unsigned stream)
646 {
647 /* Update TNLcontext::draw_arrays and return that pointer.
648 */
649 const struct tnl_vertex_array* arrays = _tnl_bind_inputs(ctx);
650
651 _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib,
652 index_bounds_valid, min_index, max_index,
653 num_instances, base_instance, tfb_vertcount, stream);
654 }
655
656
657 void
658 _tnl_init_driver_draw_function(struct dd_function_table *functions)
659 {
660 functions->Draw = _tnl_draw;
661 }