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 "main/macros.h"
46 #include "swrast/swrast.h"
49 #include "swrast_setup/swrast_setup.h"
51 #include "drirenderbuffer.h"
54 /* =============================================================
60 * Calculate the hardware blend factor setting. This same function is used
61 * for source and destination of both alpha and RGB.
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
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.
73 static int blend_factor( r128ContextPtr rmesa
, GLenum factor
, GLboolean is_src
)
79 func
= R128_ALPHA_BLEND_ZERO
;
82 func
= R128_ALPHA_BLEND_ONE
;
86 func
= R128_ALPHA_BLEND_SRCCOLOR
;
88 case GL_ONE_MINUS_SRC_COLOR
:
89 func
= R128_ALPHA_BLEND_INVSRCCOLOR
;
92 func
= R128_ALPHA_BLEND_SRCALPHA
;
94 case GL_ONE_MINUS_SRC_ALPHA
:
95 func
= R128_ALPHA_BLEND_INVSRCALPHA
;
97 case GL_SRC_ALPHA_SATURATE
:
98 func
= (is_src
) ? R128_ALPHA_BLEND_SAT
: R128_ALPHA_BLEND_ZERO
;
102 func
= R128_ALPHA_BLEND_DSTCOLOR
;
104 case GL_ONE_MINUS_DST_COLOR
:
105 func
= R128_ALPHA_BLEND_INVDSTCOLOR
;
108 func
= R128_ALPHA_BLEND_DSTALPHA
;
110 case GL_ONE_MINUS_DST_ALPHA
:
111 func
= R128_ALPHA_BLEND_INVDSTALPHA
;
114 case GL_CONSTANT_COLOR
:
115 case GL_ONE_MINUS_CONSTANT_COLOR
:
116 case GL_CONSTANT_ALPHA
:
117 case GL_ONE_MINUS_CONSTANT_ALPHA
:
119 FALLBACK( rmesa
, R128_FALLBACK_BLEND_FUNC
, GL_TRUE
);
120 func
= (is_src
) ? R128_ALPHA_BLEND_ONE
: R128_ALPHA_BLEND_ZERO
;
128 static void r128UpdateAlphaMode( struct gl_context
*ctx
)
130 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
131 GLuint a
= rmesa
->setup
.misc_3d_state_cntl_reg
;
132 GLuint t
= rmesa
->setup
.tex_cntl_c
;
134 if ( ctx
->Color
.AlphaEnabled
) {
137 CLAMPED_FLOAT_TO_UBYTE(ref
, ctx
->Color
.AlphaRef
);
139 a
&= ~(R128_ALPHA_TEST_MASK
| R128_REF_ALPHA_MASK
);
141 switch ( ctx
->Color
.AlphaFunc
) {
143 a
|= R128_ALPHA_TEST_NEVER
;
146 a
|= R128_ALPHA_TEST_LESS
;
149 a
|= R128_ALPHA_TEST_LESSEQUAL
;
152 a
|= R128_ALPHA_TEST_EQUAL
;
155 a
|= R128_ALPHA_TEST_GREATEREQUAL
;
158 a
|= R128_ALPHA_TEST_GREATER
;
161 a
|= R128_ALPHA_TEST_NEQUAL
;
164 a
|= R128_ALPHA_TEST_ALWAYS
;
168 a
|= ref
& R128_REF_ALPHA_MASK
;
169 t
|= R128_ALPHA_TEST_ENABLE
;
171 t
&= ~R128_ALPHA_TEST_ENABLE
;
174 FALLBACK( rmesa
, R128_FALLBACK_BLEND_FUNC
, GL_FALSE
);
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
);
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
;
186 switch (ctx
->Color
.BlendEquationRGB
) {
188 a
|= R128_ALPHA_COMB_ADD_CLAMP
;
190 case GL_FUNC_SUBTRACT
:
191 a
|= R128_ALPHA_COMB_SUB_SRC_DST_CLAMP
;
194 FALLBACK( rmesa
, R128_FALLBACK_BLEND_EQ
, GL_TRUE
);
197 t
|= R128_ALPHA_ENABLE
;
199 t
&= ~R128_ALPHA_ENABLE
;
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
;
206 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
207 rmesa
->setup
.tex_cntl_c
= t
;
208 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_MASKS
;
212 static void r128DDAlphaFunc( struct gl_context
*ctx
, GLenum func
, GLfloat ref
)
214 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
216 FLUSH_BATCH( rmesa
);
217 rmesa
->new_state
|= R128_NEW_ALPHA
;
220 static void r128DDBlendEquationSeparate( struct gl_context
*ctx
,
221 GLenum modeRGB
, GLenum modeA
)
223 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
225 assert( modeRGB
== modeA
);
226 FLUSH_BATCH( rmesa
);
228 /* BlendEquation sets ColorLogicOpEnabled in an unexpected
231 FALLBACK( R128_CONTEXT(ctx
), R128_FALLBACK_LOGICOP
,
232 (ctx
->Color
.ColorLogicOpEnabled
&&
233 ctx
->Color
.LogicOp
!= GL_COPY
));
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
));
239 rmesa
->new_state
|= R128_NEW_ALPHA
;
242 static void r128DDBlendFuncSeparate( struct gl_context
*ctx
,
243 GLenum sfactorRGB
, GLenum dfactorRGB
,
244 GLenum sfactorA
, GLenum dfactorA
)
246 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
248 FLUSH_BATCH( rmesa
);
249 rmesa
->new_state
|= R128_NEW_ALPHA
;
252 /* =============================================================
257 r128DDStencilFuncSeparate( struct gl_context
*ctx
, GLenum face
, GLenum func
,
258 GLint ref
, GLuint mask
)
260 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
261 GLuint refmask
= (((ctx
->Stencil
.Ref
[0] & 0xff) << 0) |
262 ((ctx
->Stencil
.ValueMask
[0] & 0xff) << 16) |
263 ((ctx
->Stencil
.WriteMask
[0] & 0xff) << 24));
264 GLuint z
= rmesa
->setup
.z_sten_cntl_c
;
266 z
&= ~R128_STENCIL_TEST_MASK
;
267 switch ( ctx
->Stencil
.Function
[0] ) {
269 z
|= R128_STENCIL_TEST_NEVER
;
272 z
|= R128_STENCIL_TEST_LESS
;
275 z
|= R128_STENCIL_TEST_EQUAL
;
278 z
|= R128_STENCIL_TEST_LESSEQUAL
;
281 z
|= R128_STENCIL_TEST_GREATER
;
284 z
|= R128_STENCIL_TEST_NEQUAL
;
287 z
|= R128_STENCIL_TEST_GREATEREQUAL
;
290 z
|= R128_STENCIL_TEST_ALWAYS
;
294 if ( rmesa
->setup
.sten_ref_mask_c
!= refmask
) {
295 rmesa
->setup
.sten_ref_mask_c
= refmask
;
296 rmesa
->dirty
|= R128_UPLOAD_MASKS
;
298 if ( rmesa
->setup
.z_sten_cntl_c
!= z
) {
299 rmesa
->setup
.z_sten_cntl_c
= z
;
300 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
305 r128DDStencilMaskSeparate( struct gl_context
*ctx
, GLenum face
, GLuint mask
)
307 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
308 GLuint refmask
= (((ctx
->Stencil
.Ref
[0] & 0xff) << 0) |
309 ((ctx
->Stencil
.ValueMask
[0] & 0xff) << 16) |
310 ((ctx
->Stencil
.WriteMask
[0] & 0xff) << 24));
312 if ( rmesa
->setup
.sten_ref_mask_c
!= refmask
) {
313 rmesa
->setup
.sten_ref_mask_c
= refmask
;
314 rmesa
->dirty
|= R128_UPLOAD_MASKS
;
318 static void r128DDStencilOpSeparate( struct gl_context
*ctx
, GLenum face
, GLenum fail
,
319 GLenum zfail
, GLenum zpass
)
321 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
322 GLuint z
= rmesa
->setup
.z_sten_cntl_c
;
324 if (!( ctx
->Visual
.stencilBits
> 0 && ctx
->Visual
.depthBits
== 24 ))
327 z
&= ~(R128_STENCIL_S_FAIL_MASK
| R128_STENCIL_ZPASS_MASK
|
328 R128_STENCIL_ZFAIL_MASK
);
330 switch ( ctx
->Stencil
.FailFunc
[0] ) {
332 z
|= R128_STENCIL_S_FAIL_KEEP
;
335 z
|= R128_STENCIL_S_FAIL_ZERO
;
338 z
|= R128_STENCIL_S_FAIL_REPLACE
;
341 z
|= R128_STENCIL_S_FAIL_INC
;
344 z
|= R128_STENCIL_S_FAIL_DEC
;
347 z
|= R128_STENCIL_S_FAIL_INV
;
350 z
|= R128_STENCIL_S_FAIL_INC_WRAP
;
353 z
|= R128_STENCIL_S_FAIL_DEC_WRAP
;
357 switch ( ctx
->Stencil
.ZFailFunc
[0] ) {
359 z
|= R128_STENCIL_ZFAIL_KEEP
;
362 z
|= R128_STENCIL_ZFAIL_ZERO
;
365 z
|= R128_STENCIL_ZFAIL_REPLACE
;
368 z
|= R128_STENCIL_ZFAIL_INC
;
371 z
|= R128_STENCIL_ZFAIL_DEC
;
374 z
|= R128_STENCIL_ZFAIL_INV
;
377 z
|= R128_STENCIL_ZFAIL_INC_WRAP
;
380 z
|= R128_STENCIL_ZFAIL_DEC_WRAP
;
384 switch ( ctx
->Stencil
.ZPassFunc
[0] ) {
386 z
|= R128_STENCIL_ZPASS_KEEP
;
389 z
|= R128_STENCIL_ZPASS_ZERO
;
392 z
|= R128_STENCIL_ZPASS_REPLACE
;
395 z
|= R128_STENCIL_ZPASS_INC
;
398 z
|= R128_STENCIL_ZPASS_DEC
;
401 z
|= R128_STENCIL_ZPASS_INV
;
404 z
|= R128_STENCIL_ZPASS_INC_WRAP
;
407 z
|= R128_STENCIL_ZPASS_DEC_WRAP
;
411 if ( rmesa
->setup
.z_sten_cntl_c
!= z
) {
412 rmesa
->setup
.z_sten_cntl_c
= z
;
413 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
417 static void r128DDClearStencil( struct gl_context
*ctx
, GLint s
)
419 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
421 if (ctx
->Visual
.stencilBits
> 0 && ctx
->Visual
.depthBits
== 24) {
422 rmesa
->ClearDepth
&= 0x00ffffff;
423 rmesa
->ClearDepth
|= ctx
->Stencil
.Clear
<< 24;
427 /* =============================================================
431 static void r128UpdateZMode( struct gl_context
*ctx
)
433 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
434 GLuint z
= rmesa
->setup
.z_sten_cntl_c
;
435 GLuint t
= rmesa
->setup
.tex_cntl_c
;
437 if ( ctx
->Depth
.Test
) {
438 z
&= ~R128_Z_TEST_MASK
;
440 switch ( ctx
->Depth
.Func
) {
442 z
|= R128_Z_TEST_NEVER
;
445 z
|= R128_Z_TEST_ALWAYS
;
448 z
|= R128_Z_TEST_LESS
;
451 z
|= R128_Z_TEST_LESSEQUAL
;
454 z
|= R128_Z_TEST_EQUAL
;
457 z
|= R128_Z_TEST_GREATEREQUAL
;
460 z
|= R128_Z_TEST_GREATER
;
463 z
|= R128_Z_TEST_NEQUAL
;
472 if ( ctx
->Depth
.Mask
) {
473 t
|= R128_Z_WRITE_ENABLE
;
475 t
&= ~R128_Z_WRITE_ENABLE
;
478 if ( rmesa
->setup
.z_sten_cntl_c
!= z
) {
479 rmesa
->setup
.z_sten_cntl_c
= z
;
480 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
482 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
483 rmesa
->setup
.tex_cntl_c
= t
;
484 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
488 static void r128DDDepthFunc( struct gl_context
*ctx
, GLenum func
)
490 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
492 FLUSH_BATCH( rmesa
);
493 rmesa
->new_state
|= R128_NEW_DEPTH
;
496 static void r128DDDepthMask( struct gl_context
*ctx
, GLboolean flag
)
498 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
500 FLUSH_BATCH( rmesa
);
501 rmesa
->new_state
|= R128_NEW_DEPTH
;
504 static void r128DDClearDepth( struct gl_context
*ctx
, GLclampd d
)
506 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
508 switch ( rmesa
->setup
.z_sten_cntl_c
& R128_Z_PIX_WIDTH_MASK
) {
509 case R128_Z_PIX_WIDTH_16
:
510 rmesa
->ClearDepth
= d
* 0x0000ffff;
512 case R128_Z_PIX_WIDTH_24
:
513 rmesa
->ClearDepth
= d
* 0x00ffffff;
514 rmesa
->ClearDepth
|= ctx
->Stencil
.Clear
<< 24;
516 case R128_Z_PIX_WIDTH_32
:
517 rmesa
->ClearDepth
= d
* 0xffffffff;
523 /* =============================================================
527 static void r128UpdateFogAttrib( struct gl_context
*ctx
)
529 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
530 GLuint t
= rmesa
->setup
.tex_cntl_c
;
534 if ( ctx
->Fog
.Enabled
) {
535 t
|= R128_FOG_ENABLE
;
537 t
&= ~R128_FOG_ENABLE
;
540 c
[0] = FLOAT_TO_UBYTE( ctx
->Fog
.Color
[0] );
541 c
[1] = FLOAT_TO_UBYTE( ctx
->Fog
.Color
[1] );
542 c
[2] = FLOAT_TO_UBYTE( ctx
->Fog
.Color
[2] );
544 col
= r128PackColor( 4, c
[0], c
[1], c
[2], 0 );
546 if ( rmesa
->setup
.fog_color_c
!= col
) {
547 rmesa
->setup
.fog_color_c
= col
;
548 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
550 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
551 rmesa
->setup
.tex_cntl_c
= t
;
552 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
556 static void r128DDFogfv( struct gl_context
*ctx
, GLenum pname
, const GLfloat
*param
)
558 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
560 FLUSH_BATCH( rmesa
);
561 rmesa
->new_state
|= R128_NEW_FOG
;
565 /* =============================================================
569 static void r128UpdateClipping( struct gl_context
*ctx
)
571 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
573 if ( rmesa
->driDrawable
) {
574 __DRIdrawable
*drawable
= rmesa
->driDrawable
;
577 int x2
= drawable
->w
- 1;
578 int y2
= drawable
->h
- 1;
580 if ( ctx
->Scissor
.Enabled
) {
581 if ( ctx
->Scissor
.X
> x1
) {
584 if ( drawable
->h
- ctx
->Scissor
.Y
- ctx
->Scissor
.Height
> y1
) {
585 y1
= drawable
->h
- ctx
->Scissor
.Y
- ctx
->Scissor
.Height
;
587 if ( ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1 < x2
) {
588 x2
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1;
590 if ( drawable
->h
- ctx
->Scissor
.Y
- 1 < y2
) {
591 y2
= drawable
->h
- ctx
->Scissor
.Y
- 1;
600 /* Clamp values to screen to avoid wrapping problems */
603 else if ( x1
>= rmesa
->driScreen
->fbWidth
)
604 x1
= rmesa
->driScreen
->fbWidth
- 1;
607 else if ( y1
>= rmesa
->driScreen
->fbHeight
)
608 y1
= rmesa
->driScreen
->fbHeight
- 1;
611 else if ( x2
>= rmesa
->driScreen
->fbWidth
)
612 x2
= rmesa
->driScreen
->fbWidth
- 1;
615 else if ( y2
>= rmesa
->driScreen
->fbHeight
)
616 y2
= rmesa
->driScreen
->fbHeight
- 1;
618 rmesa
->setup
.sc_top_left_c
= (((y1
& 0x3FFF) << 16) | (x1
& 0x3FFF));
619 rmesa
->setup
.sc_bottom_right_c
= (((y2
& 0x3FFF) << 16) | (x2
& 0x3FFF));
621 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
625 static void r128DDScissor( struct gl_context
*ctx
,
626 GLint x
, GLint y
, GLsizei w
, GLsizei h
)
628 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
630 FLUSH_BATCH( rmesa
);
631 rmesa
->new_state
|= R128_NEW_CLIP
;
635 /* =============================================================
639 static void r128UpdateCull( struct gl_context
*ctx
)
641 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
642 GLuint f
= rmesa
->setup
.pm4_vc_fpu_setup
;
644 f
&= ~R128_FRONT_DIR_MASK
;
646 switch ( ctx
->Polygon
.FrontFace
) {
648 f
|= R128_FRONT_DIR_CW
;
651 f
|= R128_FRONT_DIR_CCW
;
655 f
|= R128_BACKFACE_SOLID
| R128_FRONTFACE_SOLID
;
657 if ( ctx
->Polygon
.CullFlag
) {
658 switch ( ctx
->Polygon
.CullFaceMode
) {
660 f
&= ~R128_FRONTFACE_SOLID
;
663 f
&= ~R128_BACKFACE_SOLID
;
665 case GL_FRONT_AND_BACK
:
666 f
&= ~(R128_BACKFACE_SOLID
|
667 R128_FRONTFACE_SOLID
);
672 if ( 1 || rmesa
->setup
.pm4_vc_fpu_setup
!= f
) {
673 rmesa
->setup
.pm4_vc_fpu_setup
= f
;
674 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_SETUP
;
678 static void r128DDCullFace( struct gl_context
*ctx
, GLenum mode
)
680 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
682 FLUSH_BATCH( rmesa
);
683 rmesa
->new_state
|= R128_NEW_CULL
;
686 static void r128DDFrontFace( struct gl_context
*ctx
, GLenum mode
)
688 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
690 FLUSH_BATCH( rmesa
);
691 rmesa
->new_state
|= R128_NEW_CULL
;
695 /* =============================================================
699 static void r128UpdateMasks( struct gl_context
*ctx
)
701 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
703 GLuint mask
= r128PackColor( rmesa
->r128Screen
->cpp
,
704 ctx
->Color
.ColorMask
[0][RCOMP
],
705 ctx
->Color
.ColorMask
[0][GCOMP
],
706 ctx
->Color
.ColorMask
[0][BCOMP
],
707 ctx
->Color
.ColorMask
[0][ACOMP
] );
709 if ( rmesa
->setup
.plane_3d_mask_c
!= mask
) {
710 rmesa
->setup
.plane_3d_mask_c
= mask
;
711 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_MASKS
;
715 static void r128DDColorMask( struct gl_context
*ctx
,
716 GLboolean r
, GLboolean g
,
717 GLboolean b
, GLboolean a
)
719 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
721 FLUSH_BATCH( rmesa
);
722 rmesa
->new_state
|= R128_NEW_MASKS
;
726 /* =============================================================
727 * Rendering attributes
729 * We really don't want to recalculate all this every time we bind a
730 * texture. These things shouldn't change all that often, so it makes
731 * sense to break them out of the core texture state update routines.
734 static void updateSpecularLighting( struct gl_context
*ctx
)
736 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
737 GLuint t
= rmesa
->setup
.tex_cntl_c
;
739 if ( NEED_SECONDARY_COLOR( ctx
) ) {
740 if (ctx
->Light
.ShadeModel
== GL_FLAT
) {
741 /* R128 can't do flat-shaded separate specular */
742 t
&= ~R128_SPEC_LIGHT_ENABLE
;
743 FALLBACK( rmesa
, R128_FALLBACK_SEP_SPECULAR
, GL_TRUE
);
746 t
|= R128_SPEC_LIGHT_ENABLE
;
747 FALLBACK( rmesa
, R128_FALLBACK_SEP_SPECULAR
, GL_FALSE
);
751 t
&= ~R128_SPEC_LIGHT_ENABLE
;
752 FALLBACK( rmesa
, R128_FALLBACK_SEP_SPECULAR
, GL_FALSE
);
755 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
756 rmesa
->setup
.tex_cntl_c
= t
;
757 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
758 rmesa
->dirty
|= R128_UPLOAD_SETUP
;
759 rmesa
->new_state
|= R128_NEW_CONTEXT
;
764 static void r128DDLightModelfv( struct gl_context
*ctx
, GLenum pname
,
765 const GLfloat
*param
)
767 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
769 if ( pname
== GL_LIGHT_MODEL_COLOR_CONTROL
) {
770 FLUSH_BATCH( rmesa
);
771 updateSpecularLighting(ctx
);
774 if ( pname
== GL_LIGHT_MODEL_TWO_SIDE
) {
775 FLUSH_BATCH( rmesa
);
776 r128ChooseRenderState( ctx
);
780 static void r128DDShadeModel( struct gl_context
*ctx
, GLenum mode
)
782 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
783 GLuint s
= rmesa
->setup
.pm4_vc_fpu_setup
;
785 s
&= ~R128_FPU_COLOR_MASK
;
789 s
|= R128_FPU_COLOR_FLAT
;
792 s
|= R128_FPU_COLOR_GOURAUD
;
798 updateSpecularLighting(ctx
);
800 if ( rmesa
->setup
.pm4_vc_fpu_setup
!= s
) {
801 FLUSH_BATCH( rmesa
);
802 rmesa
->setup
.pm4_vc_fpu_setup
= s
;
804 rmesa
->new_state
|= R128_NEW_CONTEXT
;
805 rmesa
->dirty
|= R128_UPLOAD_SETUP
;
810 /* =============================================================
814 static void r128UpdateWindow( struct gl_context
*ctx
)
816 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
817 int x
= rmesa
->driDrawable
->x
;
818 int y
= rmesa
->driDrawable
->y
;
819 struct gl_renderbuffer
*rb
= ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
820 driRenderbuffer
*drb
= (driRenderbuffer
*) rb
;
822 rmesa
->setup
.window_xy_offset
= (((y
& 0xFFF) << R128_WINDOW_Y_SHIFT
) |
823 ((x
& 0xFFF) << R128_WINDOW_X_SHIFT
));
825 rmesa
->setup
.dst_pitch_offset_c
= (((drb
->flippedPitch
/8) << 21) |
826 (drb
->flippedOffset
>> 5));
829 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
| R128_UPLOAD_WINDOW
;
833 /* =============================================================
837 static void r128CalcViewport( struct gl_context
*ctx
)
839 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
840 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
841 GLfloat
*m
= rmesa
->hw_viewport
;
843 /* See also r128_translate_vertex.
845 m
[MAT_SX
] = v
[MAT_SX
];
846 m
[MAT_TX
] = v
[MAT_TX
] + SUBPIXEL_X
;
847 m
[MAT_SY
] = - v
[MAT_SY
];
848 m
[MAT_TY
] = - v
[MAT_TY
] + rmesa
->driDrawable
->h
+ SUBPIXEL_Y
;
849 m
[MAT_SZ
] = v
[MAT_SZ
] * rmesa
->depth_scale
;
850 m
[MAT_TZ
] = v
[MAT_TZ
] * rmesa
->depth_scale
;
853 static void r128Viewport( struct gl_context
*ctx
,
855 GLsizei width
, GLsizei height
)
857 r128CalcViewport( ctx
);
860 static void r128DepthRange( struct gl_context
*ctx
,
861 GLclampd nearval
, GLclampd farval
)
863 r128CalcViewport( ctx
);
867 /* =============================================================
871 static void r128DDClearColor( struct gl_context
*ctx
,
872 const GLfloat color
[4] )
874 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
877 CLAMPED_FLOAT_TO_UBYTE(c
[0], color
[0]);
878 CLAMPED_FLOAT_TO_UBYTE(c
[1], color
[1]);
879 CLAMPED_FLOAT_TO_UBYTE(c
[2], color
[2]);
880 CLAMPED_FLOAT_TO_UBYTE(c
[3], color
[3]);
882 rmesa
->ClearColor
= r128PackColor( rmesa
->r128Screen
->cpp
,
883 c
[0], c
[1], c
[2], c
[3] );
886 static void r128DDLogicOpCode( struct gl_context
*ctx
, GLenum opcode
)
888 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
890 if ( ctx
->Color
.ColorLogicOpEnabled
) {
891 FLUSH_BATCH( rmesa
);
893 FALLBACK( rmesa
, R128_FALLBACK_LOGICOP
, opcode
!= GL_COPY
);
897 static void r128DDDrawBuffer( struct gl_context
*ctx
, GLenum mode
)
899 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
901 FLUSH_BATCH( rmesa
);
903 if (ctx
->DrawBuffer
->_NumColorDrawBuffers
!= 1) {
904 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
905 FALLBACK( rmesa
, R128_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
909 switch ( ctx
->DrawBuffer
->_ColorDrawBufferIndexes
[0] ) {
910 case BUFFER_FRONT_LEFT
:
911 case BUFFER_BACK_LEFT
:
912 FALLBACK( rmesa
, R128_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
915 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
916 FALLBACK( rmesa
, R128_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
921 rmesa
->new_state
|= R128_NEW_WINDOW
;
924 static void r128DDReadBuffer( struct gl_context
*ctx
, GLenum mode
)
926 /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
930 /* =============================================================
934 static void r128DDPolygonStipple( struct gl_context
*ctx
, const GLubyte
*mask
)
936 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
937 GLuint stipple
[32], i
;
938 drm_r128_stipple_t stippleRec
;
940 for (i
= 0; i
< 32; i
++) {
941 stipple
[31 - i
] = ((mask
[i
*4+0] << 24) |
942 (mask
[i
*4+1] << 16) |
947 FLUSH_BATCH( rmesa
);
948 LOCK_HARDWARE( rmesa
);
950 stippleRec
.mask
= stipple
;
951 drmCommandWrite( rmesa
->driFd
, DRM_R128_STIPPLE
,
952 &stippleRec
, sizeof(stippleRec
) );
954 UNLOCK_HARDWARE( rmesa
);
956 rmesa
->new_state
|= R128_NEW_CONTEXT
;
957 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
961 /* =============================================================
965 static void r128DDRenderMode( struct gl_context
*ctx
, GLenum mode
)
967 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
968 FALLBACK( rmesa
, R128_FALLBACK_RENDER_MODE
, (mode
!= GL_RENDER
) );
973 /* =============================================================
974 * State enable/disable
977 static void r128DDEnable( struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
979 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
981 if ( R128_DEBUG
& DEBUG_VERBOSE_API
) {
982 fprintf( stderr
, "%s( %s = %s )\n",
983 __FUNCTION__
, _mesa_lookup_enum_by_nr( cap
),
984 state
? "GL_TRUE" : "GL_FALSE" );
989 FLUSH_BATCH( rmesa
);
990 rmesa
->new_state
|= R128_NEW_ALPHA
;
994 FLUSH_BATCH( rmesa
);
995 rmesa
->new_state
|= R128_NEW_ALPHA
;
997 /* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
999 FALLBACK( rmesa
, R128_FALLBACK_LOGICOP
,
1000 (ctx
->Color
.ColorLogicOpEnabled
&&
1001 ctx
->Color
.LogicOp
!= GL_COPY
));
1005 FLUSH_BATCH( rmesa
);
1006 rmesa
->new_state
|= R128_NEW_CULL
;
1010 FLUSH_BATCH( rmesa
);
1011 rmesa
->new_state
|= R128_NEW_DEPTH
;
1016 GLuint t
= rmesa
->setup
.tex_cntl_c
;
1017 FLUSH_BATCH( rmesa
);
1019 if ( ctx
->Color
.DitherFlag
) {
1020 t
|= R128_DITHER_ENABLE
;
1022 t
&= ~R128_DITHER_ENABLE
;
1025 if ( rmesa
->setup
.tex_cntl_c
!= t
) {
1026 rmesa
->setup
.tex_cntl_c
= t
;
1027 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
1033 FLUSH_BATCH( rmesa
);
1034 rmesa
->new_state
|= R128_NEW_FOG
;
1037 case GL_COLOR_LOGIC_OP
:
1038 FLUSH_BATCH( rmesa
);
1039 FALLBACK( rmesa
, R128_FALLBACK_LOGICOP
,
1040 state
&& ctx
->Color
.LogicOp
!= GL_COPY
);
1044 case GL_COLOR_SUM_EXT
:
1045 updateSpecularLighting(ctx
);
1048 case GL_SCISSOR_TEST
:
1049 FLUSH_BATCH( rmesa
);
1050 rmesa
->scissor
= state
;
1051 rmesa
->new_state
|= R128_NEW_CLIP
;
1054 case GL_STENCIL_TEST
:
1055 FLUSH_BATCH( rmesa
);
1056 if ( ctx
->Visual
.stencilBits
> 0 && ctx
->Visual
.depthBits
== 24 ) {
1058 rmesa
->setup
.tex_cntl_c
|= R128_STENCIL_ENABLE
;
1059 /* Reset the fallback (if any) for bad stencil funcs */
1060 r128DDStencilOpSeparate( ctx
, 0, ctx
->Stencil
.FailFunc
[0],
1061 ctx
->Stencil
.ZFailFunc
[0],
1062 ctx
->Stencil
.ZPassFunc
[0] );
1064 rmesa
->setup
.tex_cntl_c
&= ~R128_STENCIL_ENABLE
;
1065 FALLBACK( rmesa
, R128_FALLBACK_STENCIL
, GL_FALSE
);
1067 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
1069 FALLBACK( rmesa
, R128_FALLBACK_STENCIL
, state
);
1076 FLUSH_BATCH( rmesa
);
1079 case GL_POLYGON_STIPPLE
:
1080 if ( rmesa
->render_primitive
== GL_TRIANGLES
) {
1081 FLUSH_BATCH( rmesa
);
1082 rmesa
->setup
.dp_gui_master_cntl_c
&= ~R128_GMC_BRUSH_NONE
;
1084 rmesa
->setup
.dp_gui_master_cntl_c
|=
1085 R128_GMC_BRUSH_32x32_MONO_FG_LA
;
1087 rmesa
->setup
.dp_gui_master_cntl_c
|=
1088 R128_GMC_BRUSH_SOLID_COLOR
;
1090 rmesa
->new_state
|= R128_NEW_CONTEXT
;
1091 rmesa
->dirty
|= R128_UPLOAD_CONTEXT
;
1101 /* =============================================================
1102 * State initialization, management
1105 static void r128DDPrintDirty( const char *msg
, GLuint state
)
1108 "%s: (0x%x) %s%s%s%s%s%s%s%s%s\n",
1111 (state
& R128_UPLOAD_CORE
) ? "core, " : "",
1112 (state
& R128_UPLOAD_CONTEXT
) ? "context, " : "",
1113 (state
& R128_UPLOAD_SETUP
) ? "setup, " : "",
1114 (state
& R128_UPLOAD_TEX0
) ? "tex0, " : "",
1115 (state
& R128_UPLOAD_TEX1
) ? "tex1, " : "",
1116 (state
& R128_UPLOAD_MASKS
) ? "masks, " : "",
1117 (state
& R128_UPLOAD_WINDOW
) ? "window, " : "",
1118 (state
& R128_UPLOAD_CLIPRECTS
) ? "cliprects, " : "",
1119 (state
& R128_REQUIRE_QUIESCENCE
) ? "quiescence, " : "" );
1123 * Load the current context's state into the hardware.
1125 * NOTE: Be VERY careful about ensuring the context state is marked for
1126 * upload, the only place it shouldn't be uploaded is when the setup
1127 * state has changed in ReducedPrimitiveChange as this comes right after
1130 * Blits of any type should always upload the context and masks after
1133 void r128EmitHwStateLocked( r128ContextPtr rmesa
)
1135 drm_r128_sarea_t
*sarea
= rmesa
->sarea
;
1136 drm_r128_context_regs_t
*regs
= &(rmesa
->setup
);
1137 const r128TexObjPtr t0
= rmesa
->CurrentTexObj
[0];
1138 const r128TexObjPtr t1
= rmesa
->CurrentTexObj
[1];
1140 if ( R128_DEBUG
& DEBUG_VERBOSE_MSG
) {
1141 r128DDPrintDirty( "r128EmitHwStateLocked", rmesa
->dirty
);
1144 if ( rmesa
->dirty
& (R128_UPLOAD_CONTEXT
|
1147 R128_UPLOAD_WINDOW
|
1148 R128_UPLOAD_CORE
) ) {
1149 memcpy( &sarea
->context_state
, regs
, sizeof(sarea
->context_state
) );
1151 if( rmesa
->dirty
& R128_UPLOAD_CONTEXT
)
1153 /* One possible side-effect of uploading a new context is the
1154 * setting of the R128_GMC_AUX_CLIP_DIS bit, which causes all
1155 * auxilliary cliprects to be disabled. So the next command must
1156 * upload them again. */
1157 rmesa
->dirty
|= R128_UPLOAD_CLIPRECTS
;
1161 if ( (rmesa
->dirty
& R128_UPLOAD_TEX0
) && t0
) {
1162 drm_r128_texture_regs_t
*tex
= &sarea
->tex_state
[0];
1164 tex
->tex_cntl
= t0
->setup
.tex_cntl
;
1165 tex
->tex_combine_cntl
= rmesa
->tex_combine
[0];
1166 tex
->tex_size_pitch
= t0
->setup
.tex_size_pitch
;
1167 memcpy( &tex
->tex_offset
[0], &t0
->setup
.tex_offset
[0],
1168 sizeof(tex
->tex_offset
) );
1169 tex
->tex_border_color
= t0
->setup
.tex_border_color
;
1172 if ( (rmesa
->dirty
& R128_UPLOAD_TEX1
) && t1
) {
1173 drm_r128_texture_regs_t
*tex
= &sarea
->tex_state
[1];
1175 tex
->tex_cntl
= t1
->setup
.tex_cntl
;
1176 tex
->tex_combine_cntl
= rmesa
->tex_combine
[1];
1177 tex
->tex_size_pitch
= t1
->setup
.tex_size_pitch
;
1178 memcpy( &tex
->tex_offset
[0], &t1
->setup
.tex_offset
[0],
1179 sizeof(tex
->tex_offset
) );
1180 tex
->tex_border_color
= t1
->setup
.tex_border_color
;
1183 sarea
->vertsize
= rmesa
->vertex_size
;
1184 sarea
->vc_format
= rmesa
->vertex_format
;
1186 /* Turn off the texture cache flushing */
1187 rmesa
->setup
.tex_cntl_c
&= ~R128_TEX_CACHE_FLUSH
;
1189 sarea
->dirty
|= rmesa
->dirty
;
1190 rmesa
->dirty
&= R128_UPLOAD_CLIPRECTS
;
1193 static void r128DDPrintState( const char *msg
, GLuint flags
)
1196 "%s: (0x%x) %s%s%s%s%s%s%s%s\n",
1199 (flags
& R128_NEW_CONTEXT
) ? "context, " : "",
1200 (flags
& R128_NEW_ALPHA
) ? "alpha, " : "",
1201 (flags
& R128_NEW_DEPTH
) ? "depth, " : "",
1202 (flags
& R128_NEW_FOG
) ? "fog, " : "",
1203 (flags
& R128_NEW_CLIP
) ? "clip, " : "",
1204 (flags
& R128_NEW_CULL
) ? "cull, " : "",
1205 (flags
& R128_NEW_MASKS
) ? "masks, " : "",
1206 (flags
& R128_NEW_WINDOW
) ? "window, " : "" );
1209 void r128DDUpdateHWState( struct gl_context
*ctx
)
1211 r128ContextPtr rmesa
= R128_CONTEXT(ctx
);
1212 int new_state
= rmesa
->new_state
;
1214 if ( new_state
|| rmesa
->NewGLState
& _NEW_TEXTURE
)
1216 FLUSH_BATCH( rmesa
);
1218 rmesa
->new_state
= 0;
1220 if ( R128_DEBUG
& DEBUG_VERBOSE_MSG
)
1221 r128DDPrintState( "r128UpdateHwState", new_state
);
1223 /* Update the various parts of the context's state.
1225 if ( new_state
& R128_NEW_ALPHA
)
1226 r128UpdateAlphaMode( ctx
);
1228 if ( new_state
& R128_NEW_DEPTH
)
1229 r128UpdateZMode( ctx
);
1231 if ( new_state
& R128_NEW_FOG
)
1232 r128UpdateFogAttrib( ctx
);
1234 if ( new_state
& R128_NEW_CLIP
)
1235 r128UpdateClipping( ctx
);
1237 if ( new_state
& R128_NEW_CULL
)
1238 r128UpdateCull( ctx
);
1240 if ( new_state
& R128_NEW_MASKS
)
1241 r128UpdateMasks( ctx
);
1243 if ( new_state
& R128_NEW_WINDOW
)
1245 r128UpdateWindow( ctx
);
1246 r128CalcViewport( ctx
);
1249 if ( rmesa
->NewGLState
& _NEW_TEXTURE
) {
1250 r128UpdateTextureState( ctx
);
1256 static void r128DDInvalidateState( struct gl_context
*ctx
, GLuint new_state
)
1258 _swrast_InvalidateState( ctx
, new_state
);
1259 _swsetup_InvalidateState( ctx
, new_state
);
1260 _vbo_InvalidateState( ctx
, new_state
);
1261 _tnl_InvalidateState( ctx
, new_state
);
1262 R128_CONTEXT(ctx
)->NewGLState
|= new_state
;
1267 /* Initialize the context's hardware state.
1269 void r128DDInitState( r128ContextPtr rmesa
)
1271 int dst_bpp
, depth_bpp
;
1273 switch ( rmesa
->r128Screen
->cpp
) {
1275 dst_bpp
= R128_GMC_DST_16BPP
;
1278 dst_bpp
= R128_GMC_DST_32BPP
;
1281 fprintf( stderr
, "Error: Unsupported pixel depth... exiting\n" );
1285 rmesa
->ClearColor
= 0x00000000;
1287 switch ( rmesa
->glCtx
->Visual
.depthBits
) {
1289 rmesa
->ClearDepth
= 0x0000ffff;
1290 depth_bpp
= R128_Z_PIX_WIDTH_16
;
1291 rmesa
->depth_scale
= 1.0 / (GLfloat
)0xffff;
1294 rmesa
->ClearDepth
= 0x00ffffff;
1295 depth_bpp
= R128_Z_PIX_WIDTH_24
;
1296 rmesa
->depth_scale
= 1.0 / (GLfloat
)0xffffff;
1299 fprintf( stderr
, "Error: Unsupported depth %d... exiting\n",
1300 rmesa
->glCtx
->Visual
.depthBits
);
1304 rmesa
->Fallback
= 0;
1308 rmesa
->setup
.dp_gui_master_cntl_c
= (R128_GMC_DST_PITCH_OFFSET_CNTL
|
1309 R128_GMC_DST_CLIPPING
|
1310 R128_GMC_BRUSH_SOLID_COLOR
|
1312 R128_GMC_SRC_DATATYPE_COLOR
|
1313 R128_GMC_BYTE_MSB_TO_LSB
|
1314 R128_GMC_CONVERSION_TEMP_6500
|
1316 R128_DP_SRC_SOURCE_MEMORY
|
1317 R128_GMC_3D_FCN_EN
|
1318 R128_GMC_CLR_CMP_CNTL_DIS
|
1319 R128_GMC_AUX_CLIP_DIS
|
1320 R128_GMC_WR_MSK_DIS
);
1322 rmesa
->setup
.sc_top_left_c
= 0x00000000;
1323 rmesa
->setup
.sc_bottom_right_c
= 0x1fff1fff;
1325 rmesa
->setup
.z_offset_c
= rmesa
->r128Screen
->depthOffset
;
1326 rmesa
->setup
.z_pitch_c
= ((rmesa
->r128Screen
->depthPitch
>> 3) |
1329 rmesa
->setup
.z_sten_cntl_c
= (depth_bpp
|
1331 R128_STENCIL_TEST_ALWAYS
|
1332 R128_STENCIL_S_FAIL_KEEP
|
1333 R128_STENCIL_ZPASS_KEEP
|
1334 R128_STENCIL_ZFAIL_KEEP
);
1336 rmesa
->setup
.tex_cntl_c
= (R128_Z_WRITE_ENABLE
|
1338 R128_DITHER_ENABLE
|
1339 R128_ALPHA_IN_TEX_COMPLETE_A
|
1341 R128_ALPHA_LIGHT_DIS
|
1342 R128_TEX_CACHE_FLUSH
|
1343 (0x3f << R128_LOD_BIAS_SHIFT
));
1345 rmesa
->setup
.misc_3d_state_cntl_reg
= (R128_MISC_SCALE_3D_TEXMAP_SHADE
|
1346 R128_MISC_SCALE_PIX_REPLICATE
|
1347 R128_ALPHA_COMB_ADD_CLAMP
|
1349 (R128_ALPHA_BLEND_ONE
<< R128_ALPHA_BLEND_SRC_SHIFT
) |
1350 (R128_ALPHA_BLEND_ZERO
<< R128_ALPHA_BLEND_DST_SHIFT
) |
1351 R128_ALPHA_TEST_ALWAYS
);
1353 rmesa
->setup
.texture_clr_cmp_clr_c
= 0x00000000;
1354 rmesa
->setup
.texture_clr_cmp_msk_c
= 0xffffffff;
1356 rmesa
->setup
.fog_color_c
= 0x00000000;
1358 rmesa
->setup
.pm4_vc_fpu_setup
= (R128_FRONT_DIR_CCW
|
1359 R128_BACKFACE_SOLID
|
1360 R128_FRONTFACE_SOLID
|
1361 R128_FPU_COLOR_GOURAUD
|
1362 R128_FPU_SUB_PIX_4BITS
|
1364 R128_TRAP_BITS_DISABLE
|
1367 R128_FLAT_SHADE_VERTEX_OGL
|
1368 R128_FPU_ROUND_TRUNCATE
|
1371 rmesa
->setup
.setup_cntl
= (R128_COLOR_GOURAUD
|
1372 R128_PRIM_TYPE_TRI
|
1373 R128_TEXTURE_ST_MULT_W
|
1374 R128_STARTING_VERTEX_1
|
1375 R128_ENDING_VERTEX_3
|
1376 R128_SU_POLY_LINE_NOT_LAST
|
1377 R128_SUB_PIX_4BITS
);
1379 rmesa
->setup
.tex_size_pitch_c
= 0x00000000;
1380 rmesa
->setup
.constant_color_c
= 0x00ffffff;
1382 rmesa
->setup
.dp_write_mask
= 0xffffffff;
1383 rmesa
->setup
.sten_ref_mask_c
= 0xffff0000;
1384 rmesa
->setup
.plane_3d_mask_c
= 0xffffffff;
1386 rmesa
->setup
.window_xy_offset
= 0x00000000;
1388 rmesa
->setup
.scale_3d_cntl
= (R128_SCALE_DITHER_TABLE
|
1389 R128_TEX_CACHE_SIZE_FULL
|
1390 R128_DITHER_INIT_RESET
|
1391 R128_SCALE_3D_TEXMAP_SHADE
|
1392 R128_SCALE_PIX_REPLICATE
|
1393 R128_ALPHA_COMB_ADD_CLAMP
|
1395 (R128_ALPHA_BLEND_ONE
<< R128_ALPHA_BLEND_SRC_SHIFT
) |
1396 (R128_ALPHA_BLEND_ZERO
<< R128_ALPHA_BLEND_DST_SHIFT
) |
1397 R128_ALPHA_TEST_ALWAYS
|
1398 R128_COMPOSITE_SHADOW_CMP_EQUAL
|
1399 R128_TEX_MAP_ALPHA_IN_TEXTURE
|
1400 R128_TEX_CACHE_LINE_SIZE_4QW
);
1402 rmesa
->new_state
= R128_NEW_ALL
;
1405 /* Initialize the driver's state functions.
1407 void r128DDInitStateFuncs( struct gl_context
*ctx
)
1409 ctx
->Driver
.UpdateState
= r128DDInvalidateState
;
1411 ctx
->Driver
.ClearColor
= r128DDClearColor
;
1412 ctx
->Driver
.ClearStencil
= r128DDClearStencil
;
1413 ctx
->Driver
.DrawBuffer
= r128DDDrawBuffer
;
1414 ctx
->Driver
.ReadBuffer
= r128DDReadBuffer
;
1416 ctx
->Driver
.ColorMask
= r128DDColorMask
;
1417 ctx
->Driver
.AlphaFunc
= r128DDAlphaFunc
;
1418 ctx
->Driver
.BlendEquationSeparate
= r128DDBlendEquationSeparate
;
1419 ctx
->Driver
.BlendFuncSeparate
= r128DDBlendFuncSeparate
;
1420 ctx
->Driver
.ClearDepth
= r128DDClearDepth
;
1421 ctx
->Driver
.CullFace
= r128DDCullFace
;
1422 ctx
->Driver
.FrontFace
= r128DDFrontFace
;
1423 ctx
->Driver
.DepthFunc
= r128DDDepthFunc
;
1424 ctx
->Driver
.DepthMask
= r128DDDepthMask
;
1425 ctx
->Driver
.Enable
= r128DDEnable
;
1426 ctx
->Driver
.Fogfv
= r128DDFogfv
;
1427 ctx
->Driver
.Hint
= NULL
;
1428 ctx
->Driver
.Lightfv
= NULL
;
1429 ctx
->Driver
.LightModelfv
= r128DDLightModelfv
;
1430 ctx
->Driver
.LogicOpcode
= r128DDLogicOpCode
;
1431 ctx
->Driver
.PolygonMode
= NULL
;
1432 ctx
->Driver
.PolygonStipple
= r128DDPolygonStipple
;
1433 ctx
->Driver
.RenderMode
= r128DDRenderMode
;
1434 ctx
->Driver
.Scissor
= r128DDScissor
;
1435 ctx
->Driver
.ShadeModel
= r128DDShadeModel
;
1436 ctx
->Driver
.StencilFuncSeparate
= r128DDStencilFuncSeparate
;
1437 ctx
->Driver
.StencilMaskSeparate
= r128DDStencilMaskSeparate
;
1438 ctx
->Driver
.StencilOpSeparate
= r128DDStencilOpSeparate
;
1440 ctx
->Driver
.DepthRange
= r128DepthRange
;
1441 ctx
->Driver
.Viewport
= r128Viewport
;