Merge branch 'master-merge' into vbo-0.2
[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 = VERT_BIT_POS | VERT_BIT_COLOR0;
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 /* NOTE: inputs != tnl->render_inputs - these are the untransformed
408 * inputs.
409 */
410 if (ctx->Light.Enabled) {
411 inputs |= VERT_BIT_NORMAL;
412 }
413
414 if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
415 inputs |= VERT_BIT_COLOR1;
416 }
417
418 if ( (ctx->Fog.FogCoordinateSource == GL_FOG_COORD) && ctx->Fog.Enabled ) {
419 inputs |= VERT_BIT_FOG;
420 }
421
422 for (i = 0 ; i < ctx->Const.MaxTextureUnits; i++) {
423 if (ctx->Texture.Unit[i]._ReallyEnabled) {
424 if (rmesa->TexGenNeedNormals[i]) {
425 inputs |= VERT_BIT_NORMAL;
426 }
427 inputs |= VERT_BIT_TEX(i);
428 }
429 }
430 }
431 else {
432 /* vtx_tcl_output_vtxfmt_0/1 need to match configuration of "fragment
433 part", since using some vertex interpolator later which is not in
434 out_vtxfmt0/1 will lock up. It seems to be ok to write in vertex
435 prog to a not enabled output however, so just don't mess with it.
436 We only need to change compsel. */
437 GLuint out_compsel = 0;
438 GLuint vp_out = rmesa->curr_vp_hw->mesa_program.Base.OutputsWritten;
439 /* can't handle other inputs, generic attribs etc. currently - should never arrive here */
440 assert ((rmesa->curr_vp_hw->mesa_program.Base.InputsRead &
441 ~(VERT_BIT_POS | VERT_BIT_NORMAL | VERT_BIT_COLOR0 | VERT_BIT_COLOR1 |
442 VERT_BIT_FOG | VERT_BIT_TEX0 | VERT_BIT_TEX1 | VERT_BIT_TEX2 |
443 VERT_BIT_TEX3 | VERT_BIT_TEX4 | VERT_BIT_TEX5)) == 0);
444 inputs |= rmesa->curr_vp_hw->mesa_program.Base.InputsRead;
445 assert(vp_out & (1 << VERT_RESULT_HPOS));
446 out_compsel = R200_OUTPUT_XYZW;
447 if (vp_out & (1 << VERT_RESULT_COL0)) {
448 out_compsel |= R200_OUTPUT_COLOR_0;
449 }
450 if (vp_out & (1 << VERT_RESULT_COL1)) {
451 out_compsel |= R200_OUTPUT_COLOR_1;
452 }
453 if (vp_out & (1 << VERT_RESULT_FOGC)) {
454 out_compsel |= R200_OUTPUT_DISCRETE_FOG;
455 }
456 if (vp_out & (1 << VERT_RESULT_PSIZ)) {
457 out_compsel |= R200_OUTPUT_PT_SIZE;
458 }
459 for (i = VERT_RESULT_TEX0; i < VERT_RESULT_TEX6; i++) {
460 if (vp_out & (1 << i)) {
461 out_compsel |= R200_OUTPUT_TEX_0 << (i - VERT_RESULT_TEX0);
462 }
463 }
464 if (rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] != out_compsel) {
465 R200_STATECHANGE( rmesa, vtx );
466 rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] = out_compsel;
467 }
468 }
469
470 /* Do the actual work:
471 */
472 r200ReleaseArrays( ctx, ~0 /* stage->changed_inputs */ );
473 r200EmitArrays( ctx, inputs );
474
475 rmesa->tcl.Elts = VB->Elts;
476
477 for (i = 0 ; i < VB->PrimitiveCount ; i++)
478 {
479 GLuint prim = VB->Primitive[i].mode;
480 GLuint start = VB->Primitive[i].start;
481 GLuint length = VB->Primitive[i].count;
482
483 if (!length)
484 continue;
485
486 if (rmesa->tcl.Elts)
487 r200EmitEltPrimitive( ctx, start, start+length, prim );
488 else
489 r200EmitPrimitive( ctx, start, start+length, prim );
490 }
491
492 return GL_FALSE; /* finished the pipe */
493 }
494
495
496
497 /* Initial state for tcl stage.
498 */
499 const struct tnl_pipeline_stage _r200_tcl_stage =
500 {
501 "r200 render",
502 NULL, /* private */
503 NULL,
504 NULL,
505 NULL,
506 r200_run_tcl_render /* run */
507 };
508
509
510
511 /**********************************************************************/
512 /* Validate state at pipeline start */
513 /**********************************************************************/
514
515
516 /*-----------------------------------------------------------------------
517 * Manage TCL fallbacks
518 */
519
520
521 static void transition_to_swtnl( GLcontext *ctx )
522 {
523 r200ContextPtr rmesa = R200_CONTEXT(ctx);
524 TNLcontext *tnl = TNL_CONTEXT(ctx);
525
526 R200_NEWPRIM( rmesa );
527
528 r200ChooseVertexState( ctx );
529 r200ChooseRenderState( ctx );
530
531 _mesa_validate_all_lighting_tables( ctx );
532
533 tnl->Driver.NotifyMaterialChange =
534 _mesa_validate_all_lighting_tables;
535
536 r200ReleaseArrays( ctx, ~0 );
537
538 /* Still using the D3D based hardware-rasterizer from the radeon;
539 * need to put the card into D3D mode to make it work:
540 */
541 R200_STATECHANGE( rmesa, vap );
542 rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] &= ~(R200_VAP_TCL_ENABLE|R200_VAP_PROG_VTX_SHADER_ENABLE);
543 }
544
545 static void transition_to_hwtnl( GLcontext *ctx )
546 {
547 r200ContextPtr rmesa = R200_CONTEXT(ctx);
548 TNLcontext *tnl = TNL_CONTEXT(ctx);
549
550 _tnl_need_projected_coords( ctx, GL_FALSE );
551
552 r200UpdateMaterial( ctx );
553
554 tnl->Driver.NotifyMaterialChange = r200UpdateMaterial;
555
556 if ( rmesa->dma.flush )
557 rmesa->dma.flush( rmesa );
558
559 rmesa->dma.flush = NULL;
560
561 if (rmesa->swtcl.indexed_verts.buf)
562 r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts,
563 __FUNCTION__ );
564
565 R200_STATECHANGE( rmesa, vap );
566 rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] |= R200_VAP_TCL_ENABLE;
567 rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] &= ~R200_VAP_FORCE_W_TO_ONE;
568
569 if (ctx->VertexProgram._Enabled) {
570 rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] |= R200_VAP_PROG_VTX_SHADER_ENABLE;
571 }
572
573 if ( ((rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] & R200_FOG_USE_MASK)
574 == R200_FOG_USE_SPEC_ALPHA) &&
575 (ctx->Fog.FogCoordinateSource == GL_FOG_COORD )) {
576 R200_STATECHANGE( rmesa, ctx );
577 rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_USE_MASK;
578 rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= R200_FOG_USE_VTX_FOG;
579 }
580
581 R200_STATECHANGE( rmesa, vte );
582 rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] &= ~(R200_VTX_XY_FMT|R200_VTX_Z_FMT);
583 rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] |= R200_VTX_W0_FMT;
584
585 if (R200_DEBUG & DEBUG_FALLBACKS)
586 fprintf(stderr, "R200 end tcl fallback\n");
587 }
588
589
590 static char *fallbackStrings[] = {
591 "Rasterization fallback",
592 "Unfilled triangles",
593 "Twosided lighting, differing materials",
594 "Materials in VB (maybe between begin/end)",
595 "Texgen unit 0",
596 "Texgen unit 1",
597 "Texgen unit 2",
598 "Texgen unit 3",
599 "Texgen unit 4",
600 "Texgen unit 5",
601 "User disable",
602 "Bitmap as points",
603 "Vertex program"
604 };
605
606
607 static char *getFallbackString(GLuint bit)
608 {
609 int i = 0;
610 while (bit > 1) {
611 i++;
612 bit >>= 1;
613 }
614 return fallbackStrings[i];
615 }
616
617
618
619 void r200TclFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
620 {
621 r200ContextPtr rmesa = R200_CONTEXT(ctx);
622 GLuint oldfallback = rmesa->TclFallback;
623
624 if (mode) {
625 rmesa->TclFallback |= bit;
626 if (oldfallback == 0) {
627 if (R200_DEBUG & DEBUG_FALLBACKS)
628 fprintf(stderr, "R200 begin tcl fallback %s\n",
629 getFallbackString( bit ));
630 transition_to_swtnl( ctx );
631 }
632 }
633 else {
634 rmesa->TclFallback &= ~bit;
635 if (oldfallback == bit) {
636 if (R200_DEBUG & DEBUG_FALLBACKS)
637 fprintf(stderr, "R200 end tcl fallback %s\n",
638 getFallbackString( bit ));
639 transition_to_hwtnl( ctx );
640 }
641 }
642 }