1 /**************************************************************************
3 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 on the rights to use, copy, modify, merge, publish, distribute, sub
11 license, and/or sell copies of the Software, and to permit persons to whom
12 the Software is furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Gareth Hughes <gareth@valinux.com>
31 * Kevin E. Martin <martin@valinux.com>
32 * Keith Whitwell <keith@tungstengraphics.com>
36 #include "r128_context.h"
37 #include "r128_state.h"
38 #include "r128_ioctl.h"
39 #include "r128_tris.h"
42 #include "main/context.h"
43 #include "main/enums.h"
44 #include "main/colormac.h"
45 #include "swrast/swrast.h"
48 #include "swrast_setup/swrast_setup.h"
50 #include "drirenderbuffer.h"
53 /* =============================================================
59 * Calculate the hardware blend factor setting. This same function is used
60 * for source and destination of both alpha and RGB.
63 * The hardware register value for the specified blend factor. This value
64 * will need to be shifted into the correct position for either source or
68 * Since the two cases where source and destination are handled differently
69 * are essentially error cases, they should never happen. Determine if these
70 * cases can be removed.
72 static int blend_factor( r128ContextPtr rmesa
, GLenum factor
, GLboolean is_src
)
78 func
= R128_ALPHA_BLEND_ZERO
;
81 func
= R128_ALPHA_BLEND_ONE
;
85 func
= R128_ALPHA_BLEND_SRCCOLOR
;
87 case GL_ONE_MINUS_SRC_COLOR
:
88 func
= R128_ALPHA_BLEND_INVSRCCOLOR
;
91 func
= R128_ALPHA_BLEND_SRCALPHA
;
93 case GL_ONE_MINUS_SRC_ALPHA
:
94 func
= R128_ALPHA_BLEND_INVSRCALPHA
;
96 case GL_SRC_ALPHA_SATURATE
:
97 func
= (is_src
) ? R128_ALPHA_BLEND_SAT
: R128_ALPHA_BLEND_ZERO
;
101 func
= R128_ALPHA_BLEND_DSTCOLOR
;
103 case GL_ONE_MINUS_DST_COLOR
:
104 func
= R128_ALPHA_BLEND_INVDSTCOLOR
;
107 func
= R128_ALPHA_BLEND_DSTALPHA
;
109 case GL_ONE_MINUS_DST_ALPHA
:
110 func
= R128_ALPHA_BLEND_INVDSTALPHA
;
113 case GL_CONSTANT_COLOR
:
114 case GL_ONE_MINUS_CONSTANT_COLOR
:
115 case GL_CONSTANT_ALPHA
:
116 case GL_ONE_MINUS_CONSTANT_ALPHA
:
118 FALLBACK( rmesa
, R128_FALLBACK_BLEND_FUNC
, GL_TRUE
);
119 func
= (is_src
) ? R128_ALPHA_BLEND_ONE
: R128_ALPHA_BLEND_ZERO
;
127 static void r128UpdateAlphaMode( GLcontext
*ctx
)
129 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
130 GLuint a
= rmesa
->setup
.misc_3d_state_cntl_reg
;
131 GLuint t
= rmesa
->setup
.tex_cntl_c
;
133 if ( ctx
->Color
.AlphaEnabled
) {
136 CLAMPED_FLOAT_TO_UBYTE(ref
, ctx
->Color
.AlphaRef
);
138 a
&= ~(R128_ALPHA_TEST_MASK
| R128_REF_ALPHA_MASK
);
140 switch ( ctx
->Color
.AlphaFunc
) {
142 a
|= R128_ALPHA_TEST_NEVER
;
145 a
|= R128_ALPHA_TEST_LESS
;
148 a
|= R128_ALPHA_TEST_LESSEQUAL
;
151 a
|= R128_ALPHA_TEST_EQUAL
;
154 a
|= R128_ALPHA_TEST_GREATEREQUAL
;
157 a
|= R128_ALPHA_TEST_GREATER
;
160 a
|= R128_ALPHA_TEST_NEQUAL
;
163 a
|= R128_ALPHA_TEST_ALWAYS
;
167 a
|= ref
& R128_REF_ALPHA_MASK
;
168 t
|= R128_ALPHA_TEST_ENABLE
;
170 t
&= ~R128_ALPHA_TEST_ENABLE
;
173 FALLBACK( rmesa
, R128_FALLBACK_BLEND_FUNC
, GL_FALSE
);
175 if ( ctx
->Color
.BlendEnabled
) {
176 a
&= ~((R128_ALPHA_BLEND_MASK
<< R128_ALPHA_BLEND_SRC_SHIFT
) |
177 (R128_ALPHA_BLEND_MASK
<< R128_ALPHA_BLEND_DST_SHIFT
)
178 | R128_ALPHA_COMB_FCN_MASK
);
180 a
|= blend_factor( rmesa
, ctx
->Color
.BlendSrcRGB
, GL_TRUE
)
181 << R128_ALPHA_BLEND_SRC_SHIFT
;
182 a
|= blend_factor( rmesa
, ctx
->Color
.BlendDstRGB
, GL_FALSE
)
183 << R128_ALPHA_BLEND_DST_SHIFT
;
185 switch (ctx
->Color
.BlendEquationRGB
) {
187 a
|= R128_ALPHA_COMB_ADD_CLAMP
;
189 case GL_FUNC_SUBTRACT
:
190 a
|= R128_ALPHA_COMB_SUB_SRC_DST_CLAMP
;
193 FALLBACK( rmesa
, R128_FALLBACK_BLEND_EQ
, GL_TRUE
);
196 t
|= R128_ALPHA_ENABLE
;
198 t
&= ~R128_ALPHA_ENABLE
;
201 if ( rmesa
->setup
.misc_3d_state_cntl_reg
!= a
) {
202 rmesa
->setup
.misc_3d_state_cntl_reg
= a
;
203 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_MASKS
;
205 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
206 rmesa
->setup
.tex_cntl_c
= t
;
207 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_MASKS
;
211 static void r128DDAlphaFunc( GLcontext
*ctx
, GLenum func
, GLfloat ref
)
213 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
215 FLUSH_BATCH( rmesa
);
216 rmesa
->new_state
|= R128_NEW_ALPHA
;
219 static void r128DDBlendEquationSeparate( GLcontext
*ctx
,
220 GLenum modeRGB
, GLenum modeA
)
222 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
224 assert( modeRGB
== modeA
);
225 FLUSH_BATCH( rmesa
);
227 /* BlendEquation sets ColorLogicOpEnabled in an unexpected
230 FALLBACK( R128_CONTEXT(ctx
), R128_FALLBACK_LOGICOP
,
231 (ctx
->Color
.ColorLogicOpEnabled
&&
232 ctx
->Color
.LogicOp
!= GL_COPY
));
234 /* Can only do blend addition, not min, max, subtract, etc. */
235 FALLBACK( R128_CONTEXT(ctx
), R128_FALLBACK_BLEND_EQ
,
236 (modeRGB
!= GL_FUNC_ADD
) && (modeRGB
!= GL_FUNC_SUBTRACT
));
238 rmesa
->new_state
|= R128_NEW_ALPHA
;
241 static void r128DDBlendFuncSeparate( GLcontext
*ctx
,
242 GLenum sfactorRGB
, GLenum dfactorRGB
,
243 GLenum sfactorA
, GLenum dfactorA
)
245 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
247 FLUSH_BATCH( rmesa
);
248 rmesa
->new_state
|= R128_NEW_ALPHA
;
251 /* =============================================================
256 r128DDStencilFuncSeparate( GLcontext
*ctx
, GLenum face
, GLenum func
,
257 GLint ref
, GLuint mask
)
259 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
260 GLuint refmask
= (((ctx
->Stencil
.Ref
[0] & 0xff) << 0) |
261 ((ctx
->Stencil
.ValueMask
[0] & 0xff) << 16) |
262 ((ctx
->Stencil
.WriteMask
[0] & 0xff) << 24));
263 GLuint z
= rmesa
->setup
.z_sten_cntl_c
;
265 z
&= ~R128_STENCIL_TEST_MASK
;
266 switch ( ctx
->Stencil
.Function
[0] ) {
268 z
|= R128_STENCIL_TEST_NEVER
;
271 z
|= R128_STENCIL_TEST_LESS
;
274 z
|= R128_STENCIL_TEST_EQUAL
;
277 z
|= R128_STENCIL_TEST_LESSEQUAL
;
280 z
|= R128_STENCIL_TEST_GREATER
;
283 z
|= R128_STENCIL_TEST_NEQUAL
;
286 z
|= R128_STENCIL_TEST_GREATEREQUAL
;
289 z
|= R128_STENCIL_TEST_ALWAYS
;
293 if ( rmesa
->setup
.sten_ref_mask_c
!= refmask
) {
294 rmesa
->setup
.sten_ref_mask_c
= refmask
;
295 rmesa
->dirty
|= R128_UPLOAD_MASKS
;
297 if ( rmesa
->setup
.z_sten_cntl_c
!= z
) {
298 rmesa
->setup
.z_sten_cntl_c
= z
;
299 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
304 r128DDStencilMaskSeparate( GLcontext
*ctx
, GLenum face
, GLuint mask
)
306 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
307 GLuint refmask
= (((ctx
->Stencil
.Ref
[0] & 0xff) << 0) |
308 ((ctx
->Stencil
.ValueMask
[0] & 0xff) << 16) |
309 ((ctx
->Stencil
.WriteMask
[0] & 0xff) << 24));
311 if ( rmesa
->setup
.sten_ref_mask_c
!= refmask
) {
312 rmesa
->setup
.sten_ref_mask_c
= refmask
;
313 rmesa
->dirty
|= R128_UPLOAD_MASKS
;
317 static void r128DDStencilOpSeparate( GLcontext
*ctx
, GLenum face
, GLenum fail
,
318 GLenum zfail
, GLenum zpass
)
320 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
321 GLuint z
= rmesa
->setup
.z_sten_cntl_c
;
323 if (!( ctx
->Visual
.stencilBits
> 0 && ctx
->Visual
.depthBits
== 24 ))
326 z
&= ~(R128_STENCIL_S_FAIL_MASK
| R128_STENCIL_ZPASS_MASK
|
327 R128_STENCIL_ZFAIL_MASK
);
329 switch ( ctx
->Stencil
.FailFunc
[0] ) {
331 z
|= R128_STENCIL_S_FAIL_KEEP
;
334 z
|= R128_STENCIL_S_FAIL_ZERO
;
337 z
|= R128_STENCIL_S_FAIL_REPLACE
;
340 z
|= R128_STENCIL_S_FAIL_INC
;
343 z
|= R128_STENCIL_S_FAIL_DEC
;
346 z
|= R128_STENCIL_S_FAIL_INV
;
349 z
|= R128_STENCIL_S_FAIL_INC_WRAP
;
352 z
|= R128_STENCIL_S_FAIL_DEC_WRAP
;
356 switch ( ctx
->Stencil
.ZFailFunc
[0] ) {
358 z
|= R128_STENCIL_ZFAIL_KEEP
;
361 z
|= R128_STENCIL_ZFAIL_ZERO
;
364 z
|= R128_STENCIL_ZFAIL_REPLACE
;
367 z
|= R128_STENCIL_ZFAIL_INC
;
370 z
|= R128_STENCIL_ZFAIL_DEC
;
373 z
|= R128_STENCIL_ZFAIL_INV
;
376 z
|= R128_STENCIL_ZFAIL_INC_WRAP
;
379 z
|= R128_STENCIL_ZFAIL_DEC_WRAP
;
383 switch ( ctx
->Stencil
.ZPassFunc
[0] ) {
385 z
|= R128_STENCIL_ZPASS_KEEP
;
388 z
|= R128_STENCIL_ZPASS_ZERO
;
391 z
|= R128_STENCIL_ZPASS_REPLACE
;
394 z
|= R128_STENCIL_ZPASS_INC
;
397 z
|= R128_STENCIL_ZPASS_DEC
;
400 z
|= R128_STENCIL_ZPASS_INV
;
403 z
|= R128_STENCIL_ZPASS_INC_WRAP
;
406 z
|= R128_STENCIL_ZPASS_DEC_WRAP
;
410 if ( rmesa
->setup
.z_sten_cntl_c
!= z
) {
411 rmesa
->setup
.z_sten_cntl_c
= z
;
412 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
416 static void r128DDClearStencil( GLcontext
*ctx
, GLint s
)
418 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
420 if (ctx
->Visual
.stencilBits
> 0 && ctx
->Visual
.depthBits
== 24) {
421 rmesa
->ClearDepth
&= 0x00ffffff;
422 rmesa
->ClearDepth
|= ctx
->Stencil
.Clear
<< 24;
426 /* =============================================================
430 static void r128UpdateZMode( GLcontext
*ctx
)
432 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
433 GLuint z
= rmesa
->setup
.z_sten_cntl_c
;
434 GLuint t
= rmesa
->setup
.tex_cntl_c
;
436 if ( ctx
->Depth
.Test
) {
437 z
&= ~R128_Z_TEST_MASK
;
439 switch ( ctx
->Depth
.Func
) {
441 z
|= R128_Z_TEST_NEVER
;
444 z
|= R128_Z_TEST_ALWAYS
;
447 z
|= R128_Z_TEST_LESS
;
450 z
|= R128_Z_TEST_LESSEQUAL
;
453 z
|= R128_Z_TEST_EQUAL
;
456 z
|= R128_Z_TEST_GREATEREQUAL
;
459 z
|= R128_Z_TEST_GREATER
;
462 z
|= R128_Z_TEST_NEQUAL
;
471 if ( ctx
->Depth
.Mask
) {
472 t
|= R128_Z_WRITE_ENABLE
;
474 t
&= ~R128_Z_WRITE_ENABLE
;
477 if ( rmesa
->setup
.z_sten_cntl_c
!= z
) {
478 rmesa
->setup
.z_sten_cntl_c
= z
;
479 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
481 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
482 rmesa
->setup
.tex_cntl_c
= t
;
483 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
487 static void r128DDDepthFunc( GLcontext
*ctx
, GLenum func
)
489 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
491 FLUSH_BATCH( rmesa
);
492 rmesa
->new_state
|= R128_NEW_DEPTH
;
495 static void r128DDDepthMask( GLcontext
*ctx
, GLboolean flag
)
497 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
499 FLUSH_BATCH( rmesa
);
500 rmesa
->new_state
|= R128_NEW_DEPTH
;
503 static void r128DDClearDepth( GLcontext
*ctx
, GLclampd d
)
505 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
507 switch ( rmesa
->setup
.z_sten_cntl_c
& R128_Z_PIX_WIDTH_MASK
) {
508 case R128_Z_PIX_WIDTH_16
:
509 rmesa
->ClearDepth
= d
* 0x0000ffff;
511 case R128_Z_PIX_WIDTH_24
:
512 rmesa
->ClearDepth
= d
* 0x00ffffff;
513 rmesa
->ClearDepth
|= ctx
->Stencil
.Clear
<< 24;
515 case R128_Z_PIX_WIDTH_32
:
516 rmesa
->ClearDepth
= d
* 0xffffffff;
522 /* =============================================================
526 static void r128UpdateFogAttrib( GLcontext
*ctx
)
528 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
529 GLuint t
= rmesa
->setup
.tex_cntl_c
;
533 if ( ctx
->Fog
.Enabled
) {
534 t
|= R128_FOG_ENABLE
;
536 t
&= ~R128_FOG_ENABLE
;
539 c
[0] = FLOAT_TO_UBYTE( ctx
->Fog
.Color
[0] );
540 c
[1] = FLOAT_TO_UBYTE( ctx
->Fog
.Color
[1] );
541 c
[2] = FLOAT_TO_UBYTE( ctx
->Fog
.Color
[2] );
543 col
= r128PackColor( 4, c
[0], c
[1], c
[2], 0 );
545 if ( rmesa
->setup
.fog_color_c
!= col
) {
546 rmesa
->setup
.fog_color_c
= col
;
547 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
549 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
550 rmesa
->setup
.tex_cntl_c
= t
;
551 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
555 static void r128DDFogfv( GLcontext
*ctx
, GLenum pname
, const GLfloat
*param
)
557 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
559 FLUSH_BATCH( rmesa
);
560 rmesa
->new_state
|= R128_NEW_FOG
;
564 /* =============================================================
568 static void r128UpdateClipping( GLcontext
*ctx
)
570 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
572 if ( rmesa
->driDrawable
) {
573 __DRIdrawable
*drawable
= rmesa
->driDrawable
;
576 int x2
= drawable
->w
- 1;
577 int y2
= drawable
->h
- 1;
579 if ( ctx
->Scissor
.Enabled
) {
580 if ( ctx
->Scissor
.X
> x1
) {
583 if ( drawable
->h
- ctx
->Scissor
.Y
- ctx
->Scissor
.Height
> y1
) {
584 y1
= drawable
->h
- ctx
->Scissor
.Y
- ctx
->Scissor
.Height
;
586 if ( ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1 < x2
) {
587 x2
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1;
589 if ( drawable
->h
- ctx
->Scissor
.Y
- 1 < y2
) {
590 y2
= drawable
->h
- ctx
->Scissor
.Y
- 1;
599 /* Clamp values to screen to avoid wrapping problems */
602 else if ( x1
>= rmesa
->driScreen
->fbWidth
)
603 x1
= rmesa
->driScreen
->fbWidth
- 1;
606 else if ( y1
>= rmesa
->driScreen
->fbHeight
)
607 y1
= rmesa
->driScreen
->fbHeight
- 1;
610 else if ( x2
>= rmesa
->driScreen
->fbWidth
)
611 x2
= rmesa
->driScreen
->fbWidth
- 1;
614 else if ( y2
>= rmesa
->driScreen
->fbHeight
)
615 y2
= rmesa
->driScreen
->fbHeight
- 1;
617 rmesa
->setup
.sc_top_left_c
= (((y1
& 0x3FFF) << 16) | (x1
& 0x3FFF));
618 rmesa
->setup
.sc_bottom_right_c
= (((y2
& 0x3FFF) << 16) | (x2
& 0x3FFF));
620 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
624 static void r128DDScissor( GLcontext
*ctx
,
625 GLint x
, GLint y
, GLsizei w
, GLsizei h
)
627 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
629 FLUSH_BATCH( rmesa
);
630 rmesa
->new_state
|= R128_NEW_CLIP
;
634 /* =============================================================
638 static void r128UpdateCull( GLcontext
*ctx
)
640 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
641 GLuint f
= rmesa
->setup
.pm4_vc_fpu_setup
;
643 f
&= ~R128_FRONT_DIR_MASK
;
645 switch ( ctx
->Polygon
.FrontFace
) {
647 f
|= R128_FRONT_DIR_CW
;
650 f
|= R128_FRONT_DIR_CCW
;
654 f
|= R128_BACKFACE_SOLID
| R128_FRONTFACE_SOLID
;
656 if ( ctx
->Polygon
.CullFlag
) {
657 switch ( ctx
->Polygon
.CullFaceMode
) {
659 f
&= ~R128_FRONTFACE_SOLID
;
662 f
&= ~R128_BACKFACE_SOLID
;
664 case GL_FRONT_AND_BACK
:
665 f
&= ~(R128_BACKFACE_SOLID
|
666 R128_FRONTFACE_SOLID
);
671 if ( 1 || rmesa
->setup
.pm4_vc_fpu_setup
!= f
) {
672 rmesa
->setup
.pm4_vc_fpu_setup
= f
;
673 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_SETUP
;
677 static void r128DDCullFace( GLcontext
*ctx
, GLenum mode
)
679 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
681 FLUSH_BATCH( rmesa
);
682 rmesa
->new_state
|= R128_NEW_CULL
;
685 static void r128DDFrontFace( GLcontext
*ctx
, GLenum mode
)
687 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
689 FLUSH_BATCH( rmesa
);
690 rmesa
->new_state
|= R128_NEW_CULL
;
694 /* =============================================================
698 static void r128UpdateMasks( GLcontext
*ctx
)
700 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
702 GLuint mask
= r128PackColor( rmesa
->r128Screen
->cpp
,
703 ctx
->Color
.ColorMask
[0][RCOMP
],
704 ctx
->Color
.ColorMask
[0][GCOMP
],
705 ctx
->Color
.ColorMask
[0][BCOMP
],
706 ctx
->Color
.ColorMask
[0][ACOMP
] );
708 if ( rmesa
->setup
.plane_3d_mask_c
!= mask
) {
709 rmesa
->setup
.plane_3d_mask_c
= mask
;
710 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_MASKS
;
714 static void r128DDColorMask( GLcontext
*ctx
,
715 GLboolean r
, GLboolean g
,
716 GLboolean b
, GLboolean a
)
718 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
720 FLUSH_BATCH( rmesa
);
721 rmesa
->new_state
|= R128_NEW_MASKS
;
725 /* =============================================================
726 * Rendering attributes
728 * We really don't want to recalculate all this every time we bind a
729 * texture. These things shouldn't change all that often, so it makes
730 * sense to break them out of the core texture state update routines.
733 static void updateSpecularLighting( GLcontext
*ctx
)
735 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
736 GLuint t
= rmesa
->setup
.tex_cntl_c
;
738 if ( NEED_SECONDARY_COLOR( ctx
) ) {
739 if (ctx
->Light
.ShadeModel
== GL_FLAT
) {
740 /* R128 can't do flat-shaded separate specular */
741 t
&= ~R128_SPEC_LIGHT_ENABLE
;
742 FALLBACK( rmesa
, R128_FALLBACK_SEP_SPECULAR
, GL_TRUE
);
745 t
|= R128_SPEC_LIGHT_ENABLE
;
746 FALLBACK( rmesa
, R128_FALLBACK_SEP_SPECULAR
, GL_FALSE
);
750 t
&= ~R128_SPEC_LIGHT_ENABLE
;
751 FALLBACK( rmesa
, R128_FALLBACK_SEP_SPECULAR
, GL_FALSE
);
754 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
755 rmesa
->setup
.tex_cntl_c
= t
;
756 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
757 rmesa
->dirty
|= R128_UPLOAD_SETUP
;
758 rmesa
->new_state
|= R128_NEW_CONTEXT
;
763 static void r128DDLightModelfv( GLcontext
*ctx
, GLenum pname
,
764 const GLfloat
*param
)
766 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
768 if ( pname
== GL_LIGHT_MODEL_COLOR_CONTROL
) {
769 FLUSH_BATCH( rmesa
);
770 updateSpecularLighting(ctx
);
773 if ( pname
== GL_LIGHT_MODEL_TWO_SIDE
) {
774 FLUSH_BATCH( rmesa
);
775 r128ChooseRenderState( ctx
);
779 static void r128DDShadeModel( GLcontext
*ctx
, GLenum mode
)
781 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
782 GLuint s
= rmesa
->setup
.pm4_vc_fpu_setup
;
784 s
&= ~R128_FPU_COLOR_MASK
;
788 s
|= R128_FPU_COLOR_FLAT
;
791 s
|= R128_FPU_COLOR_GOURAUD
;
797 updateSpecularLighting(ctx
);
799 if ( rmesa
->setup
.pm4_vc_fpu_setup
!= s
) {
800 FLUSH_BATCH( rmesa
);
801 rmesa
->setup
.pm4_vc_fpu_setup
= s
;
803 rmesa
->new_state
|= R128_NEW_CONTEXT
;
804 rmesa
->dirty
|= R128_UPLOAD_SETUP
;
809 /* =============================================================
813 static void r128UpdateWindow( GLcontext
*ctx
)
815 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
816 int x
= rmesa
->driDrawable
->x
;
817 int y
= rmesa
->driDrawable
->y
;
818 struct gl_renderbuffer
*rb
= ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
819 driRenderbuffer
*drb
= (driRenderbuffer
*) rb
;
821 rmesa
->setup
.window_xy_offset
= (((y
& 0xFFF) << R128_WINDOW_Y_SHIFT
) |
822 ((x
& 0xFFF) << R128_WINDOW_X_SHIFT
));
824 rmesa
->setup
.dst_pitch_offset_c
= (((drb
->flippedPitch
/8) << 21) |
825 (drb
->flippedOffset
>> 5));
828 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_WINDOW
;
832 /* =============================================================
836 static void r128CalcViewport( GLcontext
*ctx
)
838 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
839 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
840 GLfloat
*m
= rmesa
->hw_viewport
;
842 /* See also r128_translate_vertex.
844 m
[MAT_SX
] = v
[MAT_SX
];
845 m
[MAT_TX
] = v
[MAT_TX
] + SUBPIXEL_X
;
846 m
[MAT_SY
] = - v
[MAT_SY
];
847 m
[MAT_TY
] = - v
[MAT_TY
] + rmesa
->driDrawable
->h
+ SUBPIXEL_Y
;
848 m
[MAT_SZ
] = v
[MAT_SZ
] * rmesa
->depth_scale
;
849 m
[MAT_TZ
] = v
[MAT_TZ
] * rmesa
->depth_scale
;
852 static void r128Viewport( GLcontext
*ctx
,
854 GLsizei width
, GLsizei height
)
856 r128CalcViewport( ctx
);
859 static void r128DepthRange( GLcontext
*ctx
,
860 GLclampd nearval
, GLclampd farval
)
862 r128CalcViewport( ctx
);
866 /* =============================================================
870 static void r128DDClearColor( GLcontext
*ctx
,
871 const GLfloat color
[4] )
873 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
876 CLAMPED_FLOAT_TO_UBYTE(c
[0], color
[0]);
877 CLAMPED_FLOAT_TO_UBYTE(c
[1], color
[1]);
878 CLAMPED_FLOAT_TO_UBYTE(c
[2], color
[2]);
879 CLAMPED_FLOAT_TO_UBYTE(c
[3], color
[3]);
881 rmesa
->ClearColor
= r128PackColor( rmesa
->r128Screen
->cpp
,
882 c
[0], c
[1], c
[2], c
[3] );
885 static void r128DDLogicOpCode( GLcontext
*ctx
, GLenum opcode
)
887 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
889 if ( ctx
->Color
.ColorLogicOpEnabled
) {
890 FLUSH_BATCH( rmesa
);
892 FALLBACK( rmesa
, R128_FALLBACK_LOGICOP
, opcode
!= GL_COPY
);
896 static void r128DDDrawBuffer( GLcontext
*ctx
, GLenum mode
)
898 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
900 FLUSH_BATCH( rmesa
);
902 if (ctx
->DrawBuffer
->_NumColorDrawBuffers
!= 1) {
903 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
904 FALLBACK( rmesa
, R128_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
908 switch ( ctx
->DrawBuffer
->_ColorDrawBufferIndexes
[0] ) {
909 case BUFFER_FRONT_LEFT
:
910 case BUFFER_BACK_LEFT
:
911 FALLBACK( rmesa
, R128_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
914 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
915 FALLBACK( rmesa
, R128_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
920 rmesa
->new_state
|= R128_NEW_WINDOW
;
923 static void r128DDReadBuffer( GLcontext
*ctx
, GLenum mode
)
925 /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
929 /* =============================================================
933 static void r128DDPolygonStipple( GLcontext
*ctx
, const GLubyte
*mask
)
935 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
936 GLuint stipple
[32], i
;
937 drm_r128_stipple_t stippleRec
;
939 for (i
= 0; i
< 32; i
++) {
940 stipple
[31 - i
] = ((mask
[i
*4+0] << 24) |
941 (mask
[i
*4+1] << 16) |
946 FLUSH_BATCH( rmesa
);
947 LOCK_HARDWARE( rmesa
);
949 stippleRec
.mask
= stipple
;
950 drmCommandWrite( rmesa
->driFd
, DRM_R128_STIPPLE
,
951 &stippleRec
, sizeof(stippleRec
) );
953 UNLOCK_HARDWARE( rmesa
);
955 rmesa
->new_state
|= R128_NEW_CONTEXT
;
956 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
960 /* =============================================================
964 static void r128DDRenderMode( GLcontext
*ctx
, GLenum mode
)
966 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
967 FALLBACK( rmesa
, R128_FALLBACK_RENDER_MODE
, (mode
!= GL_RENDER
) );
972 /* =============================================================
973 * State enable/disable
976 static void r128DDEnable( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
978 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
980 if ( R128_DEBUG
& DEBUG_VERBOSE_API
) {
981 fprintf( stderr
, "%s( %s = %s )\n",
982 __FUNCTION__
, _mesa_lookup_enum_by_nr( cap
),
983 state
? "GL_TRUE" : "GL_FALSE" );
988 FLUSH_BATCH( rmesa
);
989 rmesa
->new_state
|= R128_NEW_ALPHA
;
993 FLUSH_BATCH( rmesa
);
994 rmesa
->new_state
|= R128_NEW_ALPHA
;
996 /* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
998 FALLBACK( rmesa
, R128_FALLBACK_LOGICOP
,
999 (ctx
->Color
.ColorLogicOpEnabled
&&
1000 ctx
->Color
.LogicOp
!= GL_COPY
));
1004 FLUSH_BATCH( rmesa
);
1005 rmesa
->new_state
|= R128_NEW_CULL
;
1009 FLUSH_BATCH( rmesa
);
1010 rmesa
->new_state
|= R128_NEW_DEPTH
;
1015 GLuint t
= rmesa
->setup
.tex_cntl_c
;
1016 FLUSH_BATCH( rmesa
);
1018 if ( ctx
->Color
.DitherFlag
) {
1019 t
|= R128_DITHER_ENABLE
;
1021 t
&= ~R128_DITHER_ENABLE
;
1024 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
1025 rmesa
->setup
.tex_cntl_c
= t
;
1026 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
1032 FLUSH_BATCH( rmesa
);
1033 rmesa
->new_state
|= R128_NEW_FOG
;
1036 case GL_COLOR_LOGIC_OP
:
1037 FLUSH_BATCH( rmesa
);
1038 FALLBACK( rmesa
, R128_FALLBACK_LOGICOP
,
1039 state
&& ctx
->Color
.LogicOp
!= GL_COPY
);
1043 case GL_COLOR_SUM_EXT
:
1044 updateSpecularLighting(ctx
);
1047 case GL_SCISSOR_TEST
:
1048 FLUSH_BATCH( rmesa
);
1049 rmesa
->scissor
= state
;
1050 rmesa
->new_state
|= R128_NEW_CLIP
;
1053 case GL_STENCIL_TEST
:
1054 FLUSH_BATCH( rmesa
);
1055 if ( ctx
->Visual
.stencilBits
> 0 && ctx
->Visual
.depthBits
== 24 ) {
1057 rmesa
->setup
.tex_cntl_c
|= R128_STENCIL_ENABLE
;
1058 /* Reset the fallback (if any) for bad stencil funcs */
1059 r128DDStencilOpSeparate( ctx
, 0, ctx
->Stencil
.FailFunc
[0],
1060 ctx
->Stencil
.ZFailFunc
[0],
1061 ctx
->Stencil
.ZPassFunc
[0] );
1063 rmesa
->setup
.tex_cntl_c
&= ~R128_STENCIL_ENABLE
;
1064 FALLBACK( rmesa
, R128_FALLBACK_STENCIL
, GL_FALSE
);
1066 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
1068 FALLBACK( rmesa
, R128_FALLBACK_STENCIL
, state
);
1075 FLUSH_BATCH( rmesa
);
1078 case GL_POLYGON_STIPPLE
:
1079 if ( rmesa
->render_primitive
== GL_TRIANGLES
) {
1080 FLUSH_BATCH( rmesa
);
1081 rmesa
->setup
.dp_gui_master_cntl_c
&= ~R128_GMC_BRUSH_NONE
;
1083 rmesa
->setup
.dp_gui_master_cntl_c
|=
1084 R128_GMC_BRUSH_32x32_MONO_FG_LA
;
1086 rmesa
->setup
.dp_gui_master_cntl_c
|=
1087 R128_GMC_BRUSH_SOLID_COLOR
;
1089 rmesa
->new_state
|= R128_NEW_CONTEXT
;
1090 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
1100 /* =============================================================
1101 * State initialization, management
1104 static void r128DDPrintDirty( const char *msg
, GLuint state
)
1107 "%s: (0x%x) %s%s%s%s%s%s%s%s%s\n",
1110 (state
& R128_UPLOAD_CORE
) ? "core, " : "",
1111 (state
& R128_UPLOAD_CONTEXT
) ? "context, " : "",
1112 (state
& R128_UPLOAD_SETUP
) ? "setup, " : "",
1113 (state
& R128_UPLOAD_TEX0
) ? "tex0, " : "",
1114 (state
& R128_UPLOAD_TEX1
) ? "tex1, " : "",
1115 (state
& R128_UPLOAD_MASKS
) ? "masks, " : "",
1116 (state
& R128_UPLOAD_WINDOW
) ? "window, " : "",
1117 (state
& R128_UPLOAD_CLIPRECTS
) ? "cliprects, " : "",
1118 (state
& R128_REQUIRE_QUIESCENCE
) ? "quiescence, " : "" );
1122 * Load the current context's state into the hardware.
1124 * NOTE: Be VERY careful about ensuring the context state is marked for
1125 * upload, the only place it shouldn't be uploaded is when the setup
1126 * state has changed in ReducedPrimitiveChange as this comes right after
1129 * Blits of any type should always upload the context and masks after
1132 void r128EmitHwStateLocked( r128ContextPtr rmesa
)
1134 drm_r128_sarea_t
*sarea
= rmesa
->sarea
;
1135 drm_r128_context_regs_t
*regs
= &(rmesa
->setup
);
1136 const r128TexObjPtr t0
= rmesa
->CurrentTexObj
[0];
1137 const r128TexObjPtr t1
= rmesa
->CurrentTexObj
[1];
1139 if ( R128_DEBUG
& DEBUG_VERBOSE_MSG
) {
1140 r128DDPrintDirty( "r128EmitHwStateLocked", rmesa
->dirty
);
1143 if ( rmesa
->dirty
& (R128_UPLOAD_CONTEXT
|
1146 R128_UPLOAD_WINDOW
|
1147 R128_UPLOAD_CORE
) ) {
1148 memcpy( &sarea
->context_state
, regs
, sizeof(sarea
->context_state
) );
1150 if( rmesa
->dirty
& R128_UPLOAD_CONTEXT
)
1152 /* One possible side-effect of uploading a new context is the
1153 * setting of the R128_GMC_AUX_CLIP_DIS bit, which causes all
1154 * auxilliary cliprects to be disabled. So the next command must
1155 * upload them again. */
1156 rmesa
->dirty
|= R128_UPLOAD_CLIPRECTS
;
1160 if ( (rmesa
->dirty
& R128_UPLOAD_TEX0
) && t0
) {
1161 drm_r128_texture_regs_t
*tex
= &sarea
->tex_state
[0];
1163 tex
->tex_cntl
= t0
->setup
.tex_cntl
;
1164 tex
->tex_combine_cntl
= rmesa
->tex_combine
[0];
1165 tex
->tex_size_pitch
= t0
->setup
.tex_size_pitch
;
1166 memcpy( &tex
->tex_offset
[0], &t0
->setup
.tex_offset
[0],
1167 sizeof(tex
->tex_offset
) );
1168 tex
->tex_border_color
= t0
->setup
.tex_border_color
;
1171 if ( (rmesa
->dirty
& R128_UPLOAD_TEX1
) && t1
) {
1172 drm_r128_texture_regs_t
*tex
= &sarea
->tex_state
[1];
1174 tex
->tex_cntl
= t1
->setup
.tex_cntl
;
1175 tex
->tex_combine_cntl
= rmesa
->tex_combine
[1];
1176 tex
->tex_size_pitch
= t1
->setup
.tex_size_pitch
;
1177 memcpy( &tex
->tex_offset
[0], &t1
->setup
.tex_offset
[0],
1178 sizeof(tex
->tex_offset
) );
1179 tex
->tex_border_color
= t1
->setup
.tex_border_color
;
1182 sarea
->vertsize
= rmesa
->vertex_size
;
1183 sarea
->vc_format
= rmesa
->vertex_format
;
1185 /* Turn off the texture cache flushing */
1186 rmesa
->setup
.tex_cntl_c
&= ~R128_TEX_CACHE_FLUSH
;
1188 sarea
->dirty
|= rmesa
->dirty
;
1189 rmesa
->dirty
&= R128_UPLOAD_CLIPRECTS
;
1192 static void r128DDPrintState( const char *msg
, GLuint flags
)
1195 "%s: (0x%x) %s%s%s%s%s%s%s%s\n",
1198 (flags
& R128_NEW_CONTEXT
) ? "context, " : "",
1199 (flags
& R128_NEW_ALPHA
) ? "alpha, " : "",
1200 (flags
& R128_NEW_DEPTH
) ? "depth, " : "",
1201 (flags
& R128_NEW_FOG
) ? "fog, " : "",
1202 (flags
& R128_NEW_CLIP
) ? "clip, " : "",
1203 (flags
& R128_NEW_CULL
) ? "cull, " : "",
1204 (flags
& R128_NEW_MASKS
) ? "masks, " : "",
1205 (flags
& R128_NEW_WINDOW
) ? "window, " : "" );
1208 void r128DDUpdateHWState( GLcontext
*ctx
)
1210 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
1211 int new_state
= rmesa
->new_state
;
1213 if ( new_state
|| rmesa
->NewGLState
& _NEW_TEXTURE
)
1215 FLUSH_BATCH( rmesa
);
1217 rmesa
->new_state
= 0;
1219 if ( R128_DEBUG
& DEBUG_VERBOSE_MSG
)
1220 r128DDPrintState( "r128UpdateHwState", new_state
);
1222 /* Update the various parts of the context's state.
1224 if ( new_state
& R128_NEW_ALPHA
)
1225 r128UpdateAlphaMode( ctx
);
1227 if ( new_state
& R128_NEW_DEPTH
)
1228 r128UpdateZMode( ctx
);
1230 if ( new_state
& R128_NEW_FOG
)
1231 r128UpdateFogAttrib( ctx
);
1233 if ( new_state
& R128_NEW_CLIP
)
1234 r128UpdateClipping( ctx
);
1236 if ( new_state
& R128_NEW_CULL
)
1237 r128UpdateCull( ctx
);
1239 if ( new_state
& R128_NEW_MASKS
)
1240 r128UpdateMasks( ctx
);
1242 if ( new_state
& R128_NEW_WINDOW
)
1244 r128UpdateWindow( ctx
);
1245 r128CalcViewport( ctx
);
1248 if ( rmesa
->NewGLState
& _NEW_TEXTURE
) {
1249 r128UpdateTextureState( ctx
);
1255 static void r128DDInvalidateState( GLcontext
*ctx
, GLuint new_state
)
1257 _swrast_InvalidateState( ctx
, new_state
);
1258 _swsetup_InvalidateState( ctx
, new_state
);
1259 _vbo_InvalidateState( ctx
, new_state
);
1260 _tnl_InvalidateState( ctx
, new_state
);
1261 R128_CONTEXT(ctx
)->NewGLState
|= new_state
;
1266 /* Initialize the context's hardware state.
1268 void r128DDInitState( r128ContextPtr rmesa
)
1270 int dst_bpp
, depth_bpp
;
1272 switch ( rmesa
->r128Screen
->cpp
) {
1274 dst_bpp
= R128_GMC_DST_16BPP
;
1277 dst_bpp
= R128_GMC_DST_32BPP
;
1280 fprintf( stderr
, "Error: Unsupported pixel depth... exiting\n" );
1284 rmesa
->ClearColor
= 0x00000000;
1286 switch ( rmesa
->glCtx
->Visual
.depthBits
) {
1288 rmesa
->ClearDepth
= 0x0000ffff;
1289 depth_bpp
= R128_Z_PIX_WIDTH_16
;
1290 rmesa
->depth_scale
= 1.0 / (GLfloat
)0xffff;
1293 rmesa
->ClearDepth
= 0x00ffffff;
1294 depth_bpp
= R128_Z_PIX_WIDTH_24
;
1295 rmesa
->depth_scale
= 1.0 / (GLfloat
)0xffffff;
1298 fprintf( stderr
, "Error: Unsupported depth %d... exiting\n",
1299 rmesa
->glCtx
->Visual
.depthBits
);
1303 rmesa
->Fallback
= 0;
1307 rmesa
->setup
.dp_gui_master_cntl_c
= (R128_GMC_DST_PITCH_OFFSET_CNTL
|
1308 R128_GMC_DST_CLIPPING
|
1309 R128_GMC_BRUSH_SOLID_COLOR
|
1311 R128_GMC_SRC_DATATYPE_COLOR
|
1312 R128_GMC_BYTE_MSB_TO_LSB
|
1313 R128_GMC_CONVERSION_TEMP_6500
|
1315 R128_DP_SRC_SOURCE_MEMORY
|
1316 R128_GMC_3D_FCN_EN
|
1317 R128_GMC_CLR_CMP_CNTL_DIS
|
1318 R128_GMC_AUX_CLIP_DIS
|
1319 R128_GMC_WR_MSK_DIS
);
1321 rmesa
->setup
.sc_top_left_c
= 0x00000000;
1322 rmesa
->setup
.sc_bottom_right_c
= 0x1fff1fff;
1324 rmesa
->setup
.z_offset_c
= rmesa
->r128Screen
->depthOffset
;
1325 rmesa
->setup
.z_pitch_c
= ((rmesa
->r128Screen
->depthPitch
>> 3) |
1328 rmesa
->setup
.z_sten_cntl_c
= (depth_bpp
|
1330 R128_STENCIL_TEST_ALWAYS
|
1331 R128_STENCIL_S_FAIL_KEEP
|
1332 R128_STENCIL_ZPASS_KEEP
|
1333 R128_STENCIL_ZFAIL_KEEP
);
1335 rmesa
->setup
.tex_cntl_c
= (R128_Z_WRITE_ENABLE
|
1337 R128_DITHER_ENABLE
|
1338 R128_ALPHA_IN_TEX_COMPLETE_A
|
1340 R128_ALPHA_LIGHT_DIS
|
1341 R128_TEX_CACHE_FLUSH
|
1342 (0x3f << R128_LOD_BIAS_SHIFT
));
1344 rmesa
->setup
.misc_3d_state_cntl_reg
= (R128_MISC_SCALE_3D_TEXMAP_SHADE
|
1345 R128_MISC_SCALE_PIX_REPLICATE
|
1346 R128_ALPHA_COMB_ADD_CLAMP
|
1348 (R128_ALPHA_BLEND_ONE
<< R128_ALPHA_BLEND_SRC_SHIFT
) |
1349 (R128_ALPHA_BLEND_ZERO
<< R128_ALPHA_BLEND_DST_SHIFT
) |
1350 R128_ALPHA_TEST_ALWAYS
);
1352 rmesa
->setup
.texture_clr_cmp_clr_c
= 0x00000000;
1353 rmesa
->setup
.texture_clr_cmp_msk_c
= 0xffffffff;
1355 rmesa
->setup
.fog_color_c
= 0x00000000;
1357 rmesa
->setup
.pm4_vc_fpu_setup
= (R128_FRONT_DIR_CCW
|
1358 R128_BACKFACE_SOLID
|
1359 R128_FRONTFACE_SOLID
|
1360 R128_FPU_COLOR_GOURAUD
|
1361 R128_FPU_SUB_PIX_4BITS
|
1363 R128_TRAP_BITS_DISABLE
|
1366 R128_FLAT_SHADE_VERTEX_OGL
|
1367 R128_FPU_ROUND_TRUNCATE
|
1370 rmesa
->setup
.setup_cntl
= (R128_COLOR_GOURAUD
|
1371 R128_PRIM_TYPE_TRI
|
1372 R128_TEXTURE_ST_MULT_W
|
1373 R128_STARTING_VERTEX_1
|
1374 R128_ENDING_VERTEX_3
|
1375 R128_SU_POLY_LINE_NOT_LAST
|
1376 R128_SUB_PIX_4BITS
);
1378 rmesa
->setup
.tex_size_pitch_c
= 0x00000000;
1379 rmesa
->setup
.constant_color_c
= 0x00ffffff;
1381 rmesa
->setup
.dp_write_mask
= 0xffffffff;
1382 rmesa
->setup
.sten_ref_mask_c
= 0xffff0000;
1383 rmesa
->setup
.plane_3d_mask_c
= 0xffffffff;
1385 rmesa
->setup
.window_xy_offset
= 0x00000000;
1387 rmesa
->setup
.scale_3d_cntl
= (R128_SCALE_DITHER_TABLE
|
1388 R128_TEX_CACHE_SIZE_FULL
|
1389 R128_DITHER_INIT_RESET
|
1390 R128_SCALE_3D_TEXMAP_SHADE
|
1391 R128_SCALE_PIX_REPLICATE
|
1392 R128_ALPHA_COMB_ADD_CLAMP
|
1394 (R128_ALPHA_BLEND_ONE
<< R128_ALPHA_BLEND_SRC_SHIFT
) |
1395 (R128_ALPHA_BLEND_ZERO
<< R128_ALPHA_BLEND_DST_SHIFT
) |
1396 R128_ALPHA_TEST_ALWAYS
|
1397 R128_COMPOSITE_SHADOW_CMP_EQUAL
|
1398 R128_TEX_MAP_ALPHA_IN_TEXTURE
|
1399 R128_TEX_CACHE_LINE_SIZE_4QW
);
1401 rmesa
->new_state
= R128_NEW_ALL
;
1404 /* Initialize the driver's state functions.
1406 void r128DDInitStateFuncs( GLcontext
*ctx
)
1408 ctx
->Driver
.UpdateState
= r128DDInvalidateState
;
1410 ctx
->Driver
.ClearIndex
= NULL
;
1411 ctx
->Driver
.ClearColor
= r128DDClearColor
;
1412 ctx
->Driver
.ClearStencil
= r128DDClearStencil
;
1413 ctx
->Driver
.DrawBuffer
= r128DDDrawBuffer
;
1414 ctx
->Driver
.ReadBuffer
= r128DDReadBuffer
;
1416 ctx
->Driver
.IndexMask
= NULL
;
1417 ctx
->Driver
.ColorMask
= r128DDColorMask
;
1418 ctx
->Driver
.AlphaFunc
= r128DDAlphaFunc
;
1419 ctx
->Driver
.BlendEquationSeparate
= r128DDBlendEquationSeparate
;
1420 ctx
->Driver
.BlendFuncSeparate
= r128DDBlendFuncSeparate
;
1421 ctx
->Driver
.ClearDepth
= r128DDClearDepth
;
1422 ctx
->Driver
.CullFace
= r128DDCullFace
;
1423 ctx
->Driver
.FrontFace
= r128DDFrontFace
;
1424 ctx
->Driver
.DepthFunc
= r128DDDepthFunc
;
1425 ctx
->Driver
.DepthMask
= r128DDDepthMask
;
1426 ctx
->Driver
.Enable
= r128DDEnable
;
1427 ctx
->Driver
.Fogfv
= r128DDFogfv
;
1428 ctx
->Driver
.Hint
= NULL
;
1429 ctx
->Driver
.Lightfv
= NULL
;
1430 ctx
->Driver
.LightModelfv
= r128DDLightModelfv
;
1431 ctx
->Driver
.LogicOpcode
= r128DDLogicOpCode
;
1432 ctx
->Driver
.PolygonMode
= NULL
;
1433 ctx
->Driver
.PolygonStipple
= r128DDPolygonStipple
;
1434 ctx
->Driver
.RenderMode
= r128DDRenderMode
;
1435 ctx
->Driver
.Scissor
= r128DDScissor
;
1436 ctx
->Driver
.ShadeModel
= r128DDShadeModel
;
1437 ctx
->Driver
.StencilFuncSeparate
= r128DDStencilFuncSeparate
;
1438 ctx
->Driver
.StencilMaskSeparate
= r128DDStencilMaskSeparate
;
1439 ctx
->Driver
.StencilOpSeparate
= r128DDStencilOpSeparate
;
1441 ctx
->Driver
.DepthRange
= r128DepthRange
;
1442 ctx
->Driver
.Viewport
= r128Viewport
;