1 /**************************************************************************
3 Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
4 Copyright 2003 Eric Anholt
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 ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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 **************************************************************************/
27 /* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
31 * Sung-Ching Lin <sclin@sis.com.tw>
32 * Eric Anholt <anholt@FreeBSD.org>
37 #include "sis_context.h"
38 #include "sis_state.h"
41 #include "sis_stencil.h"
44 #include "sis_alloc.h"
48 #include "extensions.h"
50 #include "framebuffer.h"
52 #include "drivers/common/driverfuncs.h"
54 #include "swrast/swrast.h"
55 #include "swrast_setup/swrast_setup.h"
56 #include "array_cache/acache.h"
59 #include "tnl/t_pipeline.h"
61 #define need_GL_ARB_multisample
62 #define need_GL_ARB_texture_compression
63 #define need_GL_EXT_fog_coord
64 #define need_GL_EXT_secondary_color
65 #include "extension_helper.h"
71 int GlobalCurrentHwcx
= -1;
72 int GlobalHwcxCountBase
= 1;
73 int GlobalCmdQueueLen
= 0;
75 struct dri_extension card_extensions
[] =
77 { "GL_ARB_multisample", GL_ARB_multisample_functions
},
78 { "GL_ARB_multitexture", NULL
},
79 { "GL_ARB_texture_border_clamp", NULL
},
80 { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions
},
81 { "GL_ARB_texture_mirrored_repeat", NULL
},
82 /*{ "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },*/
83 { "GL_EXT_texture_lod_bias", NULL
},
84 { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions
},
85 { "GL_EXT_stencil_wrap", NULL
},
86 { "GL_MESA_ycbcr_texture", NULL
},
87 { "GL_NV_blend_square", NULL
},
91 struct dri_extension card_extensions_6326
[] =
93 { "GL_ARB_multisample", GL_ARB_multisample_functions
},
94 /*{ "GL_ARB_texture_border_clamp", NULL },*/
95 { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions
},
96 /*{ "GL_ARB_texture_mirrored_repeat", NULL },*/
97 /*{ "GL_MESA_ycbcr_texture", NULL },*/
101 static const struct dri_debug_control debug_control
[] =
103 { "fall", DEBUG_FALLBACKS
},
108 WaitEngIdle (sisContextPtr smesa
)
114 engineState
= MMIO_READ(REG_3D_EngineFire
); /* XXX right reg? */
115 } while ((engineState
& ENG_3DIDLEQE
) != 0);
118 engineState
= MMIO_READ(REG_CommandQueue
);
119 } while ((engineState
& SiS_EngIdle
) != SiS_EngIdle
);
124 Wait2DEngIdle (sisContextPtr smesa
)
130 engineState
= MMIO_READ(REG_6326_BitBlt_Cmd
);
131 } while ((engineState
& BLT_BUSY
) != 0);
134 engineState
= MMIO_READ(REG_CommandQueue
);
135 } while ((engineState
& SiS_EngIdle2d
) != SiS_EngIdle2d
);
139 /* To be called from mWait3DCmdQueue. Separate function for profiling
140 * purposes, and speed doesn't matter because we're spinning anyway.
143 WaitingFor3dIdle(sisContextPtr smesa
, int wLen
)
146 while (*(smesa
->CurrentQueueLenPtr
) < wLen
) {
147 *(smesa
->CurrentQueueLenPtr
) =
148 ((GLuint
)MMIO_READ(REG_3D_EngineFire
) >> 16) * 2;
151 while (*(smesa
->CurrentQueueLenPtr
) < wLen
) {
152 *(smesa
->CurrentQueueLenPtr
) =
153 (MMIO_READ(REG_CommandQueue
) & MASK_QueueLen
) - 20;
158 void sisReAllocateBuffers(GLcontext
*ctx
, GLframebuffer
*drawbuffer
,
159 GLuint width
, GLuint height
)
161 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
163 sisUpdateBufferSize(smesa
);
165 _mesa_resize_framebuffer(ctx
, drawbuffer
, width
, height
);
169 sisCreateContext( const __GLcontextModes
*glVisual
,
170 __DRIcontextPrivate
*driContextPriv
,
171 void *sharedContextPrivate
)
173 GLcontext
*ctx
, *shareCtx
;
174 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
176 sisScreenPtr sisScreen
;
178 struct dd_function_table functions
;
180 smesa
= (sisContextPtr
)CALLOC( sizeof(*smesa
) );
184 /* Init default driver functions then plug in our SIS-specific functions
185 * (the texture functions are especially important)
187 _mesa_init_driver_functions(&functions
);
188 sisInitDriverFuncs(&functions
);
189 sisInitTextureFuncs(&functions
);
191 /* Allocate the Mesa context */
192 if (sharedContextPrivate
)
193 shareCtx
= ((sisContextPtr
)sharedContextPrivate
)->glCtx
;
196 smesa
->glCtx
= _mesa_create_context( glVisual
, shareCtx
,
197 &functions
, (void *) smesa
);
202 driContextPriv
->driverPrivate
= smesa
;
205 sisScreen
= smesa
->sisScreen
= (sisScreenPtr
)(sPriv
->private);
207 smesa
->is6326
= GL_FALSE
; /* XXX */
208 smesa
->driContext
= driContextPriv
;
209 smesa
->driScreen
= sPriv
;
210 smesa
->driDrawable
= NULL
;
211 smesa
->hHWContext
= driContextPriv
->hHWContext
;
212 smesa
->driHwLock
= &sPriv
->pSAREA
->lock
;
213 smesa
->driFd
= sPriv
->fd
;
215 smesa
->virtualX
= sisScreen
->screenX
;
216 smesa
->virtualY
= sisScreen
->screenY
;
217 smesa
->bytesPerPixel
= sisScreen
->cpp
;
218 smesa
->IOBase
= sisScreen
->mmio
.map
;
219 smesa
->Chipset
= sisScreen
->deviceID
;
221 smesa
->FbBase
= sPriv
->pFB
;
222 smesa
->displayWidth
= sPriv
->fbWidth
;
223 smesa
->front
.pitch
= sPriv
->fbStride
;
225 smesa
->sarea
= (SISSAREAPriv
*)((char *)sPriv
->pSAREA
+
226 sisScreen
->sarea_priv_offset
);
228 /* support ARGB8888 and RGB565 */
229 switch (smesa
->bytesPerPixel
)
232 smesa
->redMask
= 0x00ff0000;
233 smesa
->greenMask
= 0x0000ff00;
234 smesa
->blueMask
= 0x000000ff;
235 smesa
->alphaMask
= 0xff000000;
236 smesa
->colorFormat
= DST_FORMAT_ARGB_8888
;
239 smesa
->redMask
= 0xf800;
240 smesa
->greenMask
= 0x07e0;
241 smesa
->blueMask
= 0x001f;
242 smesa
->alphaMask
= 0;
243 smesa
->colorFormat
= DST_FORMAT_RGB_565
;
246 sis_fatal_error("Bad bytesPerPixel %d.\n", smesa
->bytesPerPixel
);
250 ctx
->Const
.MaxTextureUnits
= 1;
251 ctx
->Const
.MaxTextureLevels
= 9;
253 ctx
->Const
.MaxTextureUnits
= 2;
254 ctx
->Const
.MaxTextureLevels
= 11;
256 ctx
->Const
.MaxTextureImageUnits
= ctx
->Const
.MaxTextureUnits
;
257 ctx
->Const
.MaxTextureCoordUnits
= ctx
->Const
.MaxTextureUnits
;
259 /* Parse configuration files */
260 driParseConfigFiles (&smesa
->optionCache
, &sisScreen
->optionCache
,
261 sisScreen
->driScreen
->myNum
, "sis");
264 SIS_DEBUG
= driParseDebugString(getenv("SIS_DEBUG"), debug_control
);
267 /* TODO: index mode */
269 smesa
->CurrentQueueLenPtr
= &(smesa
->sarea
->QueueLength
);
270 smesa
->FrameCountPtr
= &(smesa
->sarea
->FrameCount
);
273 smesa
->AGPSize
= sisScreen
->agp
.size
;
274 smesa
->AGPBase
= sisScreen
->agp
.map
;
275 smesa
->AGPAddr
= sisScreen
->agpBaseOffset
;
277 /* Create AGP command buffer */
278 if (smesa
->AGPSize
!= 0 &&
279 !driQueryOptionb(&smesa
->optionCache
, "agp_disable"))
281 smesa
->vb
= sisAllocAGP(smesa
, 64 * 1024, &smesa
->vb_agp_handle
);
282 if (smesa
->vb
!= NULL
) {
283 smesa
->using_agp
= GL_TRUE
;
284 smesa
->vb_cur
= smesa
->vb
;
285 smesa
->vb_last
= smesa
->vb
;
286 smesa
->vb_end
= smesa
->vb
+ 64 * 1024;
287 smesa
->vb_agp_offset
= ((long)smesa
->vb
- (long)smesa
->AGPBase
+
288 (long)smesa
->AGPAddr
);
291 if (!smesa
->using_agp
) {
292 smesa
->vb
= malloc(64 * 1024);
293 if (smesa
->vb
== NULL
) {
297 smesa
->vb_cur
= smesa
->vb
;
298 smesa
->vb_last
= smesa
->vb
;
299 smesa
->vb_end
= smesa
->vb
+ 64 * 1024;
302 smesa
->GlobalFlag
= 0L;
306 /* Initialize the software rasterizer and helper modules.
308 _swrast_CreateContext( ctx
);
309 _ac_CreateContext( ctx
);
310 _tnl_CreateContext( ctx
);
311 _swsetup_CreateContext( ctx
);
313 _swrast_allow_pixel_fog( ctx
, GL_TRUE
);
314 _swrast_allow_vertex_fog( ctx
, GL_FALSE
);
315 _tnl_allow_pixel_fog( ctx
, GL_TRUE
);
316 _tnl_allow_vertex_fog( ctx
, GL_FALSE
);
318 /* XXX these should really go right after _mesa_init_driver_functions() */
320 sis6326DDInitStateFuncs( ctx
);
321 sis6326DDInitState( smesa
); /* Initializes smesa->zFormat, important */
323 sisDDInitStateFuncs( ctx
);
324 sisDDInitState( smesa
); /* Initializes smesa->zFormat, important */
325 sisDDInitStencilFuncs( ctx
);
327 sisInitTriFuncs( ctx
);
328 sisDDInitSpanFuncs( ctx
);
330 driInitExtensions( ctx
, card_extensions
, GL_FALSE
);
332 for (i
= 0; i
< SIS_MAX_TEXTURES
; i
++) {
333 smesa
->TexStates
[i
] = 0;
334 smesa
->PrevTexFormat
[i
] = 0;
337 if (driQueryOptionb(&smesa
->optionCache
, "no_rast")) {
338 fprintf(stderr
, "disabling 3D acceleration\n");
339 FALLBACK(smesa
, SIS_FALLBACK_DISABLE
, 1);
341 smesa
->texture_depth
= driQueryOptioni(&smesa
->optionCache
, "texture_depth");
347 sisDestroyContext ( __DRIcontextPrivate
*driContextPriv
)
349 sisContextPtr smesa
= (sisContextPtr
)driContextPriv
->driverPrivate
;
351 assert( smesa
!= NULL
);
353 if ( smesa
!= NULL
) {
354 _swsetup_DestroyContext( smesa
->glCtx
);
355 _tnl_DestroyContext( smesa
->glCtx
);
356 _ac_DestroyContext( smesa
->glCtx
);
357 _swrast_DestroyContext( smesa
->glCtx
);
359 if (smesa
->using_agp
)
360 sisFreeAGP(smesa
, smesa
->vb_agp_handle
);
362 /* free the Mesa context */
363 /* XXX: Is the next line needed? The DriverCtx (smesa) reference is
364 * needed for sisDDDeleteTexture, since it needs to call the FB/AGP free
367 /* smesa->glCtx->DriverCtx = NULL; */
368 _mesa_destroy_context(smesa
->glCtx
);
375 sisMakeCurrent( __DRIcontextPrivate
*driContextPriv
,
376 __DRIdrawablePrivate
*driDrawPriv
,
377 __DRIdrawablePrivate
*driReadPriv
)
379 if ( driContextPriv
) {
380 GET_CURRENT_CONTEXT(ctx
);
381 sisContextPtr oldSisCtx
= ctx
? SIS_CONTEXT(ctx
) : NULL
;
382 sisContextPtr newSisCtx
= (sisContextPtr
) driContextPriv
->driverPrivate
;
383 struct gl_framebuffer
*drawBuffer
, *readBuffer
;
385 if ( newSisCtx
!= oldSisCtx
) {
386 newSisCtx
->GlobalFlag
= GFLAG_ALL
;
389 newSisCtx
->driDrawable
= driDrawPriv
;
391 drawBuffer
= (GLframebuffer
*)driDrawPriv
->driverPrivate
;
392 readBuffer
= (GLframebuffer
*)driReadPriv
->driverPrivate
;
394 _mesa_make_current( newSisCtx
->glCtx
, drawBuffer
, readBuffer
);
396 sisUpdateBufferSize( newSisCtx
);
397 sisUpdateClipping( newSisCtx
->glCtx
);
399 _mesa_make_current( NULL
, NULL
, NULL
);
406 sisUnbindContext( __DRIcontextPrivate
*driContextPriv
)
412 sis_update_render_state( sisContextPtr smesa
)
414 __GLSiSHardware
*prev
= &smesa
->prev
;
416 mWait3DCmdQueue (45);
418 if (smesa
->GlobalFlag
& GFLAG_ENABLESETTING
) {
419 if (!smesa
->clearTexCache
) {
420 MMIO(REG_3D_TEnable
, prev
->hwCapEnable
);
422 MMIO(REG_3D_TEnable
, prev
->hwCapEnable
| MASK_TextureCacheClear
);
423 MMIO(REG_3D_TEnable
, prev
->hwCapEnable
);
424 smesa
->clearTexCache
= GL_FALSE
;
428 if (smesa
->GlobalFlag
& GFLAG_ENABLESETTING2
)
429 MMIO(REG_3D_TEnable2
, prev
->hwCapEnable2
);
432 if (smesa
->GlobalFlag
& GFLAG_ZSETTING
)
434 MMIO(REG_3D_ZSet
, prev
->hwZ
);
435 MMIO(REG_3D_ZStWriteMask
, prev
->hwZMask
);
436 MMIO(REG_3D_ZAddress
, prev
->hwOffsetZ
);
440 if (smesa
->GlobalFlag
& GFLAG_ALPHASETTING
)
441 MMIO(REG_3D_AlphaSet
, prev
->hwAlpha
);
443 if (smesa
->GlobalFlag
& GFLAG_DESTSETTING
) {
444 MMIO(REG_3D_DstSet
, prev
->hwDstSet
);
445 MMIO(REG_3D_DstAlphaWriteMask
, prev
->hwDstMask
);
446 MMIO(REG_3D_DstAddress
, prev
->hwOffsetDest
);
451 if (smesa
->GlobalFlag
& GFLAG_LINESETTING
)
452 MMIO(REG_3D_LinePattern
, prev
->hwLinePattern
);
456 if (smesa
->GlobalFlag
& GFLAG_FOGSETTING
)
458 MMIO(REG_3D_FogSet
, prev
->hwFog
);
459 MMIO(REG_3D_FogInverseDistance
, prev
->hwFogInverse
);
460 MMIO(REG_3D_FogFarDistance
, prev
->hwFogFar
);
461 MMIO(REG_3D_FogFactorDensity
, prev
->hwFogDensity
);
464 /* Stencil Setting */
465 if (smesa
->GlobalFlag
& GFLAG_STENCILSETTING
) {
466 MMIO(REG_3D_StencilSet
, prev
->hwStSetting
);
467 MMIO(REG_3D_StencilSet2
, prev
->hwStSetting2
);
470 /* Miscellaneous Setting */
471 if (smesa
->GlobalFlag
& GFLAG_DSTBLEND
)
472 MMIO(REG_3D_DstBlendMode
, prev
->hwDstSrcBlend
);
473 if (smesa
->GlobalFlag
& GFLAG_CLIPPING
) {
474 MMIO(REG_3D_ClipTopBottom
, prev
->clipTopBottom
);
475 MMIO(REG_3D_ClipLeftRight
, prev
->clipLeftRight
);
478 smesa
->GlobalFlag
&= ~GFLAG_RENDER_STATES
;
482 sis_update_texture_state (sisContextPtr smesa
)
484 __GLSiSHardware
*prev
= &smesa
->prev
;
486 mWait3DCmdQueue (55);
487 if (smesa
->clearTexCache
|| (smesa
->GlobalFlag
& GFLAG_TEXTUREADDRESS
)) {
488 MMIO(REG_3D_TEnable
, prev
->hwCapEnable
| MASK_TextureCacheClear
);
489 MMIO(REG_3D_TEnable
, prev
->hwCapEnable
);
490 smesa
->clearTexCache
= GL_FALSE
;
493 /* Texture Setting */
494 if (smesa
->GlobalFlag
& CFLAG_TEXTURERESET
)
495 MMIO(REG_3D_TextureSet
, prev
->texture
[0].hwTextureSet
);
497 if (smesa
->GlobalFlag
& GFLAG_TEXTUREMIPMAP
)
498 MMIO(REG_3D_TextureMip
, prev
->texture
[0].hwTextureMip
);
501 MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh);
502 MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow);
505 if (smesa
->GlobalFlag
& GFLAG_TEXBORDERCOLOR
)
506 MMIO(REG_3D_TextureBorderColor
, prev
->texture
[0].hwTextureBorderColor
);
508 if (smesa
->GlobalFlag
& GFLAG_TEXTUREADDRESS
) {
509 switch ((prev
->texture
[0].hwTextureSet
& MASK_TextureLevel
) >> 8)
512 MMIO(REG_3D_TextureAddress11
, prev
->texture
[0].texOffset11
);
514 MMIO(REG_3D_TextureAddress10
, prev
->texture
[0].texOffset10
);
515 MMIO(REG_3D_TexturePitch10
, prev
->texture
[0].texPitch10
);
517 MMIO(REG_3D_TextureAddress9
, prev
->texture
[0].texOffset9
);
519 MMIO(REG_3D_TextureAddress8
, prev
->texture
[0].texOffset8
);
520 MMIO(REG_3D_TexturePitch8
, prev
->texture
[0].texPitch89
);
522 MMIO(REG_3D_TextureAddress7
, prev
->texture
[0].texOffset7
);
524 MMIO(REG_3D_TextureAddress6
, prev
->texture
[0].texOffset6
);
525 MMIO(REG_3D_TexturePitch6
, prev
->texture
[0].texPitch67
);
527 MMIO(REG_3D_TextureAddress5
, prev
->texture
[0].texOffset5
);
529 MMIO(REG_3D_TextureAddress4
, prev
->texture
[0].texOffset4
);
530 MMIO(REG_3D_TexturePitch4
, prev
->texture
[0].texPitch45
);
532 MMIO(REG_3D_TextureAddress3
, prev
->texture
[0].texOffset3
);
534 MMIO(REG_3D_TextureAddress2
, prev
->texture
[0].texOffset2
);
535 MMIO(REG_3D_TexturePitch2
, prev
->texture
[0].texPitch23
);
537 MMIO(REG_3D_TextureAddress1
, prev
->texture
[0].texOffset1
);
539 MMIO(REG_3D_TextureAddress0
, prev
->texture
[0].texOffset0
);
540 MMIO(REG_3D_TexturePitch0
, prev
->texture
[0].texPitch01
);
543 if (smesa
->GlobalFlag
& CFLAG_TEXTURERESET_1
)
544 MMIO(REG_3D_Texture1Set
, prev
->texture
[1].hwTextureSet
);
545 if (smesa
->GlobalFlag
& GFLAG_TEXTUREMIPMAP_1
)
546 MMIO(REG_3D_Texture1Mip
, prev
->texture
[1].hwTextureMip
);
548 if (smesa
->GlobalFlag
& GFLAG_TEXBORDERCOLOR_1
) {
549 MMIO(REG_3D_Texture1BorderColor
,
550 prev
->texture
[1].hwTextureBorderColor
);
552 if (smesa
->GlobalFlag
& GFLAG_TEXTUREADDRESS_1
) {
553 switch ((prev
->texture
[1].hwTextureSet
& MASK_TextureLevel
) >> 8)
556 MMIO(REG_3D_Texture1Address11
, prev
->texture
[1].texOffset11
);
558 MMIO(REG_3D_Texture1Address10
, prev
->texture
[1].texOffset10
);
559 MMIO(REG_3D_Texture1Pitch10
, prev
->texture
[1].texPitch10
);
561 MMIO(REG_3D_Texture1Address9
, prev
->texture
[1].texOffset9
);
563 MMIO(REG_3D_Texture1Address8
, prev
->texture
[1].texOffset8
);
564 MMIO(REG_3D_Texture1Pitch8
, prev
->texture
[1].texPitch89
);
566 MMIO(REG_3D_Texture1Address7
, prev
->texture
[1].texOffset7
);
568 MMIO(REG_3D_Texture1Address6
, prev
->texture
[1].texOffset6
);
569 MMIO(REG_3D_Texture1Pitch6
, prev
->texture
[1].texPitch67
);
571 MMIO(REG_3D_Texture1Address5
, prev
->texture
[1].texOffset5
);
573 MMIO(REG_3D_Texture1Address4
, prev
->texture
[1].texOffset4
);
574 MMIO(REG_3D_Texture1Pitch4
, prev
->texture
[1].texPitch45
);
576 MMIO(REG_3D_Texture1Address3
, prev
->texture
[1].texOffset3
);
578 MMIO(REG_3D_Texture1Address2
, prev
->texture
[1].texOffset2
);
579 MMIO(REG_3D_Texture1Pitch2
, prev
->texture
[1].texPitch23
);
581 MMIO(REG_3D_Texture1Address1
, prev
->texture
[1].texOffset1
);
583 MMIO(REG_3D_Texture1Address0
, prev
->texture
[1].texOffset0
);
584 MMIO(REG_3D_Texture1Pitch0
, prev
->texture
[1].texPitch01
);
588 /* texture environment */
589 if (smesa
->GlobalFlag
& GFLAG_TEXTUREENV
) {
590 MMIO(REG_3D_TextureBlendFactor
, prev
->hwTexEnvColor
);
591 MMIO(REG_3D_TextureColorBlendSet0
, prev
->hwTexBlendColor0
);
592 MMIO(REG_3D_TextureAlphaBlendSet0
, prev
->hwTexBlendAlpha0
);
594 if (smesa
->GlobalFlag
& GFLAG_TEXTUREENV_1
) {
595 MMIO(REG_3D_TextureBlendFactor
, prev
->hwTexEnvColor
);
596 MMIO(REG_3D_TextureColorBlendSet1
, prev
->hwTexBlendColor1
);
597 MMIO(REG_3D_TextureAlphaBlendSet1
, prev
->hwTexBlendAlpha1
);
600 smesa
->GlobalFlag
&= ~GFLAG_TEXTURE_STATES
;
604 sis6326_update_render_state( sisContextPtr smesa
)
606 __GLSiSHardware
*prev
= &smesa
->prev
;
608 mWait3DCmdQueue (45);
610 if (smesa
->GlobalFlag
& GFLAG_ENABLESETTING
) {
611 if (!smesa
->clearTexCache
) {
612 MMIO(REG_6326_3D_TEnable
, prev
->hwCapEnable
);
614 MMIO(REG_6326_3D_TEnable
, prev
->hwCapEnable
& ~S_ENABLE_TextureCache
);
615 MMIO(REG_6326_3D_TEnable
, prev
->hwCapEnable
);
616 smesa
->clearTexCache
= GL_FALSE
;
621 if (smesa
->GlobalFlag
& GFLAG_ZSETTING
) {
622 MMIO(REG_6326_3D_ZSet
, prev
->hwZ
);
623 MMIO(REG_6326_3D_ZAddress
, prev
->hwOffsetZ
);
627 if (smesa
->GlobalFlag
& GFLAG_ALPHASETTING
)
628 MMIO(REG_6326_3D_AlphaSet
, prev
->hwAlpha
);
630 if (smesa
->GlobalFlag
& GFLAG_DESTSETTING
) {
631 MMIO(REG_6326_3D_DstSet
, prev
->hwDstSet
);
632 MMIO(REG_6326_3D_DstAddress
, prev
->hwOffsetDest
);
636 if (smesa
->GlobalFlag
& GFLAG_FOGSETTING
) {
637 MMIO(REG_6326_3D_FogSet
, prev
->hwFog
);
640 /* Miscellaneous Setting */
641 if (smesa
->GlobalFlag
& GFLAG_DSTBLEND
)
642 MMIO(REG_6326_3D_DstSrcBlendMode
, prev
->hwDstSrcBlend
);
644 if (smesa
->GlobalFlag
& GFLAG_CLIPPING
) {
645 MMIO(REG_6326_3D_ClipTopBottom
, prev
->clipTopBottom
);
646 MMIO(REG_6326_3D_ClipLeftRight
, prev
->clipLeftRight
);
649 smesa
->GlobalFlag
&= ~GFLAG_RENDER_STATES
;
653 sis6326_update_texture_state (sisContextPtr smesa
)
655 __GLSiSHardware
*prev
= &smesa
->prev
;
657 mWait3DCmdQueue (55);
658 if (smesa
->clearTexCache
|| (smesa
->GlobalFlag
& GFLAG_TEXTUREADDRESS
)) {
659 MMIO(REG_6326_3D_TEnable
, prev
->hwCapEnable
& ~S_ENABLE_TextureCache
);
660 MMIO(REG_6326_3D_TEnable
, prev
->hwCapEnable
);
661 smesa
->clearTexCache
= GL_FALSE
;
664 /* Texture Setting */
665 if (smesa
->GlobalFlag
& CFLAG_TEXTURERESET
)
666 MMIO(REG_6326_3D_TextureSet
, prev
->texture
[0].hwTextureSet
);
668 if (smesa
->GlobalFlag
& GFLAG_TEXTUREMIPMAP
)
669 MMIO(REG_6326_3D_TextureWidthHeight
, prev
->texture
[0].hwTexWidthHeight
);
672 MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh);
673 MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow);
676 if (smesa
->GlobalFlag
& GFLAG_TEXBORDERCOLOR
)
677 MMIO(REG_6326_3D_TextureBorderColor
, prev
->texture
[0].hwTextureBorderColor
);
679 if (smesa
->GlobalFlag
& GFLAG_TEXTUREADDRESS
) {
680 switch ((prev
->texture
[0].hwTextureSet
& MASK_6326_TextureLevel
) >> 8)
683 MMIO(REG_6326_3D_TextureAddress9
, prev
->texture
[0].texOffset9
);
686 MMIO(REG_6326_3D_TextureAddress8
, prev
->texture
[0].texOffset8
);
687 MMIO(REG_6326_3D_TexturePitch89
, prev
->texture
[0].texPitch89
);
690 MMIO(REG_6326_3D_TextureAddress7
, prev
->texture
[0].texOffset7
);
693 MMIO(REG_6326_3D_TextureAddress6
, prev
->texture
[0].texOffset6
);
694 MMIO(REG_6326_3D_TexturePitch67
, prev
->texture
[0].texPitch67
);
697 MMIO(REG_6326_3D_TextureAddress5
, prev
->texture
[0].texOffset5
);
700 MMIO(REG_6326_3D_TextureAddress4
, prev
->texture
[0].texOffset4
);
701 MMIO(REG_6326_3D_TexturePitch45
, prev
->texture
[0].texPitch45
);
704 MMIO(REG_6326_3D_TextureAddress3
, prev
->texture
[0].texOffset3
);
707 MMIO(REG_6326_3D_TextureAddress2
, prev
->texture
[0].texOffset2
);
708 MMIO(REG_6326_3D_TexturePitch23
, prev
->texture
[0].texPitch23
);
711 MMIO(REG_6326_3D_TextureAddress1
, prev
->texture
[0].texOffset1
);
714 MMIO(REG_6326_3D_TextureAddress0
, prev
->texture
[0].texOffset0
);
715 MMIO(REG_6326_3D_TexturePitch01
, prev
->texture
[0].texPitch01
);
720 /* texture environment */
721 if (smesa
->GlobalFlag
& GFLAG_TEXTUREENV
) {
722 MMIO(REG_6326_3D_TextureBlendSet
, prev
->hwTexBlendSet
);
725 smesa
->GlobalFlag
&= ~GFLAG_TEXTURE_STATES
;