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 "tnl/t_pipeline.h"
52 #include "drirenderbuffer.h"
55 /* =============================================================
61 * Calculate the hardware blend factor setting. This same function is used
62 * for source and destination of both alpha and RGB.
65 * The hardware register value for the specified blend factor. This value
66 * will need to be shifted into the correct position for either source or
70 * Since the two cases where source and destination are handled differently
71 * are essentially error cases, they should never happen. Determine if these
72 * cases can be removed.
74 static int blend_factor( r128ContextPtr rmesa
, GLenum factor
, GLboolean is_src
)
80 func
= R128_ALPHA_BLEND_ZERO
;
83 func
= R128_ALPHA_BLEND_ONE
;
87 func
= R128_ALPHA_BLEND_SRCCOLOR
;
89 case GL_ONE_MINUS_SRC_COLOR
:
90 func
= R128_ALPHA_BLEND_INVSRCCOLOR
;
93 func
= R128_ALPHA_BLEND_SRCALPHA
;
95 case GL_ONE_MINUS_SRC_ALPHA
:
96 func
= R128_ALPHA_BLEND_INVSRCALPHA
;
98 case GL_SRC_ALPHA_SATURATE
:
99 func
= (is_src
) ? R128_ALPHA_BLEND_SAT
: R128_ALPHA_BLEND_ZERO
;
103 func
= R128_ALPHA_BLEND_DSTCOLOR
;
105 case GL_ONE_MINUS_DST_COLOR
:
106 func
= R128_ALPHA_BLEND_INVDSTCOLOR
;
109 func
= R128_ALPHA_BLEND_DSTALPHA
;
111 case GL_ONE_MINUS_DST_ALPHA
:
112 func
= R128_ALPHA_BLEND_INVDSTALPHA
;
115 case GL_CONSTANT_COLOR
:
116 case GL_ONE_MINUS_CONSTANT_COLOR
:
117 case GL_CONSTANT_ALPHA
:
118 case GL_ONE_MINUS_CONSTANT_ALPHA
:
120 FALLBACK( rmesa
, R128_FALLBACK_BLEND_FUNC
, GL_TRUE
);
121 func
= (is_src
) ? R128_ALPHA_BLEND_ONE
: R128_ALPHA_BLEND_ZERO
;
129 static void r128UpdateAlphaMode( GLcontext
*ctx
)
131 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
132 GLuint a
= rmesa
->setup
.misc_3d_state_cntl_reg
;
133 GLuint t
= rmesa
->setup
.tex_cntl_c
;
135 if ( ctx
->Color
.AlphaEnabled
) {
138 CLAMPED_FLOAT_TO_UBYTE(ref
, ctx
->Color
.AlphaRef
);
140 a
&= ~(R128_ALPHA_TEST_MASK
| R128_REF_ALPHA_MASK
);
142 switch ( ctx
->Color
.AlphaFunc
) {
144 a
|= R128_ALPHA_TEST_NEVER
;
147 a
|= R128_ALPHA_TEST_LESS
;
150 a
|= R128_ALPHA_TEST_LESSEQUAL
;
153 a
|= R128_ALPHA_TEST_EQUAL
;
156 a
|= R128_ALPHA_TEST_GREATEREQUAL
;
159 a
|= R128_ALPHA_TEST_GREATER
;
162 a
|= R128_ALPHA_TEST_NEQUAL
;
165 a
|= R128_ALPHA_TEST_ALWAYS
;
169 a
|= ref
& R128_REF_ALPHA_MASK
;
170 t
|= R128_ALPHA_TEST_ENABLE
;
172 t
&= ~R128_ALPHA_TEST_ENABLE
;
175 FALLBACK( rmesa
, R128_FALLBACK_BLEND_FUNC
, GL_FALSE
);
177 if ( ctx
->Color
.BlendEnabled
) {
178 a
&= ~((R128_ALPHA_BLEND_MASK
<< R128_ALPHA_BLEND_SRC_SHIFT
) |
179 (R128_ALPHA_BLEND_MASK
<< R128_ALPHA_BLEND_DST_SHIFT
)
180 | R128_ALPHA_COMB_FCN_MASK
);
182 a
|= blend_factor( rmesa
, ctx
->Color
.BlendSrcRGB
, GL_TRUE
)
183 << R128_ALPHA_BLEND_SRC_SHIFT
;
184 a
|= blend_factor( rmesa
, ctx
->Color
.BlendDstRGB
, GL_FALSE
)
185 << R128_ALPHA_BLEND_DST_SHIFT
;
187 switch (ctx
->Color
.BlendEquationRGB
) {
189 a
|= R128_ALPHA_COMB_ADD_CLAMP
;
191 case GL_FUNC_SUBTRACT
:
192 a
|= R128_ALPHA_COMB_SUB_SRC_DST_CLAMP
;
195 FALLBACK( rmesa
, R128_FALLBACK_BLEND_EQ
, GL_TRUE
);
198 t
|= R128_ALPHA_ENABLE
;
200 t
&= ~R128_ALPHA_ENABLE
;
203 if ( rmesa
->setup
.misc_3d_state_cntl_reg
!= a
) {
204 rmesa
->setup
.misc_3d_state_cntl_reg
= a
;
205 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_MASKS
;
207 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
208 rmesa
->setup
.tex_cntl_c
= t
;
209 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_MASKS
;
213 static void r128DDAlphaFunc( GLcontext
*ctx
, GLenum func
, GLfloat ref
)
215 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
217 FLUSH_BATCH( rmesa
);
218 rmesa
->new_state
|= R128_NEW_ALPHA
;
221 static void r128DDBlendEquationSeparate( GLcontext
*ctx
,
222 GLenum modeRGB
, GLenum modeA
)
224 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
226 assert( modeRGB
== modeA
);
227 FLUSH_BATCH( rmesa
);
229 /* BlendEquation sets ColorLogicOpEnabled in an unexpected
232 FALLBACK( R128_CONTEXT(ctx
), R128_FALLBACK_LOGICOP
,
233 (ctx
->Color
.ColorLogicOpEnabled
&&
234 ctx
->Color
.LogicOp
!= GL_COPY
));
236 /* Can only do blend addition, not min, max, subtract, etc. */
237 FALLBACK( R128_CONTEXT(ctx
), R128_FALLBACK_BLEND_EQ
,
238 (modeRGB
!= GL_FUNC_ADD
) && (modeRGB
!= GL_FUNC_SUBTRACT
));
240 rmesa
->new_state
|= R128_NEW_ALPHA
;
243 static void r128DDBlendFuncSeparate( GLcontext
*ctx
,
244 GLenum sfactorRGB
, GLenum dfactorRGB
,
245 GLenum sfactorA
, GLenum dfactorA
)
247 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
249 FLUSH_BATCH( rmesa
);
250 rmesa
->new_state
|= R128_NEW_ALPHA
;
253 /* =============================================================
258 r128DDStencilFuncSeparate( GLcontext
*ctx
, GLenum face
, GLenum func
,
259 GLint ref
, GLuint mask
)
261 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
262 GLuint refmask
= (((ctx
->Stencil
.Ref
[0] & 0xff) << 0) |
263 ((ctx
->Stencil
.ValueMask
[0] & 0xff) << 16) |
264 ((ctx
->Stencil
.WriteMask
[0] & 0xff) << 24));
265 GLuint z
= rmesa
->setup
.z_sten_cntl_c
;
267 z
&= ~R128_STENCIL_TEST_MASK
;
268 switch ( ctx
->Stencil
.Function
[0] ) {
270 z
|= R128_STENCIL_TEST_NEVER
;
273 z
|= R128_STENCIL_TEST_LESS
;
276 z
|= R128_STENCIL_TEST_EQUAL
;
279 z
|= R128_STENCIL_TEST_LESSEQUAL
;
282 z
|= R128_STENCIL_TEST_GREATER
;
285 z
|= R128_STENCIL_TEST_NEQUAL
;
288 z
|= R128_STENCIL_TEST_GREATEREQUAL
;
291 z
|= R128_STENCIL_TEST_ALWAYS
;
295 if ( rmesa
->setup
.sten_ref_mask_c
!= refmask
) {
296 rmesa
->setup
.sten_ref_mask_c
= refmask
;
297 rmesa
->dirty
|= R128_UPLOAD_MASKS
;
299 if ( rmesa
->setup
.z_sten_cntl_c
!= z
) {
300 rmesa
->setup
.z_sten_cntl_c
= z
;
301 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
306 r128DDStencilMaskSeparate( GLcontext
*ctx
, GLenum face
, GLuint mask
)
308 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
309 GLuint refmask
= (((ctx
->Stencil
.Ref
[0] & 0xff) << 0) |
310 ((ctx
->Stencil
.ValueMask
[0] & 0xff) << 16) |
311 ((ctx
->Stencil
.WriteMask
[0] & 0xff) << 24));
313 if ( rmesa
->setup
.sten_ref_mask_c
!= refmask
) {
314 rmesa
->setup
.sten_ref_mask_c
= refmask
;
315 rmesa
->dirty
|= R128_UPLOAD_MASKS
;
319 static void r128DDStencilOpSeparate( GLcontext
*ctx
, GLenum face
, GLenum fail
,
320 GLenum zfail
, GLenum zpass
)
322 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
323 GLuint z
= rmesa
->setup
.z_sten_cntl_c
;
325 if (!( ctx
->Visual
.stencilBits
> 0 && ctx
->Visual
.depthBits
== 24 ))
328 z
&= ~(R128_STENCIL_S_FAIL_MASK
| R128_STENCIL_ZPASS_MASK
|
329 R128_STENCIL_ZFAIL_MASK
);
331 switch ( ctx
->Stencil
.FailFunc
[0] ) {
333 z
|= R128_STENCIL_S_FAIL_KEEP
;
336 z
|= R128_STENCIL_S_FAIL_ZERO
;
339 z
|= R128_STENCIL_S_FAIL_REPLACE
;
342 z
|= R128_STENCIL_S_FAIL_INC
;
345 z
|= R128_STENCIL_S_FAIL_DEC
;
348 z
|= R128_STENCIL_S_FAIL_INV
;
351 z
|= R128_STENCIL_S_FAIL_INC_WRAP
;
354 z
|= R128_STENCIL_S_FAIL_DEC_WRAP
;
358 switch ( ctx
->Stencil
.ZFailFunc
[0] ) {
360 z
|= R128_STENCIL_ZFAIL_KEEP
;
363 z
|= R128_STENCIL_ZFAIL_ZERO
;
366 z
|= R128_STENCIL_ZFAIL_REPLACE
;
369 z
|= R128_STENCIL_ZFAIL_INC
;
372 z
|= R128_STENCIL_ZFAIL_DEC
;
375 z
|= R128_STENCIL_ZFAIL_INV
;
378 z
|= R128_STENCIL_ZFAIL_INC_WRAP
;
381 z
|= R128_STENCIL_ZFAIL_DEC_WRAP
;
385 switch ( ctx
->Stencil
.ZPassFunc
[0] ) {
387 z
|= R128_STENCIL_ZPASS_KEEP
;
390 z
|= R128_STENCIL_ZPASS_ZERO
;
393 z
|= R128_STENCIL_ZPASS_REPLACE
;
396 z
|= R128_STENCIL_ZPASS_INC
;
399 z
|= R128_STENCIL_ZPASS_DEC
;
402 z
|= R128_STENCIL_ZPASS_INV
;
405 z
|= R128_STENCIL_ZPASS_INC_WRAP
;
408 z
|= R128_STENCIL_ZPASS_DEC_WRAP
;
412 if ( rmesa
->setup
.z_sten_cntl_c
!= z
) {
413 rmesa
->setup
.z_sten_cntl_c
= z
;
414 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
418 static void r128DDClearStencil( GLcontext
*ctx
, GLint s
)
420 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
422 if (ctx
->Visual
.stencilBits
> 0 && ctx
->Visual
.depthBits
== 24) {
423 rmesa
->ClearDepth
&= 0x00ffffff;
424 rmesa
->ClearDepth
|= ctx
->Stencil
.Clear
<< 24;
428 /* =============================================================
432 static void r128UpdateZMode( GLcontext
*ctx
)
434 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
435 GLuint z
= rmesa
->setup
.z_sten_cntl_c
;
436 GLuint t
= rmesa
->setup
.tex_cntl_c
;
438 if ( ctx
->Depth
.Test
) {
439 z
&= ~R128_Z_TEST_MASK
;
441 switch ( ctx
->Depth
.Func
) {
443 z
|= R128_Z_TEST_NEVER
;
446 z
|= R128_Z_TEST_ALWAYS
;
449 z
|= R128_Z_TEST_LESS
;
452 z
|= R128_Z_TEST_LESSEQUAL
;
455 z
|= R128_Z_TEST_EQUAL
;
458 z
|= R128_Z_TEST_GREATEREQUAL
;
461 z
|= R128_Z_TEST_GREATER
;
464 z
|= R128_Z_TEST_NEQUAL
;
473 if ( ctx
->Depth
.Mask
) {
474 t
|= R128_Z_WRITE_ENABLE
;
476 t
&= ~R128_Z_WRITE_ENABLE
;
479 if ( rmesa
->setup
.z_sten_cntl_c
!= z
) {
480 rmesa
->setup
.z_sten_cntl_c
= z
;
481 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
483 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
484 rmesa
->setup
.tex_cntl_c
= t
;
485 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
489 static void r128DDDepthFunc( GLcontext
*ctx
, GLenum func
)
491 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
493 FLUSH_BATCH( rmesa
);
494 rmesa
->new_state
|= R128_NEW_DEPTH
;
497 static void r128DDDepthMask( GLcontext
*ctx
, GLboolean flag
)
499 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
501 FLUSH_BATCH( rmesa
);
502 rmesa
->new_state
|= R128_NEW_DEPTH
;
505 static void r128DDClearDepth( GLcontext
*ctx
, GLclampd d
)
507 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
509 switch ( rmesa
->setup
.z_sten_cntl_c
& R128_Z_PIX_WIDTH_MASK
) {
510 case R128_Z_PIX_WIDTH_16
:
511 rmesa
->ClearDepth
= d
* 0x0000ffff;
513 case R128_Z_PIX_WIDTH_24
:
514 rmesa
->ClearDepth
= d
* 0x00ffffff;
515 rmesa
->ClearDepth
|= ctx
->Stencil
.Clear
<< 24;
517 case R128_Z_PIX_WIDTH_32
:
518 rmesa
->ClearDepth
= d
* 0xffffffff;
524 /* =============================================================
528 static void r128UpdateFogAttrib( GLcontext
*ctx
)
530 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
531 GLuint t
= rmesa
->setup
.tex_cntl_c
;
535 if ( ctx
->Fog
.Enabled
) {
536 t
|= R128_FOG_ENABLE
;
538 t
&= ~R128_FOG_ENABLE
;
541 c
[0] = FLOAT_TO_UBYTE( ctx
->Fog
.Color
[0] );
542 c
[1] = FLOAT_TO_UBYTE( ctx
->Fog
.Color
[1] );
543 c
[2] = FLOAT_TO_UBYTE( ctx
->Fog
.Color
[2] );
545 col
= r128PackColor( 4, c
[0], c
[1], c
[2], 0 );
547 if ( rmesa
->setup
.fog_color_c
!= col
) {
548 rmesa
->setup
.fog_color_c
= col
;
549 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
551 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
552 rmesa
->setup
.tex_cntl_c
= t
;
553 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
557 static void r128DDFogfv( GLcontext
*ctx
, GLenum pname
, const GLfloat
*param
)
559 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
561 FLUSH_BATCH( rmesa
);
562 rmesa
->new_state
|= R128_NEW_FOG
;
566 /* =============================================================
570 static void r128UpdateClipping( GLcontext
*ctx
)
572 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
574 if ( rmesa
->driDrawable
) {
575 __DRIdrawablePrivate
*drawable
= rmesa
->driDrawable
;
578 int x2
= drawable
->w
- 1;
579 int y2
= drawable
->h
- 1;
581 if ( ctx
->Scissor
.Enabled
) {
582 if ( ctx
->Scissor
.X
> x1
) {
585 if ( drawable
->h
- ctx
->Scissor
.Y
- ctx
->Scissor
.Height
> y1
) {
586 y1
= drawable
->h
- ctx
->Scissor
.Y
- ctx
->Scissor
.Height
;
588 if ( ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1 < x2
) {
589 x2
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1;
591 if ( drawable
->h
- ctx
->Scissor
.Y
- 1 < y2
) {
592 y2
= drawable
->h
- ctx
->Scissor
.Y
- 1;
601 /* Clamp values to screen to avoid wrapping problems */
604 else if ( x1
>= rmesa
->driScreen
->fbWidth
)
605 x1
= rmesa
->driScreen
->fbWidth
- 1;
608 else if ( y1
>= rmesa
->driScreen
->fbHeight
)
609 y1
= rmesa
->driScreen
->fbHeight
- 1;
612 else if ( x2
>= rmesa
->driScreen
->fbWidth
)
613 x2
= rmesa
->driScreen
->fbWidth
- 1;
616 else if ( y2
>= rmesa
->driScreen
->fbHeight
)
617 y2
= rmesa
->driScreen
->fbHeight
- 1;
619 rmesa
->setup
.sc_top_left_c
= (((y1
& 0x3FFF) << 16) | (x1
& 0x3FFF));
620 rmesa
->setup
.sc_bottom_right_c
= (((y2
& 0x3FFF) << 16) | (x2
& 0x3FFF));
622 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
626 static void r128DDScissor( GLcontext
*ctx
,
627 GLint x
, GLint y
, GLsizei w
, GLsizei h
)
629 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
631 FLUSH_BATCH( rmesa
);
632 rmesa
->new_state
|= R128_NEW_CLIP
;
636 /* =============================================================
640 static void r128UpdateCull( GLcontext
*ctx
)
642 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
643 GLuint f
= rmesa
->setup
.pm4_vc_fpu_setup
;
645 f
&= ~R128_FRONT_DIR_MASK
;
647 switch ( ctx
->Polygon
.FrontFace
) {
649 f
|= R128_FRONT_DIR_CW
;
652 f
|= R128_FRONT_DIR_CCW
;
656 f
|= R128_BACKFACE_SOLID
| R128_FRONTFACE_SOLID
;
658 if ( ctx
->Polygon
.CullFlag
) {
659 switch ( ctx
->Polygon
.CullFaceMode
) {
661 f
&= ~R128_FRONTFACE_SOLID
;
664 f
&= ~R128_BACKFACE_SOLID
;
666 case GL_FRONT_AND_BACK
:
667 f
&= ~(R128_BACKFACE_SOLID
|
668 R128_FRONTFACE_SOLID
);
673 if ( 1 || rmesa
->setup
.pm4_vc_fpu_setup
!= f
) {
674 rmesa
->setup
.pm4_vc_fpu_setup
= f
;
675 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_SETUP
;
679 static void r128DDCullFace( GLcontext
*ctx
, GLenum mode
)
681 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
683 FLUSH_BATCH( rmesa
);
684 rmesa
->new_state
|= R128_NEW_CULL
;
687 static void r128DDFrontFace( GLcontext
*ctx
, GLenum mode
)
689 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
691 FLUSH_BATCH( rmesa
);
692 rmesa
->new_state
|= R128_NEW_CULL
;
696 /* =============================================================
700 static void r128UpdateMasks( GLcontext
*ctx
)
702 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
704 GLuint mask
= r128PackColor( rmesa
->r128Screen
->cpp
,
705 ctx
->Color
.ColorMask
[RCOMP
],
706 ctx
->Color
.ColorMask
[GCOMP
],
707 ctx
->Color
.ColorMask
[BCOMP
],
708 ctx
->Color
.ColorMask
[ACOMP
] );
710 if ( rmesa
->setup
.plane_3d_mask_c
!= mask
) {
711 rmesa
->setup
.plane_3d_mask_c
= mask
;
712 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_MASKS
;
716 static void r128DDColorMask( GLcontext
*ctx
,
717 GLboolean r
, GLboolean g
,
718 GLboolean b
, GLboolean a
)
720 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
722 FLUSH_BATCH( rmesa
);
723 rmesa
->new_state
|= R128_NEW_MASKS
;
727 /* =============================================================
728 * Rendering attributes
730 * We really don't want to recalculate all this every time we bind a
731 * texture. These things shouldn't change all that often, so it makes
732 * sense to break them out of the core texture state update routines.
735 static void updateSpecularLighting( GLcontext
*ctx
)
737 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
738 GLuint t
= rmesa
->setup
.tex_cntl_c
;
740 if ( NEED_SECONDARY_COLOR( ctx
) ) {
741 if (ctx
->Light
.ShadeModel
== GL_FLAT
) {
742 /* R128 can't do flat-shaded separate specular */
743 t
&= ~R128_SPEC_LIGHT_ENABLE
;
744 FALLBACK( rmesa
, R128_FALLBACK_SEP_SPECULAR
, GL_TRUE
);
747 t
|= R128_SPEC_LIGHT_ENABLE
;
748 FALLBACK( rmesa
, R128_FALLBACK_SEP_SPECULAR
, GL_FALSE
);
752 t
&= ~R128_SPEC_LIGHT_ENABLE
;
753 FALLBACK( rmesa
, R128_FALLBACK_SEP_SPECULAR
, GL_FALSE
);
756 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
757 rmesa
->setup
.tex_cntl_c
= t
;
758 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
759 rmesa
->dirty
|= R128_UPLOAD_SETUP
;
760 rmesa
->new_state
|= R128_NEW_CONTEXT
;
765 static void r128DDLightModelfv( GLcontext
*ctx
, GLenum pname
,
766 const GLfloat
*param
)
768 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
770 if ( pname
== GL_LIGHT_MODEL_COLOR_CONTROL
) {
771 FLUSH_BATCH( rmesa
);
772 updateSpecularLighting(ctx
);
776 static void r128DDShadeModel( GLcontext
*ctx
, GLenum mode
)
778 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
779 GLuint s
= rmesa
->setup
.pm4_vc_fpu_setup
;
781 s
&= ~R128_FPU_COLOR_MASK
;
785 s
|= R128_FPU_COLOR_FLAT
;
788 s
|= R128_FPU_COLOR_GOURAUD
;
794 updateSpecularLighting(ctx
);
796 if ( rmesa
->setup
.pm4_vc_fpu_setup
!= s
) {
797 FLUSH_BATCH( rmesa
);
798 rmesa
->setup
.pm4_vc_fpu_setup
= s
;
800 rmesa
->new_state
|= R128_NEW_CONTEXT
;
801 rmesa
->dirty
|= R128_UPLOAD_SETUP
;
806 /* =============================================================
810 static void r128UpdateWindow( GLcontext
*ctx
)
812 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
813 int x
= rmesa
->driDrawable
->x
;
814 int y
= rmesa
->driDrawable
->y
;
815 struct gl_renderbuffer
*rb
= ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
816 driRenderbuffer
*drb
= (driRenderbuffer
*) rb
;
818 rmesa
->setup
.window_xy_offset
= (((y
& 0xFFF) << R128_WINDOW_Y_SHIFT
) |
819 ((x
& 0xFFF) << R128_WINDOW_X_SHIFT
));
821 rmesa
->setup
.dst_pitch_offset_c
= (((drb
->flippedPitch
/8) << 21) |
822 (drb
->flippedOffset
>> 5));
825 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_WINDOW
;
829 /* =============================================================
833 static void r128CalcViewport( GLcontext
*ctx
)
835 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
836 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
837 GLfloat
*m
= rmesa
->hw_viewport
;
839 /* See also r128_translate_vertex.
841 m
[MAT_SX
] = v
[MAT_SX
];
842 m
[MAT_TX
] = v
[MAT_TX
] + SUBPIXEL_X
;
843 m
[MAT_SY
] = - v
[MAT_SY
];
844 m
[MAT_TY
] = - v
[MAT_TY
] + rmesa
->driDrawable
->h
+ SUBPIXEL_Y
;
845 m
[MAT_SZ
] = v
[MAT_SZ
] * rmesa
->depth_scale
;
846 m
[MAT_TZ
] = v
[MAT_TZ
] * rmesa
->depth_scale
;
849 static void r128Viewport( GLcontext
*ctx
,
851 GLsizei width
, GLsizei height
)
853 r128CalcViewport( ctx
);
856 static void r128DepthRange( GLcontext
*ctx
,
857 GLclampd nearval
, GLclampd farval
)
859 r128CalcViewport( ctx
);
863 /* =============================================================
867 static void r128DDClearColor( GLcontext
*ctx
,
868 const GLfloat color
[4] )
870 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
873 CLAMPED_FLOAT_TO_UBYTE(c
[0], color
[0]);
874 CLAMPED_FLOAT_TO_UBYTE(c
[1], color
[1]);
875 CLAMPED_FLOAT_TO_UBYTE(c
[2], color
[2]);
876 CLAMPED_FLOAT_TO_UBYTE(c
[3], color
[3]);
878 rmesa
->ClearColor
= r128PackColor( rmesa
->r128Screen
->cpp
,
879 c
[0], c
[1], c
[2], c
[3] );
882 static void r128DDLogicOpCode( GLcontext
*ctx
, GLenum opcode
)
884 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
886 if ( ctx
->Color
.ColorLogicOpEnabled
) {
887 FLUSH_BATCH( rmesa
);
889 FALLBACK( rmesa
, R128_FALLBACK_LOGICOP
, opcode
!= GL_COPY
);
893 static void r128DDDrawBuffer( GLcontext
*ctx
, GLenum mode
)
895 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
897 FLUSH_BATCH( rmesa
);
899 if (ctx
->DrawBuffer
->_NumColorDrawBuffers
!= 1) {
900 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
901 FALLBACK( rmesa
, R128_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
905 switch ( ctx
->DrawBuffer
->_ColorDrawBufferIndexes
[0] ) {
906 case BUFFER_FRONT_LEFT
:
907 case BUFFER_BACK_LEFT
:
908 FALLBACK( rmesa
, R128_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
911 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
912 FALLBACK( rmesa
, R128_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
917 rmesa
->new_state
|= R128_NEW_WINDOW
;
920 static void r128DDReadBuffer( GLcontext
*ctx
, GLenum mode
)
922 /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
926 /* =============================================================
930 static void r128DDPolygonStipple( GLcontext
*ctx
, const GLubyte
*mask
)
932 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
933 GLuint stipple
[32], i
;
934 drm_r128_stipple_t stippleRec
;
936 for (i
= 0; i
< 32; i
++) {
937 stipple
[31 - i
] = ((mask
[i
*4+0] << 24) |
938 (mask
[i
*4+1] << 16) |
943 FLUSH_BATCH( rmesa
);
944 LOCK_HARDWARE( rmesa
);
946 stippleRec
.mask
= stipple
;
947 drmCommandWrite( rmesa
->driFd
, DRM_R128_STIPPLE
,
948 &stippleRec
, sizeof(stippleRec
) );
950 UNLOCK_HARDWARE( rmesa
);
952 rmesa
->new_state
|= R128_NEW_CONTEXT
;
953 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
957 /* =============================================================
961 static void r128DDRenderMode( GLcontext
*ctx
, GLenum mode
)
963 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
964 FALLBACK( rmesa
, R128_FALLBACK_RENDER_MODE
, (mode
!= GL_RENDER
) );
969 /* =============================================================
970 * State enable/disable
973 static void r128DDEnable( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
975 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
977 if ( R128_DEBUG
& DEBUG_VERBOSE_API
) {
978 fprintf( stderr
, "%s( %s = %s )\n",
979 __FUNCTION__
, _mesa_lookup_enum_by_nr( cap
),
980 state
? "GL_TRUE" : "GL_FALSE" );
985 FLUSH_BATCH( rmesa
);
986 rmesa
->new_state
|= R128_NEW_ALPHA
;
990 FLUSH_BATCH( rmesa
);
991 rmesa
->new_state
|= R128_NEW_ALPHA
;
993 /* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
995 FALLBACK( rmesa
, R128_FALLBACK_LOGICOP
,
996 (ctx
->Color
.ColorLogicOpEnabled
&&
997 ctx
->Color
.LogicOp
!= GL_COPY
));
1001 FLUSH_BATCH( rmesa
);
1002 rmesa
->new_state
|= R128_NEW_CULL
;
1006 FLUSH_BATCH( rmesa
);
1007 rmesa
->new_state
|= R128_NEW_DEPTH
;
1012 GLuint t
= rmesa
->setup
.tex_cntl_c
;
1013 FLUSH_BATCH( rmesa
);
1015 if ( ctx
->Color
.DitherFlag
) {
1016 t
|= R128_DITHER_ENABLE
;
1018 t
&= ~R128_DITHER_ENABLE
;
1021 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
1022 rmesa
->setup
.tex_cntl_c
= t
;
1023 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
1029 FLUSH_BATCH( rmesa
);
1030 rmesa
->new_state
|= R128_NEW_FOG
;
1033 case GL_COLOR_LOGIC_OP
:
1034 FLUSH_BATCH( rmesa
);
1035 FALLBACK( rmesa
, R128_FALLBACK_LOGICOP
,
1036 state
&& ctx
->Color
.LogicOp
!= GL_COPY
);
1040 case GL_COLOR_SUM_EXT
:
1041 updateSpecularLighting(ctx
);
1044 case GL_SCISSOR_TEST
:
1045 FLUSH_BATCH( rmesa
);
1046 rmesa
->scissor
= state
;
1047 rmesa
->new_state
|= R128_NEW_CLIP
;
1050 case GL_STENCIL_TEST
:
1051 FLUSH_BATCH( rmesa
);
1052 if ( ctx
->Visual
.stencilBits
> 0 && ctx
->Visual
.depthBits
== 24 ) {
1054 rmesa
->setup
.tex_cntl_c
|= R128_STENCIL_ENABLE
;
1055 /* Reset the fallback (if any) for bad stencil funcs */
1056 r128DDStencilOpSeparate( ctx
, 0, ctx
->Stencil
.FailFunc
[0],
1057 ctx
->Stencil
.ZFailFunc
[0],
1058 ctx
->Stencil
.ZPassFunc
[0] );
1060 rmesa
->setup
.tex_cntl_c
&= ~R128_STENCIL_ENABLE
;
1061 FALLBACK( rmesa
, R128_FALLBACK_STENCIL
, GL_FALSE
);
1063 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
1065 FALLBACK( rmesa
, R128_FALLBACK_STENCIL
, state
);
1072 FLUSH_BATCH( rmesa
);
1075 case GL_POLYGON_STIPPLE
:
1076 if ( rmesa
->render_primitive
== GL_TRIANGLES
) {
1077 FLUSH_BATCH( rmesa
);
1078 rmesa
->setup
.dp_gui_master_cntl_c
&= ~R128_GMC_BRUSH_NONE
;
1080 rmesa
->setup
.dp_gui_master_cntl_c
|=
1081 R128_GMC_BRUSH_32x32_MONO_FG_LA
;
1083 rmesa
->setup
.dp_gui_master_cntl_c
|=
1084 R128_GMC_BRUSH_SOLID_COLOR
;
1086 rmesa
->new_state
|= R128_NEW_CONTEXT
;
1087 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
1097 /* =============================================================
1098 * State initialization, management
1101 static void r128DDPrintDirty( const char *msg
, GLuint state
)
1104 "%s: (0x%x) %s%s%s%s%s%s%s%s%s\n",
1107 (state
& R128_UPLOAD_CORE
) ? "core, " : "",
1108 (state
& R128_UPLOAD_CONTEXT
) ? "context, " : "",
1109 (state
& R128_UPLOAD_SETUP
) ? "setup, " : "",
1110 (state
& R128_UPLOAD_TEX0
) ? "tex0, " : "",
1111 (state
& R128_UPLOAD_TEX1
) ? "tex1, " : "",
1112 (state
& R128_UPLOAD_MASKS
) ? "masks, " : "",
1113 (state
& R128_UPLOAD_WINDOW
) ? "window, " : "",
1114 (state
& R128_UPLOAD_CLIPRECTS
) ? "cliprects, " : "",
1115 (state
& R128_REQUIRE_QUIESCENCE
) ? "quiescence, " : "" );
1119 * Load the current context's state into the hardware.
1121 * NOTE: Be VERY careful about ensuring the context state is marked for
1122 * upload, the only place it shouldn't be uploaded is when the setup
1123 * state has changed in ReducedPrimitiveChange as this comes right after
1126 * Blits of any type should always upload the context and masks after
1129 void r128EmitHwStateLocked( r128ContextPtr rmesa
)
1131 drm_r128_sarea_t
*sarea
= rmesa
->sarea
;
1132 drm_r128_context_regs_t
*regs
= &(rmesa
->setup
);
1133 const r128TexObjPtr t0
= rmesa
->CurrentTexObj
[0];
1134 const r128TexObjPtr t1
= rmesa
->CurrentTexObj
[1];
1136 if ( R128_DEBUG
& DEBUG_VERBOSE_MSG
) {
1137 r128DDPrintDirty( "r128EmitHwStateLocked", rmesa
->dirty
);
1140 if ( rmesa
->dirty
& (R128_UPLOAD_CONTEXT
|
1143 R128_UPLOAD_WINDOW
|
1144 R128_UPLOAD_CORE
) ) {
1145 memcpy( &sarea
->context_state
, regs
, sizeof(sarea
->context_state
) );
1147 if( rmesa
->dirty
& R128_UPLOAD_CONTEXT
)
1149 /* One possible side-effect of uploading a new context is the
1150 * setting of the R128_GMC_AUX_CLIP_DIS bit, which causes all
1151 * auxilliary cliprects to be disabled. So the next command must
1152 * upload them again. */
1153 rmesa
->dirty
|= R128_UPLOAD_CLIPRECTS
;
1157 if ( (rmesa
->dirty
& R128_UPLOAD_TEX0
) && t0
) {
1158 drm_r128_texture_regs_t
*tex
= &sarea
->tex_state
[0];
1160 tex
->tex_cntl
= t0
->setup
.tex_cntl
;
1161 tex
->tex_combine_cntl
= rmesa
->tex_combine
[0];
1162 tex
->tex_size_pitch
= t0
->setup
.tex_size_pitch
;
1163 memcpy( &tex
->tex_offset
[0], &t0
->setup
.tex_offset
[0],
1164 sizeof(tex
->tex_offset
) );
1165 tex
->tex_border_color
= t0
->setup
.tex_border_color
;
1168 if ( (rmesa
->dirty
& R128_UPLOAD_TEX1
) && t1
) {
1169 drm_r128_texture_regs_t
*tex
= &sarea
->tex_state
[1];
1171 tex
->tex_cntl
= t1
->setup
.tex_cntl
;
1172 tex
->tex_combine_cntl
= rmesa
->tex_combine
[1];
1173 tex
->tex_size_pitch
= t1
->setup
.tex_size_pitch
;
1174 memcpy( &tex
->tex_offset
[0], &t1
->setup
.tex_offset
[0],
1175 sizeof(tex
->tex_offset
) );
1176 tex
->tex_border_color
= t1
->setup
.tex_border_color
;
1179 sarea
->vertsize
= rmesa
->vertex_size
;
1180 sarea
->vc_format
= rmesa
->vertex_format
;
1182 /* Turn off the texture cache flushing */
1183 rmesa
->setup
.tex_cntl_c
&= ~R128_TEX_CACHE_FLUSH
;
1185 sarea
->dirty
|= rmesa
->dirty
;
1186 rmesa
->dirty
&= R128_UPLOAD_CLIPRECTS
;
1189 static void r128DDPrintState( const char *msg
, GLuint flags
)
1192 "%s: (0x%x) %s%s%s%s%s%s%s%s\n",
1195 (flags
& R128_NEW_CONTEXT
) ? "context, " : "",
1196 (flags
& R128_NEW_ALPHA
) ? "alpha, " : "",
1197 (flags
& R128_NEW_DEPTH
) ? "depth, " : "",
1198 (flags
& R128_NEW_FOG
) ? "fog, " : "",
1199 (flags
& R128_NEW_CLIP
) ? "clip, " : "",
1200 (flags
& R128_NEW_CULL
) ? "cull, " : "",
1201 (flags
& R128_NEW_MASKS
) ? "masks, " : "",
1202 (flags
& R128_NEW_WINDOW
) ? "window, " : "" );
1205 void r128DDUpdateHWState( GLcontext
*ctx
)
1207 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
1208 int new_state
= rmesa
->new_state
;
1210 if ( new_state
|| rmesa
->NewGLState
& _NEW_TEXTURE
)
1212 FLUSH_BATCH( rmesa
);
1214 rmesa
->new_state
= 0;
1216 if ( R128_DEBUG
& DEBUG_VERBOSE_MSG
)
1217 r128DDPrintState( "r128UpdateHwState", new_state
);
1219 /* Update the various parts of the context's state.
1221 if ( new_state
& R128_NEW_ALPHA
)
1222 r128UpdateAlphaMode( ctx
);
1224 if ( new_state
& R128_NEW_DEPTH
)
1225 r128UpdateZMode( ctx
);
1227 if ( new_state
& R128_NEW_FOG
)
1228 r128UpdateFogAttrib( ctx
);
1230 if ( new_state
& R128_NEW_CLIP
)
1231 r128UpdateClipping( ctx
);
1233 if ( new_state
& R128_NEW_CULL
)
1234 r128UpdateCull( ctx
);
1236 if ( new_state
& R128_NEW_MASKS
)
1237 r128UpdateMasks( ctx
);
1239 if ( new_state
& R128_NEW_WINDOW
)
1241 r128UpdateWindow( ctx
);
1242 r128CalcViewport( ctx
);
1245 if ( rmesa
->NewGLState
& _NEW_TEXTURE
) {
1246 r128UpdateTextureState( ctx
);
1252 static void r128DDInvalidateState( GLcontext
*ctx
, GLuint new_state
)
1254 _swrast_InvalidateState( ctx
, new_state
);
1255 _swsetup_InvalidateState( ctx
, new_state
);
1256 _vbo_InvalidateState( ctx
, new_state
);
1257 _tnl_InvalidateState( ctx
, new_state
);
1258 R128_CONTEXT(ctx
)->NewGLState
|= new_state
;
1263 /* Initialize the context's hardware state.
1265 void r128DDInitState( r128ContextPtr rmesa
)
1267 int dst_bpp
, depth_bpp
;
1269 switch ( rmesa
->r128Screen
->cpp
) {
1271 dst_bpp
= R128_GMC_DST_16BPP
;
1274 dst_bpp
= R128_GMC_DST_32BPP
;
1277 fprintf( stderr
, "Error: Unsupported pixel depth... exiting\n" );
1281 rmesa
->ClearColor
= 0x00000000;
1283 switch ( rmesa
->glCtx
->Visual
.depthBits
) {
1285 rmesa
->ClearDepth
= 0x0000ffff;
1286 depth_bpp
= R128_Z_PIX_WIDTH_16
;
1287 rmesa
->depth_scale
= 1.0 / (GLfloat
)0xffff;
1290 rmesa
->ClearDepth
= 0x00ffffff;
1291 depth_bpp
= R128_Z_PIX_WIDTH_24
;
1292 rmesa
->depth_scale
= 1.0 / (GLfloat
)0xffffff;
1295 fprintf( stderr
, "Error: Unsupported depth %d... exiting\n",
1296 rmesa
->glCtx
->Visual
.depthBits
);
1300 rmesa
->Fallback
= 0;
1304 rmesa
->setup
.dp_gui_master_cntl_c
= (R128_GMC_DST_PITCH_OFFSET_CNTL
|
1305 R128_GMC_DST_CLIPPING
|
1306 R128_GMC_BRUSH_SOLID_COLOR
|
1308 R128_GMC_SRC_DATATYPE_COLOR
|
1309 R128_GMC_BYTE_MSB_TO_LSB
|
1310 R128_GMC_CONVERSION_TEMP_6500
|
1312 R128_DP_SRC_SOURCE_MEMORY
|
1313 R128_GMC_3D_FCN_EN
|
1314 R128_GMC_CLR_CMP_CNTL_DIS
|
1315 R128_GMC_AUX_CLIP_DIS
|
1316 R128_GMC_WR_MSK_DIS
);
1318 rmesa
->setup
.sc_top_left_c
= 0x00000000;
1319 rmesa
->setup
.sc_bottom_right_c
= 0x1fff1fff;
1321 rmesa
->setup
.z_offset_c
= rmesa
->r128Screen
->depthOffset
;
1322 rmesa
->setup
.z_pitch_c
= ((rmesa
->r128Screen
->depthPitch
>> 3) |
1325 rmesa
->setup
.z_sten_cntl_c
= (depth_bpp
|
1327 R128_STENCIL_TEST_ALWAYS
|
1328 R128_STENCIL_S_FAIL_KEEP
|
1329 R128_STENCIL_ZPASS_KEEP
|
1330 R128_STENCIL_ZFAIL_KEEP
);
1332 rmesa
->setup
.tex_cntl_c
= (R128_Z_WRITE_ENABLE
|
1334 R128_DITHER_ENABLE
|
1335 R128_ALPHA_IN_TEX_COMPLETE_A
|
1337 R128_ALPHA_LIGHT_DIS
|
1338 R128_TEX_CACHE_FLUSH
|
1339 (0x3f << R128_LOD_BIAS_SHIFT
));
1341 rmesa
->setup
.misc_3d_state_cntl_reg
= (R128_MISC_SCALE_3D_TEXMAP_SHADE
|
1342 R128_MISC_SCALE_PIX_REPLICATE
|
1343 R128_ALPHA_COMB_ADD_CLAMP
|
1345 (R128_ALPHA_BLEND_ONE
<< R128_ALPHA_BLEND_SRC_SHIFT
) |
1346 (R128_ALPHA_BLEND_ZERO
<< R128_ALPHA_BLEND_DST_SHIFT
) |
1347 R128_ALPHA_TEST_ALWAYS
);
1349 rmesa
->setup
.texture_clr_cmp_clr_c
= 0x00000000;
1350 rmesa
->setup
.texture_clr_cmp_msk_c
= 0xffffffff;
1352 rmesa
->setup
.fog_color_c
= 0x00000000;
1354 rmesa
->setup
.pm4_vc_fpu_setup
= (R128_FRONT_DIR_CCW
|
1355 R128_BACKFACE_SOLID
|
1356 R128_FRONTFACE_SOLID
|
1357 R128_FPU_COLOR_GOURAUD
|
1358 R128_FPU_SUB_PIX_4BITS
|
1360 R128_TRAP_BITS_DISABLE
|
1363 R128_FLAT_SHADE_VERTEX_OGL
|
1364 R128_FPU_ROUND_TRUNCATE
|
1367 rmesa
->setup
.setup_cntl
= (R128_COLOR_GOURAUD
|
1368 R128_PRIM_TYPE_TRI
|
1369 R128_TEXTURE_ST_MULT_W
|
1370 R128_STARTING_VERTEX_1
|
1371 R128_ENDING_VERTEX_3
|
1372 R128_SU_POLY_LINE_NOT_LAST
|
1373 R128_SUB_PIX_4BITS
);
1375 rmesa
->setup
.tex_size_pitch_c
= 0x00000000;
1376 rmesa
->setup
.constant_color_c
= 0x00ffffff;
1378 rmesa
->setup
.dp_write_mask
= 0xffffffff;
1379 rmesa
->setup
.sten_ref_mask_c
= 0xffff0000;
1380 rmesa
->setup
.plane_3d_mask_c
= 0xffffffff;
1382 rmesa
->setup
.window_xy_offset
= 0x00000000;
1384 rmesa
->setup
.scale_3d_cntl
= (R128_SCALE_DITHER_TABLE
|
1385 R128_TEX_CACHE_SIZE_FULL
|
1386 R128_DITHER_INIT_RESET
|
1387 R128_SCALE_3D_TEXMAP_SHADE
|
1388 R128_SCALE_PIX_REPLICATE
|
1389 R128_ALPHA_COMB_ADD_CLAMP
|
1391 (R128_ALPHA_BLEND_ONE
<< R128_ALPHA_BLEND_SRC_SHIFT
) |
1392 (R128_ALPHA_BLEND_ZERO
<< R128_ALPHA_BLEND_DST_SHIFT
) |
1393 R128_ALPHA_TEST_ALWAYS
|
1394 R128_COMPOSITE_SHADOW_CMP_EQUAL
|
1395 R128_TEX_MAP_ALPHA_IN_TEXTURE
|
1396 R128_TEX_CACHE_LINE_SIZE_4QW
);
1398 rmesa
->new_state
= R128_NEW_ALL
;
1401 /* Initialize the driver's state functions.
1403 void r128DDInitStateFuncs( GLcontext
*ctx
)
1405 ctx
->Driver
.UpdateState
= r128DDInvalidateState
;
1407 ctx
->Driver
.ClearIndex
= NULL
;
1408 ctx
->Driver
.ClearColor
= r128DDClearColor
;
1409 ctx
->Driver
.ClearStencil
= r128DDClearStencil
;
1410 ctx
->Driver
.DrawBuffer
= r128DDDrawBuffer
;
1411 ctx
->Driver
.ReadBuffer
= r128DDReadBuffer
;
1413 ctx
->Driver
.IndexMask
= NULL
;
1414 ctx
->Driver
.ColorMask
= r128DDColorMask
;
1415 ctx
->Driver
.AlphaFunc
= r128DDAlphaFunc
;
1416 ctx
->Driver
.BlendEquationSeparate
= r128DDBlendEquationSeparate
;
1417 ctx
->Driver
.BlendFuncSeparate
= r128DDBlendFuncSeparate
;
1418 ctx
->Driver
.ClearDepth
= r128DDClearDepth
;
1419 ctx
->Driver
.CullFace
= r128DDCullFace
;
1420 ctx
->Driver
.FrontFace
= r128DDFrontFace
;
1421 ctx
->Driver
.DepthFunc
= r128DDDepthFunc
;
1422 ctx
->Driver
.DepthMask
= r128DDDepthMask
;
1423 ctx
->Driver
.Enable
= r128DDEnable
;
1424 ctx
->Driver
.Fogfv
= r128DDFogfv
;
1425 ctx
->Driver
.Hint
= NULL
;
1426 ctx
->Driver
.Lightfv
= NULL
;
1427 ctx
->Driver
.LightModelfv
= r128DDLightModelfv
;
1428 ctx
->Driver
.LogicOpcode
= r128DDLogicOpCode
;
1429 ctx
->Driver
.PolygonMode
= NULL
;
1430 ctx
->Driver
.PolygonStipple
= r128DDPolygonStipple
;
1431 ctx
->Driver
.RenderMode
= r128DDRenderMode
;
1432 ctx
->Driver
.Scissor
= r128DDScissor
;
1433 ctx
->Driver
.ShadeModel
= r128DDShadeModel
;
1434 ctx
->Driver
.StencilFuncSeparate
= r128DDStencilFuncSeparate
;
1435 ctx
->Driver
.StencilMaskSeparate
= r128DDStencilMaskSeparate
;
1436 ctx
->Driver
.StencilOpSeparate
= r128DDStencilOpSeparate
;
1438 ctx
->Driver
.DepthRange
= r128DepthRange
;
1439 ctx
->Driver
.Viewport
= r128Viewport
;