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