diff -ruN ../xc/xc/config/cf/host.def xc/config/cf/host.def --- ../xc/xc/config/cf/host.def Sun Aug 10 22:45:22 2003 +++ xc/config/cf/host.def Sun Aug 10 22:44:42 2003 @@ -4,6 +4,8 @@ */ #define XFree86CustomVersion "DRI trunk" +#define DefaultGcc2i386Opt -O2 GccAliasingArgs +#define LibraryCDebugFlags -O2 GccAliasingArgs /* Don't use any special flags by default, but leave this here commented out * so people see how to if they want @@ -32,7 +34,7 @@ #else #define XF86CardDrivers tdfx i810 mga ati glint vga -#define DriDrivers r200 tdfx mga i810 r128 radeon gamma i830 ffb /* sis */ +#define DriDrivers r200 tdfx mga i810 r128 radeon gamma i830 ffb sis #endif diff -ruN ../xc/xc/extras/Mesa/include/GL/glxext.h xc/extras/Mesa/include/GL/glxext.h --- ../xc/xc/extras/Mesa/include/GL/glxext.h Sun Aug 10 22:45:25 2003 +++ xc/extras/Mesa/include/GL/glxext.h Sun Aug 10 22:44:46 2003 @@ -597,7 +597,7 @@ #define GLX_OML_swap_method 1 #endif -#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || defined(_STDINT_H) || defined(_SYS_INTTYPES_H_) +#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || defined(_STDINT_H) || defined(_SYS_INTTYPES_H_) || 1 /* Include ISO C99 integer types for OML_sync_control; need a better test */ #include diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/Imakefile.inc xc/lib/GL/mesa/src/drv/sis/Imakefile.inc --- ../xc/xc/lib/GL/mesa/src/drv/sis/Imakefile.inc Sun Aug 10 22:45:32 2003 +++ xc/lib/GL/mesa/src/drv/sis/Imakefile.inc Sun Aug 10 22:44:55 2003 @@ -17,14 +17,16 @@ #if BuildXF86DRI DRI_DEFINES = GlxDefines $(SIS_DEFINES) - DRI_INCLUDES = -I$(GLXLIBSRC)/dri -I$(GLXLIBSRC)/glx \ - -I$(INCLUDESRC) -I$(INCLUDESRC)/GL \ - -I$(GLXLIBSRC)/mesa/dri \ + DRI_INCLUDES = -I$(GLXLIBSRC)/dri \ + -I$(GLXLIBSRC)/glx \ + -I$(INCLUDESRC) \ + -I$(INCLUDESRC)/GL \ -I$(SERVERSRC)/GL/dri \ -I$(XF86OSSRC) \ -I$(XF86DRIVERSRC)/sis \ + -I$(XF86COMSRC) \ -I$(GLXLIBSRC)/dri/drm \ - -I$(GLXLIBSRC)/mesa/src/X + -I$(GLXLIBSRC)/include #endif MESA_INCLUDES = -I$(MESASRCDIR)/src -I$(MESASRCDIR)/include \ @@ -58,8 +60,10 @@ #endif SISSRCS = $(MESADRVSISBUILDDIR)sis_render.c \ + $(MESADRVSISBUILDDIR)sis_dd.c \ + $(MESADRVSISBUILDDIR)sis_lock.c \ $(MESADRVSISBUILDDIR)sis_mesa.c \ - $(MESADRVSISBUILDDIR)sis_ctx.c \ + $(MESADRVSISBUILDDIR)sis_context.c \ $(MESADRVSISBUILDDIR)sis_alloc.c \ $(MESADRVSISBUILDDIR)sis_fog.c \ $(MESADRVSISBUILDDIR)sis_clear.c \ @@ -73,8 +77,10 @@ $(STEREO_SRC) SISOBJS = $(MESADRVSISBUILDDIR)sis_render.o \ + $(MESADRVSISBUILDDIR)sis_dd.o \ + $(MESADRVSISBUILDDIR)sis_lock.o \ $(MESADRVSISBUILDDIR)sis_mesa.o \ - $(MESADRVSISBUILDDIR)sis_ctx.o \ + $(MESADRVSISBUILDDIR)sis_context.o \ $(MESADRVSISBUILDDIR)sis_alloc.o \ $(MESADRVSISBUILDDIR)sis_fog.o \ $(MESADRVSISBUILDDIR)sis_clear.o \ @@ -88,8 +94,10 @@ $(STEREO_OBJ) SISUOBJS = $(MESADRVSISBUILDDIR)unshared/sis_render.o \ + $(MESADRVSISBUILDDIR)unshared/sis_dd.o \ + $(MESADRVSISBUILDDIR)unshared/sis_lock.o \ $(MESADRVSISBUILDDIR)unshared/sis_mesa.o \ - $(MESADRVSISBUILDDIR)unshared/sis_ctx.o \ + $(MESADRVSISBUILDDIR)unshared/sis_context.o \ $(MESADRVSISBUILDDIR)unshared/sis_alloc.o \ $(MESADRVSISBUILDDIR)unshared/sis_fog.o \ $(MESADRVSISBUILDDIR)unshared/sis_clear.o \ @@ -103,8 +111,10 @@ $(STEREO_UOBJ) SISDOBJS = $(MESADRVSISBUILDDIR)debugger/sis_render.o \ + $(MESADRVSISBUILDDIR)debugger/sis_dd.o \ + $(MESADRVSISBUILDDIR)debugger/sis_lock.o \ $(MESADRVSISBUILDDIR)debugger/sis_mesa.o \ - $(MESADRVSISBUILDDIR)debugger/sis_ctx.o \ + $(MESADRVSISBUILDDIR)debugger/sis_context.o \ $(MESADRVSISBUILDDIR)debugger/sis_alloc.o \ $(MESADRVSISBUILDDIR)debugger/sis_fog.o \ $(MESADRVSISBUILDDIR)debugger/sis_clear.o \ @@ -118,8 +128,10 @@ $(STEREO_DOBJ) SISPOBJS = $(MESADRVSISBUILDDIR)profiled/sis_render.o \ + $(MESADRVSISBUILDDIR)profiled/sis_dd.o \ + $(MESADRVSISBUILDDIR)profiled/sis_lock.o \ $(MESADRVSISBUILDDIR)profiled/sis_mesa.o \ - $(MESADRVSISBUILDDIR)profiled/sis_ctx.o \ + $(MESADRVSISBUILDDIR)profiled/sis_context.o \ $(MESADRVSISBUILDDIR)profiled/sis_alloc.o \ $(MESADRVSISBUILDDIR)profiled/sis_fog.o \ $(MESADRVSISBUILDDIR)profiled/sis_clear.o \ @@ -135,7 +147,7 @@ #ifdef NeedToLinkMesaSrc LinkSourceFile(sis_render.c, $(MESADRVSRCDIR)/sis) LinkSourceFile(sis_mesa.c, $(MESADRVSRCDIR)/sis) -LinkSourceFile(sis_ctx.c, $(MESADRVSRCDIR)/sis) +LinkSourceFile(sis_context.c, $(MESADRVSRCDIR)/sis) LinkSourceFile(sis_alloc.c, $(MESADRVSRCDIR)/sis) LinkSourceFile(sis_fog.c, $(MESADRVSRCDIR)/sis) LinkSourceFile(sis_clear.c, $(MESADRVSRCDIR)/sis) diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c xc/lib/GL/mesa/src/drv/sis/sis_alloc.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c Sun Aug 10 22:45:32 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_alloc.c Sun Aug 10 22:44:55 2003 @@ -34,18 +34,11 @@ #include -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" +#include "sis_alloc.h" -#if defined(XFree86Server) && !defined(XF86DRI) -# include "xf86fbman.h" -#else -# define CONFIG_DRM_SIS -# include "drm.h" -# undef CONFIG_DRM_SIS -# include "sis_drm.h" -# include -#endif +#include "sis_common.h" #define Z_BUFFER_HW_ALIGNMENT 16 #define Z_BUFFER_HW_PLUS (16 + 4) @@ -67,161 +60,92 @@ #endif #define ALIGNMENT(value, align) (ROUNDUP((value),(align))*(align)) -#if defined(XFree86Server) && !defined(XF86DRI) - -static void * -sis_alloc_fb (__GLSiScontext * hwcx, GLuint size, void **free) -{ - GLcontext *ctx = hwcx->gc; - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - - ScreenPtr pScreen = xmesa->display; - - GLuint offset; - BoxPtr pBox; - - size = ROUNDUP (size, GET_DEPTH (hwcx)); - *free = xf86AllocateLinearOffscreenArea (pScreen, size, 1, - NULL, NULL, NULL); - - if (!*free) - return NULL; - - pBox = &((FBAreaPtr) (*free))->box; - offset = pBox->y1 * GET_PITCH (hwcx) + pBox->x1 * GET_DEPTH (hwcx); - - return GET_FbBase (hwcx) + offset; -} - -static void -sis_free_fb (int hHWContext, void *free) -{ - xf86FreeOffscreenArea ((FBAreaPtr) free); -} - -#else - -int gDRMSubFD = -1; - -/* debug */ -#if 1 - static int _total_video_memory_used = 0; static int _total_video_memory_count = 0; static void * -sis_alloc_fb (__GLSiScontext * hwcx, GLuint size, void **free) +sisAllocFB( sisContextPtr smesa, GLuint size, void **free ) { - GLcontext *ctx = hwcx->gc; - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - drm_sis_mem_t fb; _total_video_memory_used += size; - fb.context = xmesa->driContextPriv->hHWContext; + fb.context = smesa->hHWContext; fb.size = size; - if(ioctl(hwcx->drmSubFD, SIS_IOCTL_FB_ALLOC, &fb) || !fb.offset) + if (drmCommandWriteRead( smesa->driFd, DRM_SIS_FB_ALLOC, &fb, + sizeof(drm_sis_mem_t) ) || fb.offset == NULL) + { return NULL; + } *free = (void *)fb.free; - /* debug */ - /* memset(fb.offset + GET_FbBase(hwcx), 0xff, size); */ - if (SIS_VERBOSE&VERBOSE_SIS_MEMORY) { - fprintf(stderr, "sis_alloc_fb: size=%u, offset=%lu, pid=%lu, count=%d\n", - size, (DWORD)fb.offset, (DWORD)getpid(), + fprintf(stderr, "sisAllocFB: size=%d, offset=%lu, pid=%d, count=%d\n", + size, fb.offset, (GLint)getpid(), ++_total_video_memory_count); } - return (void *)(fb.offset + GET_FbBase(hwcx)); + return (void *)(fb.offset + GET_FbBase(smesa)); } static void -sis_free_fb (int hHWContext, void *free) +sisFreeFB( sisContextPtr smesa, void *free ) { drm_sis_mem_t fb; if (SIS_VERBOSE&VERBOSE_SIS_MEMORY) { - fprintf(stderr, "sis_free_fb: free=%lu, pid=%lu, count=%d\n", - (DWORD)free, (DWORD)getpid(), --_total_video_memory_count); + fprintf(stderr, "sisFreeFB: free=%p, pid=%d, count=%d\n", + free, (GLint)getpid(), --_total_video_memory_count); } - fb.context = hHWContext; - fb.free = (unsigned long)free; - ioctl(gDRMSubFD, SIS_IOCTL_FB_FREE, &fb); + fb.context = smesa->hHWContext; + fb.free = free; + drmCommandWrite( gDRMSubFD, DRM_SIS_FB_FREE, &fb, sizeof(drm_sis_mem_t) ); } -#else - static void * -sis_alloc_fb (__GLSiScontext * hwcx, GLuint size, void **free) +sisAllocAGP( sisContextPtr smesa, GLuint size, void **free ) { - static char *vidmem_base = 0x400000; - char *rval = vidmem_base; - - vidmem_base += size; - if(vidmem_base >= 31*0x100000) - return NULL; - - *free = rval + (DWORD)hwcx->FbBase; - - return rval + (DWORD)hwcx->FbBase; -} - -static void -sis_free_fb (int hHWContext, void *free) -{ - return; -} - -#endif - -#endif - -static void * -sis_alloc_agp (__GLSiScontext * hwcx, GLuint size, void **free) -{ - GLcontext *ctx = hwcx->gc; - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - drm_sis_mem_t agp; - if(!hwcx->AGPSize) + if(!smesa->AGPSize) return NULL; - agp.context = xmesa->driContextPriv->hHWContext; + agp.context = smesa->hHWContext; agp.size = size; - if(ioctl(hwcx->drmSubFD, SIS_IOCTL_AGP_ALLOC, &agp) || !agp.offset) + if (drmCommandWriteRead( smesa->driFd, DRM_SIS_AGP_ALLOC, &agp, + sizeof(drm_sis_mem_t) ) || !agp.offset) + { return NULL; + } *free = (void *)agp.free; if (SIS_VERBOSE&VERBOSE_SIS_MEMORY) { - fprintf(stderr, "sis_alloc_agp: size=%u, offset=%lu, pid=%lu, count=%d\n", - size, (DWORD)agp.offset, (DWORD)getpid(), + fprintf(stderr, "sisAllocAGP: size=%u, offset=%lu, pid=%d, count=%d\n", + size, agp.offset, (GLint)getpid(), ++_total_video_memory_count); } - return (void *)(agp.offset + GET_AGPBase(hwcx)); + return (void *)(agp.offset + GET_AGPBase(smesa)); } static void -sis_free_agp (int hHWContext, void *free) +sisFreeAGP( sisContextPtr smesa, void *free ) { drm_sis_mem_t agp; if (SIS_VERBOSE&VERBOSE_SIS_MEMORY) { - fprintf(stderr, "sis_free_agp: free=%lu, pid=%lu, count=%d\n", - (DWORD)free, (DWORD)getpid(), --_total_video_memory_count); + fprintf(stderr, "sisFreeAGP: free=%p, pid=%d, count=%d\n", + free, (GLint)getpid(), --_total_video_memory_count); } - agp.context = hHWContext; - agp.free = (unsigned long)free; - ioctl(gDRMSubFD, SIS_IOCTL_AGP_FREE, &agp); + agp.context = smesa->hHWContext; + agp.free = free; + drmCommandWrite( gDRMSubFD, DRM_SIS_AGP_FREE, &agp, sizeof(drm_sis_mem_t) ); } /* debug */ @@ -229,32 +153,22 @@ static unsigned int Total_Textures_Used = 0; void -sis_alloc_z_stencil_buffer (GLcontext * ctx) +sisAllocZStencilBuffer( sisContextPtr smesa ) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - XMesaBuffer xm_buffer = xmesa->xm_buffer; - sisBufferInfo *priv = (sisBufferInfo *) xm_buffer->private; - GLuint z_depth; GLuint totalBytes; int width2; GLubyte *addr; - z_depth = (ctx->Visual->DepthBits + ctx->Visual->StencilBits) / 8; - - width2 = ALIGNMENT (xm_buffer->width * z_depth, 4); + z_depth = ( smesa->glCtx->Visual.depthBits + + smesa->glCtx->Visual.stencilBits ) / 8; - totalBytes = xm_buffer->height * width2 + Z_BUFFER_HW_PLUS; + width2 = ALIGNMENT( smesa->width * z_depth, 4 ); - if (xm_buffer->depthbuffer) - { - sis_free_z_stencil_buffer (xm_buffer); - } + totalBytes = smesa->height * width2 + Z_BUFFER_HW_PLUS; - addr = sis_alloc_fb (hwcx, totalBytes, &priv->zbFree); + addr = sisAllocFB( smesa, totalBytes, &smesa->zbFree ); if (!addr) { fprintf (stderr, "SIS driver : out of video memory\n"); @@ -263,82 +177,66 @@ if (SIS_VERBOSE&VERBOSE_SIS_BUFFER) { - fprintf(stderr, "sis_alloc_z_stencil_buffer: addr=%lu\n", (DWORD)addr); + fprintf(stderr, "sis_alloc_z_stencil_buffer: addr=%p\n", addr); } addr = (GLubyte *) ALIGNMENT ((unsigned long) addr, Z_BUFFER_HW_ALIGNMENT); - xm_buffer->depthbuffer = (void *) addr; + smesa->depthbuffer = (void *) addr; /* software render */ - hwcx->swZBase = addr; - hwcx->swZPitch = width2; + smesa->swZBase = addr; + smesa->swZPitch = width2; /* set pZClearPacket */ - memset (priv->pZClearPacket, 0, sizeof (ENGPACKET)); + memset (&smesa->zClearPacket, 0, sizeof (ENGPACKET)); - priv->pZClearPacket->dwSrcPitch = (z_depth == 2) ? 0x80000000 : 0xf0000000; - priv->pZClearPacket->dwDestBaseAddr = - (DWORD) addr - (DWORD) GET_FbBase (hwcx); - priv->pZClearPacket->wDestPitch = width2; - priv->pZClearPacket->stdwDestPos.wY = 0; - priv->pZClearPacket->stdwDestPos.wX = 0; - - priv->pZClearPacket->wDestHeight = hwcx->virtualY; - priv->pZClearPacket->stdwDim.wWidth = (WORD) width2 / z_depth; - priv->pZClearPacket->stdwDim.wHeight = (WORD) xm_buffer->height; - priv->pZClearPacket->stdwCmd.cRop = 0xf0; + smesa->zClearPacket.dwSrcPitch = (z_depth == 2) ? 0x80000000 : 0xf0000000; + smesa->zClearPacket.dwDestBaseAddr = (GLint)addr - (GLint)GET_FbBase (smesa); + smesa->zClearPacket.wDestPitch = width2; + smesa->zClearPacket.stdwDestPos.wY = 0; + smesa->zClearPacket.stdwDestPos.wX = 0; + + smesa->zClearPacket.wDestHeight = smesa->virtualY; + smesa->zClearPacket.stdwDim.wWidth = (GLshort) width2 / z_depth; + smesa->zClearPacket.stdwDim.wHeight = (GLshort) smesa->height; + smesa->zClearPacket.stdwCmd.cRop = 0xf0; - if (hwcx->blockWrite) + if (smesa->blockWrite) { - priv->pZClearPacket->stdwCmd.cCmd0 = (BYTE) (CMD0_PAT_FG_COLOR); - priv->pZClearPacket->stdwCmd.cCmd1 = - (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); + smesa->zClearPacket.stdwCmd.cCmd0 = (GLbyte) (CMD0_PAT_FG_COLOR); + smesa->zClearPacket.stdwCmd.cCmd1 = + (GLbyte) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); } else { - priv->pZClearPacket->stdwCmd.cCmd0 = 0; - priv->pZClearPacket->stdwCmd.cCmd1 = - (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); + smesa->zClearPacket.stdwCmd.cCmd0 = 0; + smesa->zClearPacket.stdwCmd.cCmd1 = + (GLbyte) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); } } void -sis_free_z_stencil_buffer (XMesaBuffer buf) +sisFreeZStencilBuffer( sisContextPtr smesa ) { - sisBufferInfo *priv = (sisBufferInfo *) buf->private; - XMesaContext xmesa = buf->xm_context; - - sis_free_fb (xmesa->driContextPriv->hHWContext, priv->zbFree); - priv->zbFree = NULL; - buf->depthbuffer = NULL; + sisFreeFB( smesa, smesa->zbFree ); + smesa->zbFree = NULL; + smesa->depthbuffer = NULL; } void -sis_alloc_back_image (GLcontext * ctx, XMesaImage *image, void **free, - ENGPACKET *packet) +sisAllocBackbuffer( sisContextPtr smesa ) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - XMesaBuffer xm_buffer = xmesa->xm_buffer; - - GLuint depth = GET_DEPTH (hwcx); + GLuint depth = GET_DEPTH (smesa); GLuint size, width2; GLbyte *addr; - if (image->data) - { - sis_free_back_image (xm_buffer, image, *free); - *free = NULL; - } - - width2 = (depth == 2) ? ALIGNMENT (xm_buffer->width, 2) : xm_buffer->width; - size = width2 * xm_buffer->height * depth + DRAW_BUFFER_HW_PLUS; + width2 = (depth == 2) ? ALIGNMENT (smesa->width, 2) : smesa->width; + size = width2 * smesa->height * depth + DRAW_BUFFER_HW_PLUS; /* Fixme: unique context alloc/free back-buffer? */ - addr = sis_alloc_fb (hwcx, size, free); + addr = sisAllocFB( smesa, size, &smesa->bbFree ); if (!addr) { fprintf (stderr, "SIS driver : out of video memory\n"); @@ -347,53 +245,43 @@ addr = (GLbyte *) ALIGNMENT ((unsigned long) addr, DRAW_BUFFER_HW_ALIGNMENT); - image->data = (char *)addr; - - image->bytes_per_line = width2 * depth; - image->bits_per_pixel = depth * 8; - - memset (packet, 0, sizeof (ENGPACKET)); + smesa->backbuffer = (char *)addr; + smesa->backPitch = width2 * depth; - packet->dwSrcPitch = (depth == 2) ? 0x80000000 : 0xf0000000; - packet->dwDestBaseAddr = - (DWORD) addr - (DWORD) GET_FbBase (hwcx); - packet->wDestPitch = image->bytes_per_line; - packet->stdwDestPos.wY = 0; - packet->stdwDestPos.wX = 0; - - packet->wDestHeight = hwcx->virtualY; - packet->stdwDim.wWidth = (WORD) width2; - packet->stdwDim.wHeight = (WORD) xm_buffer->height; - packet->stdwCmd.cRop = 0xf0; + memset (&smesa->cbClearPacket, 0, sizeof (ENGPACKET)); - if (hwcx->blockWrite) - { - packet->stdwCmd.cCmd0 = (BYTE) (CMD0_PAT_FG_COLOR); - packet->stdwCmd.cCmd1 = - (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); - } - else - { - packet->stdwCmd.cCmd0 = 0; - packet->stdwCmd.cCmd1 = (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); - } + smesa->cbClearPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xf0000000; + smesa->cbClearPacket.dwDestBaseAddr = (GLint)addr - (GLint)GET_FbBase(smesa); + smesa->cbClearPacket.wDestPitch = smesa->backPitch; + smesa->cbClearPacket.stdwDestPos.wY = 0; + smesa->cbClearPacket.stdwDestPos.wX = 0; + + smesa->cbClearPacket.wDestHeight = smesa->virtualY; + smesa->cbClearPacket.stdwDim.wWidth = (GLshort) width2; + smesa->cbClearPacket.stdwDim.wHeight = (GLshort) smesa->height; + smesa->cbClearPacket.stdwCmd.cRop = 0xf0; + + if (smesa->blockWrite) { + smesa->cbClearPacket.stdwCmd.cCmd0 = (GLbyte) (CMD0_PAT_FG_COLOR); + smesa->cbClearPacket.stdwCmd.cCmd1 = + (GLbyte) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); + } else { + smesa->cbClearPacket.stdwCmd.cCmd0 = 0; + smesa->cbClearPacket.stdwCmd.cCmd1 = + (GLbyte) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); + } } void -sis_free_back_image (XMesaBuffer buf, XMesaImage *image, void *free) +sisFreeBackbuffer( sisContextPtr smesa ) { - XMesaContext xmesa = buf->xm_context; - - sis_free_fb (xmesa->driContextPriv->hHWContext, free); - image->data = NULL; + sisFreeFB( smesa, smesa->bbFree ); + smesa->backbuffer = NULL; } void -sis_alloc_texture_image (GLcontext * ctx, GLtextureImage * image) +sisAllocTextureImage( sisContextPtr smesa, GLtextureImage * image ) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - GLuint size; SIStextureArea *area = image->DriverData; @@ -403,7 +291,7 @@ GLenum driver_format; if (area) - sis_free_texture_image (image); + sisFreeTextureImage( smesa, image ); area = calloc (1, sizeof (SIStextureArea)); if (!area){ @@ -482,13 +370,13 @@ size = image->Width * image->Height * texel_size + TEXTURE_HW_PLUS; do{ - addr = sis_alloc_fb (hwcx, size, &area->free); + addr = sisAllocFB( smesa, size, &area->free ); area->memType = VIDEO_TYPE; if(addr) break; /* TODO: swap to agp memory*/ /* video memory allocation fails */ - addr = sis_alloc_agp(hwcx, size, &area->free); + addr = sisAllocAGP( smesa, size, &area->free ); area->memType = AGP_TYPE; if(addr) break; @@ -508,7 +396,6 @@ area->Format = driver_format; area->Size = image->Width * image->Height * texel_size; area->texelSize = texel_size; - area->hHWContext = xmesa->driContextPriv->hHWContext; /* debug */ area->realSize = area->Size; @@ -519,7 +406,7 @@ } void -sis_free_texture_image (GLtextureImage * image) +sisFreeTextureImage( sisContextPtr smesa, GLtextureImage * image ) { SIStextureArea *area = (SIStextureArea *) image->DriverData; @@ -532,11 +419,11 @@ if (area->Data) switch(area->memType){ - case VIDEO_TYPE: - sis_free_fb (area->hHWContext, area->free); + case VIDEO_TYPE: + sisFreeFB( smesa, area->free ); break; - case AGP_TYPE: - sis_free_agp (area->hHWContext, area->free); + case AGP_TYPE: + sisFreeAGP( smesa, area->free ); break; default: assert(0); diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_alloc.h xc/lib/GL/mesa/src/drv/sis/sis_alloc.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_alloc.h Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_alloc.h Sun Aug 10 22:44:55 2003 @@ -0,0 +1,40 @@ +/************************************************************************** + +Copyright 2003 Eric Anholt +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ +/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */ + +/* + * Authors: + * Eric Anholt + * + */ + +void sisAllocZStencilBuffer( sisContextPtr smesa ); +void sisFreeZStencilBuffer( sisContextPtr smesa ); +void sisAllocBackbuffer( sisContextPtr smesa ); +void sisFreeBackbuffer ( sisContextPtr smesa ); +void sisAllocTextureImage( sisContextPtr smesa, GLtextureImage * image ); +void sisFreeTextureImage( sisContextPtr smesa, GLtextureImage * image ); diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_clear.c xc/lib/GL/mesa/src/drv/sis/sis_clear.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_clear.c Sun Aug 10 22:45:32 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_clear.c Sun Aug 10 22:44:55 2003 @@ -32,8 +32,9 @@ * */ -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" +#include "sis_state.h" #include "sis_lock.h" __inline__ static GLbitfield sis_3D_Clear (GLcontext * ctx, GLbitfield mask, @@ -51,10 +52,8 @@ sis_Clear (GLcontext * ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - XMesaBuffer xm_buffer = xmesa->xm_buffer; GLint x1, y1, width1, height1; if (all) @@ -81,23 +80,23 @@ * differs from current draw buffer */ - if ((ctx->Visual->StencilBits && + if ((ctx->Visual.stencilBits && ((mask | GL_DEPTH_BUFFER_BIT) ^ (mask | GL_STENCIL_BUFFER_BIT))) - || (*(DWORD *) (ctx->Color.ColorMask) != 0xffffffff) + || (*(GLint *) (ctx->Color.ColorMask) != 0xffffffff) ) { /* only Clear either depth or stencil buffer */ mask = sis_3D_Clear (ctx, mask, x1, y1, width1, height1); } - if (mask & ctx->Color.DrawDestMask) + if (mask & ctx->Color._DrawDestMask) { sis_clear_color_buffer (ctx, x1, y1, width1, height1); - mask &= ~ctx->Color.DrawDestMask; + mask &= ~ctx->Color._DrawDestMask; } if (mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) { - if (xm_buffer->depthbuffer) + if (smesa->depthbuffer != NULL) sis_clear_z_stencil_buffer (ctx, mask, x1, y1, width1, height1); mask &= ~(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } @@ -111,38 +110,36 @@ } void -sis_ClearDepth (GLcontext * ctx, GLclampd d) +sisDDClearDepth( GLcontext * ctx, GLclampd d ) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - set_z_stencil_pattern (hwcx, d, ctx->Stencil.Clear); + set_z_stencil_pattern (smesa, d, ctx->Stencil.Clear); } void -sis_ClearStencil (GLcontext * ctx, GLint s) +sisDDClearStencil( GLcontext * ctx, GLint s ) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - set_z_stencil_pattern (hwcx, ctx->Depth.Clear, s); + set_z_stencil_pattern (smesa, ctx->Depth.Clear, s); } #define MAKE_CLEAR_COLOR_8888(cc) \ - ( (((DWORD)(((GLubyte *)(cc))[3] * 255.0 + 0.5))<<24) | \ - (((DWORD)(((GLubyte *)(cc))[0] * 255.0 + 0.5))<<16) | \ - (((DWORD)(((GLubyte *)(cc))[1] * 255.0 + 0.5))<<8) | \ - ((DWORD)(((GLubyte *)(cc))[2] * 255.0 + 0.5)) ) + ( (((GLint)(((GLubyte *)(cc))[3] * 255.0 + 0.5))<<24) | \ + (((GLint)(((GLubyte *)(cc))[0] * 255.0 + 0.5))<<16) | \ + (((GLint)(((GLubyte *)(cc))[1] * 255.0 + 0.5))<<8) | \ + ((GLint)(((GLubyte *)(cc))[2] * 255.0 + 0.5)) ) __inline__ static GLbitfield sis_3D_Clear (GLcontext * ctx, GLbitfield mask, GLint x, GLint y, GLint width, GLint height) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *current = &smesa->current; #define RESETSTATE (GFLAG_ENABLESETTING | GFLAG_ENABLESETTING2 | \ GFLAG_ZSETTING | GFLAG_DESTSETTING | \ @@ -151,27 +148,27 @@ SiS_SPASS_ZPASS_REPLACE) float left, top, right, bottom, zClearVal; - DWORD dwColor=0; - DWORD bClrColor, bClrDepth, bClrStencil; - DWORD dwPrimitiveSet; - DWORD dwEnable1, dwEnable2, dwDepthMask=0, dwSten1=0, dwSten2=0; + GLint dwColor=0; + GLint bClrColor, bClrDepth, bClrStencil; + GLint dwPrimitiveSet; + GLint dwEnable1, dwEnable2, dwDepthMask=0, dwSten1=0, dwSten2=0; int count; BoxPtr pExtents; bClrColor = 0; bClrDepth = (mask & GL_DEPTH_BUFFER_BIT) && - (ctx->Visual->DepthBits); + (ctx->Visual.depthBits); bClrStencil = (mask & GL_STENCIL_BUFFER_BIT) && - (ctx->Visual->StencilBits); + (ctx->Visual.stencilBits); /* update HW state */ /* TODO: if enclosing sis_Clear by sis_RenderStart and sis_RenderEnd is * uniform, but it seems needless to do so */ - if (hwcx->GlobalFlag) + if (smesa->GlobalFlag) { - sis_update_render_state (hwcx, 0); + sis_update_render_state (smesa, 0); } dwEnable2 = 0; @@ -186,18 +183,18 @@ if (bClrDepth && bClrStencil) { - DWORD wmask, smask; + GLint wmask, smask; GLstencil sten; zClearVal = ctx->Depth.Clear; sten = ctx->Stencil.Clear; - wmask = (DWORD) ctx->Stencil.WriteMask; + wmask = (GLint) ctx->Stencil.WriteMask; smask = 0xff; dwEnable1 = MASK_ZWriteEnable | MASK_StencilTestEnable; dwEnable2 |= MASK_ZMaskWriteEnable; dwDepthMask = ((wmask << 24) | 0x00ffffff); - dwSten1 = S_8 | (((DWORD) sten << 8) | smask) | SiS_STENCIL_ALWAYS; + dwSten1 = S_8 | (((GLint) sten << 8) | smask) | SiS_STENCIL_ALWAYS; dwSten2 = STEN_OP; } else if (bClrDepth) @@ -209,18 +206,18 @@ } else if (bClrStencil) { - DWORD wmask, smask; + GLint wmask, smask; GLstencil sten; sten = (GLstencil) ctx->Stencil.Clear; - wmask = (DWORD) ctx->Stencil.WriteMask; + wmask = (GLint) ctx->Stencil.WriteMask; smask = 0xff; zClearVal = 0; dwEnable1 = MASK_ZWriteEnable | MASK_StencilTestEnable; dwEnable2 |= MASK_ZMaskWriteEnable; dwDepthMask = (wmask << 24) & 0xff000000; - dwSten1 = S_8 | (((DWORD) sten << 8) | smask) | SiS_STENCIL_ALWAYS; + dwSten1 = S_8 | (((GLint) sten << 8) | smask) | SiS_STENCIL_ALWAYS; dwSten2 = STEN_OP; } else @@ -292,27 +289,27 @@ pExtents++; } - MMIO (REG_3D_ClipTopBottom, ((DWORD) top << 13) | (DWORD) bottom); - MMIO (REG_3D_ClipLeftRight, ((DWORD) left << 13) | (DWORD) right); + MMIO (REG_3D_ClipTopBottom, ((GLint) top << 13) | (GLint) bottom); + MMIO (REG_3D_ClipLeftRight, ((GLint) left << 13) | (GLint) right); /* the first triangle */ dwPrimitiveSet = (OP_3D_TRIANGLE_DRAW | OP_3D_FIRE_TSARGBc | SHADE_FLAT_VertexC); MMIO (REG_3D_PrimitiveSet, dwPrimitiveSet); - MMIO (REG_3D_TSZa, *(DWORD *) & zClearVal); - MMIO (REG_3D_TSXa, *(DWORD *) & right); - MMIO (REG_3D_TSYa, *(DWORD *) & top); + MMIO (REG_3D_TSZa, *(GLint *) & zClearVal); + MMIO (REG_3D_TSXa, *(GLint *) & right); + MMIO (REG_3D_TSYa, *(GLint *) & top); MMIO (REG_3D_TSARGBa, dwColor); - MMIO (REG_3D_TSZb, *(DWORD *) & zClearVal); - MMIO (REG_3D_TSXb, *(DWORD *) & left); - MMIO (REG_3D_TSYb, *(DWORD *) & top); + MMIO (REG_3D_TSZb, *(GLint *) & zClearVal); + MMIO (REG_3D_TSXb, *(GLint *) & left); + MMIO (REG_3D_TSYb, *(GLint *) & top); MMIO (REG_3D_TSARGBb, dwColor); - MMIO (REG_3D_TSZc, *(DWORD *) & zClearVal); - MMIO (REG_3D_TSXc, *(DWORD *) & left); - MMIO (REG_3D_TSYc, *(DWORD *) & bottom); + MMIO (REG_3D_TSZc, *(GLint *) & zClearVal); + MMIO (REG_3D_TSXc, *(GLint *) & left); + MMIO (REG_3D_TSYc, *(GLint *) & bottom); MMIO (REG_3D_TSARGBc, dwColor); /* second triangle */ @@ -320,15 +317,15 @@ SHADE_FLAT_VertexB); MMIO (REG_3D_PrimitiveSet, dwPrimitiveSet); - MMIO (REG_3D_TSZb, *(DWORD *) & zClearVal); - MMIO (REG_3D_TSXb, *(DWORD *) & right); - MMIO (REG_3D_TSYb, *(DWORD *) & bottom); + MMIO (REG_3D_TSZb, *(GLint *) & zClearVal); + MMIO (REG_3D_TSXb, *(GLint *) & right); + MMIO (REG_3D_TSYb, *(GLint *) & bottom); MMIO (REG_3D_TSARGBb, dwColor); } mEndPrimitive (); - hwcx->GlobalFlag |= RESETSTATE; + smesa->GlobalFlag |= RESETSTATE; #undef RESETSTATE #undef STEN_OP @@ -340,13 +337,13 @@ } __inline__ static void -sis_bitblt_clear_cmd (__GLSiScontext * hwcx, ENGPACKET * pkt) +sis_bitblt_clear_cmd (sisContextPtr smesa, ENGPACKET * pkt) { - LPDWORD lpdwDest, lpdwSrc; + GLint *lpdwDest, *lpdwSrc; int i; - lpdwSrc = (DWORD *) pkt + 1; - lpdwDest = (DWORD *) (GET_IOBase (hwcx) + REG_SRC_ADDR) + 1; + lpdwSrc = (GLint *) pkt + 1; + lpdwDest = (GLint *) (GET_IOBase (smesa) + REG_SRC_ADDR) + 1; mWait3DCmdQueue (10); @@ -358,7 +355,7 @@ *lpdwDest++ = *lpdwSrc++; } - MMIO (REG_CMD0, *(DWORD *) & pkt->stdwCmd); + MMIO (REG_CMD0, *(GLint *) & pkt->stdwCmd); MMIO (0x8240, -1); } @@ -368,32 +365,27 @@ GLint x, GLint y, GLint width, GLint height) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - XMesaBuffer xm_buffer = xmesa->xm_buffer; - sisBufferInfo *priv = (sisBufferInfo *) xm_buffer->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); int count; GLuint origin_x, origin_y; - GLuint depth = GET_DEPTH (hwcx); + GLuint depth = GET_DEPTH (smesa); BoxPtr pExtents = NULL; GLint xx, yy; GLint x0, y0, width0, height0; ENGPACKET stEngPacket; - GLuint pitch; - switch (ctx->Color.DriverDrawBuffer) { case GL_BACK_LEFT: - priv->pCbClearPacket->stdwDestPos.wY = y; - priv->pCbClearPacket->stdwDestPos.wX = x; - priv->pCbClearPacket->stdwDim.wWidth = (WORD) width; - priv->pCbClearPacket->stdwDim.wHeight = (WORD) height; - priv->pCbClearPacket->dwFgRopColor = hwcx->clearColorPattern; + smesa->cbClearPacket.stdwDestPos.wY = y; + smesa->cbClearPacket.stdwDestPos.wX = x; + smesa->cbClearPacket.stdwDim.wWidth = (GLshort) width; + smesa->cbClearPacket.stdwDim.wHeight = (GLshort) height; + smesa->cbClearPacket.dwFgRopColor = smesa->clearColorPattern; - sis_bitblt_clear_cmd (hwcx, priv->pCbClearPacket); + sis_bitblt_clear_cmd( smesa, &smesa->cbClearPacket ); return; case GL_FRONT_LEFT: x0 = x; @@ -401,7 +393,6 @@ width0 = width; height0 = height; - pitch = GET_PITCH (hwcx); sis_get_drawable_origin (xmesa, &origin_x, &origin_y); sis_get_clip_rects (xmesa, &pExtents, &count); break; @@ -435,30 +426,30 @@ stEngPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xc0000000; stEngPacket.stdwDestPos.wY = y + origin_y; stEngPacket.stdwDestPos.wX = x + origin_x; - stEngPacket.dwDestBaseAddr = (DWORD) 0; - stEngPacket.wDestPitch = pitch; + stEngPacket.dwDestBaseAddr = (GLint) 0; + stEngPacket.wDestPitch = smesa->frontPitch; /* TODO: set maximum value? */ - stEngPacket.wDestHeight = hwcx->virtualY; - stEngPacket.stdwDim.wWidth = (WORD) width; - stEngPacket.stdwDim.wHeight = (WORD) height; + stEngPacket.wDestHeight = smesa->virtualY; + stEngPacket.stdwDim.wWidth = (GLshort) width; + stEngPacket.stdwDim.wHeight = (GLshort) height; stEngPacket.stdwCmd.cRop = 0xf0; - stEngPacket.dwFgRopColor = hwcx->clearColorPattern; + stEngPacket.dwFgRopColor = smesa->clearColorPattern; /* for SGRAM Block Write Enable */ - if (hwcx->blockWrite) + if (smesa->blockWrite) { - stEngPacket.stdwCmd.cCmd0 = (BYTE) (CMD0_PAT_FG_COLOR); + stEngPacket.stdwCmd.cCmd0 = (GLbyte) (CMD0_PAT_FG_COLOR); stEngPacket.stdwCmd.cCmd1 = - (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); + (GLbyte) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); } else { stEngPacket.stdwCmd.cCmd0 = 0; stEngPacket.stdwCmd.cCmd1 = - (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); + (GLbyte) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); } - sis_bitblt_clear_cmd (hwcx, &stEngPacket); + sis_bitblt_clear_cmd (smesa, &stEngPacket); } } @@ -466,144 +457,20 @@ sis_clear_z_stencil_buffer (GLcontext * ctx, GLbitfield mask, GLint x, GLint y, GLint width, GLint height) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - XMesaBuffer xm_buffer = xmesa->xm_buffer; - sisBufferInfo *priv = (sisBufferInfo *) xmesa->xm_buffer->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); /* TODO: check write mask */ - if (!xm_buffer->depthbuffer) + if ( smesa->depthbuffer == NULL ) return; /* TODO: consider alignment of width, height? */ - priv->pZClearPacket->stdwDestPos.wY = y; - priv->pZClearPacket->stdwDestPos.wX = x; - priv->pZClearPacket->stdwDim.wWidth = (WORD) width; - priv->pZClearPacket->stdwDim.wHeight = (WORD) height; - priv->pZClearPacket->dwFgRopColor = hwcx->clearZStencilPattern; - - sis_bitblt_clear_cmd (hwcx, priv->pZClearPacket); -} - -__inline__ static void -sis_bitblt_copy_cmd (__GLSiScontext * hwcx, ENGPACKET * pkt) -{ - LPDWORD lpdwDest, lpdwSrc; - int i; - - lpdwSrc = (DWORD *) pkt; - lpdwDest = (DWORD *) (GET_IOBase (hwcx) + REG_SRC_ADDR); - - mWait3DCmdQueue (10); - - for (i = 0; i < 7; i++) - { - *lpdwDest++ = *lpdwSrc++; - } - - MMIO (REG_CMD0, *(DWORD *) & pkt->stdwCmd); - MMIO (0x8240, -1); -} - -__inline__ static void -sis_swap_image (XMesaBuffer b, XMesaDrawable d, XMesaImage * image) -{ - XMesaContext xmesa = b->xm_context; - __GLSiScontext *hwcx = (__GLSiScontext *) b->xm_context->private; - - GLuint depth = GET_DEPTH (hwcx); - ENGPACKET stEngPacket; - DWORD src; - GLuint srcPitch, dstPitch; - - BoxPtr pExtents; - BoxRec box; - int count; - GLuint origin_x, origin_y; - - memset (&stEngPacket, 0, sizeof (ENGPACKET)); + smesa->zClearPacket.stdwDestPos.wY = y; + smesa->zClearPacket.stdwDestPos.wX = x; + smesa->zClearPacket.stdwDim.wWidth = (GLshort) width; + smesa->zClearPacket.stdwDim.wHeight = (GLshort) height; + smesa->zClearPacket.dwFgRopColor = smesa->clearZStencilPattern; - if (!sis_get_clip_rects (xmesa, &pExtents, &count)) - { - sis_get_drawable_box (xmesa, &box); - pExtents = &box; - count = 1; - } - - src = (DWORD) image->data - (DWORD) GET_FbBase (hwcx); - srcPitch = image->bytes_per_line; - dstPitch = GET_PITCH (hwcx); - sis_get_drawable_origin (xmesa, &origin_x, &origin_y); - - while(count --) - { - stEngPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xc0000000; - - stEngPacket.dwSrcBaseAddr = src; - stEngPacket.dwSrcPitch |= srcPitch; - - stEngPacket.stdwSrcPos.wY = pExtents->y1 - origin_y; - stEngPacket.stdwSrcPos.wX = pExtents->x1 - origin_x; - stEngPacket.stdwDestPos.wY = pExtents->y1; - stEngPacket.stdwDestPos.wX = pExtents->x1; - stEngPacket.dwDestBaseAddr = (DWORD) 0; - stEngPacket.wDestPitch = dstPitch; - - /* TODO: set maximum value? */ - stEngPacket.wDestHeight = hwcx->virtualY; - stEngPacket.stdwDim.wWidth = (WORD) pExtents->x2 - pExtents->x1; - stEngPacket.stdwDim.wHeight = (WORD) pExtents->y2 - pExtents->y1; - stEngPacket.stdwCmd.cRop = 0xcc; - - if (hwcx->blockWrite) - { - stEngPacket.stdwCmd.cCmd0 = (BYTE) (CMD0_PAT_FG_COLOR); - stEngPacket.stdwCmd.cCmd1 = - (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); - } - else - { - stEngPacket.stdwCmd.cCmd0 = 0; - stEngPacket.stdwCmd.cCmd1 = - (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); - } - - sis_bitblt_copy_cmd (hwcx, &stEngPacket); - - pExtents++; - } + sis_bitblt_clear_cmd (smesa, &smesa->zClearPacket); } -void -sis_swap_buffers (XMesaBuffer b) -{ - XMesaContext xmesa = b->xm_context; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - GLcontext *ctx = hwcx->gc; - - /* debug */ - /* return; */ - - /* frame control */ - /* TODO: need lock? */ - -#if 1 - { - int repeat = 0; - - while(((*hwcx->FrameCountPtr) - *(DWORD volatile *)(hwcx->IOBase+0x8a2c) - > SIS_MAX_FRAME_LENGTH) && - (repeat++ < 10)); - } -#endif - - LOCK_HARDWARE (); - - sis_swap_image (b, b->frontbuffer, b->backimage); - *(DWORD *)(hwcx->IOBase+0x8a2c) = *hwcx->FrameCountPtr; - (*hwcx->FrameCountPtr)++; - - UNLOCK_HARDWARE (); -} diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_common.h xc/lib/GL/mesa/src/drv/sis/sis_common.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_common.h Sun Aug 10 22:45:32 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_common.h Wed Dec 31 16:00:00 1969 @@ -1,230 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ -/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_common.h,v 1.5 2000/09/26 15:56:48 tsi Exp $ */ - -/* - * Authors: - * Sung-Ching Lin - * - */ - -#ifndef _sis_common_h_ -#define _sis_common_h_ - -#include "types.h" -#include "sis_xmesaP.h" - -#if 0 -#define free(x) -#define calloc(x,y) sis_debug_malloc((x)*(y)) -extern void *sis_debug_malloc(int x); -#endif - -#if defined(SIS_DUMP) -#include "sis_debug.h" -#endif - -#if SIS_STEREO -# include "sis_stereo.h" -#else -# define STEREO_OFFSET(v) 0 -# define STEREO_SAMPLE(v) do{}while(0) -#endif - -#ifdef XFree86Server -# include "resource.h" -# include "windowstr.h" -# include "gcstruct.h" -# include "GL/xf86glx.h" -# include "xf86glx_util.h" -# include "xf86_ansic.h" -# include "xf86_libc.h" -#else -# ifdef GLX_DIRECT_RENDERING -# include -# include -# include -# include -# include "dri_mesaint.h" -typedef struct _Box -{ - short x1, y1, x2, y2; -} -BoxRec; -#define NullBox ((BoxPtr)0) -typedef struct _Box *BoxPtr; -# endif -#endif - -typedef unsigned short WORD; -typedef unsigned long DWORD; -typedef unsigned int UINT; -typedef int INT; -typedef long LONG; -typedef DWORD *LPDWORD; - -/* BitBlt Commands */ -#define Index_SR_Misc_Ctrl11 0x3e -#define CMD0_DD_ENABLE 0x06 -#define CMD0_SRC_VIDEO 0x00 -#define CMD0_SRC_CPU 0x10 -#define CMD0_PAT_FG_COLOR 0x00 -#define CMD1_DIR_X_DEC 0x00 -#define CMD1_DIR_X_INC 0x01 -#define CMD1_DIR_Y_DEC 0x00 -#define CMD1_DIR_Y_INC 0x02 -#define REG_SRC_ADDR 0x8200 -#define REG_CMD0 0x823c - -typedef struct -{ - WORD wSrcPitch; - WORD wDestPitch; -} -_PITCH; -typedef struct -{ - WORD wWidth; - WORD wHeight; -} -_DIM; -typedef struct -{ - WORD wY; - WORD wX; -} -_POS; - -typedef struct -{ - BYTE cCmd0; - BYTE cRop; - BYTE cCmd1; - BYTE cReserved; -} -_CMD; - -typedef struct -{ - WORD wStatus0; - BYTE cStatus0_BYTE3; - BYTE cStatus0_BYTE4; -} -_CMDQUESTATUS; - -typedef struct -{ - DWORD dwSrcBaseAddr; - DWORD dwSrcPitch; - _POS stdwSrcPos; - _POS stdwDestPos; - DWORD dwDestBaseAddr; - WORD wDestPitch; - WORD wDestHeight; - _DIM stdwDim; - DWORD dwFgRopColor; - DWORD dwBgRopColor; - DWORD dwSrcHiCKey; - DWORD dwSrcLoCKey; - DWORD dwMaskA; - DWORD dwMaskB; - DWORD dwClipA; - DWORD dwClipB; - _CMD stdwCmd; - _CMDQUESTATUS stdwCmdQueStatus; -} -ENGPACKET, *LPENGPACKET; - -/* Hardware Info */ -#include "sis_reg.h" -#include "sis_init.h" - -typedef struct gl_texture_object GLtextureObject; -typedef struct gl_texture_image GLtextureImage; - -#define VIDEO_TYPE 0 -#define AGP_TYPE 1 - -typedef struct sis_texure_area -{ - GLbyte *Data; - GLenum Format; - void *free; - GLuint memType; - GLuint Pitch; - GLuint Size; - GLuint texelSize; - unsigned int hHWContext; - - /* Debug */ - GLuint realSize; -} -SIStextureArea; - -/* dirtyFlag */ -#define SIS_TEX_ENV 0x1 -#define SIS_TEX_IMAGE 0x2 /* image in video memory is stale */ -#define SIS_TEX_PARAMETER 0x4 -#define SIS_TEX_ALL (SIS_TEX_IMAGE | SIS_TEX_PARAMETER) - -typedef struct sis_texobj_area -{ - DWORD dirtyFlag; - GLboolean valid; - struct sis_texobj_area *prev, *next; -} -sisTexobjInfo; - -typedef struct sis_buffer_private -{ - void *zbFree, *bbFree; - - ENGPACKET *pZClearPacket, *pCbClearPacket; - - ENGPACKET zClearPacket, cbClearPacket; - -#if SIS_STEREO - XMesaImage *pStereoImages[3]; - ENGPACKET *pStereoPackets[3]; - void *stereoFrees[3]; /* stereoFrees[0] is useless */ - - ENGPACKET stereoPackets[2]; -#endif -} -sisBufferInfo; - -/* HW capability */ -#define SIS_MAX_MIPMAP_LEVEL 11 -#define SIS_MAX_TEXTURE_SIZE 2048 -#define SIS_MAX_TEXTURES 2 - -#define SIS_MAX_FRAME_LENGTH 3 - -DWORD doFPtoFixedNoRound (DWORD dwInValue, int nFraction); - -#define Y_FLIP(Y) (xmesa->xm_buffer->bottom-(Y)) -#endif diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_common2.h xc/lib/GL/mesa/src/drv/sis/sis_common2.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_common2.h Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_common2.h Sun Aug 10 22:44:55 2003 @@ -0,0 +1,191 @@ +/************************************************************************** + +Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ +/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_common.h,v 1.5 2000/09/26 15:56:48 tsi Exp $ */ + +/* + * Authors: + * Sung-Ching Lin + * + */ + +#ifndef _sis_common_h_ +#define _sis_common_h_ + +#include "sis_xmesaP.h" + +#if 0 +#define free(x) +#define calloc(x,y) sis_debug_malloc((x)*(y)) +extern void *sis_debug_malloc(int x); +#endif + +#if defined(SIS_DUMP) +#include "sis_debug.h" +#endif + +#if SIS_STEREO +# include "sis_stereo.h" +#else +# define STEREO_OFFSET(v) 0 +# define STEREO_SAMPLE(v) do{}while(0) +#endif + +#ifdef GLX_DIRECT_RENDERING +# include +# include +# include +# include +typedef struct _Box +{ + short x1, y1, x2, y2; +} +BoxRec; +#define NullBox ((BoxPtr)0) +typedef struct _Box *BoxPtr; +#endif /* GLX_DIRECT_RENDERING */ + +/* BitBlt Commands */ +#define Index_SR_Misc_Ctrl11 0x3e +#define CMD0_DD_ENABLE 0x06 +#define CMD0_SRC_VIDEO 0x00 +#define CMD0_SRC_CPU 0x10 +#define CMD0_PAT_FG_COLOR 0x00 +#define CMD1_DIR_X_DEC 0x00 +#define CMD1_DIR_X_INC 0x01 +#define CMD1_DIR_Y_DEC 0x00 +#define CMD1_DIR_Y_INC 0x02 +#define REG_SRC_ADDR 0x8200 +#define REG_CMD0 0x823c + +typedef struct +{ + GLshort wSrcPitch; + GLshort wDestPitch; +} +_PITCH; +typedef struct +{ + GLshort wWidth; + GLshort wHeight; +} +_DIM; +typedef struct +{ + GLshort wY; + GLshort wX; +} +_POS; + +typedef struct +{ + GLbyte cCmd0; + GLbyte cRop; + GLbyte cCmd1; + GLbyte cReserved; +} +_CMD; + +typedef struct +{ + GLshort wStatus0; + GLbyte cStatus0_GLbyte3; + GLbyte cStatus0_GLbyte4; +} +_CMDQUESTATUS; + +typedef struct +{ + GLint dwSrcBaseAddr; + GLint dwSrcPitch; + _POS stdwSrcPos; + _POS stdwDestPos; + GLint dwDestBaseAddr; + GLshort wDestPitch; + GLshort wDestHeight; + _DIM stdwDim; + GLint dwFgRopColor; + GLint dwBgRopColor; + GLint dwSrcHiCKey; + GLint dwSrcLoCKey; + GLint dwMaskA; + GLint dwMaskB; + GLint dwClipA; + GLint dwClipB; + _CMD stdwCmd; + _CMDQUESTATUS stdwCmdQueStatus; +} +ENGPACKET, *LPENGPACKET; + +/* Hardware Info */ +#include "sis_reg.h" +#include "sis_init.h" + +typedef struct gl_texture_object GLtextureObject; +typedef struct gl_texture_image GLtextureImage; + +#define VIDEO_TYPE 0 +#define AGP_TYPE 1 + +typedef struct sis_texure_area +{ + GLbyte *Data; + GLenum Format; + void *free; + GLuint memType; + GLuint Pitch; + GLuint Size; + GLuint texelSize; + + /* Debug */ + GLuint realSize; +} +SIStextureArea; + +/* dirtyFlag */ +#define SIS_TEX_ENV 0x1 +#define SIS_TEX_IMAGE 0x2 /* image in video memory is stale */ +#define SIS_TEX_PARAMETER 0x4 +#define SIS_TEX_ALL (SIS_TEX_IMAGE | SIS_TEX_PARAMETER) + +typedef struct sis_texobj_area +{ + GLint dirtyFlag; + GLboolean valid; + struct sis_texobj_area *prev, *next; +} +sisTexobjInfo; + +/* HW capability */ +#define SIS_MAX_MIPMAP_LEVEL 11 +#define SIS_MAX_TEXTURE_SIZE 2048 +#define SIS_MAX_TEXTURES 2 + +#define SIS_MAX_FRAME_LENGTH 3 + +GLint doFPtoFixedNoRound (GLint dwInValue, int nFraction); + +#endif diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_context.c xc/lib/GL/mesa/src/drv/sis/sis_context.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_context.c Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_context.c Sun Aug 10 22:44:55 2003 @@ -0,0 +1,850 @@ +/************************************************************************** + +Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ +/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */ + +/* + * Authors: + * Sung-Ching Lin + * + */ + +#include "sis_dri.h" + +#include "sis_context.h" +#include "sis_state.h" +#include "sis_mesa.h" +#include "sis_dd.h" + +#include "imports.h" +#include "matrix.h" +#include "extensions.h" +#include "utils.h" + +#include "swrast/swrast.h" +#include "swrast_setup/swrast_setup.h" +#include "array_cache/acache.h" + +#include "tnl/tnl.h" +#include "tnl/t_pipeline.h" + +int GlobalCurrentHwcx = -1; +int GlobalHwcxCountBase = 1; +int GlobalCmdQueueLen = 0; + +static const char * const card_extensions[] = +{ + "GL_ARB_multitexture", + NULL +}; + +void +WaitEngIdle (sisContextPtr smesa) +{ + GLbyte *IOBase = GET_IOBase (smesa); + GLbyte cEngineState; + + cEngineState = *((GLbyte volatile *) (IOBase + 0x8243)); + while (((cEngineState & 0x80) == 0) || + ((cEngineState & 0x40) == 0) || ((cEngineState & 0x20) == 0)) + { + cEngineState = *((GLbyte volatile *) (IOBase + 0x8243)); + } +} + +void +Wait2DEngIdle (sisContextPtr smesa) +{ + GLbyte *IOBase = GET_IOBase (smesa); + GLbyte cEngineState; + + cEngineState = *((GLbyte volatile *) (IOBase + 0x8243)); + while (!(cEngineState & 0x80)) + { + cEngineState = *((GLbyte volatile *) (IOBase + 0x8243)); + } +} + +static void +sis_init_opengl_state (GLcontext * ctx) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + __GLSiSHardware *current = &smesa->current; + __GLSiSHardware *prev = &(smesa->prev); + + /* + prev->hwCapEnable = INIT_6327_CapsEnable ; + prev->hwCapEnable = 0x000000a0; + */ + /* add Texture Perspective Enable */ + prev->hwCapEnable = 0x000002a0; + + /* + prev->hwCapEnable2 = INIT_6327_CapsEnable2; + prev->hwCapEnable2 = 0x00aa0080; + */ + /* if multi-texture enabled, disable Z pre-test */ + prev->hwCapEnable2 = 0x00000000; + + /* Z test mode is LE */ + prev->hwZ = INIT_6327_ZSet; + + /* TODO : maybe call sis_DepthFunc to update is a better way */ + ctx->Driver.DepthFunc (ctx, ctx->Depth.Func); + + /* Depth mask */ + prev->hwZMask = INIT_6327_ZMask; + + /* Alpha test mode is ALWAYS, Alpha ref value is 0 */ + prev->hwAlpha = INIT_6327_AlphaSet; + + /* ROP2 is COPYPEN */ + prev->hwDstSet = INIT_6327_DstSet; + + /* color mask */ + prev->hwDstMask = INIT_6327_DstMask; + + /* LinePattern is 0, Repeat Factor is 0 */ + prev->hwLinePattern = 0x00008000; + + /* Fog mode is Linear Fog, Fog color is (0, 0, 0) */ + prev->hwFog = INIT_6327_FogSet; + + /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */ + prev->hwDstSrcBlend = INIT_6327_BlendMode; + + /* Texture mapping mode is Tile */ +#if 0 + prev->texture[0].hwTextqureSet = INIT_6327_TextureSet; +#endif + /* Magnified & minified texture filter is NEAREST */ +#if 0 + prev->texture[0].hwTextureMip = INIT_6327_TextureMip; +#endif + + /* Texture Blending seeting */ + prev->hwTexBlendClr0 = INIT_6327_TextureColorBlend0; + + prev->hwTexBlendClr1 = INIT_6327_TextureColorBlend1; + + prev->hwTexBlendAlpha0 = INIT_6327_TextureAlphaBlend0; + + prev->hwTexBlendAlpha1 = INIT_6327_TextureAlphaBlend1; + + memcpy (current, prev, sizeof (__GLSiSHardware)); + + /* Init the texture transparency color high range value */ +#if 0 + lpdwRegIO = ((GLint *)smesa->lpEngIO + REG_3D_TransparencyColorHigh); + prev->hwTextureClrHigh = INIT_6326_TextureClrHigh; + *(lpdwRegIO) = INIT_6327_TextureClrHigh; +#endif +} + +static void +sis_init_user_setting (GLcontext * ctx) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + +#if 0 /* XXX */ + /* disable all unsupported per-pixel extensions */ + gl_extensions_disable (ctx, "GL_EXT_blend_color"); + gl_extensions_disable (ctx, "GL_EXT_blend_minmax"); + gl_extensions_disable (ctx, "GL_EXT_blend_logic_op"); + gl_extensions_disable (ctx, "GL_EXT_blend_subtract"); + gl_extensions_disable (ctx, "GL_EXT_paletted_texture"); + gl_extensions_disable (ctx, "GL_EXT_point_parameters"); + gl_extensions_disable (ctx, "GL_EXT_texture3D"); + gl_extensions_disable (ctx, "GL_INGR_blend_func_separate"); + gl_extensions_disable (ctx, "GL_PGI_misc_hints"); + gl_extensions_disable (ctx, "GL_EXT_clip_volume_hint"); + gl_extensions_disable (ctx, "GL_EXT_texture_env_add"); + + /* TODO: driver doesn't handle this */ + if (getenv ("SIS_SINGLE_TEXTURE")) + gl_extensions_disable (ctx, "GL_ARB_multitexture"); +#endif + + /* turning off the extension has more speed */ + /* if mesa supports indirect VB rendering, remove it */ + + /* if disable it, quake3 will have broken triangle */ + /* gl_extensions_disable (ctx, "GL_EXT_compiled_vertex_array"); */ + + /* debug */ + if(getenv ("SIS_NO_AGP_CMDS")) + smesa->AGPCmdModeEnabled = GL_FALSE; + +#if SIS_STEREO + if(getenv ("SIS_STEREO") && smesa->irqEnabled) + smesa->useStereo = GL_TRUE; + else + smesa->useStereo = GL_FALSE; + + { + float val; + char *str; + + /* TODO: error check */ + if((str=getenv("SIS_STEREO_OFFSET"))){ + val= atof(str); + if(val>0 && val<1){ + StereoInitOffset = val; + } + } + + if((str=getenv("SIS_STEREO_SCALE"))){ + val= atof(str); + if(val>0){ + StereoInitScale = val; + } + } + } + + if(getenv("SIS_STEREO_DYNAMIC_Z")) + StereoDynamicZ = GL_TRUE; +#endif +} + +GLboolean +sisCreateContext( const __GLcontextModes *glVisual, + __DRIcontextPrivate *driContextPriv, + void *sharedContextPrivate ) +{ + GLcontext *ctx, *shareCtx; + __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; + sisContextPtr smesa; + sisScreenPtr sisScreen; + int i; + + smesa = (sisContextPtr) CALLOC( sizeof(*smesa) ); + if ( smesa == NULL ) + return GL_FALSE; + + /* Allocate the Mesa context */ + if (sharedContextPrivate) + shareCtx = ((sisContextPtr) sharedContextPrivate)->glCtx; + else + shareCtx = NULL; + smesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) smesa, GL_TRUE); + if (!smesa->glCtx) { + FREE(smesa); + return GL_FALSE; + } + driContextPriv->driverPrivate = smesa; + ctx = smesa->glCtx; + + sisScreen = smesa->sisScreen = (sisScreenPtr)(sPriv->private); + + smesa->driContext = driContextPriv; + smesa->driScreen = sPriv; + smesa->driDrawable = NULL; + smesa->hHWContext = driContextPriv->hHWContext; + smesa->driHwLock = &sPriv->pSAREA->lock; + smesa->driFd = sPriv->fd; + + smesa->virtualX = sisScreen->screenX; + smesa->virtualY = sisScreen->screenY; + smesa->bytesPerPixel = sisScreen->bytesPerPixel; + smesa->IOBase = sisScreen->mmio.map; + smesa->Chipset = sisScreen->deviceID; + smesa->irqEnabled = sisScreen->irqEnabled; + + smesa->FbBase = sPriv->pFB; + smesa->displayWidth = sPriv->fbWidth; + smesa->frontPitch = sPriv->fbStride; + /* TODO: make sure psp->fd is sub-driver's fd */ + + smesa->sarea = (SISSAREAPriv *)((char *)sPriv->pSAREA + + sisScreen->sarea_priv_offset); + + /* set static part in ctx->Driver */ + sis_init_driver (ctx); + +#if defined(SIS_DUMP) + IOBase4Debug = GET_IOBase (smesa); +#endif + + /* support ARGB8888 and RGB565 */ + switch (smesa->bytesPerPixel) + { + case 4: + smesa->redMask = 0x00ff0000; + smesa->greenMask = 0x0000ff00; + smesa->blueMask = 0x000000ff; + smesa->alphaMask = 0xff000000; + smesa->colorFormat = DST_FORMAT_ARGB_8888; + break; + case 2: + smesa->redMask = 0xf800; + smesa->greenMask = 0x07e0; + smesa->blueMask = 0x001f; + smesa->alphaMask = 0; + smesa->colorFormat = DST_FORMAT_RGB_565; + break; + default: + assert (0); + } + + sis_sw_init_driver (ctx); + + /* TODO: index mode */ + + smesa->CurrentQueueLenPtr = &(smesa->sarea->QueueLength); + smesa->FrameCountPtr = &(smesa->sarea->FrameCount); + + /* set AGP */ + smesa->AGPSize = sisScreen->agp.size; + smesa->AGPBase = sisScreen->agp.map; + smesa->AGPAddr = sisScreen->agp.handle; + + /* set AGP command buffer */ + smesa->AGPCmdModeEnabled = GL_FALSE; + if (smesa->AGPSize){ + if (sisScreen->AGPCmdBufSize){ + smesa->AGPCmdBufBase = smesa->AGPBase + sisScreen->AGPCmdBufOffset; + smesa->AGPCmdBufAddr = smesa->AGPAddr + sisScreen->AGPCmdBufOffset; + smesa->AGPCmdBufSize = sisScreen->AGPCmdBufSize; + + smesa->pAGPCmdBufNext = (GLint *)&(smesa->sarea->AGPCmdBufNext); + smesa->AGPCmdModeEnabled = GL_TRUE; + } + } + + smesa->GlobalFlag = 0L; + + smesa->swRenderFlag = 0; + smesa->swForceRender = GL_FALSE; + smesa->Primitive = 0; + smesa->useFastPath = GL_FALSE; + + /* Initialize the software rasterizer and helper modules. + */ + _swrast_CreateContext( ctx ); + _ac_CreateContext( ctx ); + _tnl_CreateContext( ctx ); + _swsetup_CreateContext( ctx ); + + /* Configure swrast to match hardware characteristics: + */ + _swrast_allow_pixel_fog( ctx, GL_FALSE ); + _swrast_allow_vertex_fog( ctx, GL_TRUE ); /* XXX Fixme? */ + + sisDDInitDriverFuncs( ctx ); + sisDDInitStateFuncs( ctx ); + + driInitExtensions( ctx, card_extensions, GL_FALSE ); + + /* TODO */ + /* smesa->blockWrite = SGRAMbw = IsBlockWrite (); */ + smesa->blockWrite = GL_FALSE; + + /* this function will over-write AGPCmdModeEnabled */ + /* TODO: pay attention to side-effect */ + sis_init_user_setting (ctx); + + sis_init_opengl_state (ctx); + sis_set_buffer_static (ctx); + set_color_pattern (smesa, 0, 0, 0, 0); + set_z_stencil_pattern (smesa, 1.0, 0); + + /* TODO: need to clear cache? */ + smesa->clearTexCache = GL_TRUE; + + smesa->AGPParseSet = 0x00000040; + smesa->dwPrimitiveSet = 0x00060000; + + for (i = 0; i < SIS_MAX_TEXTURES; i++) + { + smesa->TexStates[i] = 0; + smesa->PrevTexFormat[i] = 0; + } + +#if SIS_STEREO + smesa->isFullScreen = GL_FALSE; + smesa->stereoEnabled = GL_FALSE; +#endif + + return GL_TRUE; +} + +void +sisDestroyContext ( __DRIcontextPrivate *driContextPriv ) +{ + sisContextPtr smesa = (sisContextPtr) driContextPriv->driverPrivate; + + assert( smesa != NULL ); + + if ( smesa != NULL ) { + _swsetup_DestroyContext( smesa->glCtx ); + _tnl_DestroyContext( smesa->glCtx ); + _ac_DestroyContext( smesa->glCtx ); + _swrast_DestroyContext( smesa->glCtx ); + + /* free the Mesa context */ + smesa->glCtx->DriverCtx = NULL; + _mesa_destroy_context(smesa->glCtx); + } + + FREE( smesa ); +} + +/* Force the context `c' to be the current context and associate with it + * buffer `b'. + */ +GLboolean +sisMakeCurrent( __DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv ) +{ + if ( driContextPriv ) { + /*GET_CURRENT_CONTEXT(ctx); + sisContextPtr oldSisCtx = ctx ? SIS_CONTEXT(ctx) : NULL;*/ /* XXX see r128 */ + sisContextPtr newSisCtx = (sisContextPtr) driContextPriv->driverPrivate; + + newSisCtx->driDrawable = driDrawPriv; + + _mesa_make_current2( newSisCtx->glCtx, + (GLframebuffer *) driDrawPriv->driverPrivate, + (GLframebuffer *) driReadPriv->driverPrivate ); + + sisUpdateBufferSize( newSisCtx ); + sis_update_drawable_state(newSisCtx->glCtx); + + if ( newSisCtx->glCtx->Viewport.Width == 0 ) { + _mesa_set_viewport(newSisCtx->glCtx, 0, 0, + driDrawPriv->w, driDrawPriv->h); + } + } else { + _mesa_make_current( 0, 0 ); + } + + return GL_TRUE; +} + +void +sis_update_render_state (sisContextPtr smesa, GLuint stateType) +{ + __GLSiSHardware *prev = &smesa->prev; + + mWait3DCmdQueue (45); + + if (smesa->GlobalFlag & GFLAG_ENABLESETTING) + { + if (!smesa->clearTexCache) + { + MMIO (REG_3D_TEnable, prev->hwCapEnable); + } + else + { + MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear); + MMIO (REG_3D_TEnable, prev->hwCapEnable); + smesa->clearTexCache = GL_FALSE; + } + } + + if (smesa->GlobalFlag & GFLAG_ENABLESETTING2) + { + MMIO (REG_3D_TEnable2, prev->hwCapEnable2); + } + + /* Z Setting */ + if (smesa->GlobalFlag & GFLAG_ZSETTING) + { + MMIO (REG_3D_ZSet, prev->hwZ); + MMIO (REG_3D_ZStWriteMask, prev->hwZMask); + MMIO (REG_3D_ZAddress, prev->hwOffsetZ); + } + + /* Alpha Setting */ + if (smesa->GlobalFlag & GFLAG_ALPHASETTING) + { + MMIO (REG_3D_AlphaSet, prev->hwAlpha); + } + + if (smesa->GlobalFlag & GFLAG_DESTSETTING) + { + MMIO (REG_3D_DstSet, prev->hwDstSet); + MMIO (REG_3D_DstAlphaWriteMask, prev->hwDstMask); + MMIO (REG_3D_DstAddress, prev->hwOffsetDest); + } + + /* Line Setting */ +#if 0 + if (smesa->GlobalFlag & GFLAG_LINESETTING) + { + MMIO(REG_3D_LinePattern, prev->hwLinePattern); + } +#endif + + /* Fog Setting */ + if (smesa->GlobalFlag & GFLAG_FOGSETTING) + { + MMIO (REG_3D_FogSet, prev->hwFog); + MMIO (REG_3D_FogInverseDistance, prev->hwFogInverse); + MMIO (REG_3D_FogFarDistance, prev->hwFogFar); + MMIO (REG_3D_FogFactorDensity, prev->hwFogDensity); + } + + /* Stencil Setting */ + if (smesa->GlobalFlag & GFLAG_STENCILSETTING) + { + MMIO (REG_3D_StencilSet, prev->hwStSetting); + MMIO (REG_3D_StencilSet2, prev->hwStSetting2); + } + + /* Miscellaneous Setting */ + if (smesa->GlobalFlag & GFLAG_DSTBLEND) + { + MMIO (REG_3D_DstBlendMode, prev->hwDstSrcBlend); + } + if (smesa->GlobalFlag & GFLAG_CLIPPING) + { + MMIO (REG_3D_ClipTopBottom, prev->clipTopBottom); + MMIO (REG_3D_ClipLeftRight, prev->clipLeftRight); + } + + smesa->GlobalFlag &= ~GFLAG_RENDER_STATES; +} + +void +sis_update_texture_state (sisContextPtr smesa) +{ + __GLSiSHardware *prev = &smesa->prev; + + mWait3DCmdQueue (55); + + if (smesa->clearTexCache) + { + MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear); + MMIO (REG_3D_TEnable, prev->hwCapEnable); + smesa->clearTexCache = GL_FALSE; + } + + /* Texture Setting */ + if (smesa->GlobalFlag & CFLAG_TEXTURERESET) + { + MMIO (REG_3D_TextureSet, prev->texture[0].hwTextureSet); + } + if (smesa->GlobalFlag & GFLAG_TEXTUREMIPMAP) + { + MMIO (REG_3D_TextureMip, prev->texture[0].hwTextureMip); + } + + /* + MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh); + MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow); + */ + + if (smesa->GlobalFlag & GFLAG_TEXBORDERCOLOR) + { + MMIO (REG_3D_TextureBorderColor, prev->texture[0].hwTextureBorderColor); + } + if (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS) + { + MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear); + MMIO (REG_3D_TEnable, prev->hwCapEnable); + + switch ((prev->texture[0].hwTextureSet & MASK_TextureLevel) >> 8) + { + case 11: + MMIO (REG_3D_TextureAddress11, prev->texture[0].texOffset11); + case 10: + MMIO (REG_3D_TextureAddress10, prev->texture[0].texOffset10); + MMIO (REG_3D_TexturePitch10, prev->texture[0].texPitch10); + case 9: + MMIO (REG_3D_TextureAddress9, prev->texture[0].texOffset9); + case 8: + MMIO (REG_3D_TextureAddress8, prev->texture[0].texOffset8); + MMIO (REG_3D_TexturePitch8, prev->texture[0].texPitch89); + case 7: + MMIO (REG_3D_TextureAddress7, prev->texture[0].texOffset7); + case 6: + MMIO (REG_3D_TextureAddress6, prev->texture[0].texOffset6); + MMIO (REG_3D_TexturePitch6, prev->texture[0].texPitch67); + case 5: + MMIO (REG_3D_TextureAddress5, prev->texture[0].texOffset5); + case 4: + MMIO (REG_3D_TextureAddress4, prev->texture[0].texOffset4); + MMIO (REG_3D_TexturePitch4, prev->texture[0].texPitch45); + case 3: + MMIO (REG_3D_TextureAddress3, prev->texture[0].texOffset3); + case 2: + MMIO (REG_3D_TextureAddress2, prev->texture[0].texOffset2); + MMIO (REG_3D_TexturePitch2, prev->texture[0].texPitch23); + case 1: + MMIO (REG_3D_TextureAddress1, prev->texture[0].texOffset1); + case 0: + MMIO (REG_3D_TextureAddress0, prev->texture[0].texOffset0); + MMIO (REG_3D_TexturePitch0, prev->texture[0].texPitch01); + } + } + if (smesa->GlobalFlag & CFLAG_TEXTURERESET_1) + { + MMIO (REG_3D_Texture1Set, prev->texture[1].hwTextureSet); + } + if (smesa->GlobalFlag & GFLAG_TEXTUREMIPMAP_1) + { + MMIO (REG_3D_Texture1Mip, prev->texture[1].hwTextureMip); + } + + if (smesa->GlobalFlag & GFLAG_TEXBORDERCOLOR_1) + { + MMIO (REG_3D_Texture1BorderColor, + prev->texture[1].hwTextureBorderColor); + } + if (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS_1) + { + switch ((prev->texture[1].hwTextureSet & MASK_TextureLevel) >> 8) + { + case 11: + MMIO (REG_3D_Texture1Address11, prev->texture[1].texOffset11); + case 10: + MMIO (REG_3D_Texture1Address10, prev->texture[1].texOffset10); + MMIO (REG_3D_Texture1Pitch10, prev->texture[1].texPitch10); + case 9: + MMIO (REG_3D_Texture1Address9, prev->texture[1].texOffset9); + case 8: + MMIO (REG_3D_Texture1Address8, prev->texture[1].texOffset8); + MMIO (REG_3D_Texture1Pitch8, prev->texture[1].texPitch89); + case 7: + MMIO (REG_3D_Texture1Address7, prev->texture[1].texOffset7); + case 6: + MMIO (REG_3D_Texture1Address6, prev->texture[1].texOffset6); + MMIO (REG_3D_Texture1Pitch6, prev->texture[1].texPitch67); + case 5: + MMIO (REG_3D_Texture1Address5, prev->texture[1].texOffset5); + case 4: + MMIO (REG_3D_Texture1Address4, prev->texture[1].texOffset4); + MMIO (REG_3D_Texture1Pitch4, prev->texture[1].texPitch45); + case 3: + MMIO (REG_3D_Texture1Address3, prev->texture[1].texOffset3); + case 2: + MMIO (REG_3D_Texture1Address2, prev->texture[1].texOffset2); + MMIO (REG_3D_Texture1Pitch2, prev->texture[1].texPitch23); + case 1: + MMIO (REG_3D_Texture1Address1, prev->texture[1].texOffset1); + case 0: + MMIO (REG_3D_Texture1Address0, prev->texture[1].texOffset0); + MMIO (REG_3D_Texture1Pitch0, prev->texture[1].texPitch01); + } + } + + /* texture environment */ + if (smesa->GlobalFlag & GFLAG_TEXTUREENV) + { + MMIO (REG_3D_TextureBlendFactor, prev->hwTexEnvColor); + MMIO (REG_3D_TextureColorBlendSet0, prev->hwTexBlendClr0); + MMIO (REG_3D_TextureAlphaBlendSet0, prev->hwTexBlendAlpha0); + } + if (smesa->GlobalFlag & GFLAG_TEXTUREENV_1) + { + MMIO (REG_3D_TextureBlendFactor, prev->hwTexEnvColor); + MMIO (REG_3D_TextureColorBlendSet1, prev->hwTexBlendClr1); + MMIO (REG_3D_TextureAlphaBlendSet1, prev->hwTexBlendAlpha1); + } + + smesa->GlobalFlag &= ~GFLAG_TEXTURE_STATES; +} + +void +sis_validate_all_state (sisContextPtr smesa) +{ + __GLSiSHardware *prev = &smesa->prev; + + mEndPrimitive (); + mWait3DCmdQueue (40); + + /* Enable Setting */ + MMIO (REG_3D_TEnable, prev->hwCapEnable); + MMIO (REG_3D_TEnable2, prev->hwCapEnable2); + + /* Z Setting */ + /* if (prev->hwCapEnable & MASK_ZTestEnable) { */ + MMIO (REG_3D_ZSet, prev->hwZ); + MMIO (REG_3D_ZStWriteMask, prev->hwZMask); + MMIO (REG_3D_ZAddress, prev->hwOffsetZ); + /* } */ + + /* Alpha Setting */ + if (prev->hwCapEnable & MASK_AlphaTestEnable) + { + MMIO (REG_3D_AlphaSet, prev->hwAlpha); + } + + /* Destination Setting */ + MMIO (REG_3D_DstSet, prev->hwDstSet); + MMIO (REG_3D_DstAlphaWriteMask, prev->hwDstMask); + MMIO (REG_3D_DstAddress, prev->hwOffsetDest); + + /* Line Setting */ +#if 0 + if (prev->hwCapEnable2 & MASK_LinePatternEnable) { + MMIO(REG_3D_LinePattern, prev->hwLinePattern); + } +#endif + + /* Fog Setting */ + if (prev->hwCapEnable & MASK_FogEnable) + { + MMIO (REG_3D_FogSet, prev->hwFog); + MMIO (REG_3D_FogInverseDistance, prev->hwFogInverse); + MMIO (REG_3D_FogFarDistance, prev->hwFogFar); + MMIO (REG_3D_FogFactorDensity, prev->hwFogDensity); + } + + /* Stencil Setting */ + if (prev->hwCapEnable & MASK_StencilTestEnable) + { + MMIO (REG_3D_StencilSet, prev->hwStSetting); + MMIO (REG_3D_StencilSet2, prev->hwStSetting2); + } + + /* Miscellaneous Setting */ + if (prev->hwCapEnable & MASK_BlendEnable) + { + MMIO (REG_3D_DstBlendMode, prev->hwDstSrcBlend); + } + + MMIO (REG_3D_ClipTopBottom, prev->clipTopBottom); + MMIO (REG_3D_ClipLeftRight, prev->clipLeftRight); + + /* TODO */ + /* Texture Setting */ + /* if (prev->hwCapEnable & MASK_TextureEnable) */ + { + MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear); + + MMIO (REG_3D_TEnable, prev->hwCapEnable); + + MMIO (REG_3D_TextureSet, prev->texture[0].hwTextureSet); + MMIO (REG_3D_TextureMip, prev->texture[0].hwTextureMip); + /* + MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh); + MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow); + */ + MMIO (REG_3D_TextureBorderColor, prev->texture[0].hwTextureBorderColor); + + switch ((prev->texture[0].hwTextureSet & MASK_TextureLevel) >> 8) + { + case 11: + MMIO (REG_3D_TextureAddress11, prev->texture[0].texOffset11); + case 10: + MMIO (REG_3D_TextureAddress10, prev->texture[0].texOffset10); + MMIO (REG_3D_TexturePitch10, prev->texture[0].texPitch10); + case 9: + MMIO (REG_3D_TextureAddress9, prev->texture[0].texOffset9); + case 8: + MMIO (REG_3D_TextureAddress8, prev->texture[0].texOffset8); + MMIO (REG_3D_TexturePitch8, prev->texture[0].texPitch89); + case 7: + MMIO (REG_3D_TextureAddress7, prev->texture[0].texOffset7); + case 6: + MMIO (REG_3D_TextureAddress6, prev->texture[0].texOffset6); + MMIO (REG_3D_TexturePitch6, prev->texture[0].texPitch67); + case 5: + MMIO (REG_3D_TextureAddress5, prev->texture[0].texOffset5); + case 4: + MMIO (REG_3D_TextureAddress4, prev->texture[0].texOffset4); + MMIO (REG_3D_TexturePitch4, prev->texture[0].texPitch45); + case 3: + MMIO (REG_3D_TextureAddress3, prev->texture[0].texOffset3); + case 2: + MMIO (REG_3D_TextureAddress2, prev->texture[0].texOffset2); + MMIO (REG_3D_TexturePitch2, prev->texture[0].texPitch23); + case 1: + MMIO (REG_3D_TextureAddress1, prev->texture[0].texOffset1); + case 0: + MMIO (REG_3D_TextureAddress0, prev->texture[0].texOffset0); + MMIO (REG_3D_TexturePitch0, prev->texture[0].texPitch01); + } + + /* TODO */ + /* if (smesa->ctx->Texture.Unit[1].ReallyEnabled) */ + { + MMIO (REG_3D_Texture1Set, prev->texture[1].hwTextureSet); + MMIO (REG_3D_Texture1Mip, prev->texture[1].hwTextureMip); + /* + MMIO(REG_3D_Texture1TransparencyColorHigh, prev->texture[1].hwTextureClrHigh); + MMIO(REG_3D_Texture1TransparencyColorLow, prev->texture[1].hwTextureClrLow); + */ + MMIO (REG_3D_Texture1BorderColor, prev->texture[1].hwTextureBorderColor); + + switch ((prev->texture[1].hwTextureSet & MASK_TextureLevel) >> 8) + { + case 11: + MMIO (REG_3D_Texture1Address11, prev->texture[1].texOffset11); + case 10: + MMIO (REG_3D_Texture1Address10, prev->texture[1].texOffset10); + MMIO (REG_3D_Texture1Pitch10, prev->texture[1].texPitch10); + case 9: + MMIO (REG_3D_Texture1Address9, prev->texture[1].texOffset9); + case 8: + MMIO (REG_3D_Texture1Address8, prev->texture[1].texOffset8); + MMIO (REG_3D_Texture1Pitch8, prev->texture[1].texPitch89); + case 7: + MMIO (REG_3D_Texture1Address7, prev->texture[1].texOffset7); + case 6: + MMIO (REG_3D_Texture1Address6, prev->texture[1].texOffset6); + MMIO (REG_3D_Texture1Pitch6, prev->texture[1].texPitch67); + case 5: + MMIO (REG_3D_Texture1Address5, prev->texture[1].texOffset5); + case 4: + MMIO (REG_3D_Texture1Address4, prev->texture[1].texOffset4); + MMIO (REG_3D_Texture1Pitch4, prev->texture[1].texPitch45); + case 3: + MMIO (REG_3D_Texture1Address3, prev->texture[1].texOffset3); + case 2: + MMIO (REG_3D_Texture1Address2, prev->texture[1].texOffset2); + MMIO (REG_3D_Texture1Pitch2, prev->texture[1].texPitch23); + case 1: + MMIO (REG_3D_Texture1Address1, prev->texture[1].texOffset1); + case 0: + MMIO (REG_3D_Texture1Address0, prev->texture[1].texOffset0); + MMIO (REG_3D_Texture1Pitch0, prev->texture[1].texPitch01); + } + } + + /* texture environment */ + MMIO (REG_3D_TextureBlendFactor, prev->hwTexEnvColor); + MMIO (REG_3D_TextureColorBlendSet0, prev->hwTexBlendClr0); + MMIO (REG_3D_TextureColorBlendSet1, prev->hwTexBlendClr1); + MMIO (REG_3D_TextureAlphaBlendSet0, prev->hwTexBlendAlpha0); + MMIO (REG_3D_TextureAlphaBlendSet1, prev->hwTexBlendAlpha1); + } + + smesa->GlobalFlag = 0; +} + +void +sis_fatal_error (void) +{ + /* free video memory, or the framebuffer device will do it automatically */ + + fprintf(stderr, "Fatal errors in sis_dri.so\n"); + exit (-1); +} diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_context.h xc/lib/GL/mesa/src/drv/sis/sis_context.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_context.h Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_context.h Sun Aug 10 22:44:55 2003 @@ -0,0 +1,332 @@ +/************************************************************************** + +Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ +/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.h,v 1.5 2000/09/26 15:56:48 tsi Exp $ */ + +/* + * Authors: + * Sung-Ching Lin + * + */ + +#ifndef _sis_ctx_h_ +#define _sis_ctx_h_ + +#include "context.h" +#include "dri_util.h" + +#include "sis_screen.h" +#include "sis_common2.h" +#include "sis_sarea.h" + +/* for GLboolean */ +#include + +#define PCI_CHIP_SIS300 0x0300 +#define PCI_CHIP_SIS630 0x6300 +#define PCI_CHIP_SIS540 0x5300 + +#define SIS_STATE_TRIANGLE 1 +#define SIS_STATE_LINE 2 +#define SIS_STATE_POINT 3 + +/* for swRenderFlag */ +#define SIS_SW_TRIANGLE 0x1 +#define SIS_SW_LINE 0x2 +#define SIS_SW_POINT 0x4 +#define SIS_SW_TEXTURE_DIM 0x8 +#define SIS_SW_TEXTURE_OBJ 0x10 +#define SIS_SW_TEXTURE_OBJ1 0x20 +#define SIS_SW_TEXTURE_ENV 0x100 +#define SIS_SW_TEXTURE_ENV1 0x200 + +#define SIS_SW_TEXTURE (SIS_SW_TEXTURE_DIM | \ + SIS_SW_TEXTURE_OBJ | SIS_SW_TEXTURE_OBJ1 | \ + SIS_SW_TEXTURE_ENV | SIS_SW_TEXTURE_ENV1) +#define SIS_SW_ALL (SIS_SW_POINT | SIS_SW_LINE | SIS_SW_TRIANGLE | \ + SIS_SW_TEXTURE) + +/* + ** Device dependent context state + */ +typedef struct __GLSiSTextureRec +{ + GLint hwTextureSet; + GLint hwTextureMip; + GLint hwTextureClrHigh; + GLint hwTextureClrLow; + GLint hwTextureBorderColor; + + GLint texOffset0; + GLint texOffset1; + GLint texOffset2; + GLint texOffset3; + GLint texOffset4; + GLint texOffset5; + GLint texOffset6; + GLint texOffset7; + GLint texOffset8; + GLint texOffset9; + GLint texOffset10; + GLint texOffset11; + + GLint texPitch01; + GLint texPitch23; + GLint texPitch45; + GLint texPitch67; + GLint texPitch89; + GLint texPitch10; +} +__GLSiSTexture; + +typedef struct __GLSiSHardwareRec +{ + GLint hwCapEnable, hwCapEnable2; /* Enable Setting */ + + GLint hwOffsetZ, hwZ; /* Z Setting */ + + GLint hwZBias, hwZMask; /* Z Setting */ + + GLint hwAlpha; /* Alpha Setting */ + + GLint hwDstSet, hwDstMask; /* Destination Setting */ + + GLint hwOffsetDest; /* Destination Setting */ + + GLint hwLinePattern; /* Line Setting */ + + GLint hwFog; /* Fog Setting */ + + GLint hwFogFar, hwFogInverse; /* Fog Distance setting */ + + GLint hwFogDensity; /* Fog factor & density */ + + GLint hwStSetting, hwStSetting2; /* Stencil Setting */ + + GLint hwStOffset; /* Stencil Setting */ + + GLint hwDstSrcBlend; /* Blending mode Setting */ + + GLint clipTopBottom; /* Clip for Top & Bottom */ + + GLint clipLeftRight; /* Clip for Left & Right */ + + struct __GLSiSTextureRec texture[2]; + + GLint hwTexEnvColor; /* Texture Blending Setting */ + + GLint hwTexBlendClr0; + GLint hwTexBlendClr1; + GLint hwTexBlendAlpha0; + GLint hwTexBlendAlpha1; + +} +__GLSiSHardware; + +/* Device dependent context state */ + +typedef struct sis_context sisContextRec; +typedef struct sis_context *sisContextPtr; + +struct sis_context +{ + /* This must be first in this structure */ + GLcontext *glCtx; + + unsigned int virtualX, virtualY; + unsigned int bytesPerPixel; + unsigned char *IOBase; + unsigned char *FbBase; + unsigned int displayWidth; + unsigned int frontPitch; + + /* For Software Renderer */ + GLubyte *swRenderBase; + GLuint swRenderPitch; + GLubyte *swZBase; + GLuint swZPitch; + GLuint pixelValue; + GLboolean swForceRender; + + /* HW RGBA layout */ + unsigned int redMask, greenMask, blueMask, alphaMask; + unsigned int colorFormat; + + /* Z format */ + unsigned int zFormat; + + /* Clear patterns, 4 bytes */ + unsigned int clearColorPattern; + unsigned int clearZStencilPattern; + + /* Render Function */ + points_func PointsFunc; + line_func LineFunc; + triangle_func TriangleFunc; + quad_func QuadFunc; + rect_func RectFunc; + + /* DRM fd */ + int driFd; + + /* AGP Memory */ + unsigned int AGPSize; + unsigned char *AGPBase; + unsigned int AGPAddr; + + /* AGP Command Buffer */ + /* TODO: use Global variables */ + + unsigned char *AGPCmdBufBase; + GLint AGPCmdBufAddr; + unsigned int AGPCmdBufSize; + GLint *pAGPCmdBufNext; + GLboolean AGPCmdModeEnabled; + GLboolean UseAGPCmdMode; + + /* register 0x89F4 */ + GLint AGPParseSet; + + /* register 0x89F8 */ + GLint dwPrimitiveSet; + + __GLSiSHardware prev, current; + + GLint chipVer; + int Chipset; + + GLint drawableID; + + /* SGRAM block write */ + GLboolean blockWrite; + + GLuint swRenderFlag; + GLenum Primitive; + + /* Fast Path */ + GLboolean useFastPath; + + GLint GlobalFlag; + + GLint rawLockMask; + GLint lockMask; + + void (*SwapBuffers)(XMesaBuffer b); + + /* Stereo */ + GLboolean isFullScreen; + GLboolean useStereo; + GLboolean stereoEnabled; + int stereo_drawIndex; + int stereo_drawSide; + GLboolean irqEnabled; + + GLboolean clearTexCache; + + GLuint TexStates[SIS_MAX_TEXTURES]; + GLuint PrevTexFormat[SIS_MAX_TEXTURES]; + + int *CurrentQueueLenPtr; + unsigned int *FrameCountPtr; + + /* Front/back/depth buffer info */ + GLuint width, height; /* size of buffers */ + GLint bottom; /* used for FLIP macro */ + GLvoid *backbuffer; + unsigned int backPitch; + GLvoid *depthbuffer; + void *zbFree, *bbFree; /* Cookies for freeing buffers */ + ENGPACKET zClearPacket, cbClearPacket; + + /* Mirrors of some DRI state + */ + __DRIcontextPrivate *driContext; /* DRI context */ + __DRIscreenPrivate *driScreen; /* DRI screen */ + __DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */ + + unsigned int lastStamp; /* mirror driDrawable->lastStamp */ + + drmContext hHWContext; + drmLock *driHwLock; + + sisScreenPtr sisScreen; /* Screen private DRI data */ + SISSAREAPrivPtr sarea; /* Private SAREA data */ +}; + +#define SIS_CONTEXT(ctx) ((sisContextPtr)(ctx->DriverCtx)) + +/* Macros */ +#define GET_IOBase(x) ((x)->IOBase) +#define GET_FbBase(x) ((x)->FbBase) +#define GET_AGPBase(x) ((x)->AGPBase) +#define GET_DEPTH(x) ((x)->bytesPerPixel) +#define GET_WIDTH(x) ((x)->displayWidth) +#define GET_FbPos(smesa,x,y) (GET_FbBase(smesa)+(x)*GET_DEPTH(smesa)\ + +(y)*smesa->frontPitch) + +#define GET_ColorFormat(x) ((x)->colorFormat) + +#define GET_RMASK(x) ((x)->redMask) +#define GET_GMASK(x) ((x)->greenMask) +#define GET_BMASK(x) ((x)->blueMask) +#define GET_AMASK(x) ((x)->alphaMask) +#define Y_FLIP(Y) (smesa->bottom - Y) + +extern GLboolean sisCreateContext( const __GLcontextModes *glVisual, + __DRIcontextPrivate *driContextPriv, + void *sharedContextPrivate ); +extern void sisDestroyContext( __DRIcontextPrivate * ); + +extern GLboolean sisMakeCurrent( __DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv ); + +extern GLboolean sisUnbindContext( __DRIcontextPrivate *driContextPriv ); + +void WaitEngIdle (sisContextPtr smesa); +void Wait2DEngIdle (sisContextPtr smesa); + +/* update to smesa->prev */ +extern void sis_update_drawable_state (GLcontext * ctx); + +/* update to hw */ +extern void sis_update_texture_state (sisContextPtr smesa); +extern void sis_update_render_state (sisContextPtr smesa, GLuint stateType); +extern void sis_validate_all_state (sisContextPtr smesa); + +extern void sis_set_scissor (GLcontext * gc); + +/* AGP */ +void sis_StartAGP (GLcontext * ctx); +void sis_FlushAGP (GLcontext * ctx); +extern float *AGP_CurrentPtr; + +/* DRM FD */ +extern int gDRMSubFD; + +void sis_fatal_error (void); + +#endif diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_ctx.c xc/lib/GL/mesa/src/drv/sis/sis_ctx.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_ctx.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_ctx.c Wed Dec 31 16:00:00 1969 @@ -1,874 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ -/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */ - -/* - * Authors: - * Sung-Ching Lin - * - */ - -#ifdef XFree86Server -# define PSZ 8 -# include "cfb.h" -# undef PSZ -# include "cfb16.h" -# include "cfb24.h" -# include "cfb32.h" -# include "cfb24_32.h" -/* for SISPtr */ -# include "xf86.h" -# include "xf86_OSproc.h" -# include "xf86Resources.h" -# include "xf86Version.h" -# include "xf86PciInfo.h" -# include "xf86Pci.h" -# include "xf86cmap.h" -# include "vgaHW.h" -# include "xf86RAC.h" -# include "sis_regs.h" -# include "sis.h" -# include "dristruct.h" -# include "dri.h" -#else -#include "sis_dri.h" -#endif - -#include "extensions.h" - -#include "sis_ctx.h" -#include "sis_mesa.h" - -int GlobalCurrentHwcx = -1; -int GlobalHwcxCountBase = 1; -int GlobalCmdQueueLen = 0; - -void -WaitEngIdle (__GLSiScontext * hwcx) -{ - BYTE *IOBase = GET_IOBase (hwcx); - BYTE cEngineState; - - cEngineState = *((BYTE volatile *) (IOBase + 0x8243)); - while (((cEngineState & 0x80) == 0) || - ((cEngineState & 0x40) == 0) || ((cEngineState & 0x20) == 0)) - { - cEngineState = *((BYTE volatile *) (IOBase + 0x8243)); - } -} - -void -Wait2DEngIdle (__GLSiScontext * hwcx) -{ - BYTE *IOBase = GET_IOBase (hwcx); - BYTE cEngineState; - - cEngineState = *((BYTE volatile *) (IOBase + 0x8243)); - while (!(cEngineState & 0x80)) - { - cEngineState = *((BYTE volatile *) (IOBase + 0x8243)); - } -} - -static void -sis_init_opengl_state (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *current = &hwcx->current; - __GLSiSHardware *prev = &(hwcx->prev); - - /* - prev->hwCapEnable = INIT_6327_CapsEnable ; - prev->hwCapEnable = 0x000000a0; - */ - /* add Texture Perspective Enable */ - prev->hwCapEnable = 0x000002a0; - - /* - prev->hwCapEnable2 = INIT_6327_CapsEnable2; - prev->hwCapEnable2 = 0x00aa0080; - */ - /* if multi-texture enabled, disable Z pre-test */ - prev->hwCapEnable2 = 0x00000000; - - /* Z test mode is LE */ - prev->hwZ = INIT_6327_ZSet; - - /* TODO : maybe call sis_DepthFunc to update is a better way */ - ctx->Driver.DepthFunc (ctx, ctx->Depth.Func); - - /* Depth mask */ - prev->hwZMask = INIT_6327_ZMask; - - /* Alpha test mode is ALWAYS, Alpha ref value is 0 */ - prev->hwAlpha = INIT_6327_AlphaSet; - - /* ROP2 is COPYPEN */ - prev->hwDstSet = INIT_6327_DstSet; - - /* color mask */ - prev->hwDstMask = INIT_6327_DstMask; - - /* LinePattern is 0, Repeat Factor is 0 */ - prev->hwLinePattern = 0x00008000; - - /* Fog mode is Linear Fog, Fog color is (0, 0, 0) */ - prev->hwFog = INIT_6327_FogSet; - - /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */ - prev->hwDstSrcBlend = INIT_6327_BlendMode; - - /* Texture mapping mode is Tile */ -#if 0 - prev->texture[0].hwTextqureSet = INIT_6327_TextureSet; -#endif - /* Magnified & minified texture filter is NEAREST */ -#if 0 - prev->texture[0].hwTextureMip = INIT_6327_TextureMip; -#endif - - /* Texture Blending seeting */ - prev->hwTexBlendClr0 = INIT_6327_TextureColorBlend0; - - prev->hwTexBlendClr1 = INIT_6327_TextureColorBlend1; - - prev->hwTexBlendAlpha0 = INIT_6327_TextureAlphaBlend0; - - prev->hwTexBlendAlpha1 = INIT_6327_TextureAlphaBlend1; - - memcpy (current, prev, sizeof (__GLSiSHardware)); - - /* Init the texture transparency color high range value */ -#if 0 - lpdwRegIO = ((LPDWORD)hwcx->lpEngIO + REG_3D_TransparencyColorHigh); - prev->hwTextureClrHigh = INIT_6326_TextureClrHigh; - *(lpdwRegIO) = INIT_6327_TextureClrHigh; -#endif -} - -static void -sis_init_user_setting (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - /* disable all unsupported per-pixel extensions */ - gl_extensions_disable (ctx, "GL_EXT_blend_color"); - gl_extensions_disable (ctx, "GL_EXT_blend_minmax"); - gl_extensions_disable (ctx, "GL_EXT_blend_logic_op"); - gl_extensions_disable (ctx, "GL_EXT_blend_subtract"); - gl_extensions_disable (ctx, "GL_EXT_paletted_texture"); - gl_extensions_disable (ctx, "GL_EXT_point_parameters"); - gl_extensions_disable (ctx, "GL_EXT_texture3D"); - gl_extensions_disable (ctx, "GL_INGR_blend_func_separate"); - gl_extensions_disable (ctx, "GL_PGI_misc_hints"); - gl_extensions_disable (ctx, "GL_EXT_clip_volume_hint"); - gl_extensions_disable (ctx, "GL_EXT_texture_env_add"); - - /* TODO: driver doesn't handle this */ - if (getenv ("SIS_SINGLE_TEXTURE")) - gl_extensions_disable (ctx, "GL_ARB_multitexture"); - - /* turning off the extension has more speed */ - /* if mesa supports indirect VB rendering, remove it */ - - /* if disable it, quake3 will have broken triangle */ - /* gl_extensions_disable (ctx, "GL_EXT_compiled_vertex_array"); */ - - /* debug */ - if(getenv ("SIS_NO_AGP_CMDS")) - hwcx->AGPCmdModeEnabled = GL_FALSE; - -#if SIS_STEREO - if(getenv ("SIS_STEREO") && hwcx->irqEnabled) - hwcx->useStereo = GL_TRUE; - else - hwcx->useStereo = GL_FALSE; - - { - float val; - char *str; - - /* TODO: error check */ - if((str=getenv("SIS_STEREO_OFFSET"))){ - val= atof(str); - if(val>0 && val<1){ - StereoInitOffset = val; - } - } - - if((str=getenv("SIS_STEREO_SCALE"))){ - val= atof(str); - if(val>0){ - StereoInitScale = val; - } - } - } - - if(getenv("SIS_STEREO_DYNAMIC_Z")) - StereoDynamicZ = GL_TRUE; -#endif -} - -void -SiSCreateContext (XMesaContext xmesa) -{ - GLcontext *ctx = xmesa->gl_ctx; - __GLSiScontext *hwcx; - - int i; - - hwcx = (__GLSiScontext *) calloc (1, sizeof (__GLSiScontext)); - if (!hwcx) - { - fprintf (stderr, "SIS Driver : allocating context fails\n"); - sis_fatal_error (); - return; - } - - /* set gc */ - hwcx->gc = ctx; - xmesa->private = hwcx; - - /* set static part in ctx->Driver */ - sis_init_driver (ctx); - - /* Set 2D data (from X-Server) */ - /* i assume the data will not change during X-server's lifetime */ -#ifdef XFree86Server - { - ScrnInfoPtr pScrn = xf86Screens[xmesa->display->myNum]; - SISPtr pSiS = SISPTR (pScrn); - - hwcx->virtualX = pSiS->pScrn->virtualX; - hwcx->virtualY = pSiS->pScrn->virtualY; - hwcx->bytesPerPixel = (pSiS->pScrn->bitsPerPixel + 7) / 8; - hwcx->IOBase = pSiS->IOBase; - hwcx->FbBase = pSiS->FbBase; - hwcx->displayWidth = pSiS->pScrn->displayWidth * hwcx->bytesPerPixel; - hwcx->pitch = pSiS->scrnOffset; - hwcx->Chipset = pSiS->Chipset; - hwcx->drmSubFD = pSiS->drmSubFD; -#if SIS_STEREO - hwcx->irqEnabled = pSiS->irqEnabled; -#endif - } -#else - { - __DRIscreenPrivate *psp = xmesa->driContextPriv->driScreenPriv; - SISDRIPtr priv = (SISDRIPtr) psp->pDevPriv; - - hwcx->virtualX = priv->width; - hwcx->virtualY = priv->height; - hwcx->bytesPerPixel = priv->bytesPerPixel; - hwcx->IOBase = priv->regs.map; - hwcx->FbBase = psp->pFB; - hwcx->displayWidth = psp->fbWidth; - hwcx->pitch = psp->fbStride; - hwcx->Chipset = priv->deviceID; - /* TODO: make sure psp->fd is sub-driver's fd */ - hwcx->drmSubFD = psp->fd; -#if SIS_STEREO - hwcx->irqEnabled = priv->irqEnabled; -#endif - } -#endif - -#if defined(SIS_DUMP) - IOBase4Debug = GET_IOBase (hwcx); -#endif - - /* support ARGB8888 and RGB565 */ - switch (hwcx->bytesPerPixel) - { - case 4: - hwcx->redMask = 0x00ff0000; - hwcx->greenMask = 0x0000ff00; - hwcx->blueMask = 0x000000ff; - hwcx->alphaMask = 0xff000000; - hwcx->colorFormat = DST_FORMAT_ARGB_8888; - break; - case 2: - hwcx->redMask = 0xf800; - hwcx->greenMask = 0x07e0; - hwcx->blueMask = 0x001f; - hwcx->alphaMask = 0; - hwcx->colorFormat = DST_FORMAT_RGB_565; - break; - default: - assert (0); - } - - sis_sw_init_driver (ctx); - - /* TODO: index mode */ - -#if defined(XFree86Server) - { -#if defined(XF86DRI) - ScreenPtr pScreen = xmesa->display; - ScrnInfoPtr pScrn = xf86Screens[xmesa->display->myNum]; - SISPtr pSiS = SISPTR (pScrn); - - if (pSiS->directRenderingEnabled) - { - SISSAREAPriv *saPriv = (SISSAREAPriv *) DRIGetSAREAPrivate (pScreen); - - drmContextPtr contextPtr; - - /* in DR, the action is done by DRI */ - hwcx->pDRIContextPriv = DRICreateContextPriv (pScreen, contextPtr, 0); - if (!contextPtr) - { - /* TODO */ - assert(0); - } - - hwcx->serialNumber = (int) *contextPtr; - hwcx->CurrentHwcxPtr = &(saPriv->CtxOwner); - hwcx->CurrentQueueLenPtr = pSiS->cmdQueueLenPtr; - /* hwcx->FrameCountPtr = */ - - /* what does this do? */ - /* - drmFreeReservedContextList (contextPtr); - */ - - /* TODO, set AGP command buffer */ - hwcx->AGPCmdModeEnabled = GL_FALSE; - } - else -#endif - { - hwcx->serialNumber = GlobalHwcxCountBase++; - hwcx->CurrentHwcxPtr = &GlobalCurrentHwcx; - hwcx->CurrentQueueLenPtr = pSiS->cmdQueueLenPtr; - /* hwcx->FrameCountPtr = */ - - /* TODO, set AGP command buffer */ - hwcx->AGPCmdModeEnabled = GL_FALSE; - } - } -#else - { - __DRIscreenPrivate *psp = xmesa->driContextPriv->driScreenPriv; - SISDRIPtr priv = (SISDRIPtr) psp->pDevPriv; - SISSAREAPriv *saPriv = (SISSAREAPriv *) (((char *) psp->pSAREA) + - sizeof (XF86DRISAREARec)); - - /* or use xmesa->driContextPriv->contextID - * use hHWContext is better, but limit ID to [0..2^31-1] (modify driver) - * hHWContext is CARD32 - */ - hwcx->serialNumber = xmesa->driContextPriv->hHWContext; - hwcx->CurrentHwcxPtr = &(saPriv->CtxOwner); - hwcx->CurrentQueueLenPtr = &(saPriv->QueueLength); - hwcx->FrameCountPtr = &(saPriv->FrameCount); - - /* set AGP */ - hwcx->AGPSize = priv->agp.size; - hwcx->AGPBase = priv->agp.map; - hwcx->AGPAddr = priv->agp.handle; - - /* set AGP command buffer */ - hwcx->AGPCmdModeEnabled = GL_FALSE; - if (hwcx->AGPSize){ - if(priv->AGPCmdBufSize){ - hwcx->AGPCmdBufBase = hwcx->AGPBase + priv->AGPCmdBufOffset; - hwcx->AGPCmdBufAddr = hwcx->AGPAddr + priv->AGPCmdBufOffset; - hwcx->AGPCmdBufSize = priv->AGPCmdBufSize; - - hwcx->pAGPCmdBufNext = (DWORD *)&(saPriv->AGPCmdBufNext); - hwcx->AGPCmdModeEnabled = GL_TRUE; - } - } - } -#endif - - hwcx->GlobalFlag = 0L; - - hwcx->swRenderFlag = 0; - hwcx->swForceRender = GL_FALSE; - hwcx->Primitive = 0; - hwcx->useFastPath = GL_FALSE; - - /* TODO */ - /* hwcx->blockWrite = SGRAMbw = IsBlockWrite (); */ - hwcx->blockWrite = GL_FALSE; - - /* this function will over-write AGPCmdModeEnabled */ - /* TODO: pay attention to side-effect */ - sis_init_user_setting (ctx); - - sis_init_opengl_state (ctx); - sis_set_buffer_static (ctx); - set_color_pattern (hwcx, 0, 0, 0, 0); - set_z_stencil_pattern (hwcx, 1.0, 0); - - /* TODO: need to clear cache? */ - hwcx->clearTexCache = GL_TRUE; - - hwcx->AGPParseSet = 0x00000040; - hwcx->dwPrimitiveSet = 0x00060000; - - for (i = 0; i < SIS_MAX_TEXTURES; i++) - { - hwcx->TexStates[i] = 0; - hwcx->PrevTexFormat[i] = 0; - } - -#if SIS_STEREO - hwcx->isFullScreen = GL_FALSE; - hwcx->stereoEnabled = GL_FALSE; -#endif -} - -void -SiSDestroyContext (XMesaContext xmesa) -{ - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - -#if defined(XFree86Server) && defined(XF86DRI) - DRIDestroyContextPriv ((DRIContextPrivPtr)hwcx->pDRIContextPriv); -#endif - - /* - * TODO: if the context ID given by kernel will be recycled, - * then, the current ID will set to -1 if the current ID - * is equal to my id - */ - free (hwcx); -} - -void -sis_update_render_state (__GLSiScontext * hwcx, GLuint stateType) -{ - __GLSiSHardware *prev = &hwcx->prev; - - mWait3DCmdQueue (45); - - if (hwcx->GlobalFlag & GFLAG_ENABLESETTING) - { - if (!hwcx->clearTexCache) - { - MMIO (REG_3D_TEnable, prev->hwCapEnable); - } - else - { - MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear); - MMIO (REG_3D_TEnable, prev->hwCapEnable); - hwcx->clearTexCache = GL_FALSE; - } - } - - if (hwcx->GlobalFlag & GFLAG_ENABLESETTING2) - { - MMIO (REG_3D_TEnable2, prev->hwCapEnable2); - } - - /* Z Setting */ - if (hwcx->GlobalFlag & GFLAG_ZSETTING) - { - MMIO (REG_3D_ZSet, prev->hwZ); - MMIO (REG_3D_ZStWriteMask, prev->hwZMask); - MMIO (REG_3D_ZAddress, prev->hwOffsetZ); - } - - /* Alpha Setting */ - if (hwcx->GlobalFlag & GFLAG_ALPHASETTING) - { - MMIO (REG_3D_AlphaSet, prev->hwAlpha); - } - - if (hwcx->GlobalFlag & GFLAG_DESTSETTING) - { - MMIO (REG_3D_DstSet, prev->hwDstSet); - MMIO (REG_3D_DstAlphaWriteMask, prev->hwDstMask); - MMIO (REG_3D_DstAddress, prev->hwOffsetDest); - } - - /* Line Setting */ -#if 0 - if (hwcx->GlobalFlag & GFLAG_LINESETTING) - { - MMIO(REG_3D_LinePattern, prev->hwLinePattern); - } -#endif - - /* Fog Setting */ - if (hwcx->GlobalFlag & GFLAG_FOGSETTING) - { - MMIO (REG_3D_FogSet, prev->hwFog); - MMIO (REG_3D_FogInverseDistance, prev->hwFogInverse); - MMIO (REG_3D_FogFarDistance, prev->hwFogFar); - MMIO (REG_3D_FogFactorDensity, prev->hwFogDensity); - } - - /* Stencil Setting */ - if (hwcx->GlobalFlag & GFLAG_STENCILSETTING) - { - MMIO (REG_3D_StencilSet, prev->hwStSetting); - MMIO (REG_3D_StencilSet2, prev->hwStSetting2); - } - - /* Miscellaneous Setting */ - if (hwcx->GlobalFlag & GFLAG_DSTBLEND) - { - MMIO (REG_3D_DstBlendMode, prev->hwDstSrcBlend); - } - if (hwcx->GlobalFlag & GFLAG_CLIPPING) - { - MMIO (REG_3D_ClipTopBottom, prev->clipTopBottom); - MMIO (REG_3D_ClipLeftRight, prev->clipLeftRight); - } - - hwcx->GlobalFlag &= ~GFLAG_RENDER_STATES; -} - -void -sis_update_texture_state (__GLSiScontext * hwcx) -{ - __GLSiSHardware *prev = &hwcx->prev; - - mWait3DCmdQueue (55); - - if (hwcx->clearTexCache) - { - MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear); - MMIO (REG_3D_TEnable, prev->hwCapEnable); - hwcx->clearTexCache = GL_FALSE; - } - - /* Texture Setting */ - if (hwcx->GlobalFlag & CFLAG_TEXTURERESET) - { - MMIO (REG_3D_TextureSet, prev->texture[0].hwTextureSet); - } - if (hwcx->GlobalFlag & GFLAG_TEXTUREMIPMAP) - { - MMIO (REG_3D_TextureMip, prev->texture[0].hwTextureMip); - } - - /* - MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh); - MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow); - */ - - if (hwcx->GlobalFlag & GFLAG_TEXBORDERCOLOR) - { - MMIO (REG_3D_TextureBorderColor, prev->texture[0].hwTextureBorderColor); - } - if (hwcx->GlobalFlag & GFLAG_TEXTUREADDRESS) - { - MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear); - MMIO (REG_3D_TEnable, prev->hwCapEnable); - - switch ((prev->texture[0].hwTextureSet & MASK_TextureLevel) >> 8) - { - case 11: - MMIO (REG_3D_TextureAddress11, prev->texture[0].texOffset11); - case 10: - MMIO (REG_3D_TextureAddress10, prev->texture[0].texOffset10); - MMIO (REG_3D_TexturePitch10, prev->texture[0].texPitch10); - case 9: - MMIO (REG_3D_TextureAddress9, prev->texture[0].texOffset9); - case 8: - MMIO (REG_3D_TextureAddress8, prev->texture[0].texOffset8); - MMIO (REG_3D_TexturePitch8, prev->texture[0].texPitch89); - case 7: - MMIO (REG_3D_TextureAddress7, prev->texture[0].texOffset7); - case 6: - MMIO (REG_3D_TextureAddress6, prev->texture[0].texOffset6); - MMIO (REG_3D_TexturePitch6, prev->texture[0].texPitch67); - case 5: - MMIO (REG_3D_TextureAddress5, prev->texture[0].texOffset5); - case 4: - MMIO (REG_3D_TextureAddress4, prev->texture[0].texOffset4); - MMIO (REG_3D_TexturePitch4, prev->texture[0].texPitch45); - case 3: - MMIO (REG_3D_TextureAddress3, prev->texture[0].texOffset3); - case 2: - MMIO (REG_3D_TextureAddress2, prev->texture[0].texOffset2); - MMIO (REG_3D_TexturePitch2, prev->texture[0].texPitch23); - case 1: - MMIO (REG_3D_TextureAddress1, prev->texture[0].texOffset1); - case 0: - MMIO (REG_3D_TextureAddress0, prev->texture[0].texOffset0); - MMIO (REG_3D_TexturePitch0, prev->texture[0].texPitch01); - } - } - if (hwcx->GlobalFlag & CFLAG_TEXTURERESET_1) - { - MMIO (REG_3D_Texture1Set, prev->texture[1].hwTextureSet); - } - if (hwcx->GlobalFlag & GFLAG_TEXTUREMIPMAP_1) - { - MMIO (REG_3D_Texture1Mip, prev->texture[1].hwTextureMip); - } - - if (hwcx->GlobalFlag & GFLAG_TEXBORDERCOLOR_1) - { - MMIO (REG_3D_Texture1BorderColor, - prev->texture[1].hwTextureBorderColor); - } - if (hwcx->GlobalFlag & GFLAG_TEXTUREADDRESS_1) - { - switch ((prev->texture[1].hwTextureSet & MASK_TextureLevel) >> 8) - { - case 11: - MMIO (REG_3D_Texture1Address11, prev->texture[1].texOffset11); - case 10: - MMIO (REG_3D_Texture1Address10, prev->texture[1].texOffset10); - MMIO (REG_3D_Texture1Pitch10, prev->texture[1].texPitch10); - case 9: - MMIO (REG_3D_Texture1Address9, prev->texture[1].texOffset9); - case 8: - MMIO (REG_3D_Texture1Address8, prev->texture[1].texOffset8); - MMIO (REG_3D_Texture1Pitch8, prev->texture[1].texPitch89); - case 7: - MMIO (REG_3D_Texture1Address7, prev->texture[1].texOffset7); - case 6: - MMIO (REG_3D_Texture1Address6, prev->texture[1].texOffset6); - MMIO (REG_3D_Texture1Pitch6, prev->texture[1].texPitch67); - case 5: - MMIO (REG_3D_Texture1Address5, prev->texture[1].texOffset5); - case 4: - MMIO (REG_3D_Texture1Address4, prev->texture[1].texOffset4); - MMIO (REG_3D_Texture1Pitch4, prev->texture[1].texPitch45); - case 3: - MMIO (REG_3D_Texture1Address3, prev->texture[1].texOffset3); - case 2: - MMIO (REG_3D_Texture1Address2, prev->texture[1].texOffset2); - MMIO (REG_3D_Texture1Pitch2, prev->texture[1].texPitch23); - case 1: - MMIO (REG_3D_Texture1Address1, prev->texture[1].texOffset1); - case 0: - MMIO (REG_3D_Texture1Address0, prev->texture[1].texOffset0); - MMIO (REG_3D_Texture1Pitch0, prev->texture[1].texPitch01); - } - } - - /* texture environment */ - if (hwcx->GlobalFlag & GFLAG_TEXTUREENV) - { - MMIO (REG_3D_TextureBlendFactor, prev->hwTexEnvColor); - MMIO (REG_3D_TextureColorBlendSet0, prev->hwTexBlendClr0); - MMIO (REG_3D_TextureAlphaBlendSet0, prev->hwTexBlendAlpha0); - } - if (hwcx->GlobalFlag & GFLAG_TEXTUREENV_1) - { - MMIO (REG_3D_TextureBlendFactor, prev->hwTexEnvColor); - MMIO (REG_3D_TextureColorBlendSet1, prev->hwTexBlendClr1); - MMIO (REG_3D_TextureAlphaBlendSet1, prev->hwTexBlendAlpha1); - } - - hwcx->GlobalFlag &= ~GFLAG_TEXTURE_STATES; -} - -void -sis_validate_all_state (__GLSiScontext * hwcx) -{ - __GLSiSHardware *prev = &hwcx->prev; - - mEndPrimitive (); - mWait3DCmdQueue (40); - - /* Enable Setting */ - MMIO (REG_3D_TEnable, prev->hwCapEnable); - MMIO (REG_3D_TEnable2, prev->hwCapEnable2); - - /* Z Setting */ - /* if (prev->hwCapEnable & MASK_ZTestEnable) { */ - MMIO (REG_3D_ZSet, prev->hwZ); - MMIO (REG_3D_ZStWriteMask, prev->hwZMask); - MMIO (REG_3D_ZAddress, prev->hwOffsetZ); - /* } */ - - /* Alpha Setting */ - if (prev->hwCapEnable & MASK_AlphaTestEnable) - { - MMIO (REG_3D_AlphaSet, prev->hwAlpha); - } - - /* Destination Setting */ - MMIO (REG_3D_DstSet, prev->hwDstSet); - MMIO (REG_3D_DstAlphaWriteMask, prev->hwDstMask); - MMIO (REG_3D_DstAddress, prev->hwOffsetDest); - - /* Line Setting */ -#if 0 - if (prev->hwCapEnable2 & MASK_LinePatternEnable) { - MMIO(REG_3D_LinePattern, prev->hwLinePattern); - } -#endif - - /* Fog Setting */ - if (prev->hwCapEnable & MASK_FogEnable) - { - MMIO (REG_3D_FogSet, prev->hwFog); - MMIO (REG_3D_FogInverseDistance, prev->hwFogInverse); - MMIO (REG_3D_FogFarDistance, prev->hwFogFar); - MMIO (REG_3D_FogFactorDensity, prev->hwFogDensity); - } - - /* Stencil Setting */ - if (prev->hwCapEnable & MASK_StencilTestEnable) - { - MMIO (REG_3D_StencilSet, prev->hwStSetting); - MMIO (REG_3D_StencilSet2, prev->hwStSetting2); - } - - /* Miscellaneous Setting */ - if (prev->hwCapEnable & MASK_BlendEnable) - { - MMIO (REG_3D_DstBlendMode, prev->hwDstSrcBlend); - } - - MMIO (REG_3D_ClipTopBottom, prev->clipTopBottom); - MMIO (REG_3D_ClipLeftRight, prev->clipLeftRight); - - /* TODO */ - /* Texture Setting */ - /* if (prev->hwCapEnable & MASK_TextureEnable) */ - { - MMIO (REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear); - - MMIO (REG_3D_TEnable, prev->hwCapEnable); - - MMIO (REG_3D_TextureSet, prev->texture[0].hwTextureSet); - MMIO (REG_3D_TextureMip, prev->texture[0].hwTextureMip); - /* - MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh); - MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow); - */ - MMIO (REG_3D_TextureBorderColor, prev->texture[0].hwTextureBorderColor); - - switch ((prev->texture[0].hwTextureSet & MASK_TextureLevel) >> 8) - { - case 11: - MMIO (REG_3D_TextureAddress11, prev->texture[0].texOffset11); - case 10: - MMIO (REG_3D_TextureAddress10, prev->texture[0].texOffset10); - MMIO (REG_3D_TexturePitch10, prev->texture[0].texPitch10); - case 9: - MMIO (REG_3D_TextureAddress9, prev->texture[0].texOffset9); - case 8: - MMIO (REG_3D_TextureAddress8, prev->texture[0].texOffset8); - MMIO (REG_3D_TexturePitch8, prev->texture[0].texPitch89); - case 7: - MMIO (REG_3D_TextureAddress7, prev->texture[0].texOffset7); - case 6: - MMIO (REG_3D_TextureAddress6, prev->texture[0].texOffset6); - MMIO (REG_3D_TexturePitch6, prev->texture[0].texPitch67); - case 5: - MMIO (REG_3D_TextureAddress5, prev->texture[0].texOffset5); - case 4: - MMIO (REG_3D_TextureAddress4, prev->texture[0].texOffset4); - MMIO (REG_3D_TexturePitch4, prev->texture[0].texPitch45); - case 3: - MMIO (REG_3D_TextureAddress3, prev->texture[0].texOffset3); - case 2: - MMIO (REG_3D_TextureAddress2, prev->texture[0].texOffset2); - MMIO (REG_3D_TexturePitch2, prev->texture[0].texPitch23); - case 1: - MMIO (REG_3D_TextureAddress1, prev->texture[0].texOffset1); - case 0: - MMIO (REG_3D_TextureAddress0, prev->texture[0].texOffset0); - MMIO (REG_3D_TexturePitch0, prev->texture[0].texPitch01); - } - - /* TODO */ - /* if (hwcx->ctx->Texture.Unit[1].ReallyEnabled) */ - { - MMIO (REG_3D_Texture1Set, prev->texture[1].hwTextureSet); - MMIO (REG_3D_Texture1Mip, prev->texture[1].hwTextureMip); - /* - MMIO(REG_3D_Texture1TransparencyColorHigh, prev->texture[1].hwTextureClrHigh); - MMIO(REG_3D_Texture1TransparencyColorLow, prev->texture[1].hwTextureClrLow); - */ - MMIO (REG_3D_Texture1BorderColor, prev->texture[1].hwTextureBorderColor); - - switch ((prev->texture[1].hwTextureSet & MASK_TextureLevel) >> 8) - { - case 11: - MMIO (REG_3D_Texture1Address11, prev->texture[1].texOffset11); - case 10: - MMIO (REG_3D_Texture1Address10, prev->texture[1].texOffset10); - MMIO (REG_3D_Texture1Pitch10, prev->texture[1].texPitch10); - case 9: - MMIO (REG_3D_Texture1Address9, prev->texture[1].texOffset9); - case 8: - MMIO (REG_3D_Texture1Address8, prev->texture[1].texOffset8); - MMIO (REG_3D_Texture1Pitch8, prev->texture[1].texPitch89); - case 7: - MMIO (REG_3D_Texture1Address7, prev->texture[1].texOffset7); - case 6: - MMIO (REG_3D_Texture1Address6, prev->texture[1].texOffset6); - MMIO (REG_3D_Texture1Pitch6, prev->texture[1].texPitch67); - case 5: - MMIO (REG_3D_Texture1Address5, prev->texture[1].texOffset5); - case 4: - MMIO (REG_3D_Texture1Address4, prev->texture[1].texOffset4); - MMIO (REG_3D_Texture1Pitch4, prev->texture[1].texPitch45); - case 3: - MMIO (REG_3D_Texture1Address3, prev->texture[1].texOffset3); - case 2: - MMIO (REG_3D_Texture1Address2, prev->texture[1].texOffset2); - MMIO (REG_3D_Texture1Pitch2, prev->texture[1].texPitch23); - case 1: - MMIO (REG_3D_Texture1Address1, prev->texture[1].texOffset1); - case 0: - MMIO (REG_3D_Texture1Address0, prev->texture[1].texOffset0); - MMIO (REG_3D_Texture1Pitch0, prev->texture[1].texPitch01); - } - } - - /* texture environment */ - MMIO (REG_3D_TextureBlendFactor, prev->hwTexEnvColor); - MMIO (REG_3D_TextureColorBlendSet0, prev->hwTexBlendClr0); - MMIO (REG_3D_TextureColorBlendSet1, prev->hwTexBlendClr1); - MMIO (REG_3D_TextureAlphaBlendSet0, prev->hwTexBlendAlpha0); - MMIO (REG_3D_TextureAlphaBlendSet1, prev->hwTexBlendAlpha1); - } - - hwcx->GlobalFlag = 0; -} - -void -sis_fatal_error (void) -{ - /* free video memory, or the framebuffer device will do it automatically */ - -#ifdef XFree86Server - FatalError ("Fatal errors in libGLcore.a\n"); -#else - fprintf(stderr, "Fatal errors in sis_dri.so\n"); - exit (-1); -#endif -} diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_ctx.h xc/lib/GL/mesa/src/drv/sis/sis_ctx.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_ctx.h Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_ctx.h Wed Dec 31 16:00:00 1969 @@ -1,292 +0,0 @@ -/************************************************************************** - -Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ -/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.h,v 1.5 2000/09/26 15:56:48 tsi Exp $ */ - -/* - * Authors: - * Sung-Ching Lin - * - */ - -#ifndef _sis_ctx_h_ -#define _sis_ctx_h_ - -#include "sis_common.h" - -/* for GLboolean */ -#include - -#define PCI_CHIP_SIS300 0x0300 -#define PCI_CHIP_SIS630 0x6300 -#define PCI_CHIP_SIS540 0x5300 - -#define SIS_STATE_TRIANGLE 1 -#define SIS_STATE_LINE 2 -#define SIS_STATE_POINT 3 - -/* for swRenderFlag */ -#define SIS_SW_TRIANGLE 0x1 -#define SIS_SW_LINE 0x2 -#define SIS_SW_POINT 0x4 -#define SIS_SW_TEXTURE_DIM 0x8 -#define SIS_SW_TEXTURE_OBJ 0x10 -#define SIS_SW_TEXTURE_OBJ1 0x20 -#define SIS_SW_TEXTURE_ENV 0x100 -#define SIS_SW_TEXTURE_ENV1 0x200 - -#define SIS_SW_TEXTURE (SIS_SW_TEXTURE_DIM | \ - SIS_SW_TEXTURE_OBJ | SIS_SW_TEXTURE_OBJ1 | \ - SIS_SW_TEXTURE_ENV | SIS_SW_TEXTURE_ENV1) -#define SIS_SW_ALL (SIS_SW_POINT | SIS_SW_LINE | SIS_SW_TRIANGLE | \ - SIS_SW_TEXTURE) - -/* - ** Device dependent context state - */ -typedef struct __GLSiSTextureRec -{ - DWORD hwTextureSet; - DWORD hwTextureMip; - DWORD hwTextureClrHigh; - DWORD hwTextureClrLow; - DWORD hwTextureBorderColor; - - DWORD texOffset0; - DWORD texOffset1; - DWORD texOffset2; - DWORD texOffset3; - DWORD texOffset4; - DWORD texOffset5; - DWORD texOffset6; - DWORD texOffset7; - DWORD texOffset8; - DWORD texOffset9; - DWORD texOffset10; - DWORD texOffset11; - - DWORD texPitch01; - DWORD texPitch23; - DWORD texPitch45; - DWORD texPitch67; - DWORD texPitch89; - DWORD texPitch10; -} -__GLSiSTexture; - -typedef struct __GLSiSHardwareRec -{ - DWORD hwCapEnable, hwCapEnable2; /* Enable Setting */ - - DWORD hwOffsetZ, hwZ; /* Z Setting */ - - DWORD hwZBias, hwZMask; /* Z Setting */ - - DWORD hwAlpha; /* Alpha Setting */ - - DWORD hwDstSet, hwDstMask; /* Destination Setting */ - - DWORD hwOffsetDest; /* Destination Setting */ - - DWORD hwLinePattern; /* Line Setting */ - - DWORD hwFog; /* Fog Setting */ - - DWORD hwFogFar, hwFogInverse; /* Fog Distance setting */ - - DWORD hwFogDensity; /* Fog factor & density */ - - DWORD hwStSetting, hwStSetting2; /* Stencil Setting */ - - DWORD hwStOffset; /* Stencil Setting */ - - DWORD hwDstSrcBlend; /* Blending mode Setting */ - - DWORD clipTopBottom; /* Clip for Top & Bottom */ - - DWORD clipLeftRight; /* Clip for Left & Right */ - - struct __GLSiSTextureRec texture[2]; - - DWORD hwTexEnvColor; /* Texture Blending Setting */ - - DWORD hwTexBlendClr0; - DWORD hwTexBlendClr1; - DWORD hwTexBlendAlpha0; - DWORD hwTexBlendAlpha1; - -} -__GLSiSHardware; - -/* Device dependent context state */ - -typedef struct __GLSiScontextRec -{ - /* This must be first in this structure */ - GLcontext *gc; - - unsigned int virtualX, virtualY; - unsigned int bytesPerPixel; - unsigned char *IOBase; - unsigned char *FbBase; - unsigned int displayWidth; - unsigned int pitch; - - /* For Software Renderer */ - GLubyte *swRenderBase; - GLuint swRenderPitch; - GLubyte *swZBase; - GLuint swZPitch; - GLuint pixelValue; - GLboolean swForceRender; - - /* HW RGBA layout */ - unsigned int redMask, greenMask, blueMask, alphaMask; - unsigned int colorFormat; - - /* Z format */ - unsigned int zFormat; - - /* Clear patterns, 4 bytes */ - unsigned int clearColorPattern; - unsigned int clearZStencilPattern; - - /* Render Function */ - points_func PointsFunc; - line_func LineFunc; - triangle_func TriangleFunc; - quad_func QuadFunc; - rect_func RectFunc; - - /* DRM fd */ - int drmSubFD; - - /* AGP Memory */ - unsigned int AGPSize; - unsigned char *AGPBase; - unsigned int AGPAddr; - - /* AGP Command Buffer */ - /* TODO: use Global variables */ - unsigned char *AGPCmdBufBase; - DWORD AGPCmdBufAddr; - unsigned int AGPCmdBufSize; - DWORD *pAGPCmdBufNext; - GLboolean AGPCmdModeEnabled; - GLboolean UseAGPCmdMode; - - /* register 0x89F4 */ - DWORD AGPParseSet; - - /* register 0x89F8 */ - DWORD dwPrimitiveSet; - - __GLSiSHardware prev, current; - - DWORD chipVer; - int Chipset; - - DWORD drawableID; - - /* SGRAM block write */ - GLboolean blockWrite; - - GLuint swRenderFlag; - GLenum Primitive; - - /* Fast Path */ - GLboolean useFastPath; - - DWORD GlobalFlag; - - DWORD rawLockMask; - DWORD lockMask; - - void (*SwapBuffers)(XMesaBuffer b); - - /* Stereo */ - GLboolean isFullScreen; - GLboolean useStereo; - GLboolean stereoEnabled; - int stereo_drawIndex; - int stereo_drawSide; - GLboolean irqEnabled; - - int serialNumber; - -#if defined(XFree86Server) && defined(XF86DRI) - void *pDRIContextPriv; -#endif - - GLboolean clearTexCache; - - GLuint TexStates[SIS_MAX_TEXTURES]; - GLuint PrevTexFormat[SIS_MAX_TEXTURES]; - - int *CurrentHwcxPtr; - int *CurrentQueueLenPtr; - unsigned int *FrameCountPtr; -} -__GLSiScontext; - -/* Macros */ -#define GET_IOBase(x) ((x)->IOBase) -#define GET_FbBase(x) ((x)->FbBase) -#define GET_AGPBase(x) ((x)->AGPBase) -#define GET_DEPTH(x) ((x)->bytesPerPixel) -#define GET_WIDTH(x) ((x)->displayWidth) -#define GET_PITCH(x) ((x)->pitch) -#define GET_FbPos(hwcx,x,y) (GET_FbBase(hwcx)+(x)*GET_DEPTH(hwcx)\ - +(y)*GET_PITCH(hwcx)) - -#define GET_ColorFormat(x) ((x)->colorFormat) - -#define GET_RMASK(x) ((x)->redMask) -#define GET_GMASK(x) ((x)->greenMask) -#define GET_BMASK(x) ((x)->blueMask) -#define GET_AMASK(x) ((x)->alphaMask) - -/* update to hwcx->prev */ -extern void sis_update_drawable_state (GLcontext * ctx); - -/* update to hw */ -extern void sis_update_texture_state (__GLSiScontext * hwcx); -extern void sis_update_render_state (__GLSiScontext * hwcx, GLuint stateType); -extern void sis_validate_all_state (__GLSiScontext * hwcx); - -extern void sis_set_scissor (GLcontext * gc); - -/* AGP */ -void sis_StartAGP (GLcontext * ctx); -void sis_FlushAGP (GLcontext * ctx); -extern float *AGP_CurrentPtr; - -/* DRM FD */ -extern int gDRMSubFD; - -void sis_fatal_error (void); - -#endif diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_dd.c xc/lib/GL/mesa/src/drv/sis/sis_dd.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_dd.c Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_dd.c Sun Aug 10 22:44:55 2003 @@ -0,0 +1,171 @@ +/************************************************************************** + +Copyright 2003 Eric Anholt +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ +/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */ + +/* + * Authors: + * Sung-Ching Lin + * Eric Anholt + * + */ + +#include "sis_context.h" +#include "sis_dd.h" +#include "sis_lock.h" +#include "sis_alloc.h" + +#include "swrast/swrast.h" + +#include "utils.h" + +#define DRIVER_DATE "20030810" + +/* Return the width and height of the given buffer. + */ +static void sisDDGetBufferSize( GLframebuffer *buffer, + GLuint *width, GLuint *height ) +{ + GET_CURRENT_CONTEXT(ctx); + sisContextPtr smesa = SIS_CONTEXT(ctx); + + LOCK_HARDWARE(); + *width = smesa->driDrawable->w; + *height = smesa->driDrawable->h; + UNLOCK_HARDWARE(); +} + +/* Return various strings for glGetString(). + */ +static const GLubyte *sisDDGetString( GLcontext *ctx, GLenum name ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + static char buffer[128]; + unsigned offset; + GLuint agp_mode = (smesa->AGPSize > 0); + + switch ( name ) { + /*case GL_VENDOR: + return (GLubyte *)"Tungsten Graphics, Inc.";*/ /* XXX */ + + case GL_RENDERER: + offset = driGetRendererString( buffer, "SiS", DRIVER_DATE, agp_mode ); + + return (GLubyte *)buffer; + + default: + return NULL; + } +} + +/* Send all commands to the hardware. No-op, due to mmio. + */ +static void sisDDFlush( GLcontext *ctx ) +{ + /* Do nothing */ +} + +/* Make sure all commands have been sent to the hardware and have + * completed processing. + */ +static void sisDDFinish( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + sisDDFlush( ctx ); + WaitEngIdle( smesa ); +} + +void sisUpdateBufferSize( sisContextPtr smesa ) +{ + __GLSiSHardware *current = &smesa->current; + __GLSiSHardware *prev = &smesa->prev; + GLuint z_depth; + + if ( smesa->width == smesa->driDrawable->w && + smesa->height == smesa->driDrawable->h ) + return; + + smesa->width = smesa->driDrawable->w; + smesa->height = smesa->driDrawable->h; + smesa->bottom = smesa->height - 1; + +#if SIS_STEREO + if ( (smesa->sisScreen->screenX == smesa->width) && + (smesa->sisScreen->screenY == smesa->height) ) + smesa->isFullScreen = GL_TRUE; + else + smesa->isFullScreen = GL_FALSE; +#endif + + if ( smesa->backbuffer ) + sisFreeBackbuffer( smesa ); + if ( smesa->depthbuffer ) + sisFreeZStencilBuffer( smesa ); + + if ( smesa->glCtx->Visual.depthBits > 0 ) + sisAllocZStencilBuffer( smesa ); + if ( smesa->glCtx->Visual.doubleBufferMode ) + sisAllocBackbuffer( smesa ); + + switch (smesa->zFormat) + { + case Z_16: + z_depth = 2; + break; + case Z_32: + case S_8_Z_24: + z_depth = 4; + break; + default: + assert (0); + } + + current->hwZ &= ~MASK_ZBufferPitch; + current->hwZ |= smesa->width * z_depth >> 2; + current->hwOffsetZ = ( (GLint)smesa->depthbuffer - + (GLint)GET_FbBase(smesa) ) >> 2; + + if ((current->hwOffsetZ != prev->hwOffsetZ) || (current->hwZ != prev->hwZ)) { + prev->hwOffsetZ = current->hwOffsetZ; + prev->hwZ = current->hwZ; + smesa->GlobalFlag |= GFLAG_ZSETTING; + } + + sis_set_scissor( smesa->glCtx ); +} + +/* Initialize the driver's misc functions. + */ +void sisDDInitDriverFuncs( GLcontext *ctx ) +{ + ctx->Driver.GetBufferSize = sisDDGetBufferSize; + ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; /* XXX */ + ctx->Driver.GetString = sisDDGetString; + ctx->Driver.Finish = sisDDFinish; + ctx->Driver.Flush = sisDDFlush; + ctx->Driver.Error = NULL; +} diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_dd.h xc/lib/GL/mesa/src/drv/sis/sis_dd.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_dd.h Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_dd.h Sun Aug 10 22:44:55 2003 @@ -0,0 +1,44 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 2003 Eric Anholt +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +on the rights to use, copy, modify, merge, publish, distribute, sub +license, and/or sell copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Eric Anholt + * + */ + +#ifndef __SIS_DD_H__ +#define __SIS_DD_H__ + +#ifdef GLX_DIRECT_RENDERING + +extern void sisUpdateBufferSize( sisContextPtr smesa ); + +extern void sisDDInitDriverFuncs( GLcontext *ctx ); + +#endif +#endif diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_debug.c xc/lib/GL/mesa/src/drv/sis/sis_debug.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_debug.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_debug.c Sun Aug 10 22:44:55 2003 @@ -40,7 +40,7 @@ #include #include -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" /* for SiS 300/630/540 */ @@ -53,7 +53,7 @@ char *prevLockFile = NULL; int prevLockLine = 0; -DWORD _empty[0x10000]; +GLint _empty[0x10000]; void dump_agp (void *addr, int dword_count) @@ -81,14 +81,14 @@ d2f_once (GLcontext * ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); static int serialNumber = -1; - if (serialNumber == hwcx->serialNumber) + if (serialNumber == smesa->serialNumber) return; else - serialNumber = hwcx->serialNumber; + serialNumber = smesa->serialNumber; d2f(); } diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c Sun Aug 10 22:44:55 2003 @@ -63,19 +63,19 @@ #include "xform.h" #endif -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" #define WRITE_SMOOTH_W_T2(v) \ do{ \ - DWORD dcSARGB; \ + GLint dcSARGB; \ \ AGP_CurrentPtr[0] = VB->Win.data[v][0] - 0.5; \ AGP_CurrentPtr[1] = Y_FLIP (VB->Win.data[v][1]) + 0.5; \ AGP_CurrentPtr[2] = VB->Win.data[v][2] / 65535.0; \ AGP_CurrentPtr[3] = VB->Win.data[v][3]; \ RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[v]); \ - ((DWORD *)AGP_CurrentPtr)[4] = dcSARGB; \ + ((GLint *)AGP_CurrentPtr)[4] = dcSARGB; \ AGP_CurrentPtr[5] = VB->TexCoordPtr[0]->data[v][0]; \ AGP_CurrentPtr[6] = VB->TexCoordPtr[0]->data[v][1]; \ AGP_CurrentPtr[7] = VB->TexCoordPtr[1]->data[v][0]; \ @@ -108,9 +108,9 @@ GLuint count = VB->Count; XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - if(!hwcx->useFastPath){ + if(!smesa->useFastPath){ gl_render_vb(VB); return; } diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_fog.c xc/lib/GL/mesa/src/drv/sis/sis_fog.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_fog.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_fog.c Sun Aug 10 22:44:55 2003 @@ -32,20 +32,19 @@ * */ -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" -static DWORD convertFtToFogFt (DWORD dwInValue); +static GLint convertFtToFogFt (GLint dwInValue); void sis_Fogfv (GLcontext * ctx, GLenum pname, const GLfloat * params) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *current = &hwcx->current; + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *current = &smesa->current; GLubyte dwFogColor[4]; - DWORD dwArg; + GLint dwArg; float fArg; switch (pname) @@ -66,18 +65,18 @@ } break; case GL_FOG_DENSITY: - dwArg = *(DWORD *) (&(ctx->Fog.Density)); + dwArg = *(GLint *) (&(ctx->Fog.Density)); current->hwFogDensity = 0; current->hwFogDensity |= convertFtToFogFt (dwArg); break; case GL_FOG_START: case GL_FOG_END: fArg = 1.0 / (ctx->Fog.End - ctx->Fog.Start); - current->hwFogInverse = doFPtoFixedNoRound (*(DWORD *) (&fArg), 10); + current->hwFogInverse = doFPtoFixedNoRound (*(GLint *) (&fArg), 10); if (pname == GL_FOG_END) { - dwArg = *(DWORD *) (&(ctx->Fog.End)); - if (hwcx->Chipset == PCI_CHIP_SIS300) + dwArg = *(GLint *) (&(ctx->Fog.End)); + if (smesa->Chipset == PCI_CHIP_SIS300) { current->hwFogFar = doFPtoFixedNoRound (dwArg, 10); } @@ -91,20 +90,20 @@ /* TODO */ break; case GL_FOG_COLOR: - *((DWORD *) dwFogColor) = 0; + *((GLint *) dwFogColor) = 0; dwFogColor[2] = (GLubyte)((ctx->Fog.Color[0]) * 255.0); dwFogColor[1] = (GLubyte)((ctx->Fog.Color[1]) * 255.0); dwFogColor[0] = (GLubyte)((ctx->Fog.Color[2]) * 255.0); current->hwFog &= 0xff000000; - current->hwFog |= *((DWORD *) dwFogColor); + current->hwFog |= *((GLint *) dwFogColor); break; } } -DWORD -doFPtoFixedNoRound (DWORD dwInValue, int nFraction) +GLint +doFPtoFixedNoRound (GLint dwInValue, int nFraction) { - DWORD dwMantissa; + GLint dwMantissa; int nTemp; if (dwInValue == 0) @@ -132,11 +131,11 @@ } /* s[8].23->s[7].10 */ -static DWORD -convertFtToFogFt (DWORD dwInValue) +static GLint +convertFtToFogFt (GLint dwInValue) { - DWORD dwMantissa, dwExp; - DWORD dwRet; + GLint dwMantissa, dwExp; + GLint dwRet; if (dwInValue == 0) return 0; @@ -153,7 +152,7 @@ dwExp = (dwInValue & 0x7F800000) >> 23; dwExp -= 63; - if ((LONG) dwExp < 0) + if (dwExp < 0) return 0; if (dwExp <= 0x7F) diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_init.h xc/lib/GL/mesa/src/drv/sis/sis_init.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_init.h Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_init.h Sun Aug 10 22:44:55 2003 @@ -35,13 +35,7 @@ #ifndef _sis_init_h_ #define _sis_init_h_ -typedef LONG fixed; - -typedef struct _FIXEDCOLOR -{ - fixed r, g, b, a; -} -FIXEDCOLOR; +typedef long fixed; /* XXX should this be a long? */ #define COMMANDMODE_MMIO 1 #define COMMANDMODE_WC 2 @@ -65,7 +59,7 @@ ((GLubyte *)fixedColor)[3] = ((GLubyte *)color)[3] ; \ } -/* Put ARGB into DWORD */ +/* Put ARGB into GLint */ #define setTSARGB(dcSARGB, fixedColor)\ {\ dcSARGB = ((fixedColor.a & 0x00ff0000) << 8 | \ @@ -81,13 +75,13 @@ #define MMIO(reg, value) \ {\ - *(LPDWORD)(GET_IOBase(hwcx) + (reg)) = value; \ + *(GLint *)(GET_IOBase(smesa) + (reg)) = value; \ } #define mEndPrimitive() \ { \ - *(GET_IOBase(hwcx) + REG_3D_EndPrimitiveList) = 0xFF; \ - *(DWORD *)(GET_IOBase(hwcx) + 0x8b60) = (DWORD)(-1); \ + *(GET_IOBase(smesa) + REG_3D_EndPrimitiveList) = 0xFF; \ + *(GLint *)(GET_IOBase(smesa) + 0x8b60) = (GLint)(-1); \ } #define INIT_6327_CapsEnable 0x00000080 @@ -202,13 +196,13 @@ /* Get lock before calling this */ #define mWait3DCmdQueue(wLen)\ do{\ - while ( *(hwcx->CurrentQueueLenPtr) < (int)(wLen))\ + while ( *(smesa->CurrentQueueLenPtr) < (int)(wLen))\ {\ - *(hwcx->CurrentQueueLenPtr) = \ - (int)(*(DWORD *)(GET_IOBase(hwcx) + REG_QUELEN) & MASK_QUELEN) \ + *(smesa->CurrentQueueLenPtr) = \ + (int)(*(GLint *)(GET_IOBase(smesa) + REG_QUELEN) & MASK_QUELEN) \ - (int)20; \ }\ - *(hwcx->CurrentQueueLenPtr) -= (int)(wLen);\ + *(smesa->CurrentQueueLenPtr) -= (int)(wLen);\ }while(0) #if 0 diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h Sun Aug 10 22:44:55 2003 @@ -35,7 +35,7 @@ #define SIS_TRI_FUNC 0 #define SIS_MMIO_WRITE_VERTEX(v, i) \ - if(SIS_STEREO && hwcx->stereoEnabled) \ + if(SIS_STEREO && smesa->stereoEnabled) \ { \ MMIOBase[(REG_3D_TSXa+(i)*0x30)/4] = VB->Win.data[v][0] - 0.5 + STEREO_OFFSET(v); \ MMIOBase[(REG_3D_TSYa+(i)*0x30)/4] = Y_FLIP (VB->Win.data[v][1]) + 0.5; \ @@ -103,29 +103,29 @@ \ if (SIS_STATES & (SIS_SMOOTH)) \ { \ - DWORD dcSARGB; \ + GLint dcSARGB; \ \ RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[v]); \ \ - ((DWORD *) MMIOBase)[(REG_3D_TSARGBa+(i)*0x30)/4] = dcSARGB; \ + ((GLint *) MMIOBase)[(REG_3D_TSARGBa+(i)*0x30)/4] = dcSARGB; \ } \ else if(LAST_VERTEX) \ { \ - DWORD dcSARGB; \ + GLint dcSARGB; \ \ RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[pv]); \ \ - ((DWORD *) MMIOBase)[(REG_3D_TSARGBa+(i)*0x30)/4] = dcSARGB; \ + ((GLint *) MMIOBase)[(REG_3D_TSARGBa+(i)*0x30)/4] = dcSARGB; \ } \ static void SIS_TAG (sis_line) (GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pv) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); struct vertex_buffer *VB = ctx->VB; - float *MMIOBase = (float *) GET_IOBase (hwcx); + float *MMIOBase = (float *) GET_IOBase (smesa); STEREO_SAMPLE(vert0); @@ -133,19 +133,19 @@ if (SIS_STATES & (SIS_SMOOTH)) { - hwcx->dwPrimitiveSet &= ~0x07001f07; - hwcx->dwPrimitiveSet |= + smesa->dwPrimitiveSet &= ~0x07001f07; + smesa->dwPrimitiveSet |= (OP_3D_FIRE_TSARGBb | SHADE_GOURAUD | OP_3D_LINE_DRAW); - ((DWORD *) MMIOBase)[REG_3D_PrimitiveSet / 4] = hwcx->dwPrimitiveSet; + ((GLint *) MMIOBase)[REG_3D_PrimitiveSet / 4] = smesa->dwPrimitiveSet; } else { - hwcx->dwPrimitiveSet &= ~0x07001f07; - hwcx->dwPrimitiveSet |= + smesa->dwPrimitiveSet &= ~0x07001f07; + smesa->dwPrimitiveSet |= (OP_3D_FIRE_TSARGBb | SHADE_FLAT_VertexB | OP_3D_LINE_DRAW); - ((DWORD *) MMIOBase)[REG_3D_PrimitiveSet / 4] = hwcx->dwPrimitiveSet; + ((GLint *) MMIOBase)[REG_3D_PrimitiveSet / 4] = smesa->dwPrimitiveSet; } #define LAST_VERTEX 0 @@ -157,14 +157,14 @@ /* debug mEndPrimitive (); - WaitEngIdle(hwcx); + WaitEngIdle(smesa); d2f_once (ctx); */ } #define SIS_AGP_WRITE_VERTEX(v) \ do{ \ -if(SIS_STEREO && hwcx->stereoEnabled) \ +if(SIS_STEREO && smesa->stereoEnabled) \ { \ AGP_CurrentPtr[0] = VB->Win.data[v][0] - 0.5 + STEREO_OFFSET(v); \ } \ @@ -201,16 +201,16 @@ if (SIS_STATES & (SIS_SMOOTH)) \ { \ RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[v]); \ - ((DWORD *)AGP_CurrentPtr)[0] = dcSARGB; \ + ((GLint *)AGP_CurrentPtr)[0] = dcSARGB; \ } \ else if(FIRST_VERTEX) \ { \ RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[pv]); \ - ((DWORD *)AGP_CurrentPtr)[0] = dcSARGB; \ + ((GLint *)AGP_CurrentPtr)[0] = dcSARGB; \ } \ else \ { \ - ((DWORD *)AGP_CurrentPtr)[0] = dcSARGB; \ + ((GLint *)AGP_CurrentPtr)[0] = dcSARGB; \ } \ AGP_CurrentPtr+=1; \ \ @@ -250,16 +250,16 @@ GLuint pv) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); struct vertex_buffer *VB = ctx->VB; - DWORD dcSARGB; + GLint dcSARGB; STEREO_SAMPLE(vert0); #if 0 - if ((DWORD) AGP_CurrentPtr - (DWORD) AGP_StartPtr >= (AGP_ALLOC_SIZE - 0x10)) + if ((GLint) AGP_CurrentPtr - (GLint) AGP_StartPtr >= (AGP_ALLOC_SIZE - 0x10)) { sis_FlushAGP (ctx); sis_StartAGP (ctx); diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_lock.c xc/lib/GL/mesa/src/drv/sis/sis_lock.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_lock.c Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_lock.c Sun Aug 10 22:44:55 2003 @@ -0,0 +1,77 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 2003 Eric Anholt +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +on the rights to use, copy, modify, merge, publish, distribute, sub +license, and/or sell copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Eric Anholt + * + */ + +#include "context.h" +#include "sis_context.h" +#include "sis_lock.h" +#include "sis_mesa.h" + +/* Update the hardware state. This is called if another context has + * grabbed the hardware lock, which includes the X server. This + * function also updates the driver's window state after the X server + * moves, resizes or restacks a window -- the change will be reflected + * in the drawable position and clip rects. Since the X server grabs + * the hardware lock when it changes the window state, this routine will + * automatically be called after such a change. + */ +void +sisGetLock( sisContextPtr smesa, GLuint flags ) +{ + __DRIdrawablePrivate *dPriv = smesa->driDrawable; + __DRIscreenPrivate *sPriv = smesa->driScreen; + SISSAREAPrivPtr sarea = smesa->sarea; + + drmGetLock( smesa->driFd, smesa->hHWContext, flags ); + + /* The window might have moved, so we might need to get new clip + * rects. + * + * NOTE: This releases and regrabs the hw lock to allow the X server + * to respond to the DRI protocol request for new drawable info. + * Since the hardware state depends on having the latest drawable + * clip rects, all state checking must be done _after_ this call. + */ + DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv ); + + if ( smesa->lastStamp != dPriv->lastStamp ) { + sisUpdateBufferSize( smesa ); + /* XXX FIXME */ + /*sis_SetDrawBuffer( smesa->glCtx, smesa->glCtx->Color.DriverDrawBuffer );*/ + smesa->lastStamp = dPriv->lastStamp; + } + + if ( sarea->ctxOwner != smesa->hHWContext ) { + sarea->ctxOwner = smesa->hHWContext; + sis_validate_all_state( smesa ); + } +} diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_lock.h xc/lib/GL/mesa/src/drv/sis/sis_lock.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_lock.h Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_lock.h Sun Aug 10 22:44:55 2003 @@ -32,8 +32,10 @@ * */ -#ifndef _sis_dri_h_ -#define _sis_dri_h_ +#ifndef __SIS_LOCK_H +#define __SIS_LOCK_H + +extern void sisGetLock( sisContextPtr smesa, GLuint flags ); /* from tdfx */ #define SIS_VALIDATE_DRAWABLE_INFO(dpy, psp, pdp) \ @@ -71,66 +73,26 @@ #define DEBUG_CHECK_LOCK() #endif -#ifdef XFree86Server - -/* TODO, X-server will inform us if drawable state changed? */ -#define LOCK_HARDWARE() \ - do { \ - mEndPrimitive(); \ - sis_SetDrawBuffer (ctx, ctx->Color.DriverDrawBuffer); \ - if(*(hwcx->CurrentHwcxPtr) != hwcx->serialNumber) \ - sis_validate_all_state(hwcx); \ - } while (0) - -#define UNLOCK_HARDWARE() \ - do { \ - mEndPrimitive(); \ - } while (0) - -#else - -#define DRM_LIGHT_LOCK_RETURN(fd,lock,context,__ret) \ - do { \ - DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \ - if (__ret) drmGetLock(fd,context,0); \ - } while(0) - /* Lock the hardware using the global current context */ -#define LOCK_HARDWARE() \ - do { \ - int stamp; \ - char __ret=0; \ - __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv; \ - __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \ - mEndPrimitive(); \ - DEBUG_CHECK_LOCK(); \ - DEBUG_LOCK(); \ - DRM_LIGHT_LOCK_RETURN(sPriv->fd, &sPriv->pSAREA->lock, \ - dPriv->driContextPriv->hHWContext, __ret); \ - stamp=dPriv->lastStamp; \ - XMESA_VALIDATE_DRAWABLE_INFO(xmesa->display, sPriv, dPriv); \ - if (*(dPriv->pStamp)!=stamp) \ - { \ - sis_SetDrawBuffer (ctx, ctx->Color.DriverDrawBuffer); \ - } \ - if(__ret && (*(hwcx->CurrentHwcxPtr) != hwcx->serialNumber)) \ - { \ - sis_validate_all_state(hwcx); \ - } \ +#define LOCK_HARDWARE() \ + do { \ + char __ret=0; \ + mEndPrimitive(); \ + DEBUG_CHECK_LOCK(); \ + DRM_CAS( smesa->driHwLock, smesa->hHWContext, \ + (DRM_LOCK_HELD | smesa->hHWContext), __ret ); \ + if ( __ret != 0 ) \ + sisGetLock( smesa, 0 ); \ + DEBUG_LOCK(); \ } while (0) /* Unlock the hardware using the global current context */ -#define UNLOCK_HARDWARE() \ - do { \ - __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv; \ - __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \ - mEndPrimitive(); \ - DEBUG_RESET(); \ - *(hwcx->CurrentHwcxPtr) = hwcx->serialNumber; \ - DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, \ - dPriv->driContextPriv->hHWContext); \ +#define UNLOCK_HARDWARE() \ + do { \ + mEndPrimitive(); \ + DRM_UNLOCK(smesa->driFd, smesa->driHwLock, \ + smesa->hHWContext); \ + DEBUG_RESET(); \ } while (0) - -#endif #endif diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_mesa.c xc/lib/GL/mesa/src/drv/sis/sis_mesa.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_mesa.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_mesa.c Sun Aug 10 22:44:55 2003 @@ -32,7 +32,7 @@ * */ -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" #include "sis_lock.h" @@ -42,37 +42,37 @@ sis_RenderStart (GLcontext * ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); LOCK_HARDWARE (); - if (hwcx->Primitive & hwcx->swRenderFlag) + if (smesa->Primitive & smesa->swRenderFlag) { - WaitEngIdle (hwcx); + WaitEngIdle (smesa); } if (ctx->Texture.ReallyEnabled) { sis_validate_texture (ctx); - if (hwcx->swRenderFlag & SIS_SW_TEXTURE) + if (smesa->swRenderFlag & SIS_SW_TEXTURE) { - hwcx->swForceRender = GL_TRUE; + smesa->swForceRender = GL_TRUE; gl_update_state(ctx); - hwcx->swForceRender = GL_FALSE; + smesa->swForceRender = GL_FALSE; } else { - if (hwcx->GlobalFlag & GFLAG_TEXTURE_STATES) - sis_update_texture_state (hwcx); + if (smesa->GlobalFlag & GFLAG_TEXTURE_STATES) + sis_update_texture_state (smesa); } } - if (hwcx->GlobalFlag & GFLAG_RENDER_STATES) + if (smesa->GlobalFlag & GFLAG_RENDER_STATES) { - sis_update_render_state (hwcx, 0); + sis_update_render_state (smesa, 0); } - if (hwcx->UseAGPCmdMode) + if (smesa->UseAGPCmdMode) { sis_StartAGP (ctx); } @@ -86,9 +86,9 @@ sis_RenderFinish (GLcontext * ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - if (hwcx->UseAGPCmdMode) + if (smesa->UseAGPCmdMode) { sis_FlushAGP (ctx); } @@ -100,10 +100,10 @@ sis_ReducedPrimitiveChange (GLcontext * ctx, GLenum primitive) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); /* it is possible several primitive types per VB */ - if (hwcx->UseAGPCmdMode) + if (smesa->UseAGPCmdMode) { sis_FlushAGP (ctx); sis_StartAGP (ctx); @@ -120,22 +120,22 @@ /* TODO: if above rule changes, remember to modify */ } - hwcx->AGPParseSet &= ~0xf; + smesa->AGPParseSet &= ~0xf; switch (primitive) { case GL_POINT: case GL_POINTS: - hwcx->Primitive = SIS_SW_POINT; - hwcx->AGPParseSet |= 0x0; + smesa->Primitive = SIS_SW_POINT; + smesa->AGPParseSet |= 0x0; break; case GL_LINE: case GL_LINES: - hwcx->Primitive = SIS_SW_LINE; - hwcx->AGPParseSet |= 0x4; + smesa->Primitive = SIS_SW_LINE; + smesa->AGPParseSet |= 0x4; break; case GL_POLYGON: - hwcx->Primitive = SIS_SW_TRIANGLE; - hwcx->AGPParseSet |= 0x8; + smesa->Primitive = SIS_SW_TRIANGLE; + smesa->AGPParseSet |= 0x8; break; } } @@ -144,15 +144,13 @@ sis_init_driver (GLcontext * ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); ctx->Driver.UpdateState = sis_UpdateState; ctx->Driver.RenderStart = sis_RenderStart; ctx->Driver.RenderFinish = sis_RenderFinish; ctx->Driver.ReducedPrimitiveChange = sis_ReducedPrimitiveChange; - ctx->Driver.Finish = sis_Finish; - ctx->Driver.Flush = sis_Flush; ctx->Driver.AlphaFunc = sis_AlphaFunc; ctx->Driver.BlendEquation = sis_BlendEquation; @@ -194,8 +192,6 @@ ctx->Driver.ClearColor = sis_ClearColor; ctx->Driver.SetDrawBuffer = sis_SetDrawBuffer; ctx->Driver.SetReadBuffer = sis_SetReadBuffer; - ctx->Driver.GetBufferSize = sis_GetBufferSize; - ctx->Driver.GetString = sis_GetString; ctx->Driver.ColorMask = sis_ColorMask; ctx->Driver.LogicOp = sis_LogicOp; ctx->Driver.Dither = sis_Dither; @@ -216,7 +212,7 @@ ctx->Driver.RegisterPipelineStages = sis_RegisterPipelineStages; /* driver-specific */ - hwcx->SwapBuffers = sis_swap_buffers; + smesa->SwapBuffers = sis_swap_buffers; #ifdef SIS_USE_HW_CULL /* set capability flag */ @@ -228,10 +224,10 @@ sis_UpdateState (GLcontext * ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; sis_set_render_func (ctx); @@ -283,7 +279,7 @@ int i; for (i = 0; i < SIS_MAX_TEXTURES; i++) { - hwcx->TexStates[i] |= (NEW_TEXTURING | NEW_TEXTURE_ENV); + smesa->TexStates[i] |= (NEW_TEXTURING | NEW_TEXTURE_ENV); } } #endif @@ -293,14 +289,14 @@ if (current->hwCapEnable ^ prev->hwCapEnable) { prev->hwCapEnable = current->hwCapEnable; - hwcx->GlobalFlag |= GFLAG_ENABLESETTING; + smesa->GlobalFlag |= GFLAG_ENABLESETTING; } /* enable setting 2 */ if (current->hwCapEnable2 ^ prev->hwCapEnable2) { prev->hwCapEnable2 = current->hwCapEnable2; - hwcx->GlobalFlag |= GFLAG_ENABLESETTING2; + smesa->GlobalFlag |= GFLAG_ENABLESETTING2; } /* TODO: if fog disable, don't check */ @@ -310,22 +306,22 @@ if (current->hwFog ^ prev->hwFog) { prev->hwFog = current->hwFog; - hwcx->GlobalFlag |= GFLAG_FOGSETTING; + smesa->GlobalFlag |= GFLAG_FOGSETTING; } if (current->hwFogFar ^ prev->hwFogFar) { prev->hwFogFar = current->hwFogFar; - hwcx->GlobalFlag |= GFLAG_FOGSETTING; + smesa->GlobalFlag |= GFLAG_FOGSETTING; } if (current->hwFogInverse ^ prev->hwFogInverse) { prev->hwFogInverse = current->hwFogInverse; - hwcx->GlobalFlag |= GFLAG_FOGSETTING; + smesa->GlobalFlag |= GFLAG_FOGSETTING; } if (current->hwFogDensity ^ prev->hwFogDensity) { prev->hwFogDensity = current->hwFogDensity; - hwcx->GlobalFlag |= GFLAG_FOGSETTING; + smesa->GlobalFlag |= GFLAG_FOGSETTING; } } @@ -337,16 +333,16 @@ * will be called */ #if SIS_STEREO - if(hwcx->isFullScreen && + if(smesa->isFullScreen && (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT) && - hwcx->useStereo) + smesa->useStereo) { - if(!hwcx->stereoEnabled){ + if(!smesa->stereoEnabled){ sis_init_stereo(ctx); } } else{ - if(hwcx->stereoEnabled){ + if(smesa->stereoEnabled){ sis_final_stereo(ctx); } } @@ -362,18 +358,18 @@ sis_set_buffer_static (GLcontext * ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; GLvisual *visual = ctx->Visual; - switch (hwcx->bytesPerPixel) + switch (smesa->bytesPerPixel) { case 2: /* TODO: don't check - if (hwcx->redMask == 0xf800 && hwcx->greenMask == 0x07e0 && - hwcx->blueMask == 0x001f) + if (smesa->redMask == 0xf800 && smesa->greenMask == 0x07e0 && + smesa->blueMask == 0x001f) */ { current->hwDstSet |= DST_FORMAT_RGB_565; @@ -381,8 +377,8 @@ break; case 4: /* - if (hwcx->redMask == 0xff0000 && hwcx->greenMask == 0xff00 && - hwcx->blueMask == 0xff) + if (smesa->redMask == 0xff0000 && smesa->greenMask == 0xff00 && + smesa->blueMask == 0xff) */ { switch (visual->AlphaBits) @@ -407,66 +403,49 @@ case 0: current->hwCapEnable &= ~MASK_ZWriteEnable; case 16: - hwcx->zFormat = Z_16; + smesa->zFormat = Z_16; current->hwCapEnable |= MASK_ZWriteEnable; break; case 32: - hwcx->zFormat = Z_32; + smesa->zFormat = Z_32; current->hwCapEnable |= MASK_ZWriteEnable; break; case 24: assert (visual->StencilBits); - hwcx->zFormat = S_8_Z_24; + smesa->zFormat = S_8_Z_24; current->hwCapEnable |= MASK_StencilBufferEnable; current->hwCapEnable |= MASK_ZWriteEnable; break; } current->hwZ &= ~MASK_ZBufferFormat; - current->hwZ |= hwcx->zFormat; + current->hwZ |= smesa->zFormat; /* Destination Color Format */ if (current->hwDstSet ^ prev->hwDstSet) { prev->hwDstSet = current->hwDstSet; - hwcx->GlobalFlag |= GFLAG_DESTSETTING; + smesa->GlobalFlag |= GFLAG_DESTSETTING; } /* Z Buffer Data Format */ if (current->hwZ ^ prev->hwZ) { prev->hwZ = current->hwZ; - hwcx->GlobalFlag |= GFLAG_ZSETTING; + smesa->GlobalFlag |= GFLAG_ZSETTING; } sis_sw_set_zfuncs_static (ctx); } void -sis_Finish (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - sis_Flush (ctx); - - WaitEngIdle (hwcx); -} - -void -sis_Flush (GLcontext * ctx) -{ - /* do nothing now */ -} - -void sis_AlphaFunc (GLcontext * ctx, GLenum func, GLclampf ref) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; /* TODO: ref is type GLclampf, but mesa has scaled it to 0 - 255.0 */ current->hwAlpha = ((unsigned char) ref) << 16; @@ -502,7 +481,7 @@ } prev->hwAlpha = current->hwAlpha; - hwcx->GlobalFlag |= GFLAG_ALPHASETTING; + smesa->GlobalFlag |= GFLAG_ALPHASETTING; } void @@ -516,10 +495,10 @@ sis_BlendFunc (GLcontext * ctx, GLenum sfactor, GLenum dfactor) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; /* TODO: in ICD, if no blend, it will reset these value */ /* blending enable */ @@ -587,7 +566,7 @@ if (current->hwDstSrcBlend ^ prev->hwDstSrcBlend) { prev->hwDstSrcBlend = current->hwDstSrcBlend; - hwcx->GlobalFlag |= GFLAG_DSTBLEND; + smesa->GlobalFlag |= GFLAG_DSTBLEND; } } @@ -602,17 +581,17 @@ { #ifdef SIS_USE_HW_CULL XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - hwcx->AGPParseSet &= ~0x00008000; - hwcx->dwPrimitiveSet &= ~0x08000000; + smesa->AGPParseSet &= ~0x00008000; + smesa->dwPrimitiveSet &= ~0x08000000; /* TODO : GL_FRONT_AND_BACK must be handled elsewhere */ if((mode == GL_FRONT && ctx->Polygon.FrontFace == GL_CCW) || (mode == GL_BACK && ctx->Polygon.FrontFace == GL_CW)) { - hwcx->AGPParseSet |= 0x00008000; - hwcx->dwPrimitiveSet |= 0x08000000; + smesa->AGPParseSet |= 0x00008000; + smesa->dwPrimitiveSet |= 0x08000000; } #endif } @@ -629,9 +608,9 @@ sis_DepthFunc (GLcontext * ctx, GLenum func) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; GLuint hwZFunc = 0; @@ -669,7 +648,7 @@ { prev->hwZ = current->hwZ; - hwcx->GlobalFlag |= GFLAG_ZSETTING; + smesa->GlobalFlag |= GFLAG_ZSETTING; } } @@ -677,9 +656,9 @@ sis_DepthMask (GLcontext * ctx, GLboolean flag) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; if (ctx->Visual->StencilBits) { @@ -693,13 +672,13 @@ else { current->hwCapEnable2 |= MASK_ZMaskWriteEnable; - current->hwZMask = ((DWORD) ctx->Stencil.WriteMask << 24) | + current->hwZMask = ((GLint) ctx->Stencil.WriteMask << 24) | ((flag) ? 0x00ffffff : 0); if (current->hwZMask ^ prev->hwZMask) { prev->hwZMask = current->hwZMask; - hwcx->GlobalFlag |= GFLAG_ZSETTING; + smesa->GlobalFlag |= GFLAG_ZSETTING; } } } @@ -732,9 +711,9 @@ sis_Enable (GLcontext * ctx, GLenum cap, GLboolean state) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *current = &smesa->current; switch (cap) { @@ -947,8 +926,8 @@ { #if 0 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *current = &hwcx->current; + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *current = &smesa->current; #endif switch (target) @@ -1022,9 +1001,9 @@ GLubyte blue, GLubyte alpha) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - set_color_pattern (hwcx, red, green, blue, alpha); + set_color_pattern (smesa, red, green, blue, alpha); } @@ -1037,10 +1016,10 @@ void sis_set_render_pos(GLcontext * ctx, GLubyte *base, GLuint pitch) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; assert (base != NULL); @@ -1050,10 +1029,10 @@ } /* software render */ - hwcx->swRenderBase = base; - hwcx->swRenderPitch = pitch; + smesa->swRenderBase = base; + smesa->swRenderPitch = pitch; - current->hwOffsetDest = ((DWORD) base - (DWORD) GET_FbBase (hwcx)) >> 1; + current->hwOffsetDest = ((GLint) base - (GLint) GET_FbBase (smesa)) >> 1; current->hwDstSet &= ~MASK_DstBufferPitch; current->hwDstSet |= pitch >> 2; @@ -1061,13 +1040,13 @@ if (current->hwDstSet ^ prev->hwDstSet) { prev->hwDstSet = current->hwDstSet; - hwcx->GlobalFlag |= GFLAG_DESTSETTING; + smesa->GlobalFlag |= GFLAG_DESTSETTING; } if (current->hwOffsetDest ^ prev->hwOffsetDest) { prev->hwOffsetDest = current->hwOffsetDest; - hwcx->GlobalFlag |= GFLAG_DESTSETTING; + smesa->GlobalFlag |= GFLAG_DESTSETTING; } } @@ -1075,7 +1054,7 @@ sis_SetDrawBuffer (GLcontext * ctx, GLenum mode) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); XMesaBuffer xm_buffer = xmesa->xm_buffer; GLubyte *base; @@ -1093,7 +1072,7 @@ break; case GL_FRONT_LEFT: base = sis_get_drawable_pos (xmesa); - pitch = GET_PITCH (hwcx); + pitch = GET_PITCH (smesa); retval = GL_TRUE; break; case GL_BACK_RIGHT: @@ -1121,10 +1100,10 @@ GLboolean bmask, GLboolean amask) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; if (rmask & gmask & bmask & @@ -1138,16 +1117,16 @@ current->hwCapEnable2 |= (MASK_AlphaMaskWriteEnable | MASK_ColorMaskWriteEnable); - current->hwDstMask = (rmask) ? GET_RMASK (hwcx) : 0 | - (gmask) ? GET_GMASK (hwcx) : 0 | - (bmask) ? GET_BMASK (hwcx) : 0 | - (amask) ? GET_AMASK (hwcx) : 0; + current->hwDstMask = (rmask) ? GET_RMASK (smesa) : 0 | + (gmask) ? GET_GMASK (smesa) : 0 | + (bmask) ? GET_BMASK (smesa) : 0 | + (amask) ? GET_AMASK (smesa) : 0; } if (current->hwDstMask ^ prev->hwDstMask) { prev->hwDstMask = current->hwDstMask; - hwcx->GlobalFlag |= GFLAG_DESTSETTING; + smesa->GlobalFlag |= GFLAG_DESTSETTING; } return GL_TRUE; @@ -1157,10 +1136,10 @@ sis_LogicOp (GLcontext * ctx, GLenum op) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; if (ctx->Color.ColorLogicOpEnabled) { @@ -1220,7 +1199,7 @@ if (current->hwDstSet ^ prev->hwDstSet) { prev->hwDstSet = current->hwDstSet; - hwcx->GlobalFlag |= GFLAG_DESTSETTING; + smesa->GlobalFlag |= GFLAG_DESTSETTING; } } return GL_TRUE; @@ -1230,9 +1209,9 @@ sis_Dither (GLcontext * ctx, GLboolean enable) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *current = &smesa->current; if (enable) { @@ -1273,9 +1252,9 @@ const GLvoid * pixels) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - WaitEngIdle (hwcx); + WaitEngIdle (smesa); return 0; } @@ -1285,11 +1264,11 @@ const GLubyte * bitmap) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); ctx->Driver.RenderStart( ctx ); - WaitEngIdle (hwcx); + WaitEngIdle (smesa); /* TODO: use tdfx's Bitmap */ ctx->Driver.RenderFinish( ctx ); @@ -1298,20 +1277,20 @@ } void -set_color_pattern (__GLSiScontext * hwcx, GLubyte red, GLubyte green, +set_color_pattern (sisContextPtr smesa, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) { /* XXX only RGB565 and ARGB8888 */ - switch (GET_ColorFormat (hwcx)) + switch (GET_ColorFormat (smesa)) { case DST_FORMAT_ARGB_8888: - hwcx->clearColorPattern = (alpha << 24) + + smesa->clearColorPattern = (alpha << 24) + (red << 16) + (green << 8) + (blue); break; case DST_FORMAT_RGB_565: - hwcx->clearColorPattern = ((red >> 3) << 11) + + smesa->clearColorPattern = ((red >> 3) << 11) + ((green >> 2) << 5) + (blue >> 3); - hwcx->clearColorPattern |= hwcx->clearColorPattern << 16; + smesa->clearColorPattern |= smesa->clearColorPattern << 16; break; default: assert (0); @@ -1319,7 +1298,7 @@ } void -set_z_stencil_pattern (__GLSiScontext * hwcx, GLclampd z, int stencil) +set_z_stencil_pattern (sisContextPtr smesa, GLclampd z, int stencil) { GLuint zPattern, stencilPattern; GLboolean dword_pattern; @@ -1329,11 +1308,11 @@ else if (z >= (float) 1.0) zPattern = 0xFFFFFFFF; else - zPattern = doFPtoFixedNoRound (*(DWORD *) & z, 32); + zPattern = doFPtoFixedNoRound (*(GLint *) & z, 32); stencilPattern = 0; - switch (hwcx->zFormat) + switch (smesa->zFormat) { case Z_16: zPattern = zPattern >> 16; @@ -1352,20 +1331,20 @@ default: assert (0); } - hwcx->clearZStencilPattern = zPattern | stencilPattern; + smesa->clearZStencilPattern = zPattern | stencilPattern; /* ?? */ if (!dword_pattern) - hwcx->clearZStencilPattern |= (zPattern | stencilPattern) << 16; + smesa->clearZStencilPattern |= (zPattern | stencilPattern) << 16; } void sis_update_drawable_state (GLcontext * ctx) { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *current = &hwcx->current; - __GLSiSHardware *prev = &hwcx->prev; + __GLSiSHardware *current = &smesa->current; + __GLSiSHardware *prev = &smesa->prev; XMesaBuffer xm_buffer = xmesa->xm_buffer; GLuint z_depth; @@ -1373,7 +1352,7 @@ sis_SetDrawBuffer (ctx, ctx->Color.DriverDrawBuffer); /* TODO: call sis_SetReadBuffer? */ - switch (hwcx->zFormat) + switch (smesa->zFormat) { case Z_16: z_depth = 2; @@ -1389,8 +1368,8 @@ current->hwZ &= ~MASK_ZBufferPitch; current->hwZ |= xm_buffer->width * z_depth >> 2; /* TODO, in xfree 3.9.18, no ctx->Buffer */ - current->hwOffsetZ = ((DWORD) (xm_buffer->depthbuffer) - - (DWORD) GET_FbBase (hwcx)) >> 2; + current->hwOffsetZ = ((GLint) (xm_buffer->depthbuffer) - + (GLint) GET_FbBase (smesa)) >> 2; if ((current->hwOffsetZ ^ prev->hwOffsetZ) || (current->hwZ ^ prev->hwZ)) @@ -1399,122 +1378,7 @@ prev->hwZ = current->hwZ; /* Z setting */ - hwcx->GlobalFlag |= GFLAG_ZSETTING; - } -} - -void -sis_GetBufferSize (GLframebuffer *buffer, GLuint * width, GLuint * height) -{ - GET_CURRENT_CONTEXT(ctx); - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *current = &hwcx->current; - __GLSiSHardware *prev = &hwcx->prev; - - GLuint winwidth, winheight; - XMesaBuffer xm_buffer = xmesa->xm_buffer; - -#ifndef XFree86Server - SIS_VALIDATE_DRAWABLE_INFO (xmesa->display, - xmesa->driContextPriv->driScreenPriv, - xmesa->driContextPriv->driDrawablePriv); -#endif - sis_get_drawable_size (xmesa, &winwidth, &winheight); - - *width = winwidth; - *height = winheight; - - if (winwidth != xm_buffer->width || winheight != xm_buffer->height) - { - GLuint z_depth; - - if (SIS_VERBOSE&VERBOSE_SIS_BUFFER) - { - fprintf(stderr, "GetBufferSize: before=(%d,%d), after=(%d,%d)\n", - xm_buffer->width, xm_buffer->height, winwidth, winheight); - } - - xm_buffer->width = winwidth; - xm_buffer->height = winheight; - - /* update hwcx->isFullScreen */ - /* TODO: Does X-server have exclusive-mode? */ - /* TODO: physical screen width/height will be changed dynamicly */ - -#if SIS_STEREO - if((hwcx->virtualX == winwidth) && (hwcx->virtualY == winheight)) - hwcx->isFullScreen = GL_TRUE; - else - hwcx->isFullScreen = GL_FALSE; -#endif - - if (xm_buffer->db_state) - { - sisBufferInfo *priv = (sisBufferInfo *) xm_buffer->private; - - sis_alloc_back_image (ctx, xm_buffer->backimage, &priv->bbFree, - &priv->cbClearPacket); - } - - if (ctx->Visual->DepthBits) - sis_alloc_z_stencil_buffer (ctx); - - switch (hwcx->zFormat) - { - case Z_16: - z_depth = 2; - break; - case Z_32: - case S_8_Z_24: - z_depth = 4; - break; - default: - assert (0); - } - - sis_SetDrawBuffer (ctx, ctx->Color.DriverDrawBuffer); - /* TODO: call sis_SetReadBuffer? */ - - current->hwZ &= ~MASK_ZBufferPitch; - current->hwZ |= xm_buffer->width * z_depth >> 2; - /* TODO, in xfree 3.9.18, no ctx->Buffer */ - current->hwOffsetZ = ((DWORD) (xm_buffer->depthbuffer) - - (DWORD) GET_FbBase (hwcx)) >> 2; - - if ((current->hwOffsetZ ^ prev->hwOffsetZ) - || (current->hwZ ^ prev->hwZ)) - { - prev->hwOffsetZ = current->hwOffsetZ; - prev->hwZ = current->hwZ; - - /* Z setting */ - hwcx->GlobalFlag |= GFLAG_ZSETTING; - } - } - - /* Needed by Y_FLIP macro */ - xm_buffer->bottom = (int) winheight - 1; - - sis_set_scissor (ctx); -} - -const GLubyte * -sis_GetString (GLcontext * ctx, GLenum name) -{ - (void) ctx; - - switch (name) - { - case GL_RENDERER: -#ifdef XFree86Server - return (GLubyte *)"SIS 300/630/530 IR Mode"; -#else - return (GLubyte *)"SiS 300/630/530 DR Mode"; -#endif - default: - return NULL; + smesa->GlobalFlag |= GFLAG_ZSETTING; } } @@ -1528,10 +1392,10 @@ sis_set_scissor (GLcontext * ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; GLint x1, y1, x2, y2; @@ -1573,6 +1437,6 @@ { prev->clipTopBottom = current->clipTopBottom; prev->clipLeftRight = current->clipLeftRight; - hwcx->GlobalFlag |= GFLAG_CLIPPING; + smesa->GlobalFlag |= GFLAG_CLIPPING; } } diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_mesa.h xc/lib/GL/mesa/src/drv/sis/sis_mesa.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_mesa.h Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_mesa.h Sun Aug 10 22:44:55 2003 @@ -35,6 +35,8 @@ #ifndef _sis_mesa_h_ #define _sis_mesa_h_ +#include "tnl/t_context.h" + void sis_UpdateState (GLcontext * ctx); void sis_ClearIndex (GLcontext * ctx, GLuint index); void sis_ClearColor (GLcontext * ctx, GLubyte red, GLubyte green, @@ -47,8 +49,6 @@ void sis_GetBufferSize (GLframebuffer * buffer, GLuint * width, GLuint * height); const char *sis_ExtensionString (GLcontext * ctx); const GLubyte *sis_GetString (GLcontext * ctx, GLenum name); -void sis_Finish (GLcontext * ctx); -void sis_Flush (GLcontext * ctx); GLboolean sis_IndexMask (GLcontext * ctx, GLuint mask); GLboolean sis_ColorMask (GLcontext * ctx, GLboolean rmask, GLboolean gmask, @@ -164,17 +164,6 @@ void sis_Viewport (GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h); /* - * Buffer Allocation - */ -void sis_alloc_z_stencil_buffer (GLcontext * ctx); -void sis_free_z_stencil_buffer (XMesaBuffer buf); -void sis_alloc_back_image (GLcontext * ctx, XMesaImage *image, void **free, - ENGPACKET *packet); -void sis_free_back_image (XMesaBuffer buf, XMesaImage *image, void *free); -void sis_alloc_texture_image (GLcontext * ctx, GLtextureImage * image); -void sis_free_texture_image (GLtextureImage * image); - -/* * Raster-Function Picker */ void sis_set_render_func (GLcontext * ctx); @@ -188,17 +177,14 @@ /* * Local */ -void set_color_pattern (__GLSiScontext * hwcx, GLubyte red, GLubyte green, +void set_color_pattern (sisContextPtr smesa, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -void set_z_stencil_pattern (__GLSiScontext * hwcx, GLclampd z, int stencil); +void set_z_stencil_pattern (sisContextPtr smesa, GLclampd z, int stencil); void sis_init_driver (GLcontext * ctx); void sis_sw_init_driver (GLcontext * ctx); void sis_sw_set_zfuncs_static (GLcontext * ctx); - -void WaitEngIdle (__GLSiScontext * hwcx); -void Wait2DEngIdle (__GLSiScontext * hwcx); void sis_set_buffer_static (GLcontext * ctx); void sis_set_render_pos(GLcontext * ctx, GLubyte *base, GLuint pitch); diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_render.c xc/lib/GL/mesa/src/drv/sis/sis_render.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_render.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_render.c Sun Aug 10 22:44:55 2003 @@ -32,7 +32,7 @@ * */ -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" #define SIS_SMOOTH 0x1 @@ -46,13 +46,13 @@ #define SIS_DEPTH_SCALE 1.0 /* - * TODO: assert(hwcx->AGPCmdBufSize % AGP_ALLOC_SIZE == 0) + * TODO: assert(smesa->AGPCmdBufSize % AGP_ALLOC_SIZE == 0) * depends on VB_SIZE is better */ #define AGP_ALLOC_SIZE 0x10000 /* #define AGP_ALLOC_SIZE (VB_SIZE/3*4 * 9) */ -static DWORD AGP_EngineOffset; -static DWORD *AGP_StartPtr; +static GLint AGP_EngineOffset; +static GLint *AGP_StartPtr; /* export to sis_fastpath.c */ float *AGP_CurrentPtr; @@ -179,7 +179,7 @@ sis_line_clip (GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pv) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); BoxPtr pExtents; int count; @@ -190,7 +190,7 @@ while (count--) { - DWORD clipTopBottom, clipLeftRight; + GLint clipTopBottom, clipLeftRight; clipTopBottom = ((pExtents->y1 - y) << 13) | (pExtents->y2 - y - 1); clipLeftRight = ((pExtents->x1 - x) << 13) | (pExtents->x2 - x - 1); @@ -200,12 +200,12 @@ MMIO (REG_3D_ClipTopBottom, clipTopBottom); MMIO (REG_3D_ClipLeftRight, clipLeftRight); - (hwcx->LineFunc) (ctx, vert0, vert1, pv); + (smesa->LineFunc) (ctx, vert0, vert1, pv); mEndPrimitive (); pExtents++; } - hwcx->GlobalFlag |= GFLAG_CLIPPING; + smesa->GlobalFlag |= GFLAG_CLIPPING; } static triangle_func sis_fill_triangle_func[32] = { @@ -254,7 +254,7 @@ #define USE_FLAT 0x0001000 #define USE_SMOOTH 0x0004000 -static DWORD AGPParsingValues[32] = { +static GLint AGPParsingValues[32] = { (4 << 28) | USE_XYZ | USE_RGB | USE_FLAT, (4 << 28) | USE_XYZ | USE_RGB | USE_SMOOTH, (5 << 28) | USE_XYZ | USE_W | USE_RGB | USE_FLAT, @@ -277,7 +277,7 @@ sis_tri_clip (GLcontext * ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); BoxPtr pExtents; int count; @@ -288,7 +288,7 @@ while (count--) { - DWORD clipTopBottom, clipLeftRight; + GLint clipTopBottom, clipLeftRight; clipTopBottom = ((pExtents->y1 - y) << 13) | (pExtents->y2 - y - 1); clipLeftRight = ((pExtents->x1 - x) << 13) | (pExtents->x2 - x - 1); @@ -298,32 +298,32 @@ MMIO (REG_3D_ClipTopBottom, clipTopBottom); MMIO (REG_3D_ClipLeftRight, clipLeftRight); - (hwcx->TriangleFunc) (ctx, v0, v1, v2, pv); + (smesa->TriangleFunc) (ctx, v0, v1, v2, pv); mEndPrimitive (); pExtents++; } - hwcx->GlobalFlag |= GFLAG_CLIPPING; + smesa->GlobalFlag |= GFLAG_CLIPPING; } void sis_set_render_func (GLcontext * ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); GLuint caps = ctx->TriangleCaps; int line_index = 0; int tri_index = 0; - if(hwcx->swForceRender){ + if(smesa->swForceRender){ ctx->Driver.LineFunc = NULL; ctx->Driver.TriangleFunc = NULL; return; } ctx->IndirectTriangles &= ~(DD_LINE_SW_RASTERIZE | DD_TRI_SW_RASTERIZE); - hwcx->swRenderFlag &= ~(SIS_SW_POINT | SIS_SW_LINE | SIS_SW_TRIANGLE); + smesa->swRenderFlag &= ~(SIS_SW_POINT | SIS_SW_LINE | SIS_SW_TRIANGLE); /* * TODO: Mesa 3.3 will set ctx->TriangleCaps to DD_SELECT @@ -339,18 +339,18 @@ #endif /* always set */ - hwcx->swRenderFlag |= SIS_SW_POINT; + smesa->swRenderFlag |= SIS_SW_POINT; if ((caps & DD_LINE_STIPPLE) || (caps & DD_LINE_WIDTH)) { line_index |= SIS_FALLBACK; - hwcx->swRenderFlag |= SIS_SW_LINE; + smesa->swRenderFlag |= SIS_SW_LINE; } if ((caps & DD_TRI_STIPPLE)) { tri_index |= SIS_FALLBACK; - hwcx->swRenderFlag |= SIS_SW_TRIANGLE; + smesa->swRenderFlag |= SIS_SW_TRIANGLE; } if (ctx->Light.ShadeModel == GL_SMOOTH) @@ -383,27 +383,27 @@ } /* TODO, use Pick */ - hwcx->UseAGPCmdMode = GL_FALSE; + smesa->UseAGPCmdMode = GL_FALSE; if (line_index & SIS_FALLBACK) { ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE; - hwcx->LineFunc = NULL; + smesa->LineFunc = NULL; } else { if ((ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT) && sis_is_window (xmesa)) { - hwcx->LineFunc = sis_draw_line_func[line_index]; + smesa->LineFunc = sis_draw_line_func[line_index]; ctx->Driver.LineFunc = sis_line_clip; } else { - if (hwcx->AGPCmdModeEnabled) + if (smesa->AGPCmdModeEnabled) { ctx->Driver.LineFunc = sis_agp_draw_line_func[line_index]; - hwcx->UseAGPCmdMode = GL_TRUE; + smesa->UseAGPCmdMode = GL_TRUE; } else { @@ -415,22 +415,22 @@ if (tri_index & SIS_FALLBACK) { ctx->IndirectTriangles |= DD_TRI_SW_RASTERIZE; - hwcx->TriangleFunc = NULL; + smesa->TriangleFunc = NULL; } else { if ((ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT) && sis_is_window (xmesa)) { - hwcx->TriangleFunc = sis_fill_triangle_func[tri_index]; + smesa->TriangleFunc = sis_fill_triangle_func[tri_index]; ctx->Driver.TriangleFunc = sis_tri_clip; } else { - if (hwcx->AGPCmdModeEnabled) + if (smesa->AGPCmdModeEnabled) { ctx->Driver.TriangleFunc = sis_agp_fill_triangle_func[tri_index]; - hwcx->UseAGPCmdMode = GL_TRUE; + smesa->UseAGPCmdMode = GL_TRUE; } else { @@ -443,20 +443,20 @@ if(!(ctx->TriangleCaps & (DD_TRI_UNFILLED | DD_TRI_LIGHT_TWOSIDE)) && (ctx->Driver.TriangleFunc == sis_agp_tri_smooth_w_t2) && (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT)){ - hwcx->useFastPath = GL_TRUE; + smesa->useFastPath = GL_TRUE; } else{ - hwcx->useFastPath = GL_FALSE; + smesa->useFastPath = GL_FALSE; } /* TODO: AGP and MMIO use different sis_set_render_state */ - hwcx->AGPParseSet &= ~0xffff7000; - hwcx->AGPParseSet |= AGPParsingValues[line_index & ~SIS_FALLBACK]; + smesa->AGPParseSet &= ~0xffff7000; + smesa->AGPParseSet |= AGPParsingValues[line_index & ~SIS_FALLBACK]; /* Debug, test sw-render ctx->Driver.LineFunc = NULL; ctx->Driver.TriangleFunc = NULL; - hwcx->swRenderFlag = ~0x0; + smesa->swRenderFlag = ~0x0; ctx->Visual->DepthMax = (sizeof(GLdepth)==2)?0xffff:0xffffffff; ctx->Visual->DepthMaxF = (double)(sizeof(GLdepth)==2)?0xffff:0xffffffff; */ @@ -466,13 +466,13 @@ sis_StartAGP (GLcontext * ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - DWORD start, end; + GLint start, end; - start = *(hwcx->pAGPCmdBufNext); + start = *(smesa->pAGPCmdBufNext); end = start + AGP_ALLOC_SIZE; - if (end >= hwcx->AGPCmdBufSize) + if (end >= smesa->AGPCmdBufSize) { start = 0; end = AGP_ALLOC_SIZE; @@ -486,13 +486,13 @@ do { AGP_EngineOffset = - *(DWORD volatile *) (GET_IOBase (hwcx) + REG_3D_AGPCmBase) - - (DWORD) hwcx->AGPCmdBufAddr; + *(GLint volatile *) (GET_IOBase (smesa) + REG_3D_AGPCmBase) - + (GLint) smesa->AGPCmdBufAddr; } while ((AGP_EngineOffset <= end) && (AGP_EngineOffset >= start) - && ((*(GET_IOBase (hwcx) + 0x8243) & 0xe0) != 0xe0)); + && ((*(GET_IOBase (smesa) + 0x8243) & 0xe0) != 0xe0)); - AGP_StartPtr = (DWORD *) (start + hwcx->AGPCmdBufBase); + AGP_StartPtr = (GLint *) (start + smesa->AGPCmdBufBase); AGP_CurrentPtr = (float *) AGP_StartPtr; } @@ -500,27 +500,27 @@ sis_FlushAGP (GLcontext * ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); /* TODO: wait queue length */ - if((DWORD *)AGP_CurrentPtr == AGP_StartPtr) + if((GLint *)AGP_CurrentPtr == AGP_StartPtr) { return; } mWait3DCmdQueue (5); mEndPrimitive (); - MMIO (REG_3D_AGPCmBase, ((DWORD) AGP_StartPtr - (DWORD) hwcx->AGPCmdBufBase) - + (DWORD) hwcx->AGPCmdBufAddr); + MMIO (REG_3D_AGPCmBase, ((GLint) AGP_StartPtr - (GLint) smesa->AGPCmdBufBase) + + (GLint) smesa->AGPCmdBufAddr); MMIO (REG_3D_AGPTtDwNum, - (((DWORD) AGP_CurrentPtr - (DWORD) AGP_StartPtr) >> 2) | 0x50000000); - MMIO (REG_3D_ParsingSet, hwcx->AGPParseSet); + (((GLint) AGP_CurrentPtr - (GLint) AGP_StartPtr) >> 2) | 0x50000000); + MMIO (REG_3D_ParsingSet, smesa->AGPParseSet); - MMIO (REG_3D_AGPCmFire, (DWORD) (-1)); + MMIO (REG_3D_AGPCmFire, (GLint) (-1)); mEndPrimitive (); - *(hwcx->pAGPCmdBufNext) = - (DWORD) AGP_CurrentPtr - (DWORD) hwcx->AGPCmdBufBase; - *(hwcx->pAGPCmdBufNext) = (*(hwcx->pAGPCmdBufNext) + 0xf) & ~0xf; + *(smesa->pAGPCmdBufNext) = + (GLint) AGP_CurrentPtr - (GLint) smesa->AGPCmdBufBase; + *(smesa->pAGPCmdBufNext) = (*(smesa->pAGPCmdBufNext) + 0xf) & ~0xf; } diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_screen.c xc/lib/GL/mesa/src/drv/sis/sis_screen.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_screen.c Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_screen.c Sun Aug 10 22:44:55 2003 @@ -0,0 +1,310 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 2003 Eric Anholt +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +on the rights to use, copy, modify, merge, publish, distribute, sub +license, and/or sell copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Eric Anholt + * + */ + +#include "dri_util.h" + +#include "context.h" +#include "utils.h" +#include "imports.h" + +#include "sis_context.h" +#include "sis_dri.h" +#include "sis_lock.h" + +/* Create the device specific screen private data struct. + */ +static sisScreenPtr +sisCreateScreen( __DRIscreenPrivate *sPriv ) +{ + sisScreenPtr sisScreen; + SISDRIPtr sisDRIPriv = (SISDRIPtr)sPriv->pDevPriv; + + if ( ! driCheckDriDdxDrmVersions( sPriv, "SiS", 4, 0, 4, 0, 1, 0 ) ) + return NULL; + + /* Allocate the private area */ + sisScreen = (sisScreenPtr) CALLOC( sizeof(*sisScreen) ); + if ( sisScreen == NULL ) + return NULL; + + sisScreen->screenX = sisDRIPriv->width; + sisScreen->screenY = sisDRIPriv->height; + sisScreen->cpp = sisDRIPriv->bytesPerPixel; + sisScreen->irqEnabled = sisDRIPriv->bytesPerPixel; + sisScreen->deviceID = sisDRIPriv->deviceID; + sisScreen->AGPCmdBufOffset = sisDRIPriv->AGPCmdBufOffset; + sisScreen->AGPCmdBufSize = sisDRIPriv->AGPCmdBufSize; + + /* XXX Should come from the X Server */ + sisScreen->sarea_priv_offset = sizeof(XF86DRISAREARec); + + sisScreen->mmio.handle = sisDRIPriv->regs.handle; + sisScreen->mmio.size = sisDRIPriv->regs.size; + if ( drmMap( sPriv->fd, sisScreen->mmio.handle, sisScreen->mmio.size, + &sisScreen->mmio.map ) ) { + FREE( sisScreen ); + return NULL; + } + + if (sisDRIPriv->agp.size) { + sisScreen->agp.handle = sisDRIPriv->agp.handle; + sisScreen->agp.size = sisDRIPriv->agp.size; + if ( drmMap( sPriv->fd, sisScreen->agp.handle, sisScreen->agp.size, + &sisScreen->agp.map ) ) { + sisScreen->agp.size = 0; + } + } + + sisScreen->driScreen = sPriv; + + return sisScreen; +} + +/* Destroy the device specific screen private data struct. + */ +static void +sisDestroyScreen( __DRIscreenPrivate *sPriv ) +{ + sisScreenPtr sisScreen = (sisScreenPtr)sPriv->private; + + if ( sisScreen == NULL ) + return; + + if (sisScreen->agp.size != 0) + drmUnmap( sisScreen->agp.map, sisScreen->agp.size ); + drmUnmap( sisScreen->mmio.map, sisScreen->mmio.size ); + + FREE( sisScreen ); + sPriv->private = NULL; +} + +/* Create and initialize the Mesa and driver specific pixmap buffer + * data. + */ +static GLboolean +sisCreateBuffer( __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + const __GLcontextModes *mesaVis, + GLboolean isPixmap ) +{ + if (isPixmap) { + return GL_FALSE; /* not implemented */ + } + else { + driDrawPriv->driverPrivate = (void *) + _mesa_create_framebuffer( mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->stencilBits > 0, + mesaVis->accumRedBits > 0, + mesaVis->alphaBits > 0 ); /* XXX */ + return (driDrawPriv->driverPrivate != NULL); + } +} + + +static void +sisDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) +{ + _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); +} + +__inline__ static void +sis_bitblt_copy_cmd (sisContextPtr smesa, ENGPACKET * pkt) +{ + GLint *lpdwDest, *lpdwSrc; + int i; + + lpdwSrc = (GLint *) pkt; + lpdwDest = (GLint *) (GET_IOBase (smesa) + REG_SRC_ADDR); + + mWait3DCmdQueue (10); + + for (i = 0; i < 7; i++) + *lpdwDest++ = *lpdwSrc++; + + MMIO(REG_CMD0, *(GLint *)&pkt->stdwCmd); + MMIO(0x8240, -1); +} + +static void sisCopyBuffer( __DRIdrawablePrivate *dPriv ) +{ + sisContextPtr smesa = (sisContextPtr)dPriv->driContextPriv->driverPrivate; + int i; + ENGPACKET stEngPacket; + +#if 0 + { + int repeat = 0; + + while(((*smesa->FrameCountPtr) - *(GLint volatile *)(smesa->IOBase+0x8a2c) + > SIS_MAX_FRAME_LENGTH) && + (repeat++ < 10)); + } +#endif + + LOCK_HARDWARE (); + + stEngPacket.dwSrcBaseAddr = ( (GLint)smesa->backbuffer - + (GLint)GET_FbBase(smesa) ); + stEngPacket.dwSrcPitch = smesa->backPitch | + (smesa->bytesPerPixel == 2) ? 0x80000000 : 0xc0000000; /* XXX */ + stEngPacket.dwDestBaseAddr = 0; + stEngPacket.wDestPitch = smesa->frontPitch; + /* TODO: set maximum value? */ + stEngPacket.wDestHeight = smesa->virtualY; + + stEngPacket.stdwCmd.cRop = 0xcc; + + if (smesa->blockWrite) { + stEngPacket.stdwCmd.cCmd0 = (BYTE) (CMD0_PAT_FG_COLOR); + stEngPacket.stdwCmd.cCmd1 = (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); + } else { + stEngPacket.stdwCmd.cCmd0 = 0; + stEngPacket.stdwCmd.cCmd1 = (BYTE) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); + } + + if (dPriv->numClipRects == 0) { + stEngPacket.stdwSrcPos.wY = 0; + stEngPacket.stdwSrcPos.wX = 0; + stEngPacket.stdwDestPos.wY = dPriv->y; + stEngPacket.stdwDestPos.wX = dPriv->x; + + stEngPacket.stdwDim.wWidth = dPriv->w; + stEngPacket.stdwDim.wHeight = dPriv->h; + + sis_bitblt_copy_cmd(smesa, &stEngPacket); + } else { + for (i = 0; i < dPriv->numClipRects; i++) { + XF86DRIClipRectPtr box = &dPriv->pClipRects[i]; + stEngPacket.stdwSrcPos.wY = box->y1 - dPriv->y; + stEngPacket.stdwSrcPos.wX = box->x1 - dPriv->x; + stEngPacket.stdwDestPos.wY = box->y1; + stEngPacket.stdwDestPos.wX = box->x1; + + stEngPacket.stdwDim.wWidth = (GLshort) box->x2 - box->x1; + stEngPacket.stdwDim.wHeight = (GLshort) box->y2 - box->y1; + + sis_bitblt_copy_cmd(smesa, &stEngPacket); + } + } + + *(GLint *)(smesa->IOBase+0x8a2c) = *smesa->FrameCountPtr; + (*smesa->FrameCountPtr)++; + + UNLOCK_HARDWARE (); +} + + +/* Copy the back color buffer to the front color buffer */ +static void +sisSwapBuffers(__DRIdrawablePrivate *dPriv) +{ + if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { + sisContextPtr smesa = (sisContextPtr) dPriv->driContextPriv->driverPrivate; + GLcontext *ctx = smesa->glCtx; + + if (ctx->Visual.doubleBufferMode) { + _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ + sisCopyBuffer( dPriv ); + } + } + else { + /* XXX this shouldn't be an error but we can't handle it for now */ + _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__); + } +} + + +/* Initialize the driver specific screen private data. + */ +static GLboolean +sisInitDriver( __DRIscreenPrivate *sPriv ) +{ + sPriv->private = (void *) sisCreateScreen( sPriv ); + + if ( !sPriv->private ) { + sisDestroyScreen( sPriv ); + return GL_FALSE; + } + + return GL_TRUE; +} + +/* Fullscreen mode change stub + */ +static GLboolean +sisOpenCloseFullScreen( __DRIcontextPrivate *driContextPriv ) +{ + return GL_TRUE; +} + +/* This function is called by libGL.so as soon as libGL.so is loaded. + * This is where we'd register new extension functions with the dispatcher. + */ +void __driRegisterExtensions(void) +{ + /* No extra extensions */ +} + +static struct __DriverAPIRec sisAPI = { + .InitDriver = sisInitDriver, + .DestroyScreen = sisDestroyScreen, + .CreateContext = sisCreateContext, + .DestroyContext = sisDestroyContext, + .CreateBuffer = sisCreateBuffer, + .DestroyBuffer = sisDestroyBuffer, + .SwapBuffers = sisSwapBuffers, + .MakeCurrent = sisMakeCurrent, + .UnbindContext = sisUnbindContext, + .OpenFullScreen = sisOpenCloseFullScreen, + .CloseFullScreen = sisOpenCloseFullScreen, + .GetSwapInfo = NULL, + /*.GetMSC = driGetMSC32, + .WaitForMSC = driWaitForMSC32, + .WaitForSBC = NULL,*/ /* XXX */ + .SwapBuffersMSC = NULL + +}; + +/* + * This is the bootstrap function for the driver. + * The __driCreateScreen name is the symbol that libGL.so fetches. + * Return: pointer to a __DRIscreenPrivate. + */ +void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, + int numConfigs, __GLXvisualConfig *config) +{ + __DRIscreenPrivate *psp; + psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &sisAPI); + return (void *) psp; +} diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_screen.h xc/lib/GL/mesa/src/drv/sis/sis_screen.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_screen.h Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_screen.h Sun Aug 10 22:44:55 2003 @@ -0,0 +1,62 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 2003 Eric Anholt +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +on the rights to use, copy, modify, merge, publish, distribute, sub +license, and/or sell copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Eric Anholt + * + */ + +#ifndef __SIS_SCREEN_H +#define __SIS_SCREEN_H + +typedef struct { + drmHandle handle; /* Handle to the DRM region */ + drmSize size; /* Size of the DRM region */ + drmAddress map; /* Mapping of the DRM region */ +} sisRegionRec2, *sisRegionPtr2; + +typedef struct { + sisRegionRec2 mmio; + sisRegionRec2 agp; + + unsigned int AGPCmdBufOffset; + unsigned int AGPCmdBufSize; + + int deviceID; + int bytesPerPixel; + int irqEnabled; + + int cpp; + unsigned int screenX, screenY; + + __DRIscreenPrivate *driScreen; + unsigned int sarea_priv_offset; + +} sisScreenRec, *sisScreenPtr; + +#endif diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_span.c xc/lib/GL/mesa/src/drv/sis/sis_span.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_span.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_span.c Sun Aug 10 22:44:55 2003 @@ -32,7 +32,7 @@ * */ -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" #define DBG 0 @@ -44,9 +44,9 @@ #define LOCAL_VARS \ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; \ - GLuint pitch = hwcx->swRenderPitch; \ - char *buf = (char *)hwcx->swRenderBase + sisContextPtr smesa = SIS_CONTEXT(ctx); \ + GLuint pitch = smesa->swRenderPitch; \ + char *buf = (char *)smesa->swRenderBase #define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \ _y >= miny && _y < maxy) @@ -85,7 +85,7 @@ /* RGB565 */ #define INIT_MONO_PIXEL(p) \ - GLushort p = hwcx->pixelValue; + GLushort p = smesa->pixelValue; #define WRITE_RGBA( _x, _y, r, g, b, a ) \ *(GLushort *)(buf + _x*2 + _y*pitch) = ( ((r & 0xf8) << 8) | \ @@ -110,9 +110,9 @@ GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - hwcx->pixelValue = ((red & 0xf8) << 8) | + smesa->pixelValue = ((red & 0xf8) << 8) | ((green & 0xfc) << 3) | (blue >> 3); } @@ -121,7 +121,7 @@ /* ARGB8888 */ #undef INIT_MONO_PIXEL #define INIT_MONO_PIXEL(p) \ - GLuint p = hwcx->pixelValue; + GLuint p = smesa->pixelValue; #define WRITE_RGBA( _x, _y, r, g, b, a ) \ *(GLuint *)(buf + _x*4 + _y*pitch) = ( ((a) << 24) | \ @@ -147,9 +147,9 @@ GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - hwcx->pixelValue = (red << 16) | + smesa->pixelValue = (red << 16) | (green << 8) | (blue) | (alpha << 24); @@ -158,9 +158,9 @@ void sis_sw_init_driver( GLcontext *ctx ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - if (hwcx->colorFormat == DST_FORMAT_RGB_565) { + if (smesa->colorFormat == DST_FORMAT_RGB_565) { ctx->Driver.Color = sis_Color_565; ctx->Driver.WriteRGBASpan = sis_WriteRGBASpan_565; ctx->Driver.WriteRGBSpan = sis_WriteRGBSpan_565; @@ -170,7 +170,7 @@ ctx->Driver.ReadRGBASpan = sis_ReadRGBASpan_565; ctx->Driver.ReadRGBAPixels = sis_ReadRGBAPixels_565; } - else if(hwcx->colorFormat == DST_FORMAT_ARGB_8888){ + else if(smesa->colorFormat == DST_FORMAT_ARGB_8888){ ctx->Driver.Color = sis_Color_8888; ctx->Driver.WriteRGBASpan = sis_WriteRGBASpan_8888; ctx->Driver.WriteRGBSpan = sis_WriteRGBSpan_8888; @@ -198,8 +198,8 @@ * 0 ~ 2^16-1 or 0 ~ 2^32-1 */ #define SIS_SW_Z_BASE(x,y) \ - ((SIS_SW_DTYPE *)(hwcx->swZBase + (x)*sizeof(SIS_SW_DTYPE) + \ - (y)*hwcx->swZPitch)) + ((SIS_SW_DTYPE *)(smesa->swZBase + (x)*sizeof(SIS_SW_DTYPE) + \ + (y)*smesa->swZPitch)) /* Z16 */ #define SIS_TAG(x) x##_Z16 @@ -279,9 +279,9 @@ sis_sw_set_zfuncs_static (GLcontext * ctx) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - switch (hwcx->zFormat) + switch (smesa->zFormat) { case Z_16: ctx->Driver.ReadDepthSpan = sis_ReadDepthSpan_Z16; diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_state.h xc/lib/GL/mesa/src/drv/sis/sis_state.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_state.h Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_state.h Sun Aug 10 22:44:55 2003 @@ -0,0 +1,47 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 2003 Eric Anholt +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +on the rights to use, copy, modify, merge, publish, distribute, sub +license, and/or sell copies of the Software, and to permit persons to whom +the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Eric Anholt + * + */ + +#ifndef __SIS_STATE_H__ +#define __SIS_STATE_H__ + +#ifdef GLX_DIRECT_RENDERING + +#include "sis_context.h" + +extern void sisDDInitStateFuncs( GLcontext *ctx ); + +extern void sisDDClearDepth( GLcontext * ctx, GLclampd d ); +extern void sisDDClearStencil( GLcontext * ctx, GLint s ); + +#endif +#endif diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_stencil.c xc/lib/GL/mesa/src/drv/sis/sis_stencil.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_stencil.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_stencil.c Sun Aug 10 22:44:55 2003 @@ -32,19 +32,19 @@ * */ -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" void sis_StencilFunc (GLcontext * ctx, GLenum func, GLint ref, GLuint mask) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; /* set reference */ - current->hwStSetting = ((DWORD) ref << 8) | mask; + current->hwStSetting = ((GLint) ref << 8) | mask; current->hwStSetting &= ~0x07000000; switch (func) @@ -81,7 +81,7 @@ prev->hwStSetting = current->hwStSetting; prev->hwStSetting2 = current->hwStSetting2; - hwcx->GlobalFlag |= GFLAG_STENCILSETTING; + smesa->GlobalFlag |= GFLAG_STENCILSETTING; } } @@ -99,9 +99,9 @@ sis_StencilOp (GLcontext * ctx, GLenum fail, GLenum zfail, GLenum zpass) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; current->hwStSetting2 &= ~0x00777000; @@ -177,7 +177,7 @@ prev->hwStSetting = current->hwStSetting; prev->hwStSetting2 = current->hwStSetting2; - hwcx->GlobalFlag |= GFLAG_STENCILSETTING; + smesa->GlobalFlag |= GFLAG_STENCILSETTING; } } diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h Sun Aug 10 22:44:55 2003 @@ -37,7 +37,7 @@ const GLubyte mask[]) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIS_SW_DTYPE *base = SIS_SW_Z_BASE (x, Y_FLIP (y)); @@ -53,7 +53,7 @@ GLint y, GLdepth depth[]) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIS_SW_DTYPE *base = SIS_SW_Z_BASE (x, Y_FLIP (y)); @@ -70,7 +70,7 @@ const GLubyte mask[]) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIS_SW_DTYPE *base; @@ -90,7 +90,7 @@ GLdepth depth[]) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIS_SW_DTYPE *base; @@ -110,7 +110,7 @@ const GLubyte mask[]) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIS_SW_DTYPE *base = SIS_SW_Z_BASE (x, Y_FLIP (y)); @@ -126,7 +126,7 @@ GLint y, GLstencil depth[]) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIS_SW_DTYPE *base = SIS_SW_Z_BASE (x, Y_FLIP (y)); @@ -144,7 +144,7 @@ const GLubyte mask[]) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIS_SW_DTYPE *base; @@ -164,7 +164,7 @@ GLstencil depth[]) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIS_SW_DTYPE *base; diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_texture.c xc/lib/GL/mesa/src/drv/sis/sis_texture.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_texture.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_texture.c Sun Aug 10 22:44:55 2003 @@ -32,7 +32,7 @@ * */ -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" static void @@ -46,13 +46,12 @@ static void sis_reset_texture_env (GLcontext * ctx, int hw_unit); -static DWORD TransferTexturePitch (DWORD dwPitch); +static GLint TransferTexturePitch (GLint dwPitch); void sis_validate_texture (GLcontext * ctx) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); struct gl_texture_unit *tex_unit; struct gl_texture_object *tObj; @@ -60,12 +59,12 @@ if(ctx->Texture.ReallyEnabled & (TEXTURE0_3D | TEXTURE1_3D)) { - hwcx->swRenderFlag |= SIS_SW_TEXTURE_DIM; + smesa->swRenderFlag |= SIS_SW_TEXTURE_DIM; return; } else { - hwcx->swRenderFlag &= ~SIS_SW_TEXTURE_DIM; + smesa->swRenderFlag &= ~SIS_SW_TEXTURE_DIM; } if ((ctx->Texture.ReallyEnabled & TEXTURE0_ANY) && @@ -79,22 +78,22 @@ tObj = tex_unit->Current; texObjArea = (sisTexobjInfo *) tObj->DriverData; - if (hwcx->TexStates[unit] & NEW_TEXTURING) + if (smesa->TexStates[unit] & NEW_TEXTURING) { - hwcx->swRenderFlag &= ~(SIS_SW_TEXTURE_OBJ << unit); + smesa->swRenderFlag &= ~(SIS_SW_TEXTURE_OBJ << unit); sis_set_texobj_parm (ctx, tObj, unit); } - if (hwcx->TexStates[unit] & NEW_TEXTURE_ENV) + if (smesa->TexStates[unit] & NEW_TEXTURE_ENV) { - hwcx->swRenderFlag &= ~(SIS_SW_TEXTURE_ENV << unit); + smesa->swRenderFlag &= ~(SIS_SW_TEXTURE_ENV << unit); if (unit == 0) sis_set_texture_env0 (ctx, tObj, unit); else sis_set_texture_env1 (ctx, tObj, unit); } - hwcx->TexStates[unit] = 0; + smesa->TexStates[unit] = 0; } } else @@ -105,10 +104,10 @@ tObj = tex_unit->Current; texObjArea = (sisTexobjInfo *) tObj->DriverData; - if (hwcx->TexStates[unit] & NEW_TEXTURING) + if (smesa->TexStates[unit] & NEW_TEXTURING) sis_set_texobj_parm (ctx, tObj, unit); - if (hwcx->TexStates[unit] & NEW_TEXTURE_ENV) + if (smesa->TexStates[unit] & NEW_TEXTURE_ENV) { if(unit == 0){ sis_set_texture_env0 (ctx, tObj, unit); @@ -120,7 +119,7 @@ } } - hwcx->TexStates[unit] = 0; + smesa->TexStates[unit] = 0; } } @@ -128,10 +127,9 @@ sis_TexEnv( GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param ) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; } void @@ -139,8 +137,7 @@ struct gl_texture_object *tObj, GLint level, GLint internalFormat, const struct gl_texture_image *image) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIStextureArea *area; @@ -174,7 +171,7 @@ | SIS_TEX_ENV); } - sis_alloc_texture_image (ctx, (struct gl_texture_image *) image); + sisAllocTextureImage( smesa, (struct gl_texture_image *) image ); area = (SIStextureArea *) image->DriverData; assert (area->Data); @@ -187,7 +184,7 @@ for (i = 0; i < area->Size / 4; i++) { - *(DWORD *)dst = *(DWORD *)src & 0x00ffffff; + *(GLint *)dst = *(GLint *)src & 0x00ffffff; src += 3; dst += 4; } @@ -197,12 +194,12 @@ memcpy (area->Data, image->Data, area->Size); } - if (hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] != area->Format) + if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != area->Format) { - hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; - hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] = area->Format; + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; + smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = area->Format; } - hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; } void @@ -211,8 +208,7 @@ GLint yoffset, GLsizei width, GLsizei height, GLint internalFormat, const struct gl_texture_image *image) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIStextureArea *area; int i, j; @@ -221,13 +217,13 @@ area = (SIStextureArea *) image->DriverData; - hwcx->clearTexCache = GL_TRUE; + smesa->clearTexCache = GL_TRUE; { /* * Optimize */ - WaitEngIdle (hwcx); + WaitEngIdle (smesa); } if (area->Format == GL_RGB8) @@ -240,7 +236,7 @@ { for (i = xoffset; i < xoffset + width; i++) { - *(DWORD *)dst = *(DWORD *)src & 0x00ffffff; + *(GLint *)dst = *(GLint *)src & 0x00ffffff; src += 3; dst += 4; } @@ -272,21 +268,19 @@ struct gl_texture_object *tObj, GLenum pname, const GLfloat * params) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); if (tObj->DriverData) ((sisTexobjInfo *) tObj->DriverData)->dirtyFlag |= SIS_TEX_PARAMETER; - hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; } void sis_BindTexture (GLcontext * ctx, GLenum target, struct gl_texture_object *tObj) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIStextureArea *area; if (!tObj->Image[0]) @@ -295,26 +289,25 @@ if (!(area = (SIStextureArea *) tObj->Image[0]->DriverData)) return; - if (hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] != area->Format) + if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != area->Format) { - hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; - hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] = area->Format; + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; + smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = area->Format; } - hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; } void sis_DeleteTexture (GLcontext * ctx, struct gl_texture_object *tObj) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); int i; for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { if (tObj->Image[i]) - sis_free_texture_image (tObj->Image[i]); + sisFreeTextureImage( smesa, tObj->Image[i] ); } if (tObj->DriverData) @@ -330,7 +323,7 @@ */ } - hwcx->clearTexCache = GL_TRUE; + smesa->clearTexCache = GL_TRUE; } void @@ -364,11 +357,10 @@ static void sis_set_texture_env0 (GLcontext * ctx, GLtextureObject * object, int unit) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit]; @@ -440,10 +432,10 @@ case GL_BLEND: current->hwTexEnvColor = - ((DWORD) (texture_unit->EnvColor[3])) << 24 | - ((DWORD) (texture_unit->EnvColor[0])) << 16 | - ((DWORD) (texture_unit->EnvColor[1])) << 8 | - ((DWORD) (texture_unit->EnvColor[2])); + ((GLint) (texture_unit->EnvColor[3])) << 24 | + ((GLint) (texture_unit->EnvColor[0])) << 16 | + ((GLint) (texture_unit->EnvColor[1])) << 8 | + ((GLint) (texture_unit->EnvColor[2])); switch (area->Format) { case GL_ALPHA8: @@ -475,18 +467,17 @@ prev->hwTexEnvColor = current->hwTexEnvColor; prev->hwTexBlendClr0 = current->hwTexBlendClr0; prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0; - hwcx->GlobalFlag |= GFLAG_TEXTUREENV; + smesa->GlobalFlag |= GFLAG_TEXTUREENV; } } void sis_set_texture_env1 (GLcontext * ctx, GLtextureObject * object, int unit) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit]; GLtextureImage *image = object->Image[0]; @@ -558,10 +549,10 @@ case GL_BLEND: current->hwTexEnvColor = - ((DWORD) (texture_unit->EnvColor[3])) << 24 | - ((DWORD) (texture_unit->EnvColor[0])) << 16 | - ((DWORD) (texture_unit->EnvColor[1])) << 8 | - ((DWORD) (texture_unit->EnvColor[2])); + ((GLint) (texture_unit->EnvColor[3])) << 24 | + ((GLint) (texture_unit->EnvColor[0])) << 16 | + ((GLint) (texture_unit->EnvColor[1])) << 8 | + ((GLint) (texture_unit->EnvColor[2])); switch (area->Format) { case GL_ALPHA8: @@ -593,18 +584,17 @@ prev->hwTexBlendClr1 = current->hwTexBlendClr1; prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1; prev->hwTexEnvColor = current->hwTexEnvColor; - hwcx->GlobalFlag |= GFLAG_TEXTUREENV_1; + smesa->GlobalFlag |= GFLAG_TEXTUREENV_1; } } static void sis_set_texobj_parm (GLcontext * ctx, GLtextureObject * object, int hw_unit) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; GLtextureImage *image = object->Image[0]; SIStextureArea *area = (SIStextureArea *) image->DriverData; @@ -636,7 +626,7 @@ current->texture[hw_unit].hwTextureSet |= TEXEL_ABGR_0888_32; break; default: - hwcx->swRenderFlag |= SIS_SW_TEXTURE_OBJ; + smesa->swRenderFlag |= SIS_SW_TEXTURE_OBJ; } if ((object->MinFilter == GL_NEAREST) || (object->MinFilter == GL_LINEAR)) @@ -655,7 +645,7 @@ else { /* can i limit capacity */ - hwcx->swRenderFlag |= SIS_SW_TEXTURE_OBJ; + smesa->swRenderFlag |= SIS_SW_TEXTURE_OBJ; } switch (object->MagFilter) @@ -753,9 +743,9 @@ prev->texture[hw_unit].hwTextureBorderColor = current->texture[hw_unit].hwTextureBorderColor; if (hw_unit == 1) - hwcx->GlobalFlag |= GFLAG_TEXBORDERCOLOR_1; + smesa->GlobalFlag |= GFLAG_TEXBORDERCOLOR_1; else - hwcx->GlobalFlag |= GFLAG_TEXBORDERCOLOR; + smesa->GlobalFlag |= GFLAG_TEXBORDERCOLOR; } current->texture[hw_unit].hwTextureSet |= (image->WidthLog2 << 4); @@ -763,9 +753,9 @@ { if (hw_unit == 0) - hwcx->GlobalFlag |= GFLAG_TEXTUREADDRESS; + smesa->GlobalFlag |= GFLAG_TEXTUREADDRESS; else - hwcx->GlobalFlag |= GFLAG_TEXTUREADDRESS_1; + smesa->GlobalFlag |= GFLAG_TEXTUREADDRESS_1; for (i = 0; i < TxLevel + 1; i++) { @@ -775,11 +765,11 @@ switch(area->memType){ case VIDEO_TYPE: - texOffset = ((char *) area->Data - (char *) GET_FbBase (hwcx)); + texOffset = ((char *) area->Data - (char *) GET_FbBase (smesa)); break; case AGP_TYPE: - texOffset = ((char *) area->Data - (char *) GET_AGPBase (hwcx)) + - (unsigned long) hwcx->AGPAddr; + texOffset = ((char *) area->Data - (char *) GET_AGPBase (smesa)) + + (unsigned long) smesa->AGPAddr; current->texture[hw_unit].hwTextureMip |= (0x40000 << i); break; default: @@ -846,9 +836,9 @@ prev->texture[hw_unit].hwTextureSet = current->texture[hw_unit].hwTextureSet; if (hw_unit == 1) - hwcx->GlobalFlag |= CFLAG_TEXTURERESET_1; + smesa->GlobalFlag |= CFLAG_TEXTURERESET_1; else - hwcx->GlobalFlag |= CFLAG_TEXTURERESET; + smesa->GlobalFlag |= CFLAG_TEXTURERESET; } if (current->texture[hw_unit].hwTextureMip ^ prev->texture[hw_unit].hwTextureMip) @@ -856,20 +846,19 @@ prev->texture[hw_unit].hwTextureMip = current->texture[hw_unit].hwTextureMip; if (hw_unit == 1) - hwcx->GlobalFlag |= GFLAG_TEXTUREMIPMAP_1; + smesa->GlobalFlag |= GFLAG_TEXTUREMIPMAP_1; else - hwcx->GlobalFlag |= GFLAG_TEXTUREMIPMAP; + smesa->GlobalFlag |= GFLAG_TEXTUREMIPMAP; } } static void sis_reset_texture_env (GLcontext * ctx, int hw_unit) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; if (hw_unit == 1) { @@ -883,7 +872,7 @@ prev->hwTexBlendClr1 = current->hwTexBlendClr1; prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1; prev->hwTexEnvColor = current->hwTexEnvColor; - hwcx->GlobalFlag |= GFLAG_TEXTUREENV_1; + smesa->GlobalFlag |= GFLAG_TEXTUREENV_1; } } else @@ -898,15 +887,15 @@ prev->hwTexBlendClr0 = current->hwTexBlendClr0; prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0; prev->hwTexEnvColor = current->hwTexEnvColor; - hwcx->GlobalFlag |= GFLAG_TEXTUREENV; + smesa->GlobalFlag |= GFLAG_TEXTUREENV; } } } -static DWORD -BitScanForward (WORD w) +static GLint +BitScanForward (GLshort w) { - DWORD i; + GLint i; for (i = 0; i < 16; i++) { @@ -916,12 +905,12 @@ return (i); } -static DWORD -TransferTexturePitch (DWORD dwPitch) +static GLint +TransferTexturePitch (GLint dwPitch) { - DWORD dwRet, i; + GLint dwRet, i; - i = BitScanForward ((WORD) dwPitch); + i = BitScanForward ((GLshort) dwPitch); dwRet = dwPitch >> i; dwRet |= i << 9; return (dwRet); diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h Sun Aug 10 22:44:55 2003 @@ -39,10 +39,10 @@ GLuint pv) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); struct vertex_buffer *VB = ctx->VB; - float *MMIOBase = (float *) GET_IOBase (hwcx); + float *MMIOBase = (float *) GET_IOBase (smesa); STEREO_SAMPLE(v0); @@ -55,19 +55,19 @@ * not move it to UpdateState because maybe optimization can be done * according to FAN and STRIP */ - hwcx->dwPrimitiveSet &= ~0x07001f07; - hwcx->dwPrimitiveSet |= + smesa->dwPrimitiveSet &= ~0x07001f07; + smesa->dwPrimitiveSet |= (OP_3D_FIRE_TSARGBc | SHADE_GOURAUD | OP_3D_TRIANGLE_DRAW); } else { - hwcx->dwPrimitiveSet &= ~0x07001f07; - hwcx->dwPrimitiveSet |= + smesa->dwPrimitiveSet &= ~0x07001f07; + smesa->dwPrimitiveSet |= (OP_3D_FIRE_TSARGBc | SHADE_FLAT_VertexC | OP_3D_TRIANGLE_DRAW); } { - ((DWORD *) MMIOBase)[REG_3D_PrimitiveSet / 4] = hwcx->dwPrimitiveSet; + ((GLint *) MMIOBase)[REG_3D_PrimitiveSet / 4] = smesa->dwPrimitiveSet; } #define LAST_VERTEX 0 @@ -80,7 +80,7 @@ /* debug mEndPrimitive (); - WaitEngIdle(hwcx); + WaitEngIdle(smesa); d2f_once (ctx); */ } @@ -90,17 +90,17 @@ GLuint v2, GLuint pv) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); struct vertex_buffer *VB = ctx->VB; - DWORD dcSARGB; + GLint dcSARGB; STEREO_SAMPLE(v0); /* delete if VB size <= AGP_ALLOC_SIZE */ #if 0 - if ((DWORD) AGP_CurrentPtr - (DWORD) AGP_StartPtr >= (AGP_ALLOC_SIZE - 0x10)) + if ((GLint) AGP_CurrentPtr - (GLint) AGP_StartPtr >= (AGP_ALLOC_SIZE - 0x10)) { sis_FlushAGP (ctx); sis_StartAGP (ctx); diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_xf86glx.c xc/lib/GL/mesa/src/drv/sis/sis_xf86glx.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_xf86glx.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_xf86glx.c Wed Dec 31 16:00:00 1969 @@ -1,962 +0,0 @@ -/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_xf86glx.c,v 1.1 2000/06/30 19:30:29 dawes Exp $ */ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * - * $PI: xc/programs/Xserver/GL/mesa/src/X/xf86glx.c,v 1.15 1999/08/04 18:14:14 faith Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "xf86glxint.h" -#include "xmesaP.h" -#include - -/* - * This define is for the glcore.h header file. - * If you add it here, then make sure you also add it in - * ../../../glx/Imakefile. - */ -#if 0 -#define DEBUG -#include -#undef DEBUG -#else -#include -#endif - - -/* - * This structure is statically allocated in the __glXScreens[] - * structure. This struct is not used anywhere other than in - * __glXScreenInit to initialize each of the active screens - * (__glXActiveScreens[]). Several of the fields must be initialized by - * the screenProbe routine before they are copied to the active screens - * struct. In particular, the contextCreate, pGlxVisual, numVisuals, - * and numUsableVisuals fields must be initialized. - */ -__GLXscreenInfo __glDDXScreenInfo = { - __MESA_screenProbe, /* Must be generic and handle all screens */ - __MESA_createContext, /* Substitute screen's createContext routine */ - __MESA_createBuffer, /* Substitute screen's createBuffer routine */ - NULL, /* Set up pGlxVisual in probe */ - NULL, /* Set up pVisualPriv in probe */ - 0, /* Set up numVisuals in probe */ - 0, /* Set up numUsableVisuals in probe */ - "Vendor String", /* GLXvendor is overwritten by __glXScreenInit */ - "Version String", /* GLXversion is overwritten by __glXScreenInit */ - "Extensions String", /* GLXextensions is overwritten by __glXScreenInit */ - NULL /* WrappedPositionWindow is overwritten */ -}; - -__GLXextensionInfo __glDDXExtensionInfo = { - GL_CORE_MESA, - __MESA_resetExtension, - __MESA_initVisuals, - __MESA_setVisualConfigs -}; - -__MESA_screen MESAScreens[MAXSCREENS]; -__GLcontext *MESA_CC = NULL; - -int numConfigs = 0; -__GLXvisualConfig *visualConfigs = NULL; -void **visualPrivates = NULL; - -static int count_bits(unsigned int n) -{ - int bits = 0; - - while (n > 0) { - if (n & 1) bits++; - n >>= 1; - } - return bits; -} - -static XMesaVisual find_mesa_visual(int screen, VisualID vid) -{ - XMesaVisual xm_vis = NULL; - __MESA_screen *pMScr = &MESAScreens[screen]; - int i; - - for (i = 0; i < pMScr->num_vis; i++) { - if (pMScr->glx_vis[i].vid == vid) { - break; - } - } - - if (i < pMScr->num_vis) { - xm_vis = pMScr->xm_vis[i]; - } - return xm_vis; -} - -#define VISUAL_CONFIG(rgba,accum,back,depth,stencil,rating) \ -{ \ - -1, /* vid */ \ - -1, /* class */ \ - rgba, /* rgba */ \ - -1, -1, -1, 0, /* rgba sizes, alpha not supported, yet */ \ - -1, -1, -1, 0, /* rgba masks, alpha not supported, yet */ \ - accum, accum, accum, accum, /* rgba accum sizes */ \ - back, /* doubleBuffer */ \ - GL_FALSE, /* stereo */ \ - -1, /* bufferSize */ \ - depth, /* depthSize */ \ - stencil, /* stencilSize */ \ - 0, /* auxBuffers */ \ - 0, /* level */ \ - rating, /* visualRating */ \ - 0, /* transparentPixel */ \ - 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ \ - 0 /* transparentIndex */ \ -} - -#define IS_RGBA GL_TRUE -#define IS_CI GL_FALSE -#define HAS_ACCUM ACCUM_BITS -#define NO_ACCUM 0 -#define HAS_BACK GL_TRUE -#define NO_BACK GL_FALSE -#define HAS_DEPTH DEPTH_BITS -#define NO_DEPTH 0 -#define HAS_STENCIL STENCIL_BITS -#define NO_STENCIL 0 - -static __GLXvisualConfig __MESAvisualConfigs[] = { - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, 0, 0, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, 16, 0, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, 32, 0, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, 24, 8, 0), - - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, 0, 0, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, 16, 0, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, 32, 0, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, 24, 8, 0), - - VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, NO_BACK, 0, 0, 0), - VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, NO_BACK, 16, 0, 0), - VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, NO_BACK, 32, 0, 0), - VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, NO_BACK, 24, 8, 0), - - VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, HAS_BACK, 0, 0, 0), - VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, HAS_BACK, 16, 0, 0), - VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, HAS_BACK, 32, 0, 0), - VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, HAS_BACK, 24, 8, 0), -/* - VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, HAS_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0), -*/ -}; - -/* -static __GLXvisualConfig __MESAvisualConfigs[] = { - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, HAS_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, HAS_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, HAS_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0), -}; -*/ - -static int __numMESAvisualConfigs = - sizeof(__MESAvisualConfigs)/sizeof(__GLXvisualConfig); -static int __numRGBconfigs = -1; -static int __numCIconfigs = -1; - -static Bool init_visuals(int *nvisualp, VisualPtr *visualp, - VisualID *defaultVisp, - int ndepth, DepthPtr pdepth, - int rootDepth) -{ - int numVisuals = *nvisualp; - int numMesaVisuals = 0; - int numMergedVisualConfigs = 0; - VisualPtr pVisual = *visualp; - VisualPtr pVisualNew = NULL; - VisualID *orig_vid = NULL; - __GLXvisualConfig *glXVisualPtr = NULL; - __GLXvisualConfig *pMergedVisualConfigs = NULL; - void **glXVisualPriv; - void **pMergedVisualPriv; - int *mesaConfigUsed; - int *driverConfigUsed; - int found_default = FALSE; - int i, j, k; - int is_rgb; - Bool match; - - /* Alloc space for the list of merged GLX visuals */ - pMergedVisualConfigs = - (__GLXvisualConfig *)__glXMalloc((numConfigs + - __numMESAvisualConfigs) * - sizeof(__GLXvisualConfig)); - if (!pMergedVisualConfigs) { - return FALSE; - } - - /* Alloc space for the list of merged GLX visual privates */ - pMergedVisualPriv = - (void **)__glXMalloc((numConfigs + __numMESAvisualConfigs) * - sizeof(void *)); - if (!pMergedVisualPriv) { - __glXFree(pMergedVisualConfigs); - return FALSE; - } - - /* Compute the intersection of the driver's visual configs */ - mesaConfigUsed = __glXCalloc(__numMESAvisualConfigs, sizeof(int)); - driverConfigUsed = __glXCalloc(numConfigs, sizeof(int)); - - for (i = j = 0; i < numConfigs; i++) { - k = 0; - while ((k < __numMESAvisualConfigs) && (!driverConfigUsed[i])) { - if (!mesaConfigUsed[k]) { - -#ifdef DEBUG_VISUAL_CONFIG -#define TEST_AND_COPY(fld) do { \ - if (match) { \ - if ((__MESAvisualConfigs[k].fld == visualConfigs[i].fld) || \ - (__MESAvisualConfigs[k].fld == -1)) { \ - pMergedVisualConfigs[j].fld = visualConfigs[i].fld; \ - } \ - else if (visualConfigs[i].fld == -1) { \ - pMergedVisualConfigs[j].fld = __MESAvisualConfigs[k].fld; \ - } \ - else { \ - match = FALSE; \ - xf86DrvMsg (0, 0, "[GLXVisualInit] mismatch: " \ - "(%s) DriverVisualConfig[%d] MesaVisualConfig[%d]\n", \ - #fld, i, k); \ - } \ - } \ - } while (0) -#else -#define TEST_AND_COPY(fld) do { \ - if (match) { \ - if ((__MESAvisualConfigs[k].fld == visualConfigs[i].fld) || \ - (__MESAvisualConfigs[k].fld == -1)) { \ - pMergedVisualConfigs[j].fld = visualConfigs[i].fld; \ - } \ - else if (visualConfigs[i].fld == -1) { \ - pMergedVisualConfigs[j].fld = __MESAvisualConfigs[k].fld; \ - } \ - else { \ - match = FALSE; \ - } \ - } \ - } while (0) -#endif - - match = TRUE; - TEST_AND_COPY(class); - TEST_AND_COPY(rgba); - TEST_AND_COPY(redSize); - TEST_AND_COPY(greenSize); - TEST_AND_COPY(blueSize); - TEST_AND_COPY(alphaSize); - TEST_AND_COPY(redMask); - TEST_AND_COPY(greenMask); - TEST_AND_COPY(blueMask); - TEST_AND_COPY(alphaMask); - TEST_AND_COPY(accumRedSize); - TEST_AND_COPY(accumGreenSize); - TEST_AND_COPY(accumBlueSize); - TEST_AND_COPY(accumAlphaSize); - TEST_AND_COPY(doubleBuffer); - TEST_AND_COPY(stereo); - TEST_AND_COPY(bufferSize); - TEST_AND_COPY(depthSize); - TEST_AND_COPY(stencilSize); - TEST_AND_COPY(auxBuffers); - TEST_AND_COPY(level); - TEST_AND_COPY(visualRating); - TEST_AND_COPY(transparentPixel); - TEST_AND_COPY(transparentRed); - TEST_AND_COPY(transparentGreen); - TEST_AND_COPY(transparentBlue); - TEST_AND_COPY(transparentAlpha); - TEST_AND_COPY(transparentIndex); - if (match) { - driverConfigUsed[i] = TRUE; - mesaConfigUsed[k] = TRUE; - pMergedVisualPriv[j] = visualPrivates[i]; - j++; -#ifdef DEBUG_VISUAL_CONFIG - xf86DrvMsg (0, 0, "[GLXVisualInit] MATCH: " - "DriverVisualConfig[%d] MesaVisualConfig[%d]\n", i, k); -#endif - } - } - k++; - } - } - - /* - ** If SetVisualConfigs was not called, then just make all of Mesa's - ** visual configs available. - */ - if (!numConfigs) { - memcpy(pMergedVisualConfigs, __MESAvisualConfigs, - sizeof(__GLXvisualConfig) * __numMESAvisualConfigs); - memset(pMergedVisualPriv, 0, sizeof(void *) * __numMESAvisualConfigs); - memset(mesaConfigUsed, TRUE, sizeof(int) * __numMESAvisualConfigs); - j = __numMESAvisualConfigs; - } - - /* - ** This code is not currently used. When the visual caveat - ** extension is supported by the DRI and Mesa, we can take advantage - ** of this code. - */ -#if 0 - /* Add any unclaimed MESA configs w/ slow caveat */ - for (i = 0; i < __numMESAvisualConfigs; i++) { - if (!mesaConfigUsed[i]) { - memcpy(&pMergedVisualConfigs[j], &__MESAvisualConfigs[i], - sizeof(__GLXvisualConfig)); - pMergedVisualConfigs[j].visualRating = GLX_SLOW_VISUAL_EXT; - j++; -#ifdef DEBUG_VISUAL_CONFIG - xf86DrvMsg (0, 0, "[GLXVisualInit] slow config: " - "MesaVisualConfig[%d]\n", i); -#endif - } - } - - /* Add any unclaimed driver configs w/ nonconformant caveat */ - for (i = 0; i < numConfigs; i++) { - if (!driverConfigUsed[i]) { - memcpy(&pMergedVisualConfigs[j], &visualConfigs[i], - sizeof(__GLXvisualConfig)); - pMergedVisualConfigs[j].visualRating = GLX_NON_CONFORMANT_VISUAL_EXT; - j++; -#ifdef DEBUG_VISUAL_CONFIG - xf86DrvMsg (0, 0, "[GLXVisualInit] non-conformant config: " - "DriverVisualConfig[%d]\n", i); -#endif - } - } -#endif - - numMergedVisualConfigs = j; - - /* Count the number of RGB and CI visual configs */ - __numRGBconfigs = __numCIconfigs = 0; - for (i = 0; i < numMergedVisualConfigs; i++) { - if (pMergedVisualConfigs[i].rgba) - __numRGBconfigs++; - else - __numCIconfigs++; - } - - /* Count the total number of visuals to compute */ - for (i = 0; i < numVisuals; i++) { - numMesaVisuals += - (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor) - ? __numRGBconfigs : __numCIconfigs; - } - - /* Reset variables for use with the next screen/driver's visual configs */ - visualConfigs = NULL; - numConfigs = 0; - - /* Alloc temp space for the list of orig VisualIDs for each new visual */ - orig_vid = (VisualID *)__glXMalloc(numMesaVisuals * sizeof(VisualID)); - if (!orig_vid) { - __glXFree(pMergedVisualPriv); - __glXFree(pMergedVisualConfigs); - return FALSE; - } - - /* Alloc space for the list of glXVisuals */ - glXVisualPtr = (__GLXvisualConfig *)__glXMalloc(numMesaVisuals * - sizeof(__GLXvisualConfig)); - if (!glXVisualPtr) { - __glXFree(orig_vid); - __glXFree(pMergedVisualPriv); - __glXFree(pMergedVisualConfigs); - return FALSE; - } - - /* Alloc space for the list of glXVisualPrivates */ - glXVisualPriv = (void **)__glXMalloc(numMesaVisuals * sizeof(void *)); - if (!glXVisualPriv) { - __glXFree(glXVisualPtr); - __glXFree(orig_vid); - __glXFree(pMergedVisualPriv); - __glXFree(pMergedVisualConfigs); - return FALSE; - } - - /* Alloc space for the new list of the X server's visuals */ - pVisualNew = (VisualPtr)__glXMalloc(numMesaVisuals * sizeof(VisualRec)); - if (!pVisualNew) { - __glXFree(glXVisualPriv); - __glXFree(glXVisualPtr); - __glXFree(orig_vid); - __glXFree(pMergedVisualPriv); - __glXFree(pMergedVisualConfigs); - return FALSE; - } - - /* Initialize the new visuals */ - for (i = j = 0; i < numVisuals; i++) { - is_rgb = (pVisual[i].class == TrueColor || - pVisual[i].class == DirectColor); - - for (k = 0; k < numMergedVisualConfigs; k++) { - if (pMergedVisualConfigs[k].rgba != is_rgb) - continue; - - /* Initialize the new visual */ - pVisualNew[j] = pVisual[i]; - pVisualNew[j].vid = FakeClientID(0); - - /* Check for the default visual */ - if (!found_default && pVisual[i].vid == *defaultVisp) { - *defaultVisp = pVisualNew[j].vid; - found_default = TRUE; - } - - /* Save the old VisualID */ - orig_vid[j] = pVisual[i].vid; - - /* Initialize the glXVisual */ - glXVisualPtr[j] = pMergedVisualConfigs[k]; - glXVisualPtr[j].vid = pVisualNew[j].vid; - - /* - * If the class is -1, then assume the X visual information - * is identical to what GLX needs, and take them from the X - * visual. NOTE: if class != -1, then all other fields MUST - * be initialized. - */ - if (glXVisualPtr[j].class == -1) { - glXVisualPtr[j].class = pVisual[i].class; - glXVisualPtr[j].redSize = count_bits(pVisual[i].redMask); - glXVisualPtr[j].greenSize = count_bits(pVisual[i].greenMask); - glXVisualPtr[j].blueSize = count_bits(pVisual[i].blueMask); - glXVisualPtr[j].alphaSize = 0; /* Not supported in Mesa */ - glXVisualPtr[j].redMask = pVisual[i].redMask; - glXVisualPtr[j].greenMask = pVisual[i].greenMask; - glXVisualPtr[j].blueMask = pVisual[i].blueMask; - glXVisualPtr[j].alphaMask = 0; /* Not supported in Mesa */ - glXVisualPtr[j].bufferSize = rootDepth; - } - - /* Save the device-dependent private for this visual */ - glXVisualPriv[j] = pMergedVisualPriv[k]; - - j++; - } - } - - /* Save the GLX visuals in the screen structure */ - MESAScreens[screenInfo.numScreens-1].num_vis = numMesaVisuals; - MESAScreens[screenInfo.numScreens-1].glx_vis = glXVisualPtr; - MESAScreens[screenInfo.numScreens-1].private = glXVisualPriv; - - /* Set up depth's VisualIDs */ - for (i = 0; i < ndepth; i++) { - int numVids = 0; - VisualID *pVids = NULL; - int k, n = 0; - - /* Count the new number of VisualIDs at this depth */ - for (j = 0; j < pdepth[i].numVids; j++) - for (k = 0; k < numMesaVisuals; k++) - if (pdepth[i].vids[j] == orig_vid[k]) - numVids++; - - /* Allocate a new list of VisualIDs for this depth */ - pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID)); - - /* Initialize the new list of VisualIDs for this depth */ - for (j = 0; j < pdepth[i].numVids; j++) - for (k = 0; k < numMesaVisuals; k++) - if (pdepth[i].vids[j] == orig_vid[k]) - pVids[n++] = pVisualNew[k].vid; - - /* Update this depth's list of VisualIDs */ - __glXFree(pdepth[i].vids); - pdepth[i].vids = pVids; - pdepth[i].numVids = numVids; - } - - /* Update the X server's visuals */ - *nvisualp = numMesaVisuals; - *visualp = pVisualNew; - - /* Free the old list of the X server's visuals */ - __glXFree(pVisual); - - /* Clean up temporary allocations */ - __glXFree(orig_vid); - __glXFree(pMergedVisualPriv); - __glXFree(pMergedVisualConfigs); - - /* Free the private list created by DDX HW driver */ - if (visualPrivates) xfree(visualPrivates); - visualPrivates = NULL; - - return TRUE; -} - -void __MESA_setVisualConfigs(int nconfigs, __GLXvisualConfig *configs, - void **privates) -{ - numConfigs = nconfigs; - visualConfigs = configs; - visualPrivates = privates; -} - -Bool __MESA_initVisuals(VisualPtr *visualp, DepthPtr *depthp, - int *nvisualp, int *ndepthp, int *rootDepthp, - VisualID *defaultVisp, unsigned long sizes, - int bitsPerRGB) -{ - /* - * Setup the visuals supported by this particular screen. - */ - return init_visuals(nvisualp, visualp, defaultVisp, - *ndepthp, *depthp, *rootDepthp); -} - -static void fixup_visuals(int screen) -{ - ScreenPtr pScreen = screenInfo.screens[screen]; - __MESA_screen *pMScr = &MESAScreens[screen]; - __GLXvisualConfig *pGLXVis = pMScr->glx_vis; - VisualPtr pVis; - int i, j; - - for (i = 0; i < pMScr->num_vis; i++, pGLXVis++) { - pVis = pScreen->visuals; - - /* Find a visual that matches the GLX visual's class and size */ - for (j = 0; j < pScreen->numVisuals; j++, pVis++) { - if (pVis->class == pGLXVis->class && - pVis->nplanes == pGLXVis->bufferSize) { - - /* Fixup the masks */ - pGLXVis->redMask = pVis->redMask; - pGLXVis->greenMask = pVis->greenMask; - pGLXVis->blueMask = pVis->blueMask; - - /* Recalc the sizes */ - pGLXVis->redSize = count_bits(pGLXVis->redMask); - pGLXVis->greenSize = count_bits(pGLXVis->greenMask); - pGLXVis->blueSize = count_bits(pGLXVis->blueMask); - } - } - } -} - -static void init_screen_visuals(int screen) -{ - ScreenPtr pScreen = screenInfo.screens[screen]; - __GLXvisualConfig *pGLXVis = MESAScreens[screen].glx_vis; - XMesaVisual *pXMesaVisual; - VisualPtr pVis; - int *used; - int i, j; - - /* Alloc space for the list of XMesa visuals */ - pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis * - sizeof(XMesaVisual)); - - used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int)); - __glXMemset(used, 0, pScreen->numVisuals * sizeof(int)); - - for (i = 0; i < MESAScreens[screen].num_vis; i++, pGLXVis++) { - - pVis = pScreen->visuals; - for (j = 0; j < pScreen->numVisuals; j++, pVis++) { - - if (pVis->class == pGLXVis->class && - pVis->nplanes == pGLXVis->bufferSize && - !used[j]) { - - if (pVis->redMask == pGLXVis->redMask && - pVis->greenMask == pGLXVis->greenMask && - pVis->blueMask == pGLXVis->blueMask) { - - /* Create the XMesa visual */ - pXMesaVisual[i] = - XMesaCreateVisual(pScreen, - pVis, - pGLXVis->rgba, - (pGLXVis->alphaSize > 0), - pGLXVis->doubleBuffer, - pGLXVis->stereo, - GL_TRUE, /* ximage_flag */ - pGLXVis->depthSize, - pGLXVis->stencilSize, - pGLXVis->accumRedSize, - pGLXVis->level); - - /* Set the VisualID */ - pGLXVis->vid = pVis->vid; - - /* Mark this visual used */ - used[j] = 1; - break; - } - } - } - } - - __glXFree(used); - - MESAScreens[screen].xm_vis = pXMesaVisual; -} - -Bool __MESA_screenProbe(int screen) -{ - /* - * Set up the current screen's visuals. - */ - __glDDXScreenInfo.pGlxVisual = MESAScreens[screen].glx_vis; - __glDDXScreenInfo.pVisualPriv = MESAScreens[screen].private; - __glDDXScreenInfo.numVisuals = - __glDDXScreenInfo.numUsableVisuals = MESAScreens[screen].num_vis; - - /* - * Set the current screen's createContext routine. This could be - * wrapped by a DDX GLX context creation routine. - */ - __glDDXScreenInfo.createContext = __MESA_createContext; - - /* - * The ordering of the rgb compenents might have been changed by the - * driver after mi initialized them. - */ - fixup_visuals(screen); - - /* - * Find the GLX visuals that are supported by this screen and create - * XMesa's visuals. - */ - init_screen_visuals(screen); - - return TRUE; -} - -extern void __MESA_resetExtension(void) -{ - int i, j; - - XMesaReset(); - - for (i = 0; i < screenInfo.numScreens; i++) { - for (j = 0; j < MESAScreens[i].num_vis; j++) { - XMesaDestroyVisual(MESAScreens[i].xm_vis[j]); - } - __glXFree(MESAScreens[i].glx_vis); - MESAScreens[i].glx_vis = NULL; - MESAScreens[i].num_vis = 0; - } - MESA_CC = NULL; -} - -void __MESA_createBuffer(__GLXdrawablePrivate *glxPriv) -{ - DrawablePtr pDraw = glxPriv->pDraw; - XMesaVisual xm_vis = find_mesa_visual(pDraw->pScreen->myNum, - glxPriv->pGlxVisual->vid); - __GLdrawablePrivate *glPriv = &glxPriv->glPriv; - __MESA_buffer buf; - - buf = (__MESA_buffer)__glXMalloc(sizeof(struct __MESA_bufferRec)); - - /* Create Mesa's buffers */ - if (glxPriv->type == DRAWABLE_WINDOW) { - buf->xm_buf = (void *)XMesaCreateWindowBuffer(xm_vis, - (WindowPtr)pDraw); - } else { - buf->xm_buf = (void *)XMesaCreatePixmapBuffer(xm_vis, - (PixmapPtr)pDraw, 0); - } - - /* Wrap the front buffer's resize routine */ - buf->fbresize = glPriv->frontBuffer.resize; - glPriv->frontBuffer.resize = __MESA_resizeBuffers; - - /* Wrap the swap buffers routine */ - buf->fbswap = glxPriv->swapBuffers; - glxPriv->swapBuffers = __MESA_swapBuffers; - - /* Save Mesa's private buffer structure */ - glPriv->private = (void *)buf; - glPriv->freePrivate = __MESA_destroyBuffer; -} - -GLboolean __MESA_resizeBuffers(__GLdrawableBuffer *buffer, - GLint x, GLint y, - GLuint width, GLuint height, - __GLdrawablePrivate *glPriv, - GLuint bufferMask) -{ - __MESA_buffer buf = (__MESA_buffer)glPriv->private; - - if (buf->xm_buf && buf->xm_buf->xm_context) { - GLcontext *ctx = buf->xm_buf->xm_context->gl_ctx; - XMesaForceCurrent(buf->xm_buf->xm_context); - (*ctx->CurrentDispatch->ResizeBuffersMESA)(); - if (MESA_CC) - XMesaForceCurrent(MESA_CC->xm_ctx); - } - - return (*buf->fbresize)(buffer, x, y, width, height, glPriv, bufferMask); -} - -GLboolean __MESA_swapBuffers(__GLXdrawablePrivate *glxPriv) -{ - __MESA_buffer buf = (__MESA_buffer)glxPriv->glPriv.private; - - /* - ** Do not call the wrapped swap buffers routine since Mesa has - ** already done the swap. - */ - XMesaSwapBuffers(buf->xm_buf); - - return GL_TRUE; -} - -void __MESA_destroyBuffer(__GLdrawablePrivate *glPriv) -{ - __MESA_buffer buf = (__MESA_buffer)glPriv->private; - __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other; - - /* Destroy Mesa's buffers */ - if (buf->xm_buf) - XMesaDestroyBuffer(buf->xm_buf); - - /* Unwrap these routines */ - glxPriv->swapBuffers = buf->fbswap; - glPriv->frontBuffer.resize = buf->fbresize; - - __glXFree(glPriv->private); - glPriv->private = NULL; -} - -__GLinterface *__MESA_createContext(__GLimports *imports, - __GLcontextModes *modes, - __GLinterface *shareGC) -{ - __GLcontext *gl_ctx; - XMesaContext m_share = NULL; - XMesaVisual xm_vis; - __GLXcontext *glxc = (__GLXcontext *)imports->other; - - gl_ctx = (__GLcontext *)__glXMalloc(sizeof(__GLcontext)); - if (!gl_ctx) - return NULL; - - gl_ctx->iface.imports = *imports; - - gl_ctx->iface.exports.destroyContext = __MESA_destroyContext; - gl_ctx->iface.exports.loseCurrent = __MESA_loseCurrent; - gl_ctx->iface.exports.makeCurrent = __MESA_makeCurrent; - gl_ctx->iface.exports.shareContext = __MESA_shareContext; - gl_ctx->iface.exports.copyContext = __MESA_copyContext; - gl_ctx->iface.exports.forceCurrent = __MESA_forceCurrent; - gl_ctx->iface.exports.notifyResize = __MESA_notifyResize; - gl_ctx->iface.exports.notifyDestroy = __MESA_notifyDestroy; - gl_ctx->iface.exports.notifySwapBuffers = __MESA_notifySwapBuffers; - gl_ctx->iface.exports.dispatchExec = __MESA_dispatchExec; - gl_ctx->iface.exports.beginDispatchOverride = __MESA_beginDispatchOverride; - gl_ctx->iface.exports.endDispatchOverride = __MESA_endDispatchOverride; - - if (shareGC) m_share = ((__GLcontext *)shareGC)->xm_ctx; - xm_vis = find_mesa_visual(glxc->pScreen->myNum, glxc->pGlxVisual->vid); - if (xm_vis) { - gl_ctx->xm_ctx = XMesaCreateContext(xm_vis, m_share); - } else { - __glXFree(gl_ctx); - gl_ctx = NULL; - } - - return (__GLinterface *)gl_ctx; -} - -GLboolean __MESA_destroyContext(__GLcontext *gc) -{ - XMesaDestroyContext(gc->xm_ctx); - __glXFree(gc); - return GL_TRUE; -} - -GLboolean __MESA_loseCurrent(__GLcontext *gc) -{ - MESA_CC = NULL; - __glXLastContext = NULL; - return XMesaLoseCurrent(gc->xm_ctx); -} - -GLboolean __MESA_makeCurrent(__GLcontext *gc, __GLdrawablePrivate *glPriv) -{ - __MESA_buffer buf = (__MESA_buffer)glPriv->private; - - MESA_CC = gc; - return XMesaMakeCurrent(gc->xm_ctx, buf->xm_buf); -} - -GLboolean __MESA_shareContext(__GLcontext *gc, __GLcontext *gcShare) -{ - /* NOT_DONE */ - ErrorF("__MESA_shareContext\n"); - return GL_FALSE; -} - -GLboolean __MESA_copyContext(__GLcontext *dst, const __GLcontext *src, - GLuint mask) -{ - /* NOT_DONE */ - ErrorF("__MESA_copyContext\n"); - return GL_FALSE; -} - -GLboolean __MESA_forceCurrent(__GLcontext *gc) -{ - MESA_CC = gc; - return XMesaForceCurrent(gc->xm_ctx); -} - -GLboolean __MESA_notifyResize(__GLcontext *gc) -{ - /* NOT_DONE */ - ErrorF("__MESA_notifyResize\n"); - return GL_FALSE; -} - -void __MESA_notifyDestroy(__GLcontext *gc) -{ - /* NOT_DONE */ - ErrorF("__MESA_notifyDestroy\n"); - return; -} - -void __MESA_notifySwapBuffers(__GLcontext *gc) -{ - /* NOT_DONE */ - ErrorF("__MESA_notifySwapBuffers\n"); - return; -} - -struct __GLdispatchStateRec *__MESA_dispatchExec(__GLcontext *gc) -{ - /* NOT_DONE */ - ErrorF("__MESA_dispatchExec\n"); - return NULL; -} - -void __MESA_beginDispatchOverride(__GLcontext *gc) -{ - /* NOT_DONE */ - ErrorF("__MESA_beginDispatchOverride\n"); - return; -} - -void __MESA_endDispatchOverride(__GLcontext *gc) -{ - /* NOT_DONE */ - ErrorF("__MESA_endDispatchOverride\n"); - return; -} - -GLint __glEvalComputeK(GLenum target) -{ - switch (target) { - case GL_MAP1_VERTEX_4: - case GL_MAP1_COLOR_4: - case GL_MAP1_TEXTURE_COORD_4: - case GL_MAP2_VERTEX_4: - case GL_MAP2_COLOR_4: - case GL_MAP2_TEXTURE_COORD_4: - return 4; - case GL_MAP1_VERTEX_3: - case GL_MAP1_TEXTURE_COORD_3: - case GL_MAP1_NORMAL: - case GL_MAP2_VERTEX_3: - case GL_MAP2_TEXTURE_COORD_3: - case GL_MAP2_NORMAL: - return 3; - case GL_MAP1_TEXTURE_COORD_2: - case GL_MAP2_TEXTURE_COORD_2: - return 2; - case GL_MAP1_TEXTURE_COORD_1: - case GL_MAP2_TEXTURE_COORD_1: - case GL_MAP1_INDEX: - case GL_MAP2_INDEX: - return 1; - default: - return 0; - } -} - -GLuint __glFloorLog2(GLuint val) -{ - int c = 0; - - while (val > 1) { - c++; - val >>= 1; - } - return c; -} - diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c Sun Aug 10 22:44:55 2003 @@ -36,7 +36,7 @@ #include #include "sis_dri.h" -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" #include @@ -289,136 +289,18 @@ } } -static XMesaBuffer SISCreateWindowBuffer ( Display *dpy, - __DRIscreenPrivate *driScrnPriv, - __DRIdrawablePrivate *driDrawPriv, - GLvisual *mesaVis, - XMesaContext xmesa) -{ - XMesaBuffer b = (XMesaBuffer) calloc (1, sizeof (struct xmesa_buffer)); - - if (SIS_VERBOSE&VERBOSE_SIS_BUFFER){ - fprintf(stderr, "SISCreateWindowBuffer: drawable ID=%lu\n", - (DWORD)driDrawPriv); - } - - if (!b) - return NULL; - - b->xm_context = NULL; - b->xm_visual = xmesa->xm_visual; - b->display = dpy; - b->pixmap_flag = GL_FALSE; - b->db_state = mesaVis->DBflag; - b->gl_buffer = driDrawPriv->mesaBuffer; - b->frontbuffer = driDrawPriv->draw; - - /* set 0 for buffer update */ - b->width = 0; - b->height = 0; - - if (b->backimage) - { -#if 0 - XMesaDestroyImage (b->backimage); -#else - free(b->backimage); -#endif - b->backimage = NULL; - } - -#if 0 - b->backimage = XCreateImage (b->display, - b->xm_visual->visinfo->visual, - GET_VISUAL_DEPTH (b->xm_visual), ZPixmap, 0, - NULL, b->width, b->height, 8, 0); -#else - b->backimage = (XMesaImage *) calloc (1, sizeof (XImage)); -#endif - - b->driDrawPriv = driDrawPriv; - - { - sisBufferInfo *buf_info; - - b->private = calloc (1, sizeof (sisBufferInfo)); - buf_info = (sisBufferInfo *)(b->private); - - buf_info->pZClearPacket = &buf_info->zClearPacket; - buf_info->pCbClearPacket = &buf_info->cbClearPacket; - } - - return b; -} - -GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, - __DRIscreenPrivate *driScrnPriv, - __DRIdrawablePrivate *driDrawPriv, - GLvisual *mesaVis) -{ - /* not implement yet */ - return NULL; -} - -static void SISDestroyBuffer (XMesaBuffer b) -{ - if (SIS_VERBOSE&VERBOSE_SIS_BUFFER){ - fprintf(stderr, "SISDestroyBuffer: b=%lu\n", (DWORD)b); - } - - if (b->backimage && b->backimage->data) - { - sisBufferInfo *priv = (sisBufferInfo *) b->private; - - sis_free_back_image (b, b->backimage, priv->bbFree); -#if SIS_STEREO - { - XMesaContext xmesa = (XMesaContext) b->xm_context; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - GLcontext *ctx = xmesa->gl_ctx; - - if(hwcx->stereoEnabled){ - sis_final_stereo(ctx); - hwcx->stereoEnabled = GL_FALSE; - } - } -#endif - } - - if (b->depthbuffer) - { - sis_free_z_stencil_buffer (b); - } - - assert (b->private); - free (b->private); - b->private = NULL; - - if (b->xm_context) - b->xm_context->xm_buffer = NULL; - -#if 0 - XMesaDestroyImage (b->backimage); -#else - free(b->backimage); -#endif - - /* TODO : if b doesn't exist, do something */ - - free (b); -} void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv) { - __GLSiScontext *hwcx; + sisContextPtr smesa; if(!XMesa) return; FLUSH_VB( XMesa->gl_ctx, "swap buffers" ); - hwcx = (__GLSiScontext *) XMesa->private; - (hwcx->SwapBuffers)(XMesa->xm_buffer); + smesa = (sisContextPtr) XMesa->private; + (smesa->SwapBuffers)(XMesa->xm_buffer); } GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv) @@ -427,88 +309,3 @@ return GL_TRUE; } -GLboolean -XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv) -{ - return GL_TRUE; -} - -GLboolean -XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv) -{ - return GL_TRUE; -} - -GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv) -{ - if (driContextPriv) - { - XMesaContext c = (XMesaContext) driContextPriv->driverPrivate; - XMesaBuffer b; - - /* TODO: ??? */ - if ((c->gl_ctx == gl_get_current_context ()) && - (driContextPriv->driDrawablePriv == driDrawPriv) && - c->xm_buffer->wasCurrent) - { - return GL_TRUE; - } - - if (SIS_VERBOSE&VERBOSE_SIS_BUFFER){ - fprintf(stderr, "XMesaMakeCurrent: c=%lu, b=%lu\n", (DWORD)c, (DWORD)b); - fprintf(stderr, "XMesaMakeCurrent: drawable ID=%lu\n", (DWORD)b->frontbuffer); - fprintf(stderr, "XMesaMakeCurrent: width=%d, height=%d\n", - b->width, b->height); - { - __DRIdrawablePrivate *dPriv = c->driContextPriv->driDrawablePriv; - fprintf(stderr, "XMesaMakeCurrent: width=%d, height=%d\n", - dPriv->w, dPriv->h); - } - } - - b = SISCreateWindowBuffer(c->display, - driContextPriv->driScreenPriv, - driDrawPriv, - c->gl_ctx->Visual, - c); - - if (c->xm_buffer){ - /* TODO: ??? */ - c->xm_buffer->xm_context = NULL; - SISDestroyBuffer(c->xm_buffer); - } - - b->xm_context = c; - c->xm_buffer = b; - - gl_make_current (c->gl_ctx, b->gl_buffer); - XMesa = c; - - if(b->width == 0){ - GLuint width, height; - - sis_GetBufferSize (c->gl_ctx, &width, &height); - } - - sis_update_drawable_state(c->gl_ctx); - - if (c->gl_ctx->Viewport.Width == 0) - { - /* initialize viewport to window size */ - gl_Viewport (c->gl_ctx, 0, 0, b->width, b->height); - c->gl_ctx->Scissor.Width = b->width; - c->gl_ctx->Scissor.Height = b->height; - } - - c->xm_buffer->wasCurrent = GL_TRUE; - } - else - { - gl_make_current (NULL, NULL); - XMesa = NULL; - } - - return GL_TRUE; -} diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h Sun Aug 10 22:44:55 2003 @@ -26,37 +26,16 @@ #ifndef XMESAP_H #define XMESAP_H +#include +#include +#include "GL/xmesa_x.h" +#include "GL/gl.h" -#ifdef XFree86Server -# include "GL/xf86glx.h" -# include "xf86glx_util.h" -#else -# ifdef GLX_DIRECT_RENDERING -# include "dri_mesa.h" -# endif -#endif +#include "dri_util.h" -#ifdef XFree86Server -# include "GL/xmesa.h" -#else -# include -# include -# include "GL/xmesa_x.h" -# include "GL/gl.h" typedef struct xmesa_context *XMesaContext; typedef struct xmesa_visual *XMesaVisual; typedef struct xmesa_buffer *XMesaBuffer; -#endif - -#include "types.h" - -#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server) -# include "xdriP.h" -#else -# define DRI_DRAWABLE_ARG -# define DRI_DRAWABLE_PARM -# define DRI_CTX_ARG -#endif struct xmesa_visual { GLvisual *gl_visual; /* Device independent visual parameters */ @@ -73,7 +52,7 @@ XMesaDisplay *display; /* == xm_visual->display */ -#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server) +#if defined(GLX_DIRECT_RENDERING) __DRIcontextPrivate *driContextPriv; /* back pointer to DRI context * used for locking */ @@ -100,7 +79,7 @@ GLint bottom; /* used for FLIP macro below */ -#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server) +#if defined(GLX_DIRECT_RENDERING) __DRIdrawablePrivate *driDrawPriv; /* back pointer to DRI drawable * used for direct access to framebuffer */ diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_xwin.c xc/lib/GL/mesa/src/drv/sis/sis_xwin.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_xwin.c Sun Aug 10 22:45:33 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_xwin.c Sun Aug 10 22:44:55 2003 @@ -32,87 +32,9 @@ * */ -#include "sis_ctx.h" +#include "sis_context.h" #include "sis_mesa.h" -#ifdef XFree86Server - -GLboolean -sis_get_clip_rects (XMesaContext xmesa, BoxPtr *ppExtents, int *pCount) -{ - XMesaDrawable d = xmesa->xm_buffer->frontbuffer; - - if (d->type == DRAWABLE_WINDOW) - { - RegionPtr pClipList = &((WindowPtr) d)->clipList; - RegDataPtr data = pClipList->data; - - if (data) - { - *ppExtents = - (BoxPtr) ((GLubyte *) (pClipList->data) + sizeof (RegDataRec)); - *pCount = data->numRects; - } - else - { - *ppExtents = &(pClipList->extents); - *pCount = 1; - } - } - else{ - /* Pixmap */ - /* - * TODO : sis_clear_color_buffer, sis_line_clip, sis_tri_clip don't - * consider this situation and result in page fault - */ - *ppExtents = NULL; - *pCount = 0; - return GL_FALSE; - } - - return GL_TRUE; -} - -void * -sis_get_drawable_pos (XMesaContext xmesa) -{ - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - XMesaDrawable d = xmesa->xm_buffer->frontbuffer; - - return GET_FbBase (hwcx) + - (d->x) * GET_DEPTH (hwcx) + (d->y) * GET_PITCH (hwcx); -} - -void -sis_get_drawable_origin (XMesaContext xmesa, GLuint * x, GLuint * y) -{ - XMesaDrawable d = xmesa->xm_buffer->frontbuffer; - - *x = d->x; - *y = d->y; -} - -void -sis_get_drawable_size (XMesaContext xmesa, GLuint * w, GLuint * h) -{ - XMesaDrawable d = xmesa->xm_buffer->frontbuffer; - - *w = d->width; - *h = d->height; -} - -void -sis_get_drawable_box (XMesaContext xmesa, BoxPtr pBox) -{ - XMesaDrawable d = xmesa->xm_buffer->frontbuffer; - - pBox->x1 = d->x; - pBox->y1 = d->y; - pBox->x2 = d->x + d->width; - pBox->y2 = d->y + d->height; -} - -#else GLboolean sis_get_clip_rects (XMesaContext xmesa, BoxPtr * ppExtents, int *pCount) @@ -141,7 +63,7 @@ void * sis_get_drawable_pos (XMesaContext xmesa) { - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv; @@ -151,8 +73,8 @@ dPriv); */ - return GET_FbBase (hwcx) + (dPriv->x) * GET_DEPTH (hwcx) + - (dPriv->y) * GET_PITCH (hwcx); + return GET_FbBase (smesa) + (dPriv->x) * GET_DEPTH (smesa) + + (dPriv->y) * GET_PITCH (smesa); } void @@ -201,5 +123,3 @@ pBox->x2 = dPriv->x + dPriv->w; pBox->y2 = dPriv->y + dPriv->h; } - -#endif diff -ruN ../xc/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_common.h xc/programs/Xserver/hw/xfree86/drivers/sis/sis_common.h --- ../xc/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_common.h Wed Dec 31 16:00:00 1969 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_common.h Sun Aug 10 22:45:10 2003 @@ -0,0 +1,60 @@ +/* sis_common.h -- common header definitions for SiS 2D/3D/DRM suite + * Created: Sun Apr 9 18:16:28 2000 by kevin@precisioninsight.com + * + * Copyright 2003 Eric Anholt + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: + * Eric Anholt + * + * $XFree86$ + * + */ + +#ifndef _SIS_COMMON_H_ +#define _SIS_COMMON_H_ + +#define DRM_SIS_FB_ALLOC 0x04 +#define DRM_SIS_FB_FREE 0x05 +#define DRM_SIS_FLIP 0x08 +#define DRM_SIS_FLIP_INIT 0x09 +#define DRM_SIS_FLIP_FINAL 0x10 +#define DRM_SIS_AGP_INIT 0x13 +#define DRM_SIS_AGP_ALLOC 0x14 +#define DRM_SIS_AGP_FREE 0x15 + +typedef struct { + int context; + unsigned long offset; + unsigned long size; + void *free; +} drm_sis_mem_t; + +typedef struct { + unsigned long offset, size; +} drm_sis_agp_t; + +typedef struct { + unsigned int left, right; +} drm_sis_flip_t; + +#endif /* _SIS_COMMON_H_ */ diff -ruN ../xc/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h --- ../xc/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h Sun Aug 10 22:45:47 2003 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h Sun Aug 10 22:45:10 2003 @@ -7,15 +7,10 @@ #include "xf86drm.h" +#include "sis_sarea.h" + #define SIS_MAX_DRAWABLES 256 #define SISIOMAPSIZE (64*1024) - -typedef struct { - int CtxOwner; - int QueueLength; - unsigned int AGPCmdBufNext; - unsigned int FrameCount; -} SISSAREAPriv; #define SIS_FRONT 0 #define SIS_BACK 1 diff -ruN ../xc/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_sarea.h xc/programs/Xserver/hw/xfree86/drivers/sis/sis_sarea.h --- ../xc/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_sarea.h Wed Dec 31 16:00:00 1969 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_sarea.h Sun Aug 10 22:45:10 2003 @@ -0,0 +1,45 @@ +/* $XFree86$ */ +/* + * Copyright 2003 Eric Anholt + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Eric Anholt + * + */ + +#ifndef _SIS_SAREA_H_ +#define _SIS_SAREA_H_ + +typedef struct { + int ctxOwner; + int QueueLength; + unsigned int AGPCmdBufNext; + unsigned int FrameCount; +} SISSAREAPriv, *SISSAREAPrivPtr; + +#endif /* _SIS_SAREA_H_ */