Merge branch 'master' of git+ssh://keithw@git.freedesktop.org/git/mesa/mesa into...
[mesa.git] / src / mesa / drivers / dri / r200 / r200_tcl.c
1 /* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tcl.c,v 1.2 2002/12/16 16:18:55 dawes Exp $ */
2 /*
3 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
4
5 The Weather Channel (TM) funded Tungsten Graphics to develop the
6 initial release of the Radeon 8500 driver under the XFree86 license.
7 This notice must be preserved.
8
9 Permission is hereby granted, free of charge, to any person obtaining
10 a copy of this software and associated documentation files (the
11 "Software"), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sublicense, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
16
17 The above copyright notice and this permission notice (including the
18 next paragraph) shall be included in all copies or substantial
19 portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
25 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29 **************************************************************************/
30
31 /*
32 * Authors:
33 * Keith Whitwell <keith@tungstengraphics.com>
34 */
35
36 #include "glheader.h"
37 #include "imports.h"
38 #include "mtypes.h"
39 #include "enums.h"
40 #include "colormac.h"
41 #include "light.h"
42
43 #include "vbo/vbo.h"
44 #include "tnl/tnl.h"
45 #include "tnl/t_pipeline.h"
46
47 #include "r200_context.h"
48 #include "r200_state.h"
49 #include "r200_ioctl.h"
50 #include "r200_tex.h"
51 #include "r200_tcl.h"
52 #include "r200_swtcl.h"
53 #include "r200_maos.h"
54
55
56
57 #define HAVE_POINTS 1
58 #define HAVE_LINES 1
59 #define HAVE_LINE_LOOP 0
60 #define HAVE_LINE_STRIPS 1
61 #define HAVE_TRIANGLES 1
62 #define HAVE_TRI_STRIPS 1
63 #define HAVE_TRI_STRIP_1 0
64 #define HAVE_TRI_FANS 1
65 #define HAVE_QUADS 1
66 #define HAVE_QUAD_STRIPS 1
67 #define HAVE_POLYGONS 1
68 #define HAVE_ELTS 1
69
70
71 #define HW_POINTS ((ctx->Point.PointSprite || \
72 ((ctx->_TriangleCaps & (DD_POINT_SIZE | DD_POINT_ATTEN)) && \
73 !(ctx->_TriangleCaps & (DD_POINT_SMOOTH)))) ? \
74 R200_VF_PRIM_POINT_SPRITES : R200_VF_PRIM_POINTS)
75 #define HW_LINES R200_VF_PRIM_LINES
76 #define HW_LINE_LOOP 0
77 #define HW_LINE_STRIP R200_VF_PRIM_LINE_STRIP
78 #define HW_TRIANGLES R200_VF_PRIM_TRIANGLES
79 #define HW_TRIANGLE_STRIP_0 R200_VF_PRIM_TRIANGLE_STRIP
80 #define HW_TRIANGLE_STRIP_1 0
81 #define HW_TRIANGLE_FAN R200_VF_PRIM_TRIANGLE_FAN
82 #define HW_QUADS R200_VF_PRIM_QUADS
83 #define HW_QUAD_STRIP R200_VF_PRIM_QUAD_STRIP
84 #define HW_POLYGON R200_VF_PRIM_POLYGON
85
86
87 static GLboolean discrete_prim[0x10] = {
88 0, /* 0 none */
89 1, /* 1 points */
90 1, /* 2 lines */
91 0, /* 3 line_strip */
92 1, /* 4 tri_list */
93 0, /* 5 tri_fan */
94 0, /* 6 tri_strip */
95 0, /* 7 tri_w_flags */
96 1, /* 8 rect list (unused) */
97 1, /* 9 3vert point */
98 1, /* a 3vert line */
99 0, /* b point sprite */
100 0, /* c line loop */
101 1, /* d quads */
102 0, /* e quad strip */
103 0, /* f polygon */
104 };
105
106
107 #define LOCAL_VARS r200ContextPtr rmesa = R200_CONTEXT(ctx)
108 #define ELT_TYPE GLushort
109
110 #define ELT_INIT(prim, hw_prim) \
111 r200TclPrimitive( ctx, prim, hw_prim | R200_VF_PRIM_WALK_IND )
112
113 #define GET_MESA_ELTS() rmesa->tcl.Elts
114
115
116 /* Don't really know how many elts will fit in what's left of cmdbuf,
117 * as there is state to emit, etc:
118 */
119
120 /* Testing on isosurf shows a maximum around here. Don't know if it's
121 * the card or driver or kernel module that is causing the behaviour.
122 */
123 #define GET_MAX_HW_ELTS() 300
124
125 #define RESET_STIPPLE() do { \
126 R200_STATECHANGE( rmesa, lin ); \
127 r200EmitState( rmesa ); \
128 } while (0)
129
130 #define AUTO_STIPPLE( mode ) do { \
131 R200_STATECHANGE( rmesa, lin ); \
132 if (mode) \
133 rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] |= \
134 R200_LINE_PATTERN_AUTO_RESET; \
135 else \
136 rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] &= \
137 ~R200_LINE_PATTERN_AUTO_RESET; \
138 r200EmitState( rmesa ); \
139 } while (0)
140
141
142 #define ALLOC_ELTS(nr) r200AllocElts( rmesa, nr )
143
144 static GLushort *r200AllocElts( r200ContextPtr rmesa, GLuint nr )
145 {
146 if (rmesa->dma.flush == r200FlushElts &&
147 rmesa->store.cmd_used + nr*2 < R200_CMD_BUF_SZ) {
148
149 GLushort *dest = (GLushort *)(rmesa->store.cmd_buf +
150 rmesa->store.cmd_used);
151
152 rmesa->store.cmd_used += nr*2;
153
154 return dest;
155 }
156 else {
157 if (rmesa->dma.flush)
158 rmesa->dma.flush( rmesa );
159
160 r200EnsureCmdBufSpace( rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
161 rmesa->hw.max_state_size + ELTS_BUFSZ(nr) );
162
163 r200EmitAOS( rmesa,
164 rmesa->tcl.aos_components,
165 rmesa->tcl.nr_aos_components, 0 );
166
167 return r200AllocEltsOpenEnded( rmesa, rmesa->tcl.hw_primitive, nr );
168 }
169 }
170
171
172 #define CLOSE_ELTS() \
173 do { \
174 if (0) R200_NEWPRIM( rmesa ); \
175 } \
176 while (0)
177
178
179 /* TODO: Try to extend existing primitive if both are identical,
180 * discrete and there are no intervening state changes. (Somewhat
181 * duplicates changes to DrawArrays code)
182 */
183 static void r200EmitPrim( GLcontext *ctx,
184 GLenum prim,
185 GLuint hwprim,
186 GLuint start,
187 GLuint count)
188 {
189 r200ContextPtr rmesa = R200_CONTEXT( ctx );
190 r200TclPrimitive( ctx, prim, hwprim );
191
192 r200EnsureCmdBufSpace( rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
193 rmesa->hw.max_state_size + VBUF_BUFSZ );
194
195 r200EmitAOS( rmesa,
196 rmesa->tcl.aos_components,
197 rmesa->tcl.nr_aos_components,
198 start );
199
200 /* Why couldn't this packet have taken an offset param?
201 */
202 r200EmitVbufPrim( rmesa,
203 rmesa->tcl.hw_primitive,
204 count - start );
205 }
206
207 #define EMIT_PRIM(ctx, prim, hwprim, start, count) do { \
208 r200EmitPrim( ctx, prim, hwprim, start, count ); \
209 (void) rmesa; } while (0)
210
211 /* Try & join small primitives
212 */
213 #if 0
214 #define PREFER_DISCRETE_ELT_PRIM( NR, PRIM ) 0
215 #else
216 #define PREFER_DISCRETE_ELT_PRIM( NR, PRIM ) \
217 ((NR) < 20 || \
218 ((NR) < 40 && \
219 rmesa->tcl.hw_primitive == (PRIM| \
220 R200_VF_TCL_OUTPUT_VTX_ENABLE| \
221 R200_VF_PRIM_WALK_IND)))
222 #endif
223
224 #ifdef MESA_BIG_ENDIAN
225 /* We could do without (most of) this ugliness if dest was always 32 bit word aligned... */
226 #define EMIT_ELT(dest, offset, x) do { \
227 int off = offset + ( ( (GLuint)dest & 0x2 ) >> 1 ); \
228 GLushort *des = (GLushort *)( (GLuint)dest & ~0x2 ); \
229 (des)[ off + 1 - 2 * ( off & 1 ) ] = (GLushort)(x); \
230 (void)rmesa; } while (0)
231 #else
232 #define EMIT_ELT(dest, offset, x) do { \
233 (dest)[offset] = (GLushort) (x); \
234 (void)rmesa; } while (0)
235 #endif
236
237 #define EMIT_TWO_ELTS(dest, offset, x, y) *(GLuint *)((dest)+offset) = ((y)<<16)|(x);
238
239
240
241 #define TAG(x) tcl_##x
242 #include "tnl_dd/t_dd_dmatmp2.h"
243
244 /**********************************************************************/
245 /* External entrypoints */
246 /**********************************************************************/
247
248 void r200EmitPrimitive( GLcontext *ctx,
249 GLuint first,
250 GLuint last,
251 GLuint flags )
252 {
253 tcl_render_tab_verts[flags&PRIM_MODE_MASK]( ctx, first, last, flags );
254 }
255
256 void r200EmitEltPrimitive( GLcontext *ctx,
257 GLuint first,
258 GLuint last,
259 GLuint flags )
260 {
261 tcl_render_tab_elts[flags&PRIM_MODE_MASK]( ctx, first, last, flags );
262 }
263
264 void r200TclPrimitive( GLcontext *ctx,
265 GLenum prim,
266 int hw_prim )
267 {
268 r200ContextPtr rmesa = R200_CONTEXT(ctx);
269 GLuint newprim = hw_prim | R200_VF_TCL_OUTPUT_VTX_ENABLE;
270
271 if (newprim != rmesa->tcl.hw_primitive ||
272 !discrete_prim[hw_prim&0xf]) {
273 /* need to disable perspective-correct texturing for point sprites */
274 if ((prim & PRIM_MODE_MASK) == GL_POINTS && ctx->Point.PointSprite) {
275 if (rmesa->hw.set.cmd[SET_RE_CNTL] & R200_PERSPECTIVE_ENABLE) {
276 R200_STATECHANGE( rmesa, set );
277 rmesa->hw.set.cmd[SET_RE_CNTL] &= ~R200_PERSPECTIVE_ENABLE;
278 }
279 }
280 else if (!(rmesa->hw.set.cmd[SET_RE_CNTL] & R200_PERSPECTIVE_ENABLE)) {
281 R200_STATECHANGE( rmesa, set );
282 rmesa->hw.set.cmd[SET_RE_CNTL] |= R200_PERSPECTIVE_ENABLE;
283 }
284 R200_NEWPRIM( rmesa );
285 rmesa->tcl.hw_primitive = newprim;
286 }
287 }
288
289
290 /**********************************************************************/
291 /* Fog blend factor computation for hw tcl */
292 /* same calculation used as in t_vb_fog.c */
293 /**********************************************************************/
294
295 #define FOG_EXP_TABLE_SIZE 256
296 #define FOG_MAX (10.0)
297 #define EXP_FOG_MAX .0006595
298 #define FOG_INCR (FOG_MAX/FOG_EXP_TABLE_SIZE)
299 static GLfloat exp_table[FOG_EXP_TABLE_SIZE];
300
301 #if 1
302 #define NEG_EXP( result, narg ) \
303 do { \
304 GLfloat f = (GLfloat) (narg * (1.0/FOG_INCR)); \
305 GLint k = (GLint) f; \
306 if (k > FOG_EXP_TABLE_SIZE-2) \
307 result = (GLfloat) EXP_FOG_MAX; \
308 else \
309 result = exp_table[k] + (f-k)*(exp_table[k+1]-exp_table[k]); \
310 } while (0)
311 #else
312 #define NEG_EXP( result, narg ) \
313 do { \
314 result = exp(-narg); \
315 } while (0)
316 #endif
317
318
319 /**
320 * Initialize the exp_table[] lookup table for approximating exp().
321 */
322 void
323 r200InitStaticFogData( void )
324 {
325 GLfloat f = 0.0F;
326 GLint i = 0;
327 for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
328 exp_table[i] = (GLfloat) exp(-f);
329 }
330 }
331
332
333 /**
334 * Compute per-vertex fog blend factors from fog coordinates by
335 * evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
336 * Fog coordinates are distances from the eye (typically between the
337 * near and far clip plane distances).
338 * Note the fog (eye Z) coords may be negative so we use ABS(z) below.
339 * Fog blend factors are in the range [0,1].
340 */
341 float
342 r200ComputeFogBlendFactor( GLcontext *ctx, GLfloat fogcoord )
343 {
344 GLfloat end = ctx->Fog.End;
345 GLfloat d, temp;
346 const GLfloat z = FABSF(fogcoord);
347
348 switch (ctx->Fog.Mode) {
349 case GL_LINEAR:
350 if (ctx->Fog.Start == ctx->Fog.End)
351 d = 1.0F;
352 else
353 d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
354 temp = (end - z) * d;
355 return CLAMP(temp, 0.0F, 1.0F);
356 break;
357 case GL_EXP:
358 d = ctx->Fog.Density;
359 NEG_EXP( temp, d * z );
360 return temp;
361 break;
362 case GL_EXP2:
363 d = ctx->Fog.Density*ctx->Fog.Density;
364 NEG_EXP( temp, d * z * z );
365 return temp;
366 break;
367 default:
368 _mesa_problem(ctx, "Bad fog mode in make_fog_coord");
369 return 0;
370 }
371 }
372
373
374 /**********************************************************************/
375 /* Render pipeline stage */
376 /**********************************************************************/
377
378
379 /* TCL render.
380 */
381 static GLboolean r200_run_tcl_render( GLcontext *ctx,
382 struct tnl_pipeline_stage *stage )
383 {
384 r200ContextPtr rmesa = R200_CONTEXT(ctx);
385 TNLcontext *tnl = TNL_CONTEXT(ctx);
386 struct vertex_buffer *VB = &tnl->vb;
387 GLuint inputs = 0;
388 GLuint i;
389
390 /* TODO: separate this from the swtnl pipeline
391 */
392 if (rmesa->TclFallback)
393 return GL_TRUE; /* fallback to software t&l */
394
395 if (R200_DEBUG & DEBUG_PRIMS)
396 fprintf(stderr, "%s\n", __FUNCTION__);
397
398 if (VB->Count == 0)
399 return GL_FALSE;
400
401 /* Validate state:
402 */
403 if (rmesa->NewGLState)
404 r200ValidateState( ctx );
405
406 if (!ctx->VertexProgram._Enabled) {
407 inputs = VERT_BIT_POS | VERT_BIT_COLOR0;
408 /* NOTE: inputs != tnl->render_inputs - these are the untransformed
409 * inputs.
410 */
411 if (ctx->Light.Enabled) {
412 inputs |= VERT_BIT_NORMAL;
413 }
414
415 if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
416 inputs |= VERT_BIT_COLOR1;
417 }
418
419 if ( (ctx->Fog.FogCoordinateSource == GL_FOG_COORD) && ctx->Fog.Enabled ) {
420 inputs |= VERT_BIT_FOG;
421 }
422
423 for (i = 0 ; i < ctx->Const.MaxTextureUnits; i++) {
424 if (ctx->Texture.Unit[i]._ReallyEnabled) {
425 if (rmesa->TexGenNeedNormals[i]) {
426 inputs |= VERT_BIT_NORMAL;
427 }
428 inputs |= VERT_BIT_TEX(i);
429 }
430 }
431 }
432 else {
433 /* vtx_tcl_output_vtxfmt_0/1 need to match configuration of "fragment
434 part", since using some vertex interpolator later which is not in
435 out_vtxfmt0/1 will lock up. It seems to be ok to write in vertex
436 prog to a not enabled output however, so just don't mess with it.
437 We only need to change compsel. */
438 GLuint out_compsel = 0;
439 GLuint vp_out = rmesa->curr_vp_hw->mesa_program.Base.OutputsWritten;
440 #if 0
441 /* can't handle other inputs, generic attribs etc. currently - should never arrive here */
442 assert ((rmesa->curr_vp_hw->mesa_program.Base.InputsRead &
443 ~(VERT_BIT_POS | VERT_BIT_NORMAL | VERT_BIT_COLOR0 | VERT_BIT_COLOR1 |
444 VERT_BIT_FOG | VERT_BIT_TEX0 | VERT_BIT_TEX1 | VERT_BIT_TEX2 |
445 VERT_BIT_TEX3 | VERT_BIT_TEX4 | VERT_BIT_TEX5)) == 0);
446 #endif
447 inputs |= rmesa->curr_vp_hw->mesa_program.Base.InputsRead;
448 assert(vp_out & (1 << VERT_RESULT_HPOS));
449 out_compsel = R200_OUTPUT_XYZW;
450 if (vp_out & (1 << VERT_RESULT_COL0)) {
451 out_compsel |= R200_OUTPUT_COLOR_0;
452 }
453 if (vp_out & (1 << VERT_RESULT_COL1)) {
454 out_compsel |= R200_OUTPUT_COLOR_1;
455 }
456 if (vp_out & (1 << VERT_RESULT_FOGC)) {
457 out_compsel |= R200_OUTPUT_DISCRETE_FOG;
458 }
459 if (vp_out & (1 << VERT_RESULT_PSIZ)) {
460 out_compsel |= R200_OUTPUT_PT_SIZE;
461 }
462 for (i = VERT_RESULT_TEX0; i < VERT_RESULT_TEX6; i++) {
463 if (vp_out & (1 << i)) {
464 out_compsel |= R200_OUTPUT_TEX_0 << (i - VERT_RESULT_TEX0);
465 }
466 }
467 if (rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] != out_compsel) {
468 R200_STATECHANGE( rmesa, vtx );
469 rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] = out_compsel;
470 }
471 }
472
473 /* Do the actual work:
474 */
475 r200ReleaseArrays( ctx, ~0 /* stage->changed_inputs */ );
476 r200EmitArrays( ctx, inputs );
477
478 rmesa->tcl.Elts = VB->Elts;
479
480 for (i = 0 ; i < VB->PrimitiveCount ; i++)
481 {
482 GLuint prim = VB->Primitive[i].mode;
483 GLuint start = VB->Primitive[i].start;
484 GLuint length = VB->Primitive[i].count;
485
486 if (!length)
487 continue;
488
489 if (rmesa->tcl.Elts)
490 r200EmitEltPrimitive( ctx, start, start+length, prim );
491 else
492 r200EmitPrimitive( ctx, start, start+length, prim );
493 }
494
495 return GL_FALSE; /* finished the pipe */
496 }
497
498
499
500 /* Initial state for tcl stage.
501 */
502 const struct tnl_pipeline_stage _r200_tcl_stage =
503 {
504 "r200 render",
505 NULL, /* private */
506 NULL,
507 NULL,
508 NULL,
509 r200_run_tcl_render /* run */
510 };
511
512
513
514 /**********************************************************************/
515 /* Validate state at pipeline start */
516 /**********************************************************************/
517
518
519 /*-----------------------------------------------------------------------
520 * Manage TCL fallbacks
521 */
522
523
524 static void transition_to_swtnl( GLcontext *ctx )
525 {
526 r200ContextPtr rmesa = R200_CONTEXT(ctx);
527 TNLcontext *tnl = TNL_CONTEXT(ctx);
528
529 R200_NEWPRIM( rmesa );
530
531 r200ChooseVertexState( ctx );
532 r200ChooseRenderState( ctx );
533
534 _mesa_validate_all_lighting_tables( ctx );
535
536 tnl->Driver.NotifyMaterialChange =
537 _mesa_validate_all_lighting_tables;
538
539 r200ReleaseArrays( ctx, ~0 );
540
541 /* Still using the D3D based hardware-rasterizer from the radeon;
542 * need to put the card into D3D mode to make it work:
543 */
544 R200_STATECHANGE( rmesa, vap );
545 rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] &= ~(R200_VAP_TCL_ENABLE|R200_VAP_PROG_VTX_SHADER_ENABLE);
546 }
547
548 static void transition_to_hwtnl( GLcontext *ctx )
549 {
550 r200ContextPtr rmesa = R200_CONTEXT(ctx);
551 TNLcontext *tnl = TNL_CONTEXT(ctx);
552
553 _tnl_need_projected_coords( ctx, GL_FALSE );
554
555 r200UpdateMaterial( ctx );
556
557 tnl->Driver.NotifyMaterialChange = r200UpdateMaterial;
558
559 if ( rmesa->dma.flush )
560 rmesa->dma.flush( rmesa );
561
562 rmesa->dma.flush = NULL;
563
564 if (rmesa->swtcl.indexed_verts.buf)
565 r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts,
566 __FUNCTION__ );
567
568 R200_STATECHANGE( rmesa, vap );
569 rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] |= R200_VAP_TCL_ENABLE;
570 rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] &= ~R200_VAP_FORCE_W_TO_ONE;
571
572 if (ctx->VertexProgram._Enabled) {
573 rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] |= R200_VAP_PROG_VTX_SHADER_ENABLE;
574 }
575
576 if ( ((rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] & R200_FOG_USE_MASK)
577 == R200_FOG_USE_SPEC_ALPHA) &&
578 (ctx->Fog.FogCoordinateSource == GL_FOG_COORD )) {
579 R200_STATECHANGE( rmesa, ctx );
580 rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_USE_MASK;
581 rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= R200_FOG_USE_VTX_FOG;
582 }
583
584 R200_STATECHANGE( rmesa, vte );
585 rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] &= ~(R200_VTX_XY_FMT|R200_VTX_Z_FMT);
586 rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] |= R200_VTX_W0_FMT;
587
588 if (R200_DEBUG & DEBUG_FALLBACKS)
589 fprintf(stderr, "R200 end tcl fallback\n");
590 }
591
592
593 static char *fallbackStrings[] = {
594 "Rasterization fallback",
595 "Unfilled triangles",
596 "Twosided lighting, differing materials",
597 "Materials in VB (maybe between begin/end)",
598 "Texgen unit 0",
599 "Texgen unit 1",
600 "Texgen unit 2",
601 "Texgen unit 3",
602 "Texgen unit 4",
603 "Texgen unit 5",
604 "User disable",
605 "Bitmap as points",
606 "Vertex program"
607 };
608
609
610 static char *getFallbackString(GLuint bit)
611 {
612 int i = 0;
613 while (bit > 1) {
614 i++;
615 bit >>= 1;
616 }
617 return fallbackStrings[i];
618 }
619
620
621
622 void r200TclFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
623 {
624 r200ContextPtr rmesa = R200_CONTEXT(ctx);
625 GLuint oldfallback = rmesa->TclFallback;
626
627 if (mode) {
628 rmesa->TclFallback |= bit;
629 if (oldfallback == 0) {
630 if (R200_DEBUG & DEBUG_FALLBACKS)
631 fprintf(stderr, "R200 begin tcl fallback %s\n",
632 getFallbackString( bit ));
633 transition_to_swtnl( ctx );
634 }
635 }
636 else {
637 rmesa->TclFallback &= ~bit;
638 if (oldfallback == bit) {
639 if (R200_DEBUG & DEBUG_FALLBACKS)
640 fprintf(stderr, "R200 end tcl fallback %s\n",
641 getFallbackString( bit ));
642 transition_to_hwtnl( ctx );
643 }
644 }
645 }