Small optimization for big-endian (e.g., PowerPC) systems.
[mesa.git] / src / mesa / drivers / dri / r128 / r128_state.c
1 /* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_state.c,v 1.11 2002/10/30 12:51:39 alanh Exp $ */
2 /**************************************************************************
3
4 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
5 Cedar Park, Texas.
6 All Rights Reserved.
7
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 on the rights to use, copy, modify, merge, publish, distribute, sub
12 license, and/or sell copies of the Software, and to permit persons to whom
13 the Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice (including the next
16 paragraph) shall be included in all copies or substantial portions of the
17 Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 USE OR OTHER DEALINGS IN THE SOFTWARE.
26
27 **************************************************************************/
28
29 /*
30 * Authors:
31 * Gareth Hughes <gareth@valinux.com>
32 * Kevin E. Martin <martin@valinux.com>
33 * Keith Whitwell <keith@tungstengraphics.com>
34 *
35 */
36
37 #include "r128_context.h"
38 #include "r128_state.h"
39 #include "r128_ioctl.h"
40 #include "r128_tris.h"
41 #include "r128_tex.h"
42
43 #include "context.h"
44 #include "enums.h"
45 #include "colormac.h"
46 #include "swrast/swrast.h"
47 #include "array_cache/acache.h"
48 #include "tnl/tnl.h"
49 #include "swrast_setup/swrast_setup.h"
50
51 #include "tnl/t_pipeline.h"
52
53
54 /* =============================================================
55 * Alpha blending
56 */
57
58
59 /**
60 * Calculate the hardware blend factor setting. This same function is used
61 * for source and destination of both alpha and RGB.
62 *
63 * \returns
64 * The hardware register value for the specified blend factor. This value
65 * will need to be shifted into the correct position for either source or
66 * destination factor.
67 *
68 * \todo
69 * Since the two cases where source and destination are handled differently
70 * are essentially error cases, they should never happen. Determine if these
71 * cases can be removed.
72 */
73 static int blend_factor( r128ContextPtr rmesa, GLenum factor, GLboolean is_src )
74 {
75 int func;
76
77 switch ( factor ) {
78 case GL_ZERO:
79 func = R128_ALPHA_BLEND_ZERO;
80 break;
81 case GL_ONE:
82 func = R128_ALPHA_BLEND_ONE;
83 break;
84
85 case GL_SRC_COLOR:
86 func = R128_ALPHA_BLEND_SRCCOLOR;
87 break;
88 case GL_ONE_MINUS_SRC_COLOR:
89 func = R128_ALPHA_BLEND_INVSRCCOLOR;
90 break;
91 case GL_SRC_ALPHA:
92 func = R128_ALPHA_BLEND_SRCALPHA;
93 break;
94 case GL_ONE_MINUS_SRC_ALPHA:
95 func = R128_ALPHA_BLEND_INVSRCALPHA;
96 break;
97 case GL_SRC_ALPHA_SATURATE:
98 func = (is_src) ? R128_ALPHA_BLEND_SAT : R128_ALPHA_BLEND_ZERO;
99 break;
100
101 case GL_DST_COLOR:
102 func = R128_ALPHA_BLEND_DSTCOLOR;
103 break;
104 case GL_ONE_MINUS_DST_COLOR:
105 func = R128_ALPHA_BLEND_INVDSTCOLOR;
106 break;
107 case GL_DST_ALPHA:
108 func = R128_ALPHA_BLEND_DSTALPHA;
109 break;
110 case GL_ONE_MINUS_DST_ALPHA:
111 func = R128_ALPHA_BLEND_INVDSTALPHA;
112 break;
113
114 case GL_CONSTANT_COLOR:
115 case GL_ONE_MINUS_CONSTANT_COLOR:
116 case GL_CONSTANT_ALPHA:
117 case GL_ONE_MINUS_CONSTANT_ALPHA:
118 default:
119 FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_TRUE );
120 func = (is_src) ? R128_ALPHA_BLEND_ONE : R128_ALPHA_BLEND_ZERO;
121 break;
122 }
123
124 return func;
125 }
126
127
128 static void r128UpdateAlphaMode( GLcontext *ctx )
129 {
130 r128ContextPtr rmesa = R128_CONTEXT(ctx);
131 GLuint a = rmesa->setup.misc_3d_state_cntl_reg;
132 GLuint t = rmesa->setup.tex_cntl_c;
133
134 if ( ctx->Color.AlphaEnabled ) {
135 GLubyte ref;
136
137 CLAMPED_FLOAT_TO_UBYTE(ref, ctx->Color.AlphaRef);
138
139 a &= ~(R128_ALPHA_TEST_MASK | R128_REF_ALPHA_MASK);
140
141 switch ( ctx->Color.AlphaFunc ) {
142 case GL_NEVER:
143 a |= R128_ALPHA_TEST_NEVER;
144 break;
145 case GL_LESS:
146 a |= R128_ALPHA_TEST_LESS;
147 break;
148 case GL_LEQUAL:
149 a |= R128_ALPHA_TEST_LESSEQUAL;
150 break;
151 case GL_EQUAL:
152 a |= R128_ALPHA_TEST_EQUAL;
153 break;
154 case GL_GEQUAL:
155 a |= R128_ALPHA_TEST_GREATEREQUAL;
156 break;
157 case GL_GREATER:
158 a |= R128_ALPHA_TEST_GREATER;
159 break;
160 case GL_NOTEQUAL:
161 a |= R128_ALPHA_TEST_NEQUAL;
162 break;
163 case GL_ALWAYS:
164 a |= R128_ALPHA_TEST_ALWAYS;
165 break;
166 }
167
168 a |= ref & R128_REF_ALPHA_MASK;
169 t |= R128_ALPHA_TEST_ENABLE;
170 } else {
171 t &= ~R128_ALPHA_TEST_ENABLE;
172 }
173
174 FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_FALSE );
175
176 if ( ctx->Color.BlendEnabled ) {
177 a &= ~((R128_ALPHA_BLEND_MASK << R128_ALPHA_BLEND_SRC_SHIFT) |
178 (R128_ALPHA_BLEND_MASK << R128_ALPHA_BLEND_DST_SHIFT)
179 | R128_ALPHA_COMB_FCN_MASK);
180
181 a |= blend_factor( rmesa, ctx->Color.BlendSrcRGB, GL_TRUE )
182 << R128_ALPHA_BLEND_SRC_SHIFT;
183 a |= blend_factor( rmesa, ctx->Color.BlendDstRGB, GL_FALSE )
184 << R128_ALPHA_BLEND_DST_SHIFT;
185
186 switch (ctx->Color.BlendEquationRGB) {
187 case GL_FUNC_ADD:
188 a |= R128_ALPHA_COMB_ADD_CLAMP;
189 break;
190 case GL_FUNC_SUBTRACT:
191 a |= R128_ALPHA_COMB_SUB_SRC_DST_CLAMP;
192 break;
193 default:
194 FALLBACK( rmesa, R128_FALLBACK_BLEND_EQ, GL_TRUE );
195 }
196
197 t |= R128_ALPHA_ENABLE;
198 } else {
199 t &= ~R128_ALPHA_ENABLE;
200 }
201
202 if ( rmesa->setup.misc_3d_state_cntl_reg != a ) {
203 rmesa->setup.misc_3d_state_cntl_reg = a;
204 rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
205 }
206 if ( rmesa->setup.tex_cntl_c != t ) {
207 rmesa->setup.tex_cntl_c = t;
208 rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
209 }
210 }
211
212 static void r128DDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
213 {
214 r128ContextPtr rmesa = R128_CONTEXT(ctx);
215
216 FLUSH_BATCH( rmesa );
217 rmesa->new_state |= R128_NEW_ALPHA;
218 }
219
220 static void r128DDBlendEquationSeparate( GLcontext *ctx,
221 GLenum modeRGB, GLenum modeA )
222 {
223 r128ContextPtr rmesa = R128_CONTEXT(ctx);
224
225 assert( modeRGB == modeA );
226 FLUSH_BATCH( rmesa );
227
228 /* BlendEquation sets ColorLogicOpEnabled in an unexpected
229 * manner.
230 */
231 FALLBACK( R128_CONTEXT(ctx), R128_FALLBACK_LOGICOP,
232 (ctx->Color.ColorLogicOpEnabled &&
233 ctx->Color.LogicOp != GL_COPY));
234
235 /* Can only do blend addition, not min, max, subtract, etc. */
236 FALLBACK( R128_CONTEXT(ctx), R128_FALLBACK_BLEND_EQ,
237 (modeRGB != GL_FUNC_ADD) && (modeRGB != GL_FUNC_SUBTRACT));
238
239 rmesa->new_state |= R128_NEW_ALPHA;
240 }
241
242 static void r128DDBlendFuncSeparate( GLcontext *ctx,
243 GLenum sfactorRGB, GLenum dfactorRGB,
244 GLenum sfactorA, GLenum dfactorA )
245 {
246 r128ContextPtr rmesa = R128_CONTEXT(ctx);
247
248 FLUSH_BATCH( rmesa );
249 rmesa->new_state |= R128_NEW_ALPHA;
250 }
251
252
253 /* =============================================================
254 * Depth testing
255 */
256
257 static void r128UpdateZMode( GLcontext *ctx )
258 {
259 r128ContextPtr rmesa = R128_CONTEXT(ctx);
260 GLuint z = rmesa->setup.z_sten_cntl_c;
261 GLuint t = rmesa->setup.tex_cntl_c;
262
263 if ( ctx->Depth.Test ) {
264 z &= ~R128_Z_TEST_MASK;
265
266 switch ( ctx->Depth.Func ) {
267 case GL_NEVER:
268 z |= R128_Z_TEST_NEVER;
269 break;
270 case GL_ALWAYS:
271 z |= R128_Z_TEST_ALWAYS;
272 break;
273 case GL_LESS:
274 z |= R128_Z_TEST_LESS;
275 break;
276 case GL_LEQUAL:
277 z |= R128_Z_TEST_LESSEQUAL;
278 break;
279 case GL_EQUAL:
280 z |= R128_Z_TEST_EQUAL;
281 break;
282 case GL_GEQUAL:
283 z |= R128_Z_TEST_GREATEREQUAL;
284 break;
285 case GL_GREATER:
286 z |= R128_Z_TEST_GREATER;
287 break;
288 case GL_NOTEQUAL:
289 z |= R128_Z_TEST_NEQUAL;
290 break;
291 }
292
293 t |= R128_Z_ENABLE;
294 } else {
295 t &= ~R128_Z_ENABLE;
296 }
297
298 if ( ctx->Depth.Mask ) {
299 t |= R128_Z_WRITE_ENABLE;
300 } else {
301 t &= ~R128_Z_WRITE_ENABLE;
302 }
303
304 if ( rmesa->setup.z_sten_cntl_c != z ) {
305 rmesa->setup.z_sten_cntl_c = z;
306 rmesa->dirty |= R128_UPLOAD_CONTEXT;
307 }
308 if ( rmesa->setup.tex_cntl_c != t ) {
309 rmesa->setup.tex_cntl_c = t;
310 rmesa->dirty |= R128_UPLOAD_CONTEXT;
311 }
312 }
313
314 static void r128DDDepthFunc( GLcontext *ctx, GLenum func )
315 {
316 r128ContextPtr rmesa = R128_CONTEXT(ctx);
317
318 FLUSH_BATCH( rmesa );
319 rmesa->new_state |= R128_NEW_DEPTH;
320 }
321
322 static void r128DDDepthMask( GLcontext *ctx, GLboolean flag )
323 {
324 r128ContextPtr rmesa = R128_CONTEXT(ctx);
325
326 FLUSH_BATCH( rmesa );
327 rmesa->new_state |= R128_NEW_DEPTH;
328 }
329
330 static void r128DDClearDepth( GLcontext *ctx, GLclampd d )
331 {
332 r128ContextPtr rmesa = R128_CONTEXT(ctx);
333
334 switch ( rmesa->setup.z_sten_cntl_c & R128_Z_PIX_WIDTH_MASK ) {
335 case R128_Z_PIX_WIDTH_16:
336 rmesa->ClearDepth = d * 0x0000ffff;
337 break;
338 case R128_Z_PIX_WIDTH_24:
339 rmesa->ClearDepth = d * 0x00ffffff;
340 break;
341 case R128_Z_PIX_WIDTH_32:
342 rmesa->ClearDepth = d * 0xffffffff;
343 break;
344 }
345 }
346
347
348 /* =============================================================
349 * Fog
350 */
351
352 static void r128UpdateFogAttrib( GLcontext *ctx )
353 {
354 r128ContextPtr rmesa = R128_CONTEXT(ctx);
355 GLuint t = rmesa->setup.tex_cntl_c;
356 GLubyte c[4];
357 GLuint col;
358
359 if ( ctx->Fog.Enabled ) {
360 t |= R128_FOG_ENABLE;
361 } else {
362 t &= ~R128_FOG_ENABLE;
363 }
364
365 c[0] = FLOAT_TO_UBYTE( ctx->Fog.Color[0] );
366 c[1] = FLOAT_TO_UBYTE( ctx->Fog.Color[1] );
367 c[2] = FLOAT_TO_UBYTE( ctx->Fog.Color[2] );
368
369 col = r128PackColor( 4, c[0], c[1], c[2], 0 );
370
371 if ( rmesa->setup.fog_color_c != col ) {
372 rmesa->setup.fog_color_c = col;
373 rmesa->dirty |= R128_UPLOAD_CONTEXT;
374 }
375 if ( rmesa->setup.tex_cntl_c != t ) {
376 rmesa->setup.tex_cntl_c = t;
377 rmesa->dirty |= R128_UPLOAD_CONTEXT;
378 }
379 }
380
381 static void r128DDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
382 {
383 r128ContextPtr rmesa = R128_CONTEXT(ctx);
384
385 FLUSH_BATCH( rmesa );
386 rmesa->new_state |= R128_NEW_FOG;
387 }
388
389
390 /* =============================================================
391 * Clipping
392 */
393
394 static void r128UpdateClipping( GLcontext *ctx )
395 {
396 r128ContextPtr rmesa = R128_CONTEXT(ctx);
397
398 if ( rmesa->driDrawable ) {
399 __DRIdrawablePrivate *drawable = rmesa->driDrawable;
400 int x1 = 0;
401 int y1 = 0;
402 int x2 = drawable->w - 1;
403 int y2 = drawable->h - 1;
404
405 if ( ctx->Scissor.Enabled ) {
406 if ( ctx->Scissor.X > x1 ) {
407 x1 = ctx->Scissor.X;
408 }
409 if ( drawable->h - ctx->Scissor.Y - ctx->Scissor.Height > y1 ) {
410 y1 = drawable->h - ctx->Scissor.Y - ctx->Scissor.Height;
411 }
412 if ( ctx->Scissor.X + ctx->Scissor.Width - 1 < x2 ) {
413 x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;
414 }
415 if ( drawable->h - ctx->Scissor.Y - 1 < y2 ) {
416 y2 = drawable->h - ctx->Scissor.Y - 1;
417 }
418 }
419
420 x1 += drawable->x;
421 y1 += drawable->y;
422 x2 += drawable->x;
423 y2 += drawable->y;
424
425 rmesa->setup.sc_top_left_c = ((y1 << 16) | x1);
426 rmesa->setup.sc_bottom_right_c = ((y2 << 16) | x2);
427
428 rmesa->dirty |= R128_UPLOAD_CONTEXT;
429 }
430 }
431
432 static void r128DDScissor( GLcontext *ctx,
433 GLint x, GLint y, GLsizei w, GLsizei h )
434 {
435 r128ContextPtr rmesa = R128_CONTEXT(ctx);
436
437 FLUSH_BATCH( rmesa );
438 rmesa->new_state |= R128_NEW_CLIP;
439 }
440
441
442 /* =============================================================
443 * Culling
444 */
445
446 static void r128UpdateCull( GLcontext *ctx )
447 {
448 r128ContextPtr rmesa = R128_CONTEXT(ctx);
449 GLuint f = rmesa->setup.pm4_vc_fpu_setup;
450
451 f &= ~R128_FRONT_DIR_MASK;
452
453 switch ( ctx->Polygon.FrontFace ) {
454 case GL_CW:
455 f |= R128_FRONT_DIR_CW;
456 break;
457 case GL_CCW:
458 f |= R128_FRONT_DIR_CCW;
459 break;
460 }
461
462 f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID;
463
464 if ( ctx->Polygon.CullFlag ) {
465 switch ( ctx->Polygon.CullFaceMode ) {
466 case GL_FRONT:
467 f &= ~R128_FRONTFACE_SOLID;
468 break;
469 case GL_BACK:
470 f &= ~R128_BACKFACE_SOLID;
471 break;
472 case GL_FRONT_AND_BACK:
473 f &= ~(R128_BACKFACE_SOLID |
474 R128_FRONTFACE_SOLID);
475 break;
476 }
477 }
478
479 if ( 1 || rmesa->setup.pm4_vc_fpu_setup != f ) {
480 rmesa->setup.pm4_vc_fpu_setup = f;
481 rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_SETUP;
482 }
483 }
484
485 static void r128DDCullFace( GLcontext *ctx, GLenum mode )
486 {
487 r128ContextPtr rmesa = R128_CONTEXT(ctx);
488
489 FLUSH_BATCH( rmesa );
490 rmesa->new_state |= R128_NEW_CULL;
491 }
492
493 static void r128DDFrontFace( GLcontext *ctx, GLenum mode )
494 {
495 r128ContextPtr rmesa = R128_CONTEXT(ctx);
496
497 FLUSH_BATCH( rmesa );
498 rmesa->new_state |= R128_NEW_CULL;
499 }
500
501
502 /* =============================================================
503 * Masks
504 */
505
506 static void r128UpdateMasks( GLcontext *ctx )
507 {
508 r128ContextPtr rmesa = R128_CONTEXT(ctx);
509
510 GLuint mask = r128PackColor( rmesa->r128Screen->cpp,
511 ctx->Color.ColorMask[RCOMP],
512 ctx->Color.ColorMask[GCOMP],
513 ctx->Color.ColorMask[BCOMP],
514 ctx->Color.ColorMask[ACOMP] );
515
516 if ( rmesa->setup.plane_3d_mask_c != mask ) {
517 rmesa->setup.plane_3d_mask_c = mask;
518 rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
519 }
520 }
521
522 static void r128DDColorMask( GLcontext *ctx,
523 GLboolean r, GLboolean g,
524 GLboolean b, GLboolean a )
525 {
526 r128ContextPtr rmesa = R128_CONTEXT(ctx);
527
528 FLUSH_BATCH( rmesa );
529 rmesa->new_state |= R128_NEW_MASKS;
530 }
531
532
533 /* =============================================================
534 * Rendering attributes
535 *
536 * We really don't want to recalculate all this every time we bind a
537 * texture. These things shouldn't change all that often, so it makes
538 * sense to break them out of the core texture state update routines.
539 */
540
541 static void updateSpecularLighting( GLcontext *ctx )
542 {
543 r128ContextPtr rmesa = R128_CONTEXT(ctx);
544 GLuint t = rmesa->setup.tex_cntl_c;
545
546 if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
547 ctx->Light.Enabled) {
548 /* XXX separate specular color just doesn't seem to work as it should.
549 * For now, we fall back to s/w rendering whenever separate specular
550 * is enabled.
551 */
552 #if 0
553 if (ctx->Light.ShadeModel == GL_FLAT) {
554 /* R128 can't do flat-shaded separate specular */
555 t &= ~R128_SPEC_LIGHT_ENABLE;
556 FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_TRUE );
557 /*printf("%s fallback sep spec\n", __FUNCTION__);*/
558 }
559 else {
560 t |= R128_SPEC_LIGHT_ENABLE;
561 FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_FALSE );
562 /*printf("%s enable sep spec\n", __FUNCTION__);*/
563 }
564 #else
565 t &= ~R128_SPEC_LIGHT_ENABLE;
566 FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_TRUE );
567 /*printf("%s fallback sep spec\n", __FUNCTION__);*/
568 #endif
569 }
570 else {
571 t &= ~R128_SPEC_LIGHT_ENABLE;
572 FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_FALSE );
573 /*printf("%s disable sep spec\n", __FUNCTION__);*/
574 }
575
576 if ( rmesa->setup.tex_cntl_c != t ) {
577 rmesa->setup.tex_cntl_c = t;
578 rmesa->dirty |= R128_UPLOAD_CONTEXT;
579 rmesa->dirty |= R128_UPLOAD_SETUP;
580 rmesa->new_state |= R128_NEW_CONTEXT;
581 }
582 }
583
584
585 static void r128DDLightModelfv( GLcontext *ctx, GLenum pname,
586 const GLfloat *param )
587 {
588 r128ContextPtr rmesa = R128_CONTEXT(ctx);
589
590 if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) {
591 FLUSH_BATCH( rmesa );
592 updateSpecularLighting(ctx);
593 }
594 }
595
596 static void r128DDShadeModel( GLcontext *ctx, GLenum mode )
597 {
598 r128ContextPtr rmesa = R128_CONTEXT(ctx);
599 GLuint s = rmesa->setup.pm4_vc_fpu_setup;
600
601 s &= ~R128_FPU_COLOR_MASK;
602
603 switch ( mode ) {
604 case GL_FLAT:
605 s |= R128_FPU_COLOR_FLAT;
606 break;
607 case GL_SMOOTH:
608 s |= R128_FPU_COLOR_GOURAUD;
609 break;
610 default:
611 return;
612 }
613
614 updateSpecularLighting(ctx);
615
616 if ( rmesa->setup.pm4_vc_fpu_setup != s ) {
617 FLUSH_BATCH( rmesa );
618 rmesa->setup.pm4_vc_fpu_setup = s;
619
620 rmesa->new_state |= R128_NEW_CONTEXT;
621 rmesa->dirty |= R128_UPLOAD_SETUP;
622 }
623 }
624
625
626 /* =============================================================
627 * Window position
628 */
629
630 void r128UpdateWindow( GLcontext *ctx )
631 {
632 r128ContextPtr rmesa = R128_CONTEXT(ctx);
633 int x = rmesa->driDrawable->x;
634 int y = rmesa->driDrawable->y;
635
636 rmesa->setup.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) |
637 (x << R128_WINDOW_X_SHIFT));
638
639 rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_WINDOW;
640 }
641
642 /* =============================================================
643 * Viewport
644 */
645
646
647 static void r128CalcViewport( GLcontext *ctx )
648 {
649 r128ContextPtr rmesa = R128_CONTEXT(ctx);
650 const GLfloat *v = ctx->Viewport._WindowMap.m;
651 GLfloat *m = rmesa->hw_viewport;
652
653 /* See also r128_translate_vertex.
654 */
655 m[MAT_SX] = v[MAT_SX];
656 m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
657 m[MAT_SY] = - v[MAT_SY];
658 m[MAT_TY] = - v[MAT_TY] + rmesa->driDrawable->h + SUBPIXEL_Y;
659 m[MAT_SZ] = v[MAT_SZ] * rmesa->depth_scale;
660 m[MAT_TZ] = v[MAT_TZ] * rmesa->depth_scale;
661 }
662
663 static void r128Viewport( GLcontext *ctx,
664 GLint x, GLint y,
665 GLsizei width, GLsizei height )
666 {
667 r128CalcViewport( ctx );
668 }
669
670 static void r128DepthRange( GLcontext *ctx,
671 GLclampd nearval, GLclampd farval )
672 {
673 r128CalcViewport( ctx );
674 }
675
676
677 /* =============================================================
678 * Miscellaneous
679 */
680
681 static void r128DDClearColor( GLcontext *ctx,
682 const GLfloat color[4] )
683 {
684 r128ContextPtr rmesa = R128_CONTEXT(ctx);
685 GLubyte c[4];
686
687 CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
688 CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
689 CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
690 CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
691
692 rmesa->ClearColor = r128PackColor( rmesa->r128Screen->cpp,
693 c[0], c[1], c[2], c[3] );
694 }
695
696 static void r128DDLogicOpCode( GLcontext *ctx, GLenum opcode )
697 {
698 r128ContextPtr rmesa = R128_CONTEXT(ctx);
699
700 if ( ctx->Color.ColorLogicOpEnabled ) {
701 FLUSH_BATCH( rmesa );
702
703 FALLBACK( rmesa, R128_FALLBACK_LOGICOP, opcode != GL_COPY );
704 }
705 }
706
707 static void r128DDDrawBuffer( GLcontext *ctx, GLenum mode )
708 {
709 r128ContextPtr rmesa = R128_CONTEXT(ctx);
710
711 FLUSH_BATCH( rmesa );
712
713 /*
714 * _DrawDestMask is easier to cope with than <mode>.
715 */
716 switch ( ctx->Color._DrawDestMask[0] ) {
717 case DD_FRONT_LEFT_BIT:
718 FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE );
719 break;
720 case DD_BACK_LEFT_BIT:
721 FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE );
722 break;
723 default:
724 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
725 FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_TRUE );
726 break;
727 }
728
729 /* We want to update the s/w rast state too so that r128DDSetBuffer()
730 * gets called.
731 */
732 _swrast_DrawBuffer(ctx, mode);
733
734 rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
735 (rmesa->drawOffset >> 5));
736 rmesa->new_state |= R128_NEW_WINDOW;
737 }
738
739 static void r128DDReadBuffer( GLcontext *ctx, GLenum mode )
740 {
741 /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
742 }
743
744
745 /* =============================================================
746 * Polygon stipple
747 */
748
749 static void r128DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
750 {
751 r128ContextPtr rmesa = R128_CONTEXT(ctx);
752 GLuint stipple[32], i;
753 drm_r128_stipple_t stippleRec;
754
755 for (i = 0; i < 32; i++) {
756 stipple[31 - i] = ((mask[i*4+0] << 24) |
757 (mask[i*4+1] << 16) |
758 (mask[i*4+2] << 8) |
759 (mask[i*4+3]));
760 }
761
762 FLUSH_BATCH( rmesa );
763 LOCK_HARDWARE( rmesa );
764
765 stippleRec.mask = stipple;
766 drmCommandWrite( rmesa->driFd, DRM_R128_STIPPLE,
767 &stippleRec, sizeof(stippleRec) );
768
769 UNLOCK_HARDWARE( rmesa );
770
771 rmesa->new_state |= R128_NEW_CONTEXT;
772 rmesa->dirty |= R128_UPLOAD_CONTEXT;
773 }
774
775
776 /* =============================================================
777 * Render mode
778 */
779
780 static void r128DDRenderMode( GLcontext *ctx, GLenum mode )
781 {
782 r128ContextPtr rmesa = R128_CONTEXT(ctx);
783 FALLBACK( rmesa, R128_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );
784 }
785
786
787
788 /* =============================================================
789 * State enable/disable
790 */
791
792 static void r128DDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
793 {
794 r128ContextPtr rmesa = R128_CONTEXT(ctx);
795
796 if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
797 fprintf( stderr, "%s( %s = %s )\n",
798 __FUNCTION__, _mesa_lookup_enum_by_nr( cap ),
799 state ? "GL_TRUE" : "GL_FALSE" );
800 }
801
802 switch ( cap ) {
803 case GL_ALPHA_TEST:
804 FLUSH_BATCH( rmesa );
805 rmesa->new_state |= R128_NEW_ALPHA;
806 break;
807
808 case GL_BLEND:
809 FLUSH_BATCH( rmesa );
810 rmesa->new_state |= R128_NEW_ALPHA;
811
812 /* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
813 */
814 FALLBACK( rmesa, R128_FALLBACK_LOGICOP,
815 (ctx->Color.ColorLogicOpEnabled &&
816 ctx->Color.LogicOp != GL_COPY));
817 break;
818
819 case GL_CULL_FACE:
820 FLUSH_BATCH( rmesa );
821 rmesa->new_state |= R128_NEW_CULL;
822 break;
823
824 case GL_DEPTH_TEST:
825 FLUSH_BATCH( rmesa );
826 rmesa->new_state |= R128_NEW_DEPTH;
827 break;
828
829 case GL_DITHER:
830 do {
831 GLuint t = rmesa->setup.tex_cntl_c;
832 FLUSH_BATCH( rmesa );
833
834 if ( ctx->Color.DitherFlag ) {
835 t |= R128_DITHER_ENABLE;
836 } else {
837 t &= ~R128_DITHER_ENABLE;
838 }
839
840 if ( rmesa->setup.tex_cntl_c != t ) {
841 rmesa->setup.tex_cntl_c = t;
842 rmesa->dirty |= R128_UPLOAD_CONTEXT;
843 }
844 } while (0);
845 break;
846
847 case GL_FOG:
848 FLUSH_BATCH( rmesa );
849 rmesa->new_state |= R128_NEW_FOG;
850 break;
851
852 case GL_COLOR_LOGIC_OP:
853 FLUSH_BATCH( rmesa );
854 FALLBACK( rmesa, R128_FALLBACK_LOGICOP,
855 state && ctx->Color.LogicOp != GL_COPY );
856 break;
857
858 case GL_LIGHTING:
859 updateSpecularLighting(ctx);
860 break;
861
862 case GL_SCISSOR_TEST:
863 FLUSH_BATCH( rmesa );
864 rmesa->scissor = state;
865 rmesa->new_state |= R128_NEW_CLIP;
866 break;
867
868 case GL_STENCIL_TEST:
869 FLUSH_BATCH( rmesa );
870 FALLBACK( rmesa, R128_FALLBACK_STENCIL, state );
871 break;
872
873 case GL_TEXTURE_1D:
874 case GL_TEXTURE_2D:
875 case GL_TEXTURE_3D:
876 FLUSH_BATCH( rmesa );
877 break;
878
879 case GL_POLYGON_STIPPLE:
880 if ( rmesa->render_primitive == GL_TRIANGLES ) {
881 FLUSH_BATCH( rmesa );
882 rmesa->setup.dp_gui_master_cntl_c &= ~R128_GMC_BRUSH_NONE;
883 if ( state ) {
884 rmesa->setup.dp_gui_master_cntl_c |=
885 R128_GMC_BRUSH_32x32_MONO_FG_LA;
886 } else {
887 rmesa->setup.dp_gui_master_cntl_c |=
888 R128_GMC_BRUSH_SOLID_COLOR;
889 }
890 rmesa->new_state |= R128_NEW_CONTEXT;
891 rmesa->dirty |= R128_UPLOAD_CONTEXT;
892 }
893 break;
894
895 default:
896 return;
897 }
898 }
899
900
901 /* =============================================================
902 * State initialization, management
903 */
904
905 static void r128DDPrintDirty( const char *msg, GLuint state )
906 {
907 fprintf( stderr,
908 "%s: (0x%x) %s%s%s%s%s%s%s%s%s\n",
909 msg,
910 state,
911 (state & R128_UPLOAD_CORE) ? "core, " : "",
912 (state & R128_UPLOAD_CONTEXT) ? "context, " : "",
913 (state & R128_UPLOAD_SETUP) ? "setup, " : "",
914 (state & R128_UPLOAD_TEX0) ? "tex0, " : "",
915 (state & R128_UPLOAD_TEX1) ? "tex1, " : "",
916 (state & R128_UPLOAD_MASKS) ? "masks, " : "",
917 (state & R128_UPLOAD_WINDOW) ? "window, " : "",
918 (state & R128_UPLOAD_CLIPRECTS) ? "cliprects, " : "",
919 (state & R128_REQUIRE_QUIESCENCE) ? "quiescence, " : "" );
920 }
921
922 /*
923 * Load the current context's state into the hardware.
924 *
925 * NOTE: Be VERY careful about ensuring the context state is marked for
926 * upload, the only place it shouldn't be uploaded is when the setup
927 * state has changed in ReducedPrimitiveChange as this comes right after
928 * a state update.
929 *
930 * Blits of any type should always upload the context and masks after
931 * they are done.
932 */
933 void r128EmitHwStateLocked( r128ContextPtr rmesa )
934 {
935 drm_r128_sarea_t *sarea = rmesa->sarea;
936 drm_r128_context_regs_t *regs = &(rmesa->setup);
937 const r128TexObjPtr t0 = rmesa->CurrentTexObj[0];
938 const r128TexObjPtr t1 = rmesa->CurrentTexObj[1];
939
940 if ( R128_DEBUG & DEBUG_VERBOSE_MSG ) {
941 r128DDPrintDirty( "r128EmitHwStateLocked", rmesa->dirty );
942 }
943
944 if ( rmesa->dirty & (R128_UPLOAD_CONTEXT |
945 R128_UPLOAD_SETUP |
946 R128_UPLOAD_MASKS |
947 R128_UPLOAD_WINDOW |
948 R128_UPLOAD_CORE) ) {
949 memcpy( &sarea->context_state, regs, sizeof(sarea->context_state) );
950 }
951
952 if ( (rmesa->dirty & R128_UPLOAD_TEX0) && t0 ) {
953 drm_r128_texture_regs_t *tex = &sarea->tex_state[0];
954
955 tex->tex_cntl = t0->setup.tex_cntl;
956 tex->tex_combine_cntl = rmesa->tex_combine[0];
957 tex->tex_size_pitch = t0->setup.tex_size_pitch;
958 memcpy( &tex->tex_offset[0], &t0->setup.tex_offset[0],
959 sizeof(tex->tex_offset ) );
960 tex->tex_border_color = t0->setup.tex_border_color;
961 }
962
963 if ( (rmesa->dirty & R128_UPLOAD_TEX1) && t1 ) {
964 drm_r128_texture_regs_t *tex = &sarea->tex_state[1];
965
966 tex->tex_cntl = t1->setup.tex_cntl;
967 tex->tex_combine_cntl = rmesa->tex_combine[1];
968 tex->tex_size_pitch = t1->setup.tex_size_pitch;
969 memcpy( &tex->tex_offset[0], &t1->setup.tex_offset[0],
970 sizeof(tex->tex_offset ) );
971 tex->tex_border_color = t1->setup.tex_border_color;
972 }
973
974 sarea->vertsize = rmesa->vertex_size;
975 sarea->vc_format = rmesa->vertex_format;
976
977 /* Turn off the texture cache flushing */
978 rmesa->setup.tex_cntl_c &= ~R128_TEX_CACHE_FLUSH;
979
980 sarea->dirty |= rmesa->dirty;
981 rmesa->dirty &= R128_UPLOAD_CLIPRECTS;
982 }
983
984 static void r128DDPrintState( const char *msg, GLuint flags )
985 {
986 fprintf( stderr,
987 "%s: (0x%x) %s%s%s%s%s%s%s%s\n",
988 msg,
989 flags,
990 (flags & R128_NEW_CONTEXT) ? "context, " : "",
991 (flags & R128_NEW_ALPHA) ? "alpha, " : "",
992 (flags & R128_NEW_DEPTH) ? "depth, " : "",
993 (flags & R128_NEW_FOG) ? "fog, " : "",
994 (flags & R128_NEW_CLIP) ? "clip, " : "",
995 (flags & R128_NEW_CULL) ? "cull, " : "",
996 (flags & R128_NEW_MASKS) ? "masks, " : "",
997 (flags & R128_NEW_WINDOW) ? "window, " : "" );
998 }
999
1000 void r128DDUpdateHWState( GLcontext *ctx )
1001 {
1002 r128ContextPtr rmesa = R128_CONTEXT(ctx);
1003 int new_state = rmesa->new_state;
1004
1005 if ( new_state || rmesa->NewGLState & _NEW_TEXTURE )
1006 {
1007 FLUSH_BATCH( rmesa );
1008
1009 rmesa->new_state = 0;
1010
1011 if ( R128_DEBUG & DEBUG_VERBOSE_MSG )
1012 r128DDPrintState( "r128UpdateHwState", new_state );
1013
1014 /* Update the various parts of the context's state.
1015 */
1016 if ( new_state & R128_NEW_ALPHA )
1017 r128UpdateAlphaMode( ctx );
1018
1019 if ( new_state & R128_NEW_DEPTH )
1020 r128UpdateZMode( ctx );
1021
1022 if ( new_state & R128_NEW_FOG )
1023 r128UpdateFogAttrib( ctx );
1024
1025 if ( new_state & R128_NEW_CLIP )
1026 r128UpdateClipping( ctx );
1027
1028 if ( new_state & R128_NEW_CULL )
1029 r128UpdateCull( ctx );
1030
1031 if ( new_state & R128_NEW_MASKS )
1032 r128UpdateMasks( ctx );
1033
1034 if ( new_state & R128_NEW_WINDOW )
1035 r128UpdateWindow( ctx );
1036
1037 if ( rmesa->NewGLState & _NEW_TEXTURE ) {
1038 r128UpdateTextureState( ctx );
1039 }
1040 }
1041 }
1042
1043
1044 static void r128DDInvalidateState( GLcontext *ctx, GLuint new_state )
1045 {
1046 _swrast_InvalidateState( ctx, new_state );
1047 _swsetup_InvalidateState( ctx, new_state );
1048 _ac_InvalidateState( ctx, new_state );
1049 _tnl_InvalidateState( ctx, new_state );
1050 R128_CONTEXT(ctx)->NewGLState |= new_state;
1051 }
1052
1053
1054
1055 /* Initialize the context's hardware state.
1056 */
1057 void r128DDInitState( r128ContextPtr rmesa )
1058 {
1059 int dst_bpp, depth_bpp;
1060
1061 switch ( rmesa->r128Screen->cpp ) {
1062 case 2:
1063 dst_bpp = R128_GMC_DST_16BPP;
1064 break;
1065 case 4:
1066 dst_bpp = R128_GMC_DST_32BPP;
1067 break;
1068 default:
1069 fprintf( stderr, "Error: Unsupported pixel depth... exiting\n" );
1070 exit( -1 );
1071 }
1072
1073 rmesa->ClearColor = 0x00000000;
1074
1075 switch ( rmesa->glCtx->Visual.depthBits ) {
1076 case 16:
1077 rmesa->ClearDepth = 0x0000ffff;
1078 depth_bpp = R128_Z_PIX_WIDTH_16;
1079 rmesa->depth_scale = 1.0 / (GLfloat)0xffff;
1080 break;
1081 case 24:
1082 rmesa->ClearDepth = 0x00ffffff;
1083 depth_bpp = R128_Z_PIX_WIDTH_24;
1084 rmesa->depth_scale = 1.0 / (GLfloat)0xffffff;
1085 break;
1086 default:
1087 fprintf( stderr, "Error: Unsupported depth %d... exiting\n",
1088 rmesa->glCtx->Visual.depthBits );
1089 exit( -1 );
1090 }
1091
1092 rmesa->Fallback = 0;
1093
1094 if ( rmesa->glCtx->Visual.doubleBufferMode && rmesa->sarea->pfCurrentPage == 0 ) {
1095 rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->backOffset;
1096 rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->backPitch;
1097 } else {
1098 rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->frontOffset;
1099 rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->frontPitch;
1100 }
1101
1102 /* Harware state:
1103 */
1104 rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
1105 (rmesa->drawOffset >> 5));
1106
1107 rmesa->setup.dp_gui_master_cntl_c = (R128_GMC_DST_PITCH_OFFSET_CNTL |
1108 R128_GMC_DST_CLIPPING |
1109 R128_GMC_BRUSH_SOLID_COLOR |
1110 dst_bpp |
1111 R128_GMC_SRC_DATATYPE_COLOR |
1112 R128_GMC_BYTE_MSB_TO_LSB |
1113 R128_GMC_CONVERSION_TEMP_6500 |
1114 R128_ROP3_S |
1115 R128_DP_SRC_SOURCE_MEMORY |
1116 R128_GMC_3D_FCN_EN |
1117 R128_GMC_CLR_CMP_CNTL_DIS |
1118 R128_GMC_AUX_CLIP_DIS |
1119 R128_GMC_WR_MSK_DIS);
1120
1121 rmesa->setup.sc_top_left_c = 0x00000000;
1122 rmesa->setup.sc_bottom_right_c = 0x1fff1fff;
1123
1124 rmesa->setup.z_offset_c = rmesa->r128Screen->depthOffset;
1125 rmesa->setup.z_pitch_c = ((rmesa->r128Screen->depthPitch >> 3) |
1126 R128_Z_TILE);
1127
1128 rmesa->setup.z_sten_cntl_c = (depth_bpp |
1129 R128_Z_TEST_LESS |
1130 R128_STENCIL_TEST_ALWAYS |
1131 R128_STENCIL_S_FAIL_KEEP |
1132 R128_STENCIL_ZPASS_KEEP |
1133 R128_STENCIL_ZFAIL_KEEP);
1134
1135 rmesa->setup.tex_cntl_c = (R128_Z_WRITE_ENABLE |
1136 R128_SHADE_ENABLE |
1137 R128_DITHER_ENABLE |
1138 R128_ALPHA_IN_TEX_COMPLETE_A |
1139 R128_LIGHT_DIS |
1140 R128_ALPHA_LIGHT_DIS |
1141 R128_TEX_CACHE_FLUSH |
1142 (0x3f << R128_LOD_BIAS_SHIFT));
1143
1144 rmesa->setup.misc_3d_state_cntl_reg = (R128_MISC_SCALE_3D_TEXMAP_SHADE |
1145 R128_MISC_SCALE_PIX_REPLICATE |
1146 R128_ALPHA_COMB_ADD_CLAMP |
1147 R128_FOG_VERTEX |
1148 (R128_ALPHA_BLEND_ONE << R128_ALPHA_BLEND_SRC_SHIFT) |
1149 (R128_ALPHA_BLEND_ZERO << R128_ALPHA_BLEND_DST_SHIFT) |
1150 R128_ALPHA_TEST_ALWAYS);
1151
1152 rmesa->setup.texture_clr_cmp_clr_c = 0x00000000;
1153 rmesa->setup.texture_clr_cmp_msk_c = 0xffffffff;
1154
1155 rmesa->setup.fog_color_c = 0x00000000;
1156
1157 rmesa->setup.pm4_vc_fpu_setup = (R128_FRONT_DIR_CCW |
1158 R128_BACKFACE_SOLID |
1159 R128_FRONTFACE_SOLID |
1160 R128_FPU_COLOR_GOURAUD |
1161 R128_FPU_SUB_PIX_4BITS |
1162 R128_FPU_MODE_3D |
1163 R128_TRAP_BITS_DISABLE |
1164 R128_XFACTOR_2 |
1165 R128_YFACTOR_2 |
1166 R128_FLAT_SHADE_VERTEX_OGL |
1167 R128_FPU_ROUND_TRUNCATE |
1168 R128_WM_SEL_8DW);
1169
1170 rmesa->setup.setup_cntl = (R128_COLOR_GOURAUD |
1171 R128_PRIM_TYPE_TRI |
1172 R128_TEXTURE_ST_MULT_W |
1173 R128_STARTING_VERTEX_1 |
1174 R128_ENDING_VERTEX_3 |
1175 R128_SU_POLY_LINE_NOT_LAST |
1176 R128_SUB_PIX_4BITS);
1177
1178 rmesa->setup.tex_size_pitch_c = 0x00000000;
1179 rmesa->setup.constant_color_c = 0x00ffffff;
1180
1181 rmesa->setup.dp_write_mask = 0xffffffff;
1182 rmesa->setup.sten_ref_mask_c = 0xffff0000;
1183 rmesa->setup.plane_3d_mask_c = 0xffffffff;
1184
1185 rmesa->setup.window_xy_offset = 0x00000000;
1186
1187 rmesa->setup.scale_3d_cntl = (R128_SCALE_DITHER_TABLE |
1188 R128_TEX_CACHE_SIZE_FULL |
1189 R128_DITHER_INIT_RESET |
1190 R128_SCALE_3D_TEXMAP_SHADE |
1191 R128_SCALE_PIX_REPLICATE |
1192 R128_ALPHA_COMB_ADD_CLAMP |
1193 R128_FOG_VERTEX |
1194 (R128_ALPHA_BLEND_ONE << R128_ALPHA_BLEND_SRC_SHIFT) |
1195 (R128_ALPHA_BLEND_ZERO << R128_ALPHA_BLEND_DST_SHIFT) |
1196 R128_ALPHA_TEST_ALWAYS |
1197 R128_COMPOSITE_SHADOW_CMP_EQUAL |
1198 R128_TEX_MAP_ALPHA_IN_TEXTURE |
1199 R128_TEX_CACHE_LINE_SIZE_4QW);
1200
1201 rmesa->new_state = R128_NEW_ALL;
1202 }
1203
1204 /* Initialize the driver's state functions.
1205 */
1206 void r128DDInitStateFuncs( GLcontext *ctx )
1207 {
1208 ctx->Driver.UpdateState = r128DDInvalidateState;
1209
1210 ctx->Driver.ClearIndex = NULL;
1211 ctx->Driver.ClearColor = r128DDClearColor;
1212 ctx->Driver.DrawBuffer = r128DDDrawBuffer;
1213 ctx->Driver.ReadBuffer = r128DDReadBuffer;
1214
1215 ctx->Driver.IndexMask = NULL;
1216 ctx->Driver.ColorMask = r128DDColorMask;
1217 ctx->Driver.AlphaFunc = r128DDAlphaFunc;
1218 ctx->Driver.BlendEquationSeparate = r128DDBlendEquationSeparate;
1219 ctx->Driver.BlendFuncSeparate = r128DDBlendFuncSeparate;
1220 ctx->Driver.ClearDepth = r128DDClearDepth;
1221 ctx->Driver.CullFace = r128DDCullFace;
1222 ctx->Driver.FrontFace = r128DDFrontFace;
1223 ctx->Driver.DepthFunc = r128DDDepthFunc;
1224 ctx->Driver.DepthMask = r128DDDepthMask;
1225 ctx->Driver.Enable = r128DDEnable;
1226 ctx->Driver.Fogfv = r128DDFogfv;
1227 ctx->Driver.Hint = NULL;
1228 ctx->Driver.Lightfv = NULL;
1229 ctx->Driver.LightModelfv = r128DDLightModelfv;
1230 ctx->Driver.LogicOpcode = r128DDLogicOpCode;
1231 ctx->Driver.PolygonMode = NULL;
1232 ctx->Driver.PolygonStipple = r128DDPolygonStipple;
1233 ctx->Driver.RenderMode = r128DDRenderMode;
1234 ctx->Driver.Scissor = r128DDScissor;
1235 ctx->Driver.ShadeModel = r128DDShadeModel;
1236 ctx->Driver.ClearStencil = NULL;
1237 ctx->Driver.StencilFunc = NULL;
1238 ctx->Driver.StencilMask = NULL;
1239 ctx->Driver.StencilOp = NULL;
1240
1241 ctx->Driver.DepthRange = r128DepthRange;
1242 ctx->Driver.Viewport = r128Viewport;
1243
1244 /* Pixel path fallbacks.
1245 */
1246 ctx->Driver.Accum = _swrast_Accum;
1247 ctx->Driver.Bitmap = _swrast_Bitmap;
1248 ctx->Driver.CopyPixels = _swrast_CopyPixels;
1249 ctx->Driver.DrawPixels = _swrast_DrawPixels;
1250 ctx->Driver.ReadPixels = _swrast_ReadPixels;
1251
1252 /* Swrast hooks for imaging extensions:
1253 */
1254 ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
1255 ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
1256 ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
1257 ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
1258 }