diff -ruN ../xc/xc/config/cf/host.def xc/config/cf/host.def --- ../xc/xc/config/cf/host.def Fri Aug 22 17:42:03 2003 +++ xc/config/cf/host.def Fri Aug 22 17:41:59 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 @@ -31,8 +33,8 @@ #elif defined(i386Architecture) -#define XF86CardDrivers tdfx i810 mga ati glint vga -#define DriDrivers r200 tdfx mga i810 r128 radeon gamma i830 ffb /* sis */ +#define XF86CardDrivers tdfx i810 mga ati glint vga sis +#define DriDrivers r200 tdfx mga i810 r128 radeon gamma i830 ffb sis #else 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 Tue Aug 12 12:03:50 2003 +++ xc/extras/Mesa/include/GL/glxext.h Tue Aug 12 12:03:13 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 xc/lib/GL/mesa/src/drv/sis/Imakefile --- ../xc/xc/lib/GL/mesa/src/drv/sis/Imakefile Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/Imakefile Wed Aug 20 01:48:03 2003 @@ -32,7 +32,7 @@ #include "../../SPARC/Imakefile.inc" #endif -XCOMM SIS_DEFINES = -DSIS_USE_HW_CULL -DSIS_USE_FASTPATH +XCOMM SIS_DEFINES = -DSIS_USE_HW_CULL SIS_DEFINES = -DSIS_USE_HW_CULL XCOMM DEBUG_DEFINES = -DDEBUG_LOCKING @@ -42,8 +42,7 @@ $(DEBUG_DEFINES) $(STEREO_DEFINES) INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES) - DRIOBJS = $(GLXLIBSRC)/mesa/dri/dri_mesa.o \ - $(GLXLIBSRC)/dri/dri_tmm.o + DRIOBJS = $(GLXLIBSRC)/dri/dri_util.o DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \ $(GLXLIBSRC)/dri/drm/xf86drmHash.o \ @@ -59,8 +58,8 @@ #endif SRCS = $(SISSRCS) - OBJS = $(DRIOBJS) $(DRMOBJS) $(COREMESAOBJS) \ - $(MESA_ASM_OBJS) $(SISOBJS) $(HIOBJS) + OBJS = $(LOOBJS) $(DRIOBJS) $(DRMOBJS) $(COREMESAOBJS) \ + $(MESA_ASM_OBJS) $(COMMONOBJS) $(SISOBJS) $(HIOBJS) REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/Imakefile.inc Mon Aug 25 00:15:50 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 \ @@ -57,93 +59,105 @@ STEREO_DEFINES = -DSIS_STEREO=0 #endif - SISSRCS = $(MESADRVSISBUILDDIR)sis_render.c \ - $(MESADRVSISBUILDDIR)sis_mesa.c \ - $(MESADRVSISBUILDDIR)sis_ctx.c \ - $(MESADRVSISBUILDDIR)sis_alloc.c \ + SISSRCS = $(MESADRVSISBUILDDIR)sis_alloc.c \ + $(MESADRVSISBUILDDIR)sis_dd.c \ + $(MESADRVSISBUILDDIR)sis_lock.c \ + $(MESADRVSISBUILDDIR)sis_context.c \ $(MESADRVSISBUILDDIR)sis_fog.c \ $(MESADRVSISBUILDDIR)sis_clear.c \ + $(MESADRVSISBUILDDIR)sis_screen.c \ + $(MESADRVSISBUILDDIR)sis_state.c \ $(MESADRVSISBUILDDIR)sis_stencil.c \ - $(MESADRVSISBUILDDIR)sis_texture.c \ - $(MESADRVSISBUILDDIR)sis_xwin.c \ - $(MESADRVSISBUILDDIR)sis_xmesa.c \ $(MESADRVSISBUILDDIR)sis_span.c \ - $(MESADRVSISBUILDDIR)sis_fastpath.c \ + $(MESADRVSISBUILDDIR)sis_tex.c \ + $(MESADRVSISBUILDDIR)sis_texstate.c \ + $(MESADRVSISBUILDDIR)sis_tris.c \ + $(MESADRVSISBUILDDIR)sis_vb.c \ $(DEBUG_SRC) \ $(STEREO_SRC) - SISOBJS = $(MESADRVSISBUILDDIR)sis_render.o \ - $(MESADRVSISBUILDDIR)sis_mesa.o \ - $(MESADRVSISBUILDDIR)sis_ctx.o \ - $(MESADRVSISBUILDDIR)sis_alloc.o \ + SISOBJS = $(MESADRVSISBUILDDIR)sis_alloc.o \ + $(MESADRVSISBUILDDIR)sis_dd.o \ + $(MESADRVSISBUILDDIR)sis_lock.o \ + $(MESADRVSISBUILDDIR)sis_context.o \ $(MESADRVSISBUILDDIR)sis_fog.o \ $(MESADRVSISBUILDDIR)sis_clear.o \ + $(MESADRVSISBUILDDIR)sis_screen.o \ + $(MESADRVSISBUILDDIR)sis_state.o \ $(MESADRVSISBUILDDIR)sis_stencil.o \ - $(MESADRVSISBUILDDIR)sis_texture.o \ - $(MESADRVSISBUILDDIR)sis_xwin.o \ - $(MESADRVSISBUILDDIR)sis_xmesa.o \ $(MESADRVSISBUILDDIR)sis_span.o \ - $(MESADRVSISBUILDDIR)sis_fastpath.o \ + $(MESADRVSISBUILDDIR)sis_tex.o \ + $(MESADRVSISBUILDDIR)sis_texstate.o \ + $(MESADRVSISBUILDDIR)sis_tris.o \ + $(MESADRVSISBUILDDIR)sis_vb.o \ $(DEBUG_OBJ) \ $(STEREO_OBJ) - SISUOBJS = $(MESADRVSISBUILDDIR)unshared/sis_render.o \ - $(MESADRVSISBUILDDIR)unshared/sis_mesa.o \ - $(MESADRVSISBUILDDIR)unshared/sis_ctx.o \ - $(MESADRVSISBUILDDIR)unshared/sis_alloc.o \ + SISUOBJS = $(MESADRVSISBUILDDIR)unshared/sis_alloc.o \ + $(MESADRVSISBUILDDIR)unshared/sis_dd.o \ + $(MESADRVSISBUILDDIR)unshared/sis_lock.o \ + $(MESADRVSISBUILDDIR)unshared/sis_context.o \ $(MESADRVSISBUILDDIR)unshared/sis_fog.o \ $(MESADRVSISBUILDDIR)unshared/sis_clear.o \ + $(MESADRVSISBUILDDIR)unshared/sis_screen.o \ + $(MESADRVSISBUILDDIR)unshared/sis_state.o \ $(MESADRVSISBUILDDIR)unshared/sis_stencil.o \ - $(MESADRVSISBUILDDIR)unshared/sis_texture.o \ - $(MESADRVSISBUILDDIR)unshared/sis_xwin.o \ - $(MESADRVSISBUILDDIR)unshared/sis_xmesa.o \ $(MESADRVSISBUILDDIR)unshared/sis_span.o \ - $(MESADRVSISBUILDDIR)unshared/sis_fastpath.o \ + $(MESADRVSISBUILDDIR)unshared/sis_tex.o \ + $(MESADRVSISBUILDDIR)unshared/sis_texstate.o \ + $(MESADRVSISBUILDDIR)unshared/sis_tris.o \ + $(MESADRVSISBUILDDIR)unshared/sis_vb.o \ $(DEBUG_UOBJ) \ $(STEREO_UOBJ) - SISDOBJS = $(MESADRVSISBUILDDIR)debugger/sis_render.o \ - $(MESADRVSISBUILDDIR)debugger/sis_mesa.o \ - $(MESADRVSISBUILDDIR)debugger/sis_ctx.o \ - $(MESADRVSISBUILDDIR)debugger/sis_alloc.o \ + SISDOBJS = $(MESADRVSISBUILDDIR)debugger/sis_alloc.o \ + $(MESADRVSISBUILDDIR)debugger/sis_dd.o \ + $(MESADRVSISBUILDDIR)debugger/sis_lock.o \ + $(MESADRVSISBUILDDIR)debugger/sis_context.o \ $(MESADRVSISBUILDDIR)debugger/sis_fog.o \ $(MESADRVSISBUILDDIR)debugger/sis_clear.o \ + $(MESADRVSISBUILDDIR)debugger/sis_screen.o \ + $(MESADRVSISBUILDDIR)debugger/sis_state.o \ $(MESADRVSISBUILDDIR)debugger/sis_stencil.o \ - $(MESADRVSISBUILDDIR)debugger/sis_texture.o \ - $(MESADRVSISBUILDDIR)debugger/sis_xwin.o \ - $(MESADRVSISBUILDDIR)debugger/sis_xmesa.o \ $(MESADRVSISBUILDDIR)debugger/sis_span.o \ - $(MESADRVSISBUILDDIR)debugger/sis_fastpath.o \ + $(MESADRVSISBUILDDIR)debugger/sis_tex.o \ + $(MESADRVSISBUILDDIR)debugger/sis_texstate.o \ + $(MESADRVSISBUILDDIR)debugger/sis_tris.o \ + $(MESADRVSISBUILDDIR)debugger/sis_vb.o \ $(DEBUG_DOBJ) \ $(STEREO_DOBJ) - SISPOBJS = $(MESADRVSISBUILDDIR)profiled/sis_render.o \ - $(MESADRVSISBUILDDIR)profiled/sis_mesa.o \ - $(MESADRVSISBUILDDIR)profiled/sis_ctx.o \ - $(MESADRVSISBUILDDIR)profiled/sis_alloc.o \ + SISPOBJS = $(MESADRVSISBUILDDIR)profiled/sis_alloc.o \ + $(MESADRVSISBUILDDIR)profiled/sis_dd.o \ + $(MESADRVSISBUILDDIR)profiled/sis_lock.o \ + $(MESADRVSISBUILDDIR)profiled/sis_context.o \ $(MESADRVSISBUILDDIR)profiled/sis_fog.o \ $(MESADRVSISBUILDDIR)profiled/sis_clear.o \ + $(MESADRVSISBUILDDIR)profiled/sis_screen.o \ + $(MESADRVSISBUILDDIR)profiled/sis_state.o \ $(MESADRVSISBUILDDIR)profiled/sis_stencil.o \ - $(MESADRVSISBUILDDIR)profiled/sis_texture.o \ - $(MESADRVSISBUILDDIR)profiled/sis_xwin.o \ - $(MESADRVSISBUILDDIR)profiled/sis_xmesa.o \ $(MESADRVSISBUILDDIR)profiled/sis_span.o \ - $(MESADRVSISBUILDDIR)profiled/sis_fastpath.o \ + $(MESADRVSISBUILDDIR)profiled/sis_tex.o \ + $(MESADRVSISBUILDDIR)profiled/sis_texstate.o \ + $(MESADRVSISBUILDDIR)profiled/sis_tris.o \ + $(MESADRVSISBUILDDIR)profiled/sis_vb.o \ $(DEBUG_POBJ) \ $(STEREO_POBJ) #ifdef NeedToLinkMesaSrc -LinkSourceFile(sis_render.c, $(MESADRVSRCDIR)/sis) -LinkSourceFile(sis_mesa.c, $(MESADRVSRCDIR)/sis) -LinkSourceFile(sis_ctx.c, $(MESADRVSRCDIR)/sis) LinkSourceFile(sis_alloc.c, $(MESADRVSRCDIR)/sis) +LinkSourceFile(sis_dd.c, $(MESADRVSRCDIR)/sis) +LinkSourceFile(sis_lock.c, $(MESADRVSRCDIR)/sis) +LinkSourceFile(sis_context.c, $(MESADRVSRCDIR)/sis) LinkSourceFile(sis_fog.c, $(MESADRVSRCDIR)/sis) LinkSourceFile(sis_clear.c, $(MESADRVSRCDIR)/sis) +LinkSourceFile(sis_screen.c $(MESADRVSRCDIR)/sis) +LinkSourceFile(sis_state.c, $(MESADRVSRCDIR)/sis) LinkSourceFile(sis_stencil.c, $(MESADRVSRCDIR)/sis) -LinkSourceFile(sis_texture.c, $(MESADRVSRCDIR)/sis) -LinkSourceFile(sis_xwin.c, $(MESADRVSRCDIR)/sis) -LinkSourceFile(sis_xmesa.c, $(MESADRVSRCDIR)/sis) LinkSourceFile(sis_span.c, $(MESADRVSRCDIR)/sis) -LinkSourceFile(sis_fastpath.c, $(MESADRVSRCDIR)/sis) +LinkSourceFile(sis_tex.c, $(MESADRVSRCDIR)/sis) +LinkSourceFile(sis_texstate.c, $(MESADRVSRCDIR)/sis) +LinkSourceFile(sis_tris.c, $(MESADRVSRCDIR)/sis) +LinkSourceFile(sis_vb.c, $(MESADRVSRCDIR)/sis) #endif 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_alloc.c Mon Aug 25 00:15:50 2003 @@ -34,18 +34,10 @@ #include -#include "sis_ctx.h" -#include "sis_mesa.h" +#include "sis_context.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) @@ -54,9 +46,6 @@ #define DRAW_BUFFER_HW_ALIGNMENT 16 #define DRAW_BUFFER_HW_PLUS (16 + 4) -#define TEXTURE_HW_ALIGNMENT 4 -#define TEXTURE_HW_PLUS (4 + 4) - #ifdef ROUNDUP #undef ROUNDUP #endif @@ -67,194 +56,111 @@ #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) +void * +sisAllocFB( sisContextPtr smesa, GLuint size, void **handle ) { - 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); */ + } + *handle = (void *)fb.free; 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) +void +sisFreeFB( sisContextPtr smesa, void *handle ) { 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", + handle, (GLint)getpid(), --_total_video_memory_count); } - fb.context = hHWContext; - fb.free = (unsigned long)free; - ioctl(gDRMSubFD, SIS_IOCTL_FB_FREE, &fb); -} - -#else - -static void * -sis_alloc_fb (__GLSiScontext * hwcx, 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; + fb.context = smesa->hHWContext; + fb.free = handle; + drmCommandWrite( smesa->driFd, DRM_SIS_FB_FREE, &fb, sizeof(drm_sis_mem_t) ); } -#endif - -#endif - -static void * -sis_alloc_agp (__GLSiScontext * hwcx, GLuint size, void **free) +void * +sisAllocAGP( sisContextPtr smesa, GLuint size, void **handle ) { - 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; + } + *handle = (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) +void +sisFreeAGP( sisContextPtr smesa, void *handle ) { 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", + handle, (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 = handle; + drmCommandWrite( smesa->driFd, DRM_SIS_AGP_FREE, &agp, sizeof(drm_sis_mem_t) ); } -/* debug */ -static unsigned int Total_Real_Textures_Used = 0; -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 +169,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)); - - 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; + memset (&smesa->zClearPacket, 0, sizeof (ENGPACKET)); - if (hwcx->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.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 (smesa->blockWrite) + { + 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,201 +237,35 @@ 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)); - - 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; - - 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); - } -} - -void -sis_free_back_image (XMesaBuffer buf, XMesaImage *image, void *free) -{ - XMesaContext xmesa = buf->xm_context; - - sis_free_fb (xmesa->driContextPriv->hHWContext, free); - image->data = NULL; -} - -void -sis_alloc_texture_image (GLcontext * ctx, GLtextureImage * image) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - GLuint size; - - SIStextureArea *area = image->DriverData; - char *addr; - - GLuint texel_size; - GLenum driver_format; + smesa->backbuffer = (char *)addr; + smesa->backOffset = (GLint)((long)addr - (long)smesa->FbBase); + smesa->backPitch = width2 * depth; - if (area) - sis_free_texture_image (image); + memset (&smesa->cbClearPacket, 0, sizeof (ENGPACKET)); - area = calloc (1, sizeof (SIStextureArea)); - if (!area){ - fprintf (stderr, "SIS Driver : allocating context fails\n"); - sis_fatal_error (); - return; - } - - switch (image->IntFormat) - { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - texel_size = 1; - driver_format = GL_ALPHA8; - break; - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - texel_size = 1; - driver_format = GL_LUMINANCE8; - break; - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - texel_size = 2; - driver_format = GL_LUMINANCE8_ALPHA8; - break; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - texel_size = 1; - driver_format = GL_INTENSITY8; - break; - case 3: - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - texel_size = 4; - driver_format = GL_RGB8; - break; - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - texel_size = 4; - driver_format = GL_RGBA8; - break; - default: - assert(0); - return; - } + smesa->cbClearPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xf0000000; + smesa->cbClearPacket.dwDestBaseAddr = smesa->backOffset; + smesa->cbClearPacket.wDestPitch = smesa->backPitch; + smesa->cbClearPacket.stdwDestPos.wY = 0; + smesa->cbClearPacket.stdwDestPos.wX = 0; - size = image->Width * image->Height * texel_size + TEXTURE_HW_PLUS; + smesa->cbClearPacket.wDestHeight = smesa->virtualY; + smesa->cbClearPacket.stdwDim.wWidth = (GLshort) width2; + smesa->cbClearPacket.stdwDim.wHeight = (GLshort) smesa->height; + smesa->cbClearPacket.stdwCmd.cRop = 0xf0; - do{ - addr = sis_alloc_fb (hwcx, 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); - area->memType = AGP_TYPE; - if(addr) break; - - /* TODO: swap to system memory */ - } - while(0); - - if (!addr){ - fprintf (stderr, "SIS driver : out of video/agp memory\n"); - sis_fatal_error (); - return; + if (smesa->blockWrite) { + smesa->cbClearPacket.stdwCmd.cCmd0 = (GLbyte) (CMD0_PAT_FG_COLOR); + } else { + smesa->cbClearPacket.stdwCmd.cCmd0 = 0; } - - area->Data = - (GLbyte *) ALIGNMENT ((unsigned long) addr, TEXTURE_HW_ALIGNMENT); - area->Pitch = image->Width * texel_size; - 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; - Total_Real_Textures_Used += area->realSize; - Total_Textures_Used++; - - image->DriverData = area; + smesa->cbClearPacket.stdwCmd.cCmd1 = + (GLbyte)(CMD1_DIR_X_INC | CMD1_DIR_Y_INC); } void -sis_free_texture_image (GLtextureImage * image) +sisFreeBackbuffer( sisContextPtr smesa ) { - SIStextureArea *area = (SIStextureArea *) image->DriverData; - - /* debug */ - Total_Real_Textures_Used -= area->realSize; - Total_Textures_Used--; - - if (!area) - return; - - if (area->Data) - switch(area->memType){ - case VIDEO_TYPE: - sis_free_fb (area->hHWContext, area->free); - break; - case AGP_TYPE: - sis_free_agp (area->hHWContext, area->free); - break; - default: - assert(0); - } - - free (area); - image->DriverData = NULL; + sisFreeFB( smesa, smesa->bbFree ); + smesa->backbuffer = NULL; } 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 Mon Aug 25 00:15:50 2003 @@ -0,0 +1,47 @@ +/************************************************************************** + +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 + * + */ + +enum { + VIDEO_TYPE, + AGP_TYPE +}; + +void sisAllocZStencilBuffer( sisContextPtr smesa ); +void sisFreeZStencilBuffer( sisContextPtr smesa ); +void sisAllocBackbuffer( sisContextPtr smesa ); +void sisFreeBackbuffer ( sisContextPtr smesa ); +void *sisAllocFB( sisContextPtr smesa, GLuint size, void **handle ); +void sisFreeFB( sisContextPtr smesa, void *handle ); +void *sisAllocAGP( sisContextPtr smesa, GLuint size, void **handle ); +void sisFreeAGP( sisContextPtr smesa, void *handle ); 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_clear.c Mon Aug 25 00:15:50 2003 @@ -32,117 +32,178 @@ * */ -#include "sis_ctx.h" -#include "sis_mesa.h" +#include "sis_context.h" +#include "sis_state.h" #include "sis_lock.h" -__inline__ static GLbitfield sis_3D_Clear (GLcontext * ctx, GLbitfield mask, - GLint x, GLint y, GLint width, - GLint height); -__inline__ static void sis_clear_color_buffer (GLcontext * ctx, GLint x, - GLint y, GLint width, - GLint height); -__inline__ static void sis_clear_z_stencil_buffer (GLcontext * ctx, - GLbitfield mask, GLint x, - GLint y, GLint width, - GLint height); - -GLbitfield -sis_Clear (GLcontext * ctx, GLbitfield mask, GLboolean all, - GLint x, GLint y, GLint width, GLint height) +#include "swrast/swrast.h" +#include "mmath.h" + +static GLbitfield sis_3D_Clear( GLcontext * ctx, GLbitfield mask, + GLint x, GLint y, GLint width, + GLint height ); +static void sis_clear_color_buffer( GLcontext *ctx, GLenum mask, GLint x, + GLint y, GLint width, GLint height ); +static void sis_clear_z_stencil_buffer( GLcontext * ctx, + GLbitfield mask, GLint x, + GLint y, GLint width, + GLint height ); + +static void +set_color_pattern( sisContextPtr smesa, GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ) +{ + /* XXX only RGB565 and ARGB8888 */ + switch (GET_ColorFormat (smesa)) + { + case DST_FORMAT_ARGB_8888: + smesa->clearColorPattern = (alpha << 24) + + (red << 16) + (green << 8) + (blue); + break; + case DST_FORMAT_RGB_565: + smesa->clearColorPattern = ((red >> 3) << 11) + + ((green >> 2) << 5) + (blue >> 3); + smesa->clearColorPattern |= smesa->clearColorPattern << 16; + break; + default: + assert(0); + } +} + +void +sisUpdateZStencilPattern( sisContextPtr smesa, GLclampd z, int stencil ) +{ + GLuint zPattern, stencilPattern; + GLboolean dword_pattern; + + if (z <= (float) 0.0) + zPattern = 0x0; + else if (z >= (float) 1.0) + zPattern = 0xFFFFFFFF; + else + zPattern = doFPtoFixedNoRound( z, 32 ); + + stencilPattern = 0; + + switch (smesa->zFormat) + { + case Z_16: + zPattern = zPattern >> 16; + zPattern &= 0x0000FFFF; + dword_pattern = GL_FALSE; + break; + case S_8_Z_24: + zPattern = zPattern >> 8; + zPattern &= 0x00FFFFFF; + stencilPattern = (stencilPattern << 24); + dword_pattern = GL_TRUE; + break; + case Z_32: + dword_pattern = GL_TRUE; + break; + default: + assert(0); + } + smesa->clearZStencilPattern = zPattern | stencilPattern; + /* ?? */ + if (!dword_pattern) + smesa->clearZStencilPattern |= (zPattern | stencilPattern) << 16; +} + +void +sisDDClear( 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) - { + if (all) { GLframebuffer *buffer = ctx->DrawBuffer; x1 = 0; y1 = 0; width1 = buffer->Width; height1 = buffer->Height; - } - else - { + } else { x1 = x; y1 = Y_FLIP(y+height-1); width1 = width; height1 = height; - } - - LOCK_HARDWARE (); + } - /* - * TODO: no considering multiple-buffer and clear buffer - * differs from current draw buffer - */ + LOCK_HARDWARE (); - if ((ctx->Visual->StencilBits && - ((mask | GL_DEPTH_BUFFER_BIT) ^ (mask | GL_STENCIL_BUFFER_BIT))) - || (*(DWORD *) (ctx->Color.ColorMask) != 0xffffffff) - ) - { + if (( ctx->Visual.stencilBits && + ((mask | GL_DEPTH_BUFFER_BIT) ^ (mask | GL_STENCIL_BUFFER_BIT)) ) || + (*(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) - { - sis_clear_color_buffer (ctx, x1, y1, width1, height1); - mask &= ~ctx->Color.DrawDestMask; - } - if (mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) - { - if (xm_buffer->depthbuffer) - sis_clear_z_stencil_buffer (ctx, mask, x1, y1, width1, height1); - mask &= ~(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - } - if (mask & GL_ACCUM_BUFFER_BIT) - { - } + if ( mask & DD_FRONT_LEFT_BIT || mask & DD_BACK_LEFT_BIT) { + sis_clear_color_buffer (ctx, mask, x1, y1, width1, height1); + mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT); + } + + if (mask & (DD_DEPTH_BIT | DD_STENCIL_BIT)) { + if (smesa->depthbuffer != NULL) + sis_clear_z_stencil_buffer (ctx, mask, x1, y1, width1, height1); + mask &= ~(DD_DEPTH_BIT | DD_STENCIL_BIT); + } + + UNLOCK_HARDWARE (); + + if ( mask ) + _swrast_Clear( ctx, mask, all, x1, y1, width, height ); +} + + +void +sisDDClearColor( GLcontext * ctx, const GLfloat color[4] ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + GLubyte c[4]; - UNLOCK_HARDWARE (); + CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); + CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); + CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); + CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - return mask; + set_color_pattern (smesa, c[0], c[1], c[2], c[3]); } 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); + sisUpdateZStencilPattern( 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); + sisUpdateZStencilPattern( 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 +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 +212,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; + XF86DRIClipRectPtr 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 ); } dwEnable2 = 0; @@ -186,18 +247,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 +270,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 @@ -254,9 +315,10 @@ MMIO (REG_3D_StencilSet2, dwSten2); } - if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT) + if (mask & DD_FRONT_LEFT_BIT) /* XXX */ { - sis_get_clip_rects (xmesa, &pExtents, &count); + pExtents = smesa->driDrawable->pClipRects; + count = smesa->driDrawable->numClipRects; } else { @@ -273,15 +335,12 @@ if (pExtents) { - GLuint origin_x, origin_y; GLuint x1, y1, x2, y2; - sis_get_drawable_origin (xmesa, &origin_x, &origin_y); - - x1 = pExtents->x1 - origin_x; - y1 = pExtents->y1 - origin_y; - x2 = pExtents->x2 - origin_x - 1; - y2 = pExtents->y2 - origin_y - 1; + x1 = pExtents->x1 - smesa->driDrawable->x; + y1 = pExtents->y1 - smesa->driDrawable->y; + x2 = pExtents->x2 - smesa->driDrawable->x - 1; + y2 = pExtents->y2 - smesa->driDrawable->y - 1; left = (left > x1) ? left : x1; right = (right > x2) ? x2 : right; @@ -292,27 +351,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 +379,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 @@ -339,14 +398,14 @@ return (mask & ~(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)); } -__inline__ static void -sis_bitblt_clear_cmd (__GLSiScontext * hwcx, ENGPACKET * pkt) +static void +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,68 +417,70 @@ *lpdwDest++ = *lpdwSrc++; } - MMIO (REG_CMD0, *(DWORD *) & pkt->stdwCmd); + MMIO (REG_CMD0, *(GLint *) & pkt->stdwCmd); MMIO (0x8240, -1); } -__inline__ static void -sis_clear_color_buffer (GLcontext * ctx, - GLint x, GLint y, GLint width, GLint height) +static void +sis_clear_color_buffer( GLcontext *ctx, GLenum 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 *) xm_buffer->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); int count; - GLuint origin_x, origin_y; - GLuint depth = GET_DEPTH (hwcx); - BoxPtr pExtents = NULL; + GLuint depth = GET_DEPTH (smesa); + XF86DRIClipRectPtr 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; + /* Clear back buffer */ + if (mask & DD_BACK_LEFT_BIT) { + 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); - return; - case GL_FRONT_LEFT: - x0 = x; - y0 = y; - 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; - case GL_BACK_RIGHT: - case GL_FRONT_RIGHT: - default: - assert (0); + sis_bitblt_clear_cmd( smesa, &smesa->cbClearPacket ); + } + + if ((mask & DD_FRONT_LEFT_BIT) == 0) return; - } - - memset (&stEngPacket, 0, sizeof (ENGPACKET)); - while (count--) - { - GLint x2 = pExtents->x1 - origin_x; - GLint y2 = pExtents->y1 - origin_y; - GLint xx2 = pExtents->x2 - origin_x; - GLint yy2 = pExtents->y2 - origin_y; + /* Clear front buffer */ + x0 = x; + y0 = y; + width0 = width; + height0 = height; + + pExtents = smesa->driDrawable->pClipRects; + count = smesa->driDrawable->numClipRects; + + memset (&stEngPacket, 0, sizeof (ENGPACKET)); + + stEngPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xc0000000; + stEngPacket.dwDestBaseAddr = smesa->frontOffset; + stEngPacket.wDestPitch = smesa->frontPitch; + /* TODO: set maximum value? */ + stEngPacket.wDestHeight = smesa->virtualY; + stEngPacket.stdwCmd.cRop = 0xf0; + stEngPacket.dwFgRopColor = smesa->clearColorPattern; + + /* for SGRAM Block Write Enable */ + if (smesa->blockWrite) + stEngPacket.stdwCmd.cCmd0 = (GLbyte) (CMD0_PAT_FG_COLOR); + else + stEngPacket.stdwCmd.cCmd0 = 0; + stEngPacket.stdwCmd.cCmd1 = (GLbyte) (CMD1_DIR_X_INC | CMD1_DIR_Y_INC); + + while (count--) { + GLint x2 = pExtents->x1 - smesa->driDrawable->x; + GLint y2 = pExtents->y1 - smesa->driDrawable->y; + GLint xx2 = pExtents->x2 - smesa->driDrawable->x; + GLint yy2 = pExtents->y2 - smesa->driDrawable->y; x = (x0 > x2) ? x0 : x2; y = (y0 > y2) ? y0 : y2; @@ -432,178 +493,33 @@ if (width <= 0 || height <= 0) continue; - 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; - /* TODO: set maximum value? */ - stEngPacket.wDestHeight = hwcx->virtualY; - stEngPacket.stdwDim.wWidth = (WORD) width; - stEngPacket.stdwDim.wHeight = (WORD) height; - stEngPacket.stdwCmd.cRop = 0xf0; - stEngPacket.dwFgRopColor = hwcx->clearColorPattern; + stEngPacket.stdwDestPos.wY = y + smesa->driDrawable->y; + stEngPacket.stdwDestPos.wX = x + smesa->driDrawable->x; + stEngPacket.stdwDim.wWidth = (GLshort)width; + stEngPacket.stdwDim.wHeight = (GLshort)height; - /* for SGRAM Block Write Enable */ - 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_clear_cmd (hwcx, &stEngPacket); - } + sis_bitblt_clear_cmd( smesa, &stEngPacket ); + } } -__inline__ static void +static void 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; + 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; - 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)); - - 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 Tue Aug 12 12:03:56 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 Mon Aug 25 00:15:50 2003 @@ -0,0 +1,153 @@ +/************************************************************************** + +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_ + +#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" + +/* HW capability */ +#define SIS_MAX_TEXTURE_SIZE 2048 +#define SIS_MAX_TEXTURES 2 + +#define SIS_MAX_FRAME_LENGTH 3 + +GLint doFPtoFixedNoRound( GLfloat 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 Mon Aug 25 00:15:50 2003 @@ -0,0 +1,907 @@ +/************************************************************************** + +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_dd.h" +#include "sis_span.h" +#include "sis_stencil.h" +#include "sis_tex.h" +#include "sis_tris.h" +#include "sis_vb.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); + + /* add Texture Perspective Enable */ + prev->hwCapEnable = MASK_FogPerspectiveEnable | MASK_TextureCacheEnable | + MASK_TexturePerspectiveEnable; + + /* + prev->hwCapEnable2 = 0x00aa0080; + */ + /* if multi-texture enabled, disable Z pre-test */ + prev->hwCapEnable2 = 0; + + /* Z test mode is LE */ + prev->hwZ = SiS_Z_COMP_S_LE_B; + + /* TODO : maybe call sis_DepthFunc to update is a better way */ + ctx->Driver.DepthFunc (ctx, ctx->Depth.Func); + + /* Depth mask */ + prev->hwZMask = 0xffffffff; + + /* Alpha test mode is ALWAYS, Alpha ref value is 0 */ + prev->hwAlpha = SiS_ALPHA_ALWAYS; + + /* ROP2 is COPYPEN */ + prev->hwDstSet = LOP_COPY; + + /* color mask */ + prev->hwDstMask = 0xffffffff; + + /* LinePattern is 0, Repeat Factor is 0 */ + prev->hwLinePattern = 0x00008000; + + /* Fog mode is Linear Fog, Fog color is (0, 0, 0) */ + prev->hwFog = FOGMODE_CHEAP; + + /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */ + prev->hwDstSrcBlend = 0x00000001; /* XXX */ + + /* Texture mapping mode is Tile */ +#if 0 + prev->texture[0].hwTextqureSet = 0x00030000; +#endif + /* Magnified & minified texture filter is NEAREST */ +#if 0 + prev->texture[0].hwTextureMip = 0; +#endif + + /* Texture Blending seeting */ + prev->hwTexBlendClr0 = L_REPLACE__RGB_STAGE0; + prev->hwTexBlendClr1 = 0x294B4000; + prev->hwTexBlendAlpha0 = 0x333A0000; + prev->hwTexBlendAlpha1 = 0x333A0000; + + 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 + + smesa->clearColorPattern = 0; +} + +static void +sis_set_buffer_static (GLcontext * ctx) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + switch (smesa->bytesPerPixel) + { + case 2: + current->hwDstSet |= DST_FORMAT_RGB_565; + break; + case 4: + current->hwDstSet |= DST_FORMAT_ARGB_8888; + break; + } + + switch (ctx->Visual.depthBits) + { + case 0: + current->hwCapEnable &= ~MASK_ZWriteEnable; + case 16: + smesa->zFormat = Z_16; + current->hwCapEnable |= MASK_ZWriteEnable; + smesa->depth_scale = 1.0 / (GLfloat)0xffff; + break; + case 32: + smesa->zFormat = Z_32; + current->hwCapEnable |= MASK_ZWriteEnable; + smesa->depth_scale = 1.0 / (GLfloat)0xffffffff; + break; + case 24: + assert (ctx->Visual.stencilBits); + smesa->zFormat = S_8_Z_24; + current->hwCapEnable |= MASK_StencilBufferEnable; + current->hwCapEnable |= MASK_ZWriteEnable; + smesa->depth_scale = 1.0 / (GLfloat)0xffffff; + break; + } + + current->hwZ &= ~MASK_ZBufferFormat; + current->hwZ |= smesa->zFormat; + + /* Destination Color Format */ + if (current->hwDstSet ^ prev->hwDstSet) { + prev->hwDstSet = current->hwDstSet; + smesa->GlobalFlag |= GFLAG_DESTSETTING; + } + + /* Z Buffer Data Format */ + if (current->hwZ ^ prev->hwZ) { + prev->hwZ = current->hwZ; + smesa->GlobalFlag |= GFLAG_ZSETTING; + } +} + +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->cpp; + 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); + +#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); + } + + /* 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->Fallback = 0; + + /* 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? */ + + sisInitVB( ctx ); + sisInitTriFuncs( ctx ); + sisDDInitDriverFuncs( ctx ); + sisDDInitStateFuncs( ctx ); + sisDDInitSpanFuncs( ctx ); + sisDDInitStencilFuncs( ctx ); + sisDDInitTextureFuncs( 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); + sisUpdateZStencilPattern( 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 ); +} + +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 ); + + 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; +} + +GLboolean +sisUnbindContext( __DRIcontextPrivate *driContextPriv ) +{ + return GL_TRUE; +} + +void +sis_update_render_state( sisContextPtr smesa ) +{ + __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; +} + +/* Updates all state. + * Called when the lock is taken and another context had the lock previously. + */ +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 Mon Aug 25 00:15:50 2003 @@ -0,0 +1,405 @@ +/************************************************************************** + +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 NEW_TEXTURING 0x1 +#define NEW_TEXTURE_ENV 0x2 + +#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) + +/* Flags for software fallback cases: + */ +#define SIS_FALLBACK_TEXTURE 0x0001 +#define SIS_FALLBACK_CULL 0x0002 +#define SIS_FALLBACK_FORCE 0x8000 + +/* Use the templated vertex format: + */ +#define TAG(x) sis##x +#include "tnl_dd/t_dd_vertex.h" +#undef TAG + +/* Subpixel offsets for window coordinates (triangles): + */ +#define SUBPIXEL_X (0.0F) /* XXX FIXME */ +#define SUBPIXEL_Y (0.0F) /* XXX FIXME */ + +#define SIS_MAX_TEXTURE_LEVELS 11 + +typedef struct { + GLbyte *Data; /* Pointer to texture in offscreen */ + GLuint memType; /* VIDEO_TYPE or AGP_TYPE */ + void *handle; /* Handle for sisFree*() */ + GLuint pitch; + GLuint size; + GLenum format; /* One of GL_ALPHA, GL_INTENSITY, GL_LUMINANCE, + * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA */ + GLint textureFormat; /* TODO: Actual hardware format */ + GLuint offset; /* TODO: Offset for hardware */ +} sisTexImage; + +typedef struct sis_tex_obj { + sisTexImage image[SIS_MAX_TEXTURE_LEVELS]; /* Image data for each mipmap + * level */ +} sisTexObj, *sisTexObjPtr; + +/* + ** 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; + +typedef struct sis_context sisContextRec; +typedef struct sis_context *sisContextPtr; + +typedef void (*sis_tri_func)( sisContextPtr, + sisVertex *, + sisVertex *, + sisVertex * ); + +typedef void (*sis_line_func)( sisContextPtr, + sisVertex *, + sisVertex * ); + +typedef void (*sis_point_func)( sisContextPtr, + sisVertex * ); + +/* Device dependent context state */ + +struct sis_context +{ + /* This must be first in this structure */ + GLcontext *glCtx; + + /* Temporaries for translating away float colors: + */ + struct gl_client_array UbyteColor; + struct gl_client_array UbyteSecondaryColor; + + GLuint NewGLState; + GLuint Fallback; + GLuint SetupIndex; + GLuint SetupNewInputs; + GLuint RenderIndex; + GLfloat hw_viewport[16]; + GLfloat depth_scale; + GLuint vertex_size; + GLuint vertex_stride_shift; + GLuint vertex_format; + GLuint num_verts; + char *verts; + + unsigned int virtualX, virtualY; + unsigned int bytesPerPixel; + unsigned char *IOBase; + unsigned char *FbBase; + unsigned int displayWidth; + unsigned int frontOffset; + unsigned int frontPitch; + + /* For Software Renderer */ + GLubyte *swZBase; + GLuint swZPitch; + 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; + + /* Fallback rasterization functions + */ + sis_point_func draw_point; + sis_line_func draw_line; + sis_tri_func draw_tri; + + GLuint hw_primitive; + GLenum raster_primitive; + GLenum render_primitive; + + /* 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; + + GLint GlobalFlag; + + GLint rawLockMask; + GLint lockMask; + + /* 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 backOffset; + unsigned int backPitch; + GLvoid *depthbuffer; + void *zbFree, *bbFree; /* Cookies for freeing buffers */ + ENGPACKET zClearPacket, cbClearPacket; + + /* Drawable, cliprect and scissor information + */ + GLint drawOffset, drawPitch; + GLint readOffset, readPitch; + + /* 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) + +#define SISPACKCOLOR565( r, g, b ) \ + ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3)) + +#define SISPACKCOLOR8888( r, g, b, a ) \ + (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) + +#define SIS_VERBOSE 0 + +enum _sis_verbose { + VERBOSE_SIS_BUFFER = 0x1, + VERBOSE_SIS_MEMORY = 0x2 +}; + +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 hw */ +extern void sis_update_texture_state( sisContextPtr smesa ); +extern void sis_update_render_state( sisContextPtr smesa ); +extern void sis_validate_all_state( sisContextPtr smesa ); + +/* AGP */ +void sisStartAGP(GLcontext *ctx); +void sisFlushAGP(GLcontext *ctx); + +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 Tue Aug 12 12:03:56 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 Tue Aug 12 12:03:56 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 Wed Aug 20 20:59:24 2003 @@ -0,0 +1,176 @@ +/************************************************************************** + +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 "sis_state.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; + + /* XXX Should get the base offset of the frontbuffer from the X Server */ + smesa->frontOffset = smesa->driDrawable->x * smesa->bytesPerPixel + + smesa->driDrawable->y * smesa->frontPitch; + +#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; + } + + sisUpdateClipping( 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 Tue Aug 12 12:03:20 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_debug.c Mon Aug 25 00:15:50 2003 @@ -40,8 +40,7 @@ #include #include -#include "sis_ctx.h" -#include "sis_mesa.h" +#include "sis_context.h" /* for SiS 300/630/540 */ #define MMIOLength (0x8FFF-0x8800+1) @@ -53,7 +52,7 @@ char *prevLockFile = NULL; int prevLockLine = 0; -DWORD _empty[0x10000]; +GLint _empty[0x10000]; void dump_agp (void *addr, int dword_count) @@ -81,14 +80,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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c Wed Dec 31 16:00:00 1969 @@ -1,227 +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_fastpath.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */ - -/* - * Authors: - * Sung-Ching Lin - * - */ - -/* - * FOR - * 1. triangle/strip with 2-texture with no other capability - * (depth-offset, edge-flag...) - * 2. smooth shading - * 3. render to backbuffer - * 4. use AGP command mode - */ - -#ifdef PC_HEADER -#include "all.h" -#else -#include "glheader.h" -#include "clip.h" -#include "context.h" -#include "light.h" -#include "lines.h" -#include "macros.h" -#include "matrix.h" -#include "pb.h" -#include "points.h" -#include "pipeline.h" -#include "stages.h" -#include "types.h" -#include "vb.h" -#include "vbcull.h" -#include "vbrender.h" -#include "vbindirect.h" -#include "xform.h" -#endif - -#include "sis_ctx.h" -#include "sis_mesa.h" - -#define WRITE_SMOOTH_W_T2(v) \ -do{ \ - DWORD 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; \ - 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]; \ - AGP_CurrentPtr[8] = VB->TexCoordPtr[1]->data[v][1]; \ - AGP_CurrentPtr+=9; \ -}while(0) - - /* TODO or use for loop and let compiler unroll it */ -#define COPY_SMOOTH_W_T2(i) \ -do{ \ - AGP_CurrentPtr[0] = (AGP_CurrentPtr+(i)*9)[0]; \ - AGP_CurrentPtr[1] = (AGP_CurrentPtr+(i)*9)[1]; \ - AGP_CurrentPtr[2] = (AGP_CurrentPtr+(i)*9)[2]; \ - AGP_CurrentPtr[3] = (AGP_CurrentPtr+(i)*9)[3]; \ - AGP_CurrentPtr[4] = (AGP_CurrentPtr+(i)*9)[4]; \ - AGP_CurrentPtr[5] = (AGP_CurrentPtr+(i)*9)[5]; \ - AGP_CurrentPtr[6] = (AGP_CurrentPtr+(i)*9)[6]; \ - AGP_CurrentPtr[7] = (AGP_CurrentPtr+(i)*9)[7]; \ - AGP_CurrentPtr[8] = (AGP_CurrentPtr+(i)*9)[8]; \ - AGP_CurrentPtr+=9; \ -}while(0) - -#if defined(SIS_USE_FASTPATH) -static void sis_render_vb( struct vertex_buffer *VB ) -{ - GLcontext *ctx = VB->ctx; - GLuint i, next, prim; - GLuint parity = VB->Parity; - render_func *tab; - GLuint count = VB->Count; - - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - if(!hwcx->useFastPath){ - gl_render_vb(VB); - return; - } - - if (VB->Indirect) { - return; -#ifndef SIS_USE_HW_CULL - } else if (VB->CullMode & CULL_MASK_ACTIVE) { - tab = ctx->Driver.RenderVBCulledTab; - - /* TODO: check */ - if (!VB->CullDone) - gl_fast_copy_vb( VB ); -#endif - } else if (VB->CullMode & CLIP_MASK_ACTIVE) { - tab = ctx->Driver.RenderVBClippedTab; - } else { - tab = ctx->Driver.RenderVBRawTab; - } - - /* TODO: know what does it do */ - gl_import_client_data( VB, ctx->RenderFlags, - (VB->ClipOrMask - ? VEC_WRITABLE|VEC_GOOD_STRIDE - : VEC_GOOD_STRIDE)); - - ctx->Driver.RenderStart( ctx ); - - if(tab != ctx->Driver.RenderVBRawTab){ - for ( i= VB->CopyStart ; i < count ; parity = 0, i = next ) - { - prim = VB->Primitive[i]; - next = VB->NextPrimitive[i]; - - tab[prim]( VB, i, next, parity ); - } - } - else{ - for ( i= VB->CopyStart ; i < count ; parity = 0, i = next ) - { - prim = VB->Primitive[i]; - next = VB->NextPrimitive[i]; - - if(prim == GL_TRIANGLE_STRIP) - { - int j; - - /* assume size >= 3 */ - /* assert(next-i+1 >= 3); */ - - if(i+2 >=next) - break; - - if(parity){ - WRITE_SMOOTH_W_T2(i+1); - WRITE_SMOOTH_W_T2(i); - WRITE_SMOOTH_W_T2(i+2); - } - else{ - WRITE_SMOOTH_W_T2(i); - WRITE_SMOOTH_W_T2(i+1); - WRITE_SMOOTH_W_T2(i+2); - } - - for(j=i+3; jDriver.RenderFinish( ctx ); -} -#endif - -GLuint sis_RegisterPipelineStages (struct gl_pipeline_stage *out, - const struct gl_pipeline_stage *in, - GLuint nr) -{ - GLuint i, o; - - for (i = o = 0 ; i < nr ; i++) { - switch (in[i].ops) { - case PIPE_OP_RENDER: - out[o] = in[i]; -#if defined(SIS_USE_FASTPATH) - if (in[i].run == gl_render_vb) { - out[o].run = sis_render_vb; - } -#endif - o++; - break; - default: - out[o++] = in[i]; - break; - } - } - - return o; -} 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_fog.c Mon Aug 25 00:15:50 2003 @@ -32,86 +32,83 @@ * */ -#include "sis_ctx.h" -#include "sis_mesa.h" +#include "sis_context.h" +#include "sis_state.h" -static DWORD convertFtToFogFt (DWORD dwInValue); +#include "mmath.h" + +static GLint convertFtToFogFt( GLfloat dwInValue ); void -sis_Fogfv (GLcontext * ctx, GLenum pname, const GLfloat * params) +sisDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *current = &hwcx->current; - - GLubyte dwFogColor[4]; - DWORD dwArg; - float fArg; + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *current = &smesa->current; - switch (pname) - { - case GL_FOG_MODE: + float fArg; + GLint fogColor; + + switch (pname) + { + case GL_FOG_MODE: current->hwFog &= ~(FOGMODE_LINEAR | FOGMODE_EXP | FOGMODE_EXP2); switch (ctx->Fog.Mode) - { - case GL_LINEAR: - current->hwFog |= FOGMODE_LINEAR; - break; - case GL_EXP: - current->hwFog |= FOGMODE_EXP; - break; - case GL_EXP2: - current->hwFog |= FOGMODE_EXP2; - break; - } + { + case GL_LINEAR: + current->hwFog |= FOGMODE_LINEAR; + break; + case GL_EXP: + current->hwFog |= FOGMODE_EXP; + break; + case GL_EXP2: + current->hwFog |= FOGMODE_EXP2; + break; + } break; - case GL_FOG_DENSITY: - dwArg = *(DWORD *) (&(ctx->Fog.Density)); - current->hwFogDensity = 0; - current->hwFogDensity |= convertFtToFogFt (dwArg); + case GL_FOG_DENSITY: + current->hwFogDensity = convertFtToFogFt( ctx->Fog.Density ); break; - case GL_FOG_START: - case GL_FOG_END: + 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( fArg, 10 ); if (pname == GL_FOG_END) - { - dwArg = *(DWORD *) (&(ctx->Fog.End)); - if (hwcx->Chipset == PCI_CHIP_SIS300) - { - current->hwFogFar = doFPtoFixedNoRound (dwArg, 10); - } - else - { - current->hwFogFar = doFPtoFixedNoRound (dwArg, 6); - } - } + { + if (smesa->Chipset == PCI_CHIP_SIS300) + current->hwFogFar = doFPtoFixedNoRound( ctx->Fog.End, 10 ); + else + current->hwFogFar = doFPtoFixedNoRound( ctx->Fog.End, 6 ); + } break; - case GL_FOG_INDEX: + case GL_FOG_INDEX: /* TODO */ break; - case GL_FOG_COLOR: - *((DWORD *) 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); + case GL_FOG_COLOR: + fogColor = FLOAT_TO_UBYTE( ctx->Fog.Color[0] ) << 16; + fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[1] ) << 8; + fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[2] ); current->hwFog &= 0xff000000; - current->hwFog |= *((DWORD *) dwFogColor); + current->hwFog |= fogColor; break; - } + } } -DWORD -doFPtoFixedNoRound (DWORD dwInValue, int nFraction) +GLint +doFPtoFixedNoRound( GLfloat dwInValue, int nFraction ) { - DWORD dwMantissa; + GLint dwMantissa; int nTemp; + union { int i; float f; } u; + GLint val; + + u.f = dwInValue; + val = u.i; - if (dwInValue == 0) + if (val == 0) return 0; - nTemp = (int) (dwInValue & 0x7F800000) >> 23; + nTemp = (int) (val & 0x7F800000) >> 23; nTemp = nTemp - 127 + nFraction - 23; - dwMantissa = (dwInValue & 0x007FFFFF) | 0x00800000; + dwMantissa = (val & 0x007FFFFF) | 0x00800000; if (nTemp < -25) return 0; @@ -124,21 +121,26 @@ nTemp = -nTemp; dwMantissa >>= nTemp; } - if (dwInValue & 0x80000000) + if (val & 0x80000000) { dwMantissa = ~dwMantissa + 1; } - return (dwMantissa); + return dwMantissa; } /* s[8].23->s[7].10 */ -static DWORD -convertFtToFogFt (DWORD dwInValue) +static GLint +convertFtToFogFt( GLfloat dwInValue ) { - DWORD dwMantissa, dwExp; - DWORD dwRet; + GLint dwMantissa, dwExp; + GLint dwRet; + union { int i; float f; } u; + GLint val; + + u.f = dwInValue; + val = u.i; - if (dwInValue == 0) + if (val == 0) return 0; /* ----- Standard float Format: s[8].23 ----- @@ -150,15 +152,15 @@ * ----- ----- */ - dwExp = (dwInValue & 0x7F800000) >> 23; + dwExp = (val & 0x7F800000) >> 23; dwExp -= 63; - if ((LONG) dwExp < 0) + if (dwExp < 0) return 0; if (dwExp <= 0x7F) { - dwMantissa = (dwInValue & 0x007FFFFF) >> (23 - 10); + dwMantissa = (val & 0x007FFFFF) >> (23 - 10); } else { @@ -167,9 +169,9 @@ dwMantissa = 0x3FF; } - dwRet = (dwInValue & 0x80000000) >> (31 - 17); /* Shift Sign Bit */ + dwRet = (val & 0x80000000) >> (31 - 17); /* Shift Sign Bit */ dwRet |= (dwExp << 10) | dwMantissa; - return (dwRet); + return dwRet; } 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_init.h Mon Aug 25 00:15:50 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 | \ @@ -74,141 +68,28 @@ (fixedColor.b & 0x00ff0000) >> 16 ); \ } -#define setTSFS(dwFactor, fFactor) \ -{\ - (dwFactor) = ((fixed)((fFactor) * 0xff)) << 24;\ -} - #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 -#define INIT_6327_CapsEnable2 0x00000000 - -#define INIT_6327_ZSet 0x00030000 -#define INIT_6327_ZMask 0xffffffff -#define INIT_6327_AlphaSet 0x07000000 -#define INIT_6327_DstSet 0x0C000000 -#define INIT_6327_DstMask 0xffffffff -#define INIT_6327_FogSet 0x04000000 -#define INIT_6327_BlendMode 0x00000001 -#define INIT_6327_TextureSet 0x00030000 -#define INIT_6327_TextureMip 0x00000000 -/* #define INIT_6327_Texture0BlendSet 0x33031941 */ -#define INIT_6327_TextureColorBlend0 0xC1485000 -#define INIT_6327_TextureAlphaBlend0 0x333A0000 -#define INIT_6327_Texture1Set 0x00030000 -#define INIT_6327_Texture1Set2 0x00000000 -/* #define INIT_6327_Texture1BlendSet 0x00000000 */ -#define INIT_6327_TextureColorBlend1 0x294B4000 -#define INIT_6327_TextureAlphaBlend1 0x333A0000 -/* #define INIT_6327_TexAddrType 0x00001000 */ -/* #define INIT_6326_InputColorFormat 0xA0000000 */ -#define INIT_6327_ParsingSet 0x00000060 - -#define SiS_Z_COMP_NEVER 0x00000000 -#define SiS_Z_COMP_S_LT_B 0x00010000 -#define SiS_Z_COMP_S_EQ_B 0x00020000 -#define SiS_Z_COMP_S_LE_B 0x00030000 -#define SiS_Z_COMP_S_GT_B 0x00040000 -#define SiS_Z_COMP_S_NE_B 0x00050000 -#define SiS_Z_COMP_S_GE_B 0x00060000 -#define SiS_Z_COMP_ALWAYS 0x00070000 - -#define SiS_ALPHA_NEVER 0x00000000 -#define SiS_ALPHA_LESS 0x01000000 -#define SiS_ALPHA_EQUAL 0x02000000 -#define SiS_ALPHA_LEQUAL 0x03000000 -#define SiS_ALPHA_GREATER 0x04000000 -#define SiS_ALPHA_NOTEQUAL 0x05000000 -#define SiS_ALPHA_GEQUAL 0x06000000 -#define SiS_ALPHA_ALWAYS 0x07000000 - -#define SiS_STENCIL_NEVER 0x00000000 -#define SiS_STENCIL_LESS 0x01000000 -#define SiS_STENCIL_EQUAL 0x02000000 -#define SiS_STENCIL_LEQUAL 0x03000000 -#define SiS_STENCIL_GREATER 0x04000000 -#define SiS_STENCIL_NOTEQUAL 0x05000000 -#define SiS_STENCIL_GEQUAL 0x06000000 -#define SiS_STENCIL_ALWAYS 0x07000000 - -#define SiS_SFAIL_KEEP 0x00000000 -#define SiS_SFAIL_ZERO 0x00100000 -#define SiS_SFAIL_REPLACE 0x00200000 -#define SiS_SFAIL_INVERT 0x00500000 -#define SiS_SFAIL_INCR 0x00600000 -#define SiS_SFAIL_DECR 0x00700000 - -#define SiS_SPASS_ZFAIL_KEEP 0x00000000 -#define SiS_SPASS_ZFAIL_ZERO 0x00010000 -#define SiS_SPASS_ZFAIL_REPLACE 0x00020000 -#define SiS_SPASS_ZFAIL_INVERT 0x00050000 -#define SiS_SPASS_ZFAIL_INCR 0x00060000 -#define SiS_SPASS_ZFAIL_DECR 0x00070000 - -#define SiS_SPASS_ZPASS_KEEP 0x00000000 -#define SiS_SPASS_ZPASS_ZERO 0x00001000 -#define SiS_SPASS_ZPASS_REPLACE 0x00002000 -#define SiS_SPASS_ZPASS_INVERT 0x00005000 -#define SiS_SPASS_ZPASS_INCR 0x00006000 -#define SiS_SPASS_ZPASS_DECR 0x00007000 - -#define SiS_D_ZERO 0x00000000 -#define SiS_D_ONE 0x00000010 -#define SiS_D_SRC_COLOR 0x00000020 -#define SiS_D_ONE_MINUS_SRC_COLOR 0x00000030 -#define SiS_D_SRC_ALPHA 0x00000040 -#define SiS_D_ONE_MINUS_SRC_ALPHA 0x00000050 -#define SiS_D_DST_ALPHA 0x00000060 -#define SiS_D_ONE_MINUS_DST_ALPHA 0x00000070 - -#define SiS_S_ZERO 0x00000000 -#define SiS_S_ONE 0x00000001 -#define SiS_S_SRC_ALPHA 0x00000004 -#define SiS_S_ONE_MINUS_SRC_ALPHA 0x00000005 -#define SiS_S_DST_ALPHA 0x00000006 -#define SiS_S_ONE_MINUS_DST_ALPHA 0x00000007 -#define SiS_S_DST_COLOR 0x00000008 -#define SiS_S_ONE_MINUS_DST_COLOR 0x00000009 -#define SiS_S_SRC_ALPHA_SATURATE 0x0000000a - -/* Logic Op */ -#define LOP_CLEAR 0x00000000 -#define LOP_NOR 0x01000000 -#define LOP_AND_INVERTED 0x02000000 -#define LOP_COPY_INVERTED 0x03000000 -#define LOP_AND_REVERSE 0x04000000 -#define LOP_INVERT 0x05000000 -#define LOP_XOR 0x06000000 -#define LOP_NAND 0x07000000 -#define LOP_AND 0x08000000 -#define LOP_EQUIV 0x09000000 -#define LOP_NOOP 0x0a000000 -#define LOP_OR_INVERTED 0x0b000000 -#define LOP_COPY 0x0c000000 -#define LOP_OR_REVERSE 0x0d000000 -#define LOP_OR 0x0e000000 -#define LOP_SET 0x0f000000 /* 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h Tue Aug 12 12:03:20 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 Mon Aug 25 00:15:50 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_dd.h" +#include "sis_state.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 ); + sisDDDrawBuffer( smesa->glCtx, smesa->glCtx->Color.DrawBuffer ); + 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_lock.h Wed Aug 20 20:59:24 2003 @@ -32,19 +32,10 @@ * */ -#ifndef _sis_dri_h_ -#define _sis_dri_h_ +#ifndef __SIS_LOCK_H +#define __SIS_LOCK_H -/* from tdfx */ -#define SIS_VALIDATE_DRAWABLE_INFO(dpy, psp, pdp) \ -do { \ - while (*(pdp->pStamp) != pdp->lastStamp) { \ - DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \ - DRI_MESA_VALIDATE_DRAWABLE_INFO(dpy, psp->myNum, pdp); \ - DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \ - sis_SetDrawBuffer (ctx, ctx->Color.DriverDrawBuffer); \ - } \ -} while (0) +extern void sisGetLock( sisContextPtr smesa, GLuint flags ); #ifdef DEBUG_LOCKING extern char *prevLockFile; @@ -71,66 +62,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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_mesa.c Wed Dec 31 16:00:00 1969 @@ -1,1578 +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_mesa.c,v 1.7 2002/10/30 12:52:00 alanh Exp $ */ - -/* - * Authors: - * Sung-Ching Lin - * - */ - -#include "sis_ctx.h" -#include "sis_mesa.h" -#include "sis_lock.h" - -#include "state.h" - -void -sis_RenderStart (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - LOCK_HARDWARE (); - - if (hwcx->Primitive & hwcx->swRenderFlag) - { - WaitEngIdle (hwcx); - } - - if (ctx->Texture.ReallyEnabled) - { - sis_validate_texture (ctx); - if (hwcx->swRenderFlag & SIS_SW_TEXTURE) - { - hwcx->swForceRender = GL_TRUE; - gl_update_state(ctx); - hwcx->swForceRender = GL_FALSE; - } - else - { - if (hwcx->GlobalFlag & GFLAG_TEXTURE_STATES) - sis_update_texture_state (hwcx); - } - } - - if (hwcx->GlobalFlag & GFLAG_RENDER_STATES) - { - sis_update_render_state (hwcx, 0); - } - - if (hwcx->UseAGPCmdMode) - { - sis_StartAGP (ctx); - } - -#if defined(SIS_DUMP) - d2f_once (ctx); -#endif -} - -void -sis_RenderFinish (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - if (hwcx->UseAGPCmdMode) - { - sis_FlushAGP (ctx); - } - - UNLOCK_HARDWARE (); -} - -void -sis_ReducedPrimitiveChange (GLcontext * ctx, GLenum primitive) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - /* it is possible several primitive types per VB */ - if (hwcx->UseAGPCmdMode) - { - sis_FlushAGP (ctx); - sis_StartAGP (ctx); - } - else - { - mEndPrimitive(); - - /* - * do nothing now because each hw's primitive-type will be set - * per primitive - */ - - /* TODO: if above rule changes, remember to modify */ - } - - hwcx->AGPParseSet &= ~0xf; - switch (primitive) - { - case GL_POINT: - case GL_POINTS: - hwcx->Primitive = SIS_SW_POINT; - hwcx->AGPParseSet |= 0x0; - break; - case GL_LINE: - case GL_LINES: - hwcx->Primitive = SIS_SW_LINE; - hwcx->AGPParseSet |= 0x4; - break; - case GL_POLYGON: - hwcx->Primitive = SIS_SW_TRIANGLE; - hwcx->AGPParseSet |= 0x8; - break; - } -} - -void -sis_init_driver (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - 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; - ctx->Driver.BlendFunc = sis_BlendFunc; - ctx->Driver.BlendFuncSeparate = sis_BlendFuncSeparate; - ctx->Driver.ClearDepth = sis_ClearDepth; - ctx->Driver.CullFace = sis_CullFace; - ctx->Driver.FrontFace = sis_FrontFace; - ctx->Driver.DepthFunc = sis_DepthFunc; - ctx->Driver.DepthMask = sis_DepthMask; - ctx->Driver.DepthRange = sis_DepthRange; - ctx->Driver.Enable = sis_Enable; - ctx->Driver.Fogfv = sis_Fogfv; - ctx->Driver.Hint = sis_Hint; - ctx->Driver.Lightfv = sis_Lightfv; - ctx->Driver.LightModelfv = sis_LightModelfv; - ctx->Driver.PolygonMode = sis_PolygonMode; - ctx->Driver.Scissor = sis_Scissor; - ctx->Driver.ShadeModel = sis_ShadeModel; - ctx->Driver.ClearStencil = sis_ClearStencil; - ctx->Driver.StencilFunc = sis_StencilFunc; - ctx->Driver.StencilMask = sis_StencilMask; - ctx->Driver.StencilOp = sis_StencilOp; - ctx->Driver.Viewport = sis_Viewport; - - ctx->Driver.Clear = sis_Clear; - - ctx->Driver.TexEnv = sis_TexEnv; - ctx->Driver.TexImage = sis_TexImage; - ctx->Driver.TexSubImage = sis_TexSubImage; - ctx->Driver.TexParameter = sis_TexParameter; - ctx->Driver.BindTexture = sis_BindTexture; - ctx->Driver.DeleteTexture = sis_DeleteTexture; - ctx->Driver.UpdateTexturePalette = sis_UpdateTexturePalette; - ctx->Driver.ActiveTexture = sis_ActiveTexture; - ctx->Driver.IsTextureResident = sis_IsTextureResident; - ctx->Driver.PrioritizeTexture = sis_PrioritizeTexture; - - 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; - ctx->Driver.GetParameteri = sis_GetParameteri; - ctx->Driver.DrawPixels = sis_DrawPixels; - ctx->Driver.Bitmap = sis_Bitmap; - - /* Optimization */ -#ifdef NOT_DONE - ctx->Driver.RasterSetup = sis_ChooseRasterSetupFunc(ctx); - ctx->Driver.RegisterVB = sis_RegisterVB; - ctx->Driver.UnregisterVB = sis_UnregisterVB; - ctx->Driver.ResetVB = sis_ResetVB; - ctx->Driver.ResetCvaVB = sis_ResetCvaVB; -#endif - - /* Fast Path */ - ctx->Driver.RegisterPipelineStages = sis_RegisterPipelineStages; - - /* driver-specific */ - hwcx->SwapBuffers = sis_swap_buffers; - -#ifdef SIS_USE_HW_CULL - /* set capability flag */ - ctx->Driver.TriangleCaps = DD_TRI_CULL; -#endif -} - -void -sis_UpdateState (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - sis_set_render_func (ctx); - - /* ?? duplicate in sis_Enable */ - if (ctx->NewState & NEW_FOG) - { - if (ctx->RasterMask & FOG_BIT) - current->hwCapEnable |= MASK_FogEnable; - else - current->hwCapEnable &= ~MASK_FogEnable; - } - - /* TODO: mesa->NewState. In sis_Enable? */ - if (ctx->RasterMask & STENCIL_BIT) - { - current->hwCapEnable |= - (MASK_StencilTestEnable | MASK_StencilWriteEnable); - } - else - { - current->hwCapEnable &= - ~(MASK_StencilTestEnable | MASK_StencilWriteEnable); - } - - /* NEW_TEXTURE_ENABLE depends on glEnable() instead of ReallyEnabled */ - /* if (ctx->NewState & NEW_TEXTURE_ENABLE) */ - if(1) - { - if (ctx->Texture.ReallyEnabled & - (TEXTURE0_1D | TEXTURE0_2D | TEXTURE1_1D | TEXTURE1_2D)) - { - current->hwCapEnable |= MASK_TextureEnable; - - current->hwCapEnable &= ~MASK_TextureNumUsed; - if (ctx->Texture.ReallyEnabled & TEXTURE1_ANY) - current->hwCapEnable |= 0x00002000; - else - current->hwCapEnable |= 0x00001000; - } - else - { - current->hwCapEnable &= ~MASK_TextureEnable; - } - -#if 1 - /* TODO : if unmark these, error in multitexture */ - if(ctx->NewState & NEW_TEXTURE_ENABLE) - { - int i; - for (i = 0; i < SIS_MAX_TEXTURES; i++) - { - hwcx->TexStates[i] |= (NEW_TEXTURING | NEW_TEXTURE_ENV); - } - } -#endif - } - - /* enable setting 1 */ - if (current->hwCapEnable ^ prev->hwCapEnable) - { - prev->hwCapEnable = current->hwCapEnable; - hwcx->GlobalFlag |= GFLAG_ENABLESETTING; - } - - /* enable setting 2 */ - if (current->hwCapEnable2 ^ prev->hwCapEnable2) - { - prev->hwCapEnable2 = current->hwCapEnable2; - hwcx->GlobalFlag |= GFLAG_ENABLESETTING2; - } - - /* TODO: if fog disable, don't check */ - if (current->hwCapEnable & MASK_FogEnable) - { - /* fog setting */ - if (current->hwFog ^ prev->hwFog) - { - prev->hwFog = current->hwFog; - hwcx->GlobalFlag |= GFLAG_FOGSETTING; - } - if (current->hwFogFar ^ prev->hwFogFar) - { - prev->hwFogFar = current->hwFogFar; - hwcx->GlobalFlag |= GFLAG_FOGSETTING; - } - if (current->hwFogInverse ^ prev->hwFogInverse) - { - prev->hwFogInverse = current->hwFogInverse; - hwcx->GlobalFlag |= GFLAG_FOGSETTING; - } - if (current->hwFogDensity ^ prev->hwFogDensity) - { - prev->hwFogDensity = current->hwFogDensity; - hwcx->GlobalFlag |= GFLAG_FOGSETTING; - } - } - -#ifdef NOT_DONE - sis_set_render_vb_tabs(ctx); -#endif - - /* TODO: assume when isFullScreen/DrawBuffer changed, UpdateState - * will be called - */ -#if SIS_STEREO - if(hwcx->isFullScreen && - (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT) && - hwcx->useStereo) - { - if(!hwcx->stereoEnabled){ - sis_init_stereo(ctx); - } - } - else{ - if(hwcx->stereoEnabled){ - sis_final_stereo(ctx); - } - } -#endif - - /* TODO : 1. where to handle SIS_SW_TEXTURE? - * 2. sw<->hw - * 3. sw-render only if next primitve need to do - */ -} - -void -sis_set_buffer_static (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - GLvisual *visual = ctx->Visual; - - switch (hwcx->bytesPerPixel) - { - case 2: - /* TODO: don't check - if (hwcx->redMask == 0xf800 && hwcx->greenMask == 0x07e0 && - hwcx->blueMask == 0x001f) - */ - { - current->hwDstSet |= DST_FORMAT_RGB_565; - } - break; - case 4: - /* - if (hwcx->redMask == 0xff0000 && hwcx->greenMask == 0xff00 && - hwcx->blueMask == 0xff) - */ - { - switch (visual->AlphaBits) - { - case 0: - case 1: - case 2: - case 4: - case 8: - /* TODO */ - current->hwDstSet |= DST_FORMAT_ARGB_8888; - break; - } - } - break; - default: - assert (0); - } - - switch (visual->DepthBits) - { - case 0: - current->hwCapEnable &= ~MASK_ZWriteEnable; - case 16: - hwcx->zFormat = Z_16; - current->hwCapEnable |= MASK_ZWriteEnable; - break; - case 32: - hwcx->zFormat = Z_32; - current->hwCapEnable |= MASK_ZWriteEnable; - break; - case 24: - assert (visual->StencilBits); - hwcx->zFormat = S_8_Z_24; - current->hwCapEnable |= MASK_StencilBufferEnable; - current->hwCapEnable |= MASK_ZWriteEnable; - break; - } - - current->hwZ &= ~MASK_ZBufferFormat; - current->hwZ |= hwcx->zFormat; - - /* Destination Color Format */ - if (current->hwDstSet ^ prev->hwDstSet) - { - prev->hwDstSet = current->hwDstSet; - hwcx->GlobalFlag |= GFLAG_DESTSETTING; - } - - /* Z Buffer Data Format */ - if (current->hwZ ^ prev->hwZ) - { - prev->hwZ = current->hwZ; - hwcx->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; - - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - /* TODO: ref is type GLclampf, but mesa has scaled it to 0 - 255.0 */ - current->hwAlpha = ((unsigned char) ref) << 16; - - /* Alpha Test function */ - current->hwAlpha &= ~0x07000000; - switch (func) - { - case GL_NEVER: - current->hwAlpha |= SiS_ALPHA_NEVER; - break; - case GL_LESS: - current->hwAlpha |= SiS_ALPHA_LESS; - break; - case GL_EQUAL: - current->hwAlpha |= SiS_ALPHA_EQUAL; - break; - case GL_LEQUAL: - current->hwAlpha |= SiS_ALPHA_LEQUAL; - break; - case GL_GREATER: - current->hwAlpha |= SiS_ALPHA_GREATER; - break; - case GL_NOTEQUAL: - current->hwAlpha |= SiS_ALPHA_NOTEQUAL; - break; - case GL_GEQUAL: - current->hwAlpha |= SiS_ALPHA_GEQUAL; - break; - case GL_ALWAYS: - current->hwAlpha |= SiS_ALPHA_ALWAYS; - break; - } - - prev->hwAlpha = current->hwAlpha; - hwcx->GlobalFlag |= GFLAG_ALPHASETTING; -} - -void -sis_BlendEquation (GLcontext * ctx, GLenum mode) -{ - /* version 1.2 specific */ - /* TODO: 300 don't support, fall back? */ -} - -void -sis_BlendFunc (GLcontext * ctx, GLenum sfactor, GLenum dfactor) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - /* TODO: in ICD, if no blend, it will reset these value */ - /* blending enable */ - current->hwDstSrcBlend = 0x10000; /* Default destination alpha */ - - switch (dfactor) - { - case GL_ZERO: - current->hwDstSrcBlend |= SiS_D_ZERO; - break; - case GL_ONE: - current->hwDstSrcBlend |= SiS_D_ONE; - break; - case GL_SRC_COLOR: - current->hwDstSrcBlend |= SiS_D_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - current->hwDstSrcBlend |= SiS_D_ONE_MINUS_SRC_COLOR; - break; - case GL_SRC_ALPHA: - current->hwDstSrcBlend |= SiS_D_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - current->hwDstSrcBlend |= SiS_D_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - current->hwDstSrcBlend |= SiS_D_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - current->hwDstSrcBlend |= SiS_D_ONE_MINUS_DST_ALPHA; - break; - } - - switch (sfactor) - { - case GL_ZERO: - current->hwDstSrcBlend |= SiS_S_ZERO; - break; - case GL_ONE: - current->hwDstSrcBlend |= SiS_S_ONE; - break; - case GL_SRC_ALPHA: - current->hwDstSrcBlend |= SiS_S_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - current->hwDstSrcBlend |= SiS_S_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - current->hwDstSrcBlend |= SiS_S_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_ALPHA; - break; - case GL_DST_COLOR: - current->hwDstSrcBlend |= SiS_S_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_COLOR; - break; - case GL_SRC_ALPHA_SATURATE: - current->hwDstSrcBlend |= SiS_S_SRC_ALPHA_SATURATE; - break; - } - - if (current->hwDstSrcBlend ^ prev->hwDstSrcBlend) - { - prev->hwDstSrcBlend = current->hwDstSrcBlend; - hwcx->GlobalFlag |= GFLAG_DSTBLEND; - } -} - -void -sis_BlendFuncSeparate (GLcontext * ctx, GLenum sfactorRGB, - GLenum dfactorRGB, GLenum sfactorA, GLenum dfactorA) -{ -} - -void -sis_CullFace (GLcontext * ctx, GLenum mode) -{ -#ifdef SIS_USE_HW_CULL - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - hwcx->AGPParseSet &= ~0x00008000; - hwcx->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; - } -#endif -} - -void -sis_FrontFace (GLcontext * ctx, GLenum mode) -{ -#ifdef SIS_USE_HW_CULL - sis_CullFace (ctx, ctx->Polygon.CullFaceMode); -#endif -} - -void -sis_DepthFunc (GLcontext * ctx, GLenum func) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - GLuint hwZFunc = 0; - - switch (func) - { - case GL_LESS: - hwZFunc = SiS_Z_COMP_S_LT_B; - break; - case GL_GEQUAL: - hwZFunc = SiS_Z_COMP_S_GE_B; - break; - case GL_LEQUAL: - hwZFunc = SiS_Z_COMP_S_LE_B; - break; - case GL_GREATER: - hwZFunc = SiS_Z_COMP_S_GT_B; - break; - case GL_NOTEQUAL: - hwZFunc = SiS_Z_COMP_S_NE_B; - break; - case GL_EQUAL: - hwZFunc = SiS_Z_COMP_S_EQ_B; - break; - case GL_ALWAYS: - hwZFunc = SiS_Z_COMP_ALWAYS; - break; - case GL_NEVER: - hwZFunc = SiS_Z_COMP_NEVER; - break; - } - current->hwZ &= ~MASK_ZTestMode; - current->hwZ |= hwZFunc; - - if (current->hwZ ^ prev->hwZ) - { - prev->hwZ = current->hwZ; - - hwcx->GlobalFlag |= GFLAG_ZSETTING; - } -} - -void -sis_DepthMask (GLcontext * ctx, GLboolean flag) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - if (ctx->Visual->StencilBits) - { - if (flag || ctx->Stencil.WriteMask) - { - current->hwCapEnable |= MASK_ZWriteEnable; - if (flag && ctx->Stencil.WriteMask == 0xff) - { - current->hwCapEnable2 &= ~MASK_ZMaskWriteEnable; - } - else - { - current->hwCapEnable2 |= MASK_ZMaskWriteEnable; - current->hwZMask = ((DWORD) ctx->Stencil.WriteMask << 24) | - ((flag) ? 0x00ffffff : 0); - - if (current->hwZMask ^ prev->hwZMask) - { - prev->hwZMask = current->hwZMask; - hwcx->GlobalFlag |= GFLAG_ZSETTING; - } - } - } - else - { - current->hwCapEnable &= ~MASK_ZWriteEnable; - } - } - else - { - if (flag) - { - current->hwCapEnable |= MASK_ZWriteEnable; - current->hwCapEnable2 &= ~MASK_ZMaskWriteEnable; - } - else - { - current->hwCapEnable &= ~MASK_ZWriteEnable; - } - } -} - -void -sis_DepthRange (GLcontext * ctx, GLclampd nearval, GLclampd farval) -{ - /* mesa handles it? */ -} - -void -sis_Enable (GLcontext * ctx, GLenum cap, GLboolean state) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *current = &hwcx->current; - - switch (cap) - { - case GL_ALPHA_TEST: - if (state) - { - current->hwCapEnable |= MASK_AlphaTestEnable; - } - else - { - current->hwCapEnable &= ~MASK_AlphaTestEnable; - } - break; -/* - case GL_AUTO_NORMAL: - break; -*/ - case GL_BLEND: - /* TODO: */ - if(state) - /* if (state & !ctx->Color.ColorLogicOpEnabled) */ - { - current->hwCapEnable |= MASK_BlendEnable; - } - else - { - current->hwCapEnable &= ~MASK_BlendEnable; - } - break; -/* - case GL_CLIP_PLANE0: - case GL_CLIP_PLANE1: - case GL_CLIP_PLANE2: - case GL_CLIP_PLANE3: - case GL_CLIP_PLANE4: - case GL_CLIP_PLANE5: - break; - case GL_COLOR_MATERIAL: - break; -*/ - case GL_CULL_FACE: -#ifdef SIS_USE_HW_CULL - if (state) - { - current->hwCapEnable |= MASK_CullEnable; - } - else - { - current->hwCapEnable &= ~MASK_CullEnable; - } -#endif - break; - case GL_DEPTH_TEST: - if (state && xmesa->xm_buffer->depthbuffer) - { - current->hwCapEnable |= MASK_ZTestEnable; - } - else - { - current->hwCapEnable &= ~MASK_ZTestEnable; - } - break; - case GL_DITHER: - if (state) - { - current->hwCapEnable |= MASK_DitherEnable; - } - else - { - current->hwCapEnable &= ~MASK_DitherEnable; - } - break; -/* - case GL_FOG: - break; - case GL_LIGHT0: - case GL_LIGHT1: - case GL_LIGHT2: - case GL_LIGHT3: - case GL_LIGHT4: - case GL_LIGHT5: - case GL_LIGHT6: - case GL_LIGHT7: - break; - case GL_LIGHTING: - break; - case GL_LINE_SMOOTH: - break; - case GL_LINE_STIPPLE: - break; - case GL_INDEX_LOGIC_OP: - break; -*/ - case GL_COLOR_LOGIC_OP: - if (state) - { - sis_LogicOp (ctx, ctx->Color.LogicOp); - } - else - { - sis_LogicOp (ctx, GL_COPY); - } - break; -/* - case GL_MAP1_COLOR_4: - break; - case GL_MAP1_INDEX: - break; - case GL_MAP1_NORMAL: - break; - case GL_MAP1_TEXTURE_COORD_1: - break; - case GL_MAP1_TEXTURE_COORD_2: - break; - case GL_MAP1_TEXTURE_COORD_3: - break; - case GL_MAP1_TEXTURE_COORD_4: - break; - case GL_MAP1_VERTEX_3: - break; - case GL_MAP1_VERTEX_4: - break; - case GL_MAP2_COLOR_4: - break; - case GL_MAP2_INDEX: - break; - case GL_MAP2_NORMAL: - break; - case GL_MAP2_TEXTURE_COORD_1: - break; - case GL_MAP2_TEXTURE_COORD_2: - break; - case GL_MAP2_TEXTURE_COORD_3: - break; - case GL_MAP2_TEXTURE_COORD_4: - break; - case GL_MAP2_VERTEX_3: - break; - case GL_MAP2_VERTEX_4: - break; - case GL_NORMALIZE: - break; - case GL_POINT_SMOOTH: - break; - case GL_POLYGON_SMOOTH: - break; - case GL_POLYGON_STIPPLE: - break; - case GL_POLYGON_OFFSET_POINT: - break; - case GL_POLYGON_OFFSET_LINE: - break; - case GL_POLYGON_OFFSET_FILL: - case GL_POLYGON_OFFSET_EXT: - break; - case GL_RESCALE_NORMAL_EXT: - break; -*/ - case GL_SCISSOR_TEST: - sis_set_scissor (ctx); - break; -/* - case GL_SHARED_TEXTURE_PALETTE_EXT: - break; -*/ - case GL_STENCIL_TEST: - if (state) - { - current->hwCapEnable |= (MASK_StencilTestEnable | - MASK_StencilWriteEnable); - } - else - { - current->hwCapEnable &= ~(MASK_StencilTestEnable | - MASK_StencilWriteEnable); - } - break; -/* - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_3D: - break; - case GL_TEXTURE_GEN_Q: - break; - case GL_TEXTURE_GEN_R: - break; - case GL_TEXTURE_GEN_S: - break; - case GL_TEXTURE_GEN_T: - break; - - case GL_VERTEX_ARRAY: - break; - case GL_NORMAL_ARRAY: - break; - case GL_COLOR_ARRAY: - break; - case GL_INDEX_ARRAY: - break; - case GL_TEXTURE_COORD_ARRAY: - break; - case GL_EDGE_FLAG_ARRAY: - break; -*/ - } -} - -void -sis_Hint (GLcontext * ctx, GLenum target, GLenum mode) -{ -#if 0 - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - __GLSiSHardware *current = &hwcx->current; -#endif - - switch (target) - { - case GL_FOG_HINT: - switch (mode) - { - case GL_DONT_CARE: - break; - case GL_FASTEST: - /* vertex fog */ - /* TODO */ - break; - case GL_NICEST: - /* pixel fog */ - break; - } - break; - case GL_LINE_SMOOTH_HINT: - break; - case GL_PERSPECTIVE_CORRECTION_HINT: -#if 0 - if (mode == GL_NICEST) - current->hwCapEnable |= MASK_TexturePerspectiveEnable; - else if (!(ctx->RasterMask & FOG_BIT)) - current->hwCapEnable &= ~MASK_TexturePerspectiveEnable; -#endif - break; - case GL_POINT_SMOOTH_HINT: - break; - case GL_POLYGON_SMOOTH_HINT: - break; - } -} - -void -sis_Lightfv (GLcontext * ctx, GLenum light, - GLenum pname, const GLfloat * params, GLint nparams) -{ -} - -void -sis_LightModelfv (GLcontext * ctx, GLenum pname, const GLfloat * params) -{ -} - -void -sis_PolygonMode (GLcontext * ctx, GLenum face, GLenum mode) -{ -} - -void -sis_Scissor (GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h) -{ - if (ctx->Scissor.Enabled) - sis_set_scissor (ctx); -} - -void -sis_ShadeModel (GLcontext * ctx, GLenum mode) -{ -} - -void -sis_Viewport (GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h) -{ -} - -void -sis_ClearColor (GLcontext * ctx, GLubyte red, GLubyte green, - GLubyte blue, GLubyte alpha) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - set_color_pattern (hwcx, red, green, blue, alpha); - -} - -/* TODO */ -void -sis_ClearIndex (GLcontext * ctx, GLuint index) -{ -} - -void sis_set_render_pos(GLcontext * ctx, GLubyte *base, GLuint pitch) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - assert (base != NULL); - - if (SIS_VERBOSE&VERBOSE_SIS_BUFFER){ - fprintf(stderr, "set drawing position: base=%lx, pitch=%lu\n", - (long)base, (long)pitch); - } - - /* software render */ - hwcx->swRenderBase = base; - hwcx->swRenderPitch = pitch; - - current->hwOffsetDest = ((DWORD) base - (DWORD) GET_FbBase (hwcx)) >> 1; - current->hwDstSet &= ~MASK_DstBufferPitch; - current->hwDstSet |= pitch >> 2; - - /* destination setting */ - if (current->hwDstSet ^ prev->hwDstSet) - { - prev->hwDstSet = current->hwDstSet; - hwcx->GlobalFlag |= GFLAG_DESTSETTING; - } - - if (current->hwOffsetDest ^ prev->hwOffsetDest) - { - prev->hwOffsetDest = current->hwOffsetDest; - hwcx->GlobalFlag |= GFLAG_DESTSETTING; - } -} - -GLboolean -sis_SetDrawBuffer (GLcontext * ctx, GLenum mode) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - XMesaBuffer xm_buffer = xmesa->xm_buffer; - GLubyte *base; - GLuint pitch; - GLboolean retval = GL_FALSE; - - /* if new context bind, the function will be call? */ - switch (mode) - { - case GL_BACK_LEFT: - base = (GLubyte *) xm_buffer->backimage->data; - pitch = xm_buffer->backimage->bytes_per_line; - - retval = GL_TRUE; - break; - case GL_FRONT_LEFT: - base = sis_get_drawable_pos (xmesa); - pitch = GET_PITCH (hwcx); - retval = GL_TRUE; - break; - case GL_BACK_RIGHT: - case GL_FRONT_RIGHT: - default: - assert (0); - return GL_FALSE; - } - - sis_set_render_pos(ctx, base, pitch); - - return retval; -} - -void -sis_SetReadBuffer (GLcontext *ctx, GLframebuffer *colorBuffer, - GLenum buffer) -{ - /* TODO */ -} - -GLboolean -sis_ColorMask (GLcontext * ctx, - GLboolean rmask, GLboolean gmask, - GLboolean bmask, GLboolean amask) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - - if (rmask & gmask & bmask & - (!ctx->Visual->AlphaBits | amask)) - { - current->hwCapEnable2 &= ~(MASK_AlphaMaskWriteEnable | - MASK_ColorMaskWriteEnable); - } - else - { - 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; - } - - if (current->hwDstMask ^ prev->hwDstMask) - { - prev->hwDstMask = current->hwDstMask; - hwcx->GlobalFlag |= GFLAG_DESTSETTING; - } - - return GL_TRUE; -} - -GLboolean -sis_LogicOp (GLcontext * ctx, GLenum op) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - if (ctx->Color.ColorLogicOpEnabled) - { - current->hwDstSet &= ~MASK_ROP2; - switch (op) - { - case GL_CLEAR: - current->hwDstSet |= LOP_CLEAR; - break; - case GL_SET: - current->hwDstSet |= LOP_SET; - break; - case GL_COPY: - current->hwDstSet |= LOP_COPY; - break; - case GL_COPY_INVERTED: - current->hwDstSet |= LOP_COPY_INVERTED; - break; - case GL_NOOP: - current->hwDstSet |= LOP_NOOP; - break; - case GL_INVERT: - current->hwDstSet |= LOP_INVERT; - break; - case GL_AND: - current->hwDstSet |= LOP_AND; - break; - case GL_NAND: - current->hwDstSet |= LOP_NAND; - break; - case GL_OR: - current->hwDstSet |= LOP_OR; - break; - case GL_NOR: - current->hwDstSet |= LOP_NOR; - break; - case GL_XOR: - current->hwDstSet |= LOP_XOR; - break; - case GL_EQUIV: - current->hwDstSet |= LOP_EQUIV; - break; - case GL_AND_REVERSE: - current->hwDstSet |= LOP_AND_REVERSE; - break; - case GL_AND_INVERTED: - current->hwDstSet |= LOP_AND_INVERTED; - break; - case GL_OR_REVERSE: - current->hwDstSet |= LOP_OR_REVERSE; - break; - case GL_OR_INVERTED: - current->hwDstSet |= LOP_OR_INVERTED; - break; - } - - if (current->hwDstSet ^ prev->hwDstSet) - { - prev->hwDstSet = current->hwDstSet; - hwcx->GlobalFlag |= GFLAG_DESTSETTING; - } - } - return GL_TRUE; -} - -void -sis_Dither (GLcontext * ctx, GLboolean enable) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *current = &hwcx->current; - - if (enable) - { - current->hwCapEnable |= MASK_DitherEnable; - } - else - { - current->hwCapEnable &= ~MASK_DitherEnable; - } -} - -GLint -sis_GetParameteri (const GLcontext * ctx, GLint param) -{ - switch (param) - { - case DD_HAVE_HARDWARE_FOG: - /* - * fragment fogging is not free when compared with hardware - * vertex fogging because of the overhead of W - */ - return 0; -/* - case DD_MAX_TEXTURE_SIZE: - return SIS_MAX_TEXTURE_SIZE; - case DD_MAX_TEXTURES: - return SIS_MAX_TEXTURES; -*/ - } - return 0; -} - -/* just sync between CPU and rendering-engine */ -GLboolean sis_DrawPixels (GLcontext * ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid * pixels) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - WaitEngIdle (hwcx); - return 0; -} - -GLboolean sis_Bitmap (GLcontext * ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte * bitmap) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - ctx->Driver.RenderStart( ctx ); - - WaitEngIdle (hwcx); - /* TODO: use tdfx's Bitmap */ - - ctx->Driver.RenderFinish( ctx ); - - return 0; -} - -void -set_color_pattern (__GLSiScontext * hwcx, GLubyte red, GLubyte green, - GLubyte blue, GLubyte alpha) -{ - /* XXX only RGB565 and ARGB8888 */ - switch (GET_ColorFormat (hwcx)) - { - case DST_FORMAT_ARGB_8888: - hwcx->clearColorPattern = (alpha << 24) + - (red << 16) + (green << 8) + (blue); - break; - case DST_FORMAT_RGB_565: - hwcx->clearColorPattern = ((red >> 3) << 11) + - ((green >> 2) << 5) + (blue >> 3); - hwcx->clearColorPattern |= hwcx->clearColorPattern << 16; - break; - default: - assert (0); - } -} - -void -set_z_stencil_pattern (__GLSiScontext * hwcx, GLclampd z, int stencil) -{ - GLuint zPattern, stencilPattern; - GLboolean dword_pattern; - - if (z <= (float) 0.0) - zPattern = 0x0; - else if (z >= (float) 1.0) - zPattern = 0xFFFFFFFF; - else - zPattern = doFPtoFixedNoRound (*(DWORD *) & z, 32); - - stencilPattern = 0; - - switch (hwcx->zFormat) - { - case Z_16: - zPattern = zPattern >> 16; - zPattern &= 0x0000FFFF; - dword_pattern = GL_FALSE; - break; - case S_8_Z_24: - zPattern = zPattern >> 8; - zPattern &= 0x00FFFFFF; - stencilPattern = (stencilPattern << 24); - dword_pattern = GL_TRUE; - break; - case Z_32: - dword_pattern = GL_TRUE; - break; - default: - assert (0); - } - hwcx->clearZStencilPattern = zPattern | stencilPattern; - /* ?? */ - if (!dword_pattern) - hwcx->clearZStencilPattern |= (zPattern | stencilPattern) << 16; -} - -void -sis_update_drawable_state (GLcontext * ctx) -{ - const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *current = &hwcx->current; - __GLSiSHardware *prev = &hwcx->prev; - - XMesaBuffer xm_buffer = xmesa->xm_buffer; - GLuint z_depth; - - sis_SetDrawBuffer (ctx, ctx->Color.DriverDrawBuffer); - /* TODO: call sis_SetReadBuffer? */ - - 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); - } - - 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; - } -} - -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; - } -} - -const char * -sis_ExtensionString (GLcontext * ctx) -{ - return NULL; -} - -void -sis_set_scissor (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - GLint x1, y1, x2, y2; - - /* ?? from context.c, do it 2 times */ - - x1 = 0; - y1 = 0; - x2 = xmesa->xm_buffer->width - 1; - y2 = xmesa->xm_buffer->height - 1; - - if (ctx->Scissor.Enabled) - { - if (ctx->Scissor.X > x1) - { - x1 = ctx->Scissor.X; - } - if (ctx->Scissor.Y > y1) - { - y1 = ctx->Scissor.Y; - } - if (ctx->Scissor.X + ctx->Scissor.Width - 1 < x2) - { - x2 = ctx->Scissor.X + ctx->Scissor.Width - 1; - } - if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < y2) - { - y2 = ctx->Scissor.Y + ctx->Scissor.Height - 1; - } - } - - y1 = Y_FLIP (y1); - y2 = Y_FLIP (y2); - - current->clipTopBottom = (y2 << 13) | y1; - current->clipLeftRight = (x1 << 13) | x2; - - if ((current->clipTopBottom ^ prev->clipTopBottom) || - (current->clipLeftRight ^ prev->clipLeftRight)) - { - prev->clipTopBottom = current->clipTopBottom; - prev->clipLeftRight = current->clipLeftRight; - hwcx->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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_mesa.h Wed Dec 31 16:00:00 1969 @@ -1,235 +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_mesa.h,v 1.4 2002/10/30 12:52:00 alanh Exp $ */ - -/* - * Authors: - * Sung-Ching Lin - * - */ - -#ifndef _sis_mesa_h_ -#define _sis_mesa_h_ - -void sis_UpdateState (GLcontext * ctx); -void sis_ClearIndex (GLcontext * ctx, GLuint index); -void sis_ClearColor (GLcontext * ctx, GLubyte red, GLubyte green, - GLubyte blue, GLubyte alpha); -GLbitfield sis_Clear (GLcontext * ctx, GLbitfield mask, GLboolean all, - GLint x, GLint y, GLint width, GLint height); -GLboolean sis_SetDrawBuffer (GLcontext * ctx, GLenum mode); -void sis_SetReadBuffer (GLcontext *ctx, GLframebuffer *colorBuffer, - GLenum buffer); -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, - GLboolean bmask, GLboolean amask); -GLboolean sis_LogicOp (GLcontext * ctx, GLenum op); -void sis_Dither (GLcontext * ctx, GLboolean enable); -void sis_Error (GLcontext * ctx); -void sis_NearFar (GLcontext * ctx, GLfloat nearVal, GLfloat farVal); -GLint sis_GetParameteri (const GLcontext * ctx, GLint param); -GLboolean sis_DrawPixels (GLcontext * ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid * pixels); -GLboolean sis_Bitmap (GLcontext * ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte * bitmap); -void sis_RenderStart (GLcontext * ctx); -void sis_RenderFinish (GLcontext * ctx); - -typedef void (*sis_setup_func_t)(struct vertex_buffer *, GLuint, GLuint); -sis_setup_func_t sis_ChooseRasterSetupFunc (GLcontext * ctx); - -void sis_ReducedPrimitiveChange (GLcontext * ctx, GLenum primitive); -GLboolean sis_MultipassFunc (struct vertex_buffer *VB, GLuint passno); - -/* - * Texture - */ -void sis_validate_texture (GLcontext * ctx); - -void sis_TexEnv( GLcontext *ctx, GLenum target, GLenum pname, - const GLfloat *param ); - -void sis_TexImage (GLcontext * ctx, GLenum target, - struct gl_texture_object *tObj, GLint level, - GLint internalFormat, - const struct gl_texture_image *image); - -void sis_TexSubImage (GLcontext * ctx, GLenum target, - struct gl_texture_object *tObj, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLint internalFormat, - const struct gl_texture_image *image); - -void sis_TexParameter (GLcontext * ctx, GLenum target, - struct gl_texture_object *tObj, - GLenum pname, const GLfloat * params); - -void sis_BindTexture (GLcontext * ctx, GLenum target, - struct gl_texture_object *tObj); - -void sis_DeleteTexture (GLcontext * ctx, struct gl_texture_object *tObj); - -void sis_UpdateTexturePalette (GLcontext * ctx, - struct gl_texture_object *tObj); - -void sis_UseGlobalTexturePalette (GLcontext * ctx, GLboolean state); - -void sis_ActiveTexture (GLcontext * ctx, GLuint texUnitNumber); - -GLboolean sis_IsTextureResident (GLcontext * ctx, - struct gl_texture_object *t); -void sis_PrioritizeTexture (GLcontext * ctx, - struct gl_texture_object *t, GLclampf priority); - -/* - * Optimization - */ -void sis_RegisterVB (struct vertex_buffer *VB); -void sis_UnregisterVB (struct vertex_buffer *VB); -void sis_ResetVB (struct vertex_buffer *VB); -void sis_ResetCvaVB (struct vertex_buffer *VB, GLuint stages); -GLuint sis_RegisterPipelineStages (struct gl_pipeline_stage *out, - const struct gl_pipeline_stage *in, - GLuint nr); -GLboolean sis_BuildPrecalcPipeline (GLcontext * ctx); -GLboolean sis_BuildEltPipeline (GLcontext * ctx); -void sis_OptimizePrecalcPipeline (GLcontext * ctx, struct gl_pipeline *pipe); -void sis_OptimizeImmediatePipeline (GLcontext * ctx, - struct gl_pipeline *pipe); - -/* - * State-Change - */ -void sis_AlphaFunc (GLcontext * ctx, GLenum func, GLclampf ref); -void sis_BlendEquation (GLcontext * ctx, GLenum mode); -void sis_BlendFunc (GLcontext * ctx, GLenum sfactor, GLenum dfactor); -void sis_BlendFuncSeparate (GLcontext * ctx, GLenum sfactorRGB, - GLenum dfactorRGB, GLenum sfactorA, - GLenum dfactorA); -void sis_ClearDepth (GLcontext * ctx, GLclampd d); -void sis_CullFace (GLcontext * ctx, GLenum mode); -void sis_FrontFace (GLcontext * ctx, GLenum mode); -void sis_DepthFunc (GLcontext * ctx, GLenum func); -void sis_DepthMask (GLcontext * ctx, GLboolean flag); -void sis_DepthRange (GLcontext * ctx, GLclampd nearval, GLclampd farval); -void sis_Enable (GLcontext * ctx, GLenum cap, GLboolean state); -void sis_Fogfv (GLcontext * ctx, GLenum pname, const GLfloat * params); -void sis_Hint (GLcontext * ctx, GLenum target, GLenum mode); -void sis_Lightfv (GLcontext * ctx, GLenum light, - GLenum pname, const GLfloat * params, GLint nparams); -void sis_LightModelfv (GLcontext * ctx, GLenum pname, const GLfloat * params); -void sis_PolygonMode (GLcontext * ctx, GLenum face, GLenum mode); -void sis_Scissor (GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h); -void sis_ShadeModel (GLcontext * ctx, GLenum mode); -void sis_ClearStencil (GLcontext * ctx, GLint s); -void sis_StencilFunc (GLcontext * ctx, GLenum func, GLint ref, GLuint mask); -void sis_StencilMask (GLcontext * ctx, GLuint mask); -void sis_StencilOp (GLcontext * ctx, GLenum fail, GLenum zfail, GLenum zpass); -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); - -/* - * VB Rendering Function - */ -void sis_init_vbrender (void); -void sis_set_render_vb_tabs (GLcontext * ctx); - -/* - * Local - */ -void set_color_pattern (__GLSiScontext * hwcx, GLubyte red, GLubyte green, - GLubyte blue, GLubyte alpha); - -void set_z_stencil_pattern (__GLSiScontext * hwcx, 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); - -/* - * X window system Information - */ -#define sis_is_window(xmesa) (!((xmesa)->xm_buffer->pixmap_flag)) -GLboolean sis_get_clip_rects (XMesaContext xmesa, BoxPtr * ppExtents, - int *pCount); -void *sis_get_drawable_pos (XMesaContext xmesa); -void sis_get_drawable_origin (XMesaContext xmesa, GLuint * x, GLuint * y); -void sis_get_drawable_size (XMesaContext xmesa, GLuint * w, GLuint * h); -void sis_get_drawable_box (XMesaContext xmesa, BoxPtr pBox); - -/* GLX */ -void SiSCreateContext (XMesaContext xmesa); -void SiSDestroyContext (XMesaContext xmesa); -void sis_swap_buffers (XMesaBuffer b); -void SiSDestroyBuffer (XMesaBuffer buf); - -/* Profile */ -#ifndef SIS_DEBUG -# define SIS_VERBOSE 0 -#else -extern int SIS_VERBOSE; -#endif - -enum _sis_verbose { - VERBOSE_SIS_BUFFER = 0x1, - VERBOSE_SIS_MEMORY = 0x2 -}; - -#endif diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_reg.h xc/lib/GL/mesa/src/drv/sis/sis_reg.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_reg.h Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_reg.h Mon Aug 25 00:15:50 2003 @@ -500,6 +500,15 @@ #define MASK_ZBufferInSystem 0x00080000 #define MASK_ZBufferFormat 0x01F00000 +#define SiS_Z_COMP_NEVER 0x00000000 +#define SiS_Z_COMP_S_LT_B 0x00010000 +#define SiS_Z_COMP_S_EQ_B 0x00020000 +#define SiS_Z_COMP_S_LE_B 0x00030000 +#define SiS_Z_COMP_S_GT_B 0x00040000 +#define SiS_Z_COMP_S_NE_B 0x00050000 +#define SiS_Z_COMP_S_GE_B 0x00060000 +#define SiS_Z_COMP_ALWAYS 0x00070000 + /* * REG_3D_ZBias -- Define Z Buffer Setting Mask (8A0Ch-8A0Fh) */ @@ -524,6 +533,15 @@ #define MASK_AlphaBufferInSystem 0x08000000 #define MASK_AlphaBufferFormat 0x30000000 +#define SiS_ALPHA_NEVER 0x00000000 +#define SiS_ALPHA_LESS 0x01000000 +#define SiS_ALPHA_EQUAL 0x02000000 +#define SiS_ALPHA_LEQUAL 0x03000000 +#define SiS_ALPHA_GREATER 0x04000000 +#define SiS_ALPHA_NOTEQUAL 0x05000000 +#define SiS_ALPHA_GEQUAL 0x06000000 +#define SiS_ALPHA_ALWAYS 0x07000000 + /* * REG_3D_AlphaAddress -- Define Alpha Buffer Base Address(8A1Ch-8A1Fh) */ @@ -540,6 +558,24 @@ #define MASK_Dst7BitFormat 0x007F0000 #define MASK_ROP2 0x0F000000 +/* Logic Op */ +#define LOP_CLEAR 0x00000000 +#define LOP_NOR 0x01000000 +#define LOP_AND_INVERTED 0x02000000 +#define LOP_COPY_INVERTED 0x03000000 +#define LOP_AND_REVERSE 0x04000000 +#define LOP_INVERT 0x05000000 +#define LOP_XOR 0x06000000 +#define LOP_NAND 0x07000000 +#define LOP_AND 0x08000000 +#define LOP_EQUIV 0x09000000 +#define LOP_NOOP 0x0a000000 +#define LOP_OR_INVERTED 0x0b000000 +#define LOP_COPY 0x0c000000 +#define LOP_OR_REVERSE 0x0d000000 +#define LOP_OR 0x0e000000 +#define LOP_SET 0x0f000000 + /* * REG_3D_DstAlphaWriteMask -- Define Destination/Alpha Buffer Write Mask (8A24h-8A27h) */ @@ -565,22 +601,191 @@ #define MASK_FogMode 0x07000000 #define MASK_FogZLookup 0x08000000 +#define FOGMODE_CHEAP 0x04000000 +#define FOGMODE_LINEAR 0x05000000 +#define FOGMODE_EXP 0x06000000 +#define FOGMODE_EXP2 0x07000000 + /* * REG_3D_FogStartEnd -- Define Fog Start End Setting (8A34h-8A37h) */ -#define MASK_FogFarDistance 0x0007FFFF +#define MASK_FogFarDistance 0x0007FFFF /* * REG_3D_FogStartEnd -- Define Fog End Setting (8A38h-8A3Bh) */ -#define MASK_FogInvFarDistance 0x0007FFFF +#define MASK_FogInvFarDistance 0x0007FFFF + +/* + * REG_3D_StencilSet -- Define stencil test (8A44h-8A47h) + */ +#define MASK_StencilTestMode 0x07000000 + +#define SiS_STENCIL_NEVER 0x00000000 +#define SiS_STENCIL_LESS 0x01000000 +#define SiS_STENCIL_EQUAL 0x02000000 +#define SiS_STENCIL_LEQUAL 0x03000000 +#define SiS_STENCIL_GREATER 0x04000000 +#define SiS_STENCIL_NOTEQUAL 0x05000000 +#define SiS_STENCIL_GEQUAL 0x06000000 +#define SiS_STENCIL_ALWAYS 0x07000000 + +/* + * REG_3D_StencilSet2 -- Define stencil test (8A4h-8A47h) + */ +#define MASK_StencilBufferPitch 0x00000FFF +#define MASK_StencilZPassOp 0x00007000 +#define MASK_StencilZFailOp 0x00070000 +#define MASK_StencilFailOp 0x00700000 +#define MASK_StencilWriteMask 0xFF000000 + +#define SiS_SFAIL_KEEP 0x00000000 +#define SiS_SFAIL_ZERO 0x00100000 +#define SiS_SFAIL_REPLACE 0x00200000 +#define SiS_SFAIL_INVERT 0x00500000 +#define SiS_SFAIL_INCR 0x00600000 +#define SiS_SFAIL_DECR 0x00700000 + +#define SiS_SPASS_ZFAIL_KEEP 0x00000000 +#define SiS_SPASS_ZFAIL_ZERO 0x00010000 +#define SiS_SPASS_ZFAIL_REPLACE 0x00020000 +#define SiS_SPASS_ZFAIL_INVERT 0x00050000 +#define SiS_SPASS_ZFAIL_INCR 0x00060000 +#define SiS_SPASS_ZFAIL_DECR 0x00070000 + +#define SiS_SPASS_ZPASS_KEEP 0x00000000 +#define SiS_SPASS_ZPASS_ZERO 0x00001000 +#define SiS_SPASS_ZPASS_REPLACE 0x00002000 +#define SiS_SPASS_ZPASS_INVERT 0x00005000 +#define SiS_SPASS_ZPASS_INCR 0x00006000 +#define SiS_SPASS_ZPASS_DECR 0x00007000 + + +/* + * REG_3D_DstBlendMode (8A50h-8A53h) + */ + +#define SiS_D_ZERO 0x00000000 +#define SiS_D_ONE 0x00000010 +#define SiS_D_SRC_COLOR 0x00000020 +#define SiS_D_ONE_MINUS_SRC_COLOR 0x00000030 +#define SiS_D_SRC_ALPHA 0x00000040 +#define SiS_D_ONE_MINUS_SRC_ALPHA 0x00000050 +#define SiS_D_DST_ALPHA 0x00000060 +#define SiS_D_ONE_MINUS_DST_ALPHA 0x00000070 + +#define SiS_S_ZERO 0x00000000 +#define SiS_S_ONE 0x00000001 +#define SiS_S_SRC_ALPHA 0x00000004 +#define SiS_S_ONE_MINUS_SRC_ALPHA 0x00000005 +#define SiS_S_DST_ALPHA 0x00000006 +#define SiS_S_ONE_MINUS_DST_ALPHA 0x00000007 +#define SiS_S_DST_COLOR 0x00000008 +#define SiS_S_ONE_MINUS_DST_COLOR 0x00000009 +#define SiS_S_SRC_ALPHA_SATURATE 0x0000000a + +/* + * REG_3D_TextureColorBlendSet0 (8B40h-8B43h) + * REG_3D_TextureColorBlendSet1 (8B40h-8B43h) + */ + +#define A_REPLACE_RGB_STAGE0 0xa1485000 +#define A_REPLACE_A_STAGE0 0xc3230000 +#define L_REPLACE__RGB_STAGE0 0xc1485000 +#define L_REPLACE__A_STAGE0 0x63230000 +#define LA_REPLACE__RGB_STAGE0 0xc1485000 +#define LA_REPLACE__A_STAGE0 0xc3230000 +#define I_REPLACE__RGB_STAGE0 0xc1485000 +#define I_REPLACE__A_STAGE0 0xc3230000 +#define RGB_REPLACE__RGB_STAGE0 0xc1485000 +#define RGB_REPLACE__A_STAGE0 0x63230000 +#define RGBA_REPLACE__RGB_STAGE0 0xc1485000 +#define RGBA_REPLACE__A_STAGE0 0xc3230000 + +#define A_MODULATE_RGB_STAGE0 0xa1485000 +#define A_MODULATE_A_STAGE0 0x63c30000 +#define L_MODULATE__RGB_STAGE0 0xa1705000 +#define L_MODULATE__A_STAGE0 0x63230000 +#define LA_MODULATE__RGB_STAGE0 0xa1705000 +#define LA_MODULATE__A_STAGE0 0x63c30000 +#define I_MODULATE__RGB_STAGE0 0xa1705000 +#define I_MODULATE__A_STAGE0 0x63c30000 +#define RGB_MODULATE__RGB_STAGE0 0xa1705000 +#define RGB_MODULATE__A_STAGE0 0x63230000 +#define RGBA_MODULATE__RGB_STAGE0 0xa1705000 +#define RGBA_MODULATE__A_STAGE0 0x63c30000 + +#define RGB_DECAL__RGB_STAGE0 0xc1485000 +#define RGB_DECAL__A_STAGE0 0x63230000 +#define RGBA_DECAL__RGB_STAGE0 0xc534c001 +#define RGBA_DECAL__A_STAGE0 0x63230000 + +#define A_BLEND_RGB_STAGE0 0xa1485000 +#define A_BLEND_A_STAGE0 0x63c30000 +#define L_BLEND__RGB_STAGE0 0x4530c001 +#define L_BLEND__A_STAGE0 0x63230000 +#define LA_BLEND__RGB_STAGE0 0x4530c001 +#define LA_BLEND__A_STAGE0 0x63c30000 +#define I_BLEND__RGB_STAGE0 0x4530c001 +#define I_BLEND__A_STAGE0 0x46c60001 +#define RGB_BLEND__RGB_STAGE0 0x4530c001 +#define RGB_BLEND__A_STAGE0 0x63230000 +#define RGBA_BLEND__RGB_STAGE0 0x4530c001 +#define RGBA_BLEND__A_STAGE0 0x63c30000 + +#define RGB_STAGE1 0xa1485000 +#define A_STAGE1 0xa3230000 + +#define A_REPLACE_RGB_STAGE1 0xa1485000 +#define A_REPLACE_A_STAGE1 0xe3230000 +#define L_REPLACE__RGB_STAGE1 0xe1485000 +#define L_REPLACE__A_STAGE1 0xa3230000 +#define LA_REPLACE__RGB_STAGE1 0xe1485000 +#define LA_REPLACE__A_STAGE1 0xe3230000 +#define I_REPLACE__RGB_STAGE1 0xe1485000 +#define I_REPLACE__A_STAGE1 0xe3230000 +#define RGB_REPLACE__RGB_STAGE1 0xe1485000 +#define RGB_REPLACE__A_STAGE1 0xa3230000 +#define RGBA_REPLACE__RGB_STAGE1 0xe1485000 +#define RGBA_REPLACE__A_STAGE1 0xe3230000 + +#define A_MODULATE_RGB_STAGE1 0xa1485000 +#define A_MODULATE_A_STAGE1 0xa3e30000 +#define L_MODULATE__RGB_STAGE1 0xa1785000 +#define L_MODULATE__A_STAGE1 0xa3230000 +#define LA_MODULATE__RGB_STAGE1 0xa1785000 +#define LA_MODULATE__A_STAGE1 0xa3e30000 +#define I_MODULATE__RGB_STAGE1 0xa1785000 +#define I_MODULATE__A_STAGE1 0xa3e30000 +#define RGB_MODULATE__RGB_STAGE1 0xa1785000 +#define RGB_MODULATE__A_STAGE1 0xa3230000 +#define RGBA_MODULATE__RGB_STAGE1 0xa1785000 +#define RGBA_MODULATE__A_STAGE1 0xa3e30000 + +#define RGB_DECAL__RGB_STAGE1 0xe1485000 +#define RGB_DECAL__A_STAGE1 0xa3230000 +#define RGBA_DECAL__RGB_STAGE1 0xe5394001 +#define RGBA_DECAL__A_STAGE1 0xa3230000 + +#define A_BLEND_RGB_STAGE1 0xa1485000 +#define A_BLEND_A_STAGE1 0xa3e30000 +#define L_BLEND__RGB_STAGE1 0x45394001 +#define L_BLEND__A_STAGE1 0xa3230000 +#define LA_BLEND__RGB_STAGE1 0x45394001 +#define LA_BLEND__A_STAGE1 0xa3e30000 +#define I_BLEND__RGB_STAGE1 0x45394001 +#define I_BLEND__A_STAGE1 0x4aea0001 +#define RGB_BLEND__RGB_STAGE1 0x45394001 +#define RGB_BLEND__A_STAGE1 0xa3230000 +#define RGBA_BLEND__RGB_STAGE1 0x45394001 +#define RGBA_BLEND__A_STAGE1 0xa3e30000 + #define MASK_FogDensity 0x0003FFFF #define MASK_FogFactor 0xFF000000 #define MASK_StencilMaskValue 0x000000FF #define MASK_StencilReferenceValue 0x0000FF00 -#define MASK_StencilTestMode 0x07000000 #define MASK_StencilBufferInSystem 0x08000000 #define MASK_StencilFormat 0x30000000 @@ -598,6 +803,7 @@ #define MASK_SrcBlendMode 0x0000000F #define MASK_DstBlendMode 0x000000F0 + #define MASK_DSTBLEND_ZERO 0x00000000 #define MASK_DSTBLEND_ONE 0x00000010 #define MASK_DSTBLEND_SRC_COLOR 0x00000020 @@ -709,19 +915,19 @@ #define OP_3D_FIRE_TFIRE 0x00000000 #define OP_3D_FIRE_TSARGBa 0x00000100 -#define OP_3D_FIRE_TSWa 0x00000200 +#define OP_3D_FIRE_TSWa 0x00000200 #define OP_3D_FIRE_TSVAa 0x00000300 #define OP_3D_FIRE_TSVBa 0x00000400 #define OP_3D_FIRE_TSVCa 0x00000500 #define OP_3D_FIRE_TSARGBb 0x00000900 -#define OP_3D_FIRE_TSWb 0x00000a00 +#define OP_3D_FIRE_TSWb 0x00000a00 #define OP_3D_FIRE_TSVAb 0x00000b00 #define OP_3D_FIRE_TSVBb 0x00000c00 #define OP_3D_FIRE_TSVCb 0x00000d00 #define OP_3D_FIRE_TSARGBc 0x00001100 -#define OP_3D_FIRE_TSWc 0x00001200 +#define OP_3D_FIRE_TSWc 0x00001200 #define OP_3D_FIRE_TSVAc 0x00001300 #define OP_3D_FIRE_TSVBc 0x00001400 #define OP_3D_FIRE_TSVCc 0x00001500 @@ -736,6 +942,8 @@ #define OP_3D_TextureBumpFromB 0x00010000 #define OP_3D_TextureBumpFromC 0x00020000 +#define OP_3D_CullDirection_CCW 0x08000000 + #define SHADE_FLAT_VertexA 0x01000000 #define SHADE_FLAT_VertexB 0x02000000 #define SHADE_FLAT_VertexC 0x03000000 @@ -863,11 +1071,6 @@ #define TEXEL_LUV655 0x02800000 #define TEXEL_LUV888 0x03000000 -#define FOGMODE_CHEAP 0x04000000 -#define FOGMODE_LINEAR 0x05000000 -#define FOGMODE_EXP 0x06000000 -#define FOGMODE_EXP2 0x07000000 - #define Z_16 0x00000000 #define S_1_Z_15 0x00400000 #define Z_32 0x00800000 @@ -888,95 +1091,5 @@ #define TEXTURE_FILTER_LINEAR_MIP_NEAREST 0x0000c000 #define TEXTURE_FILTER_LINEAR_MIP_LINEAR 0x00014000 -#define A_REPLACE_RGB_STAGE0 0xa1485000 -#define A_REPLACE_A_STAGE0 0xc3230000 -#define L_REPLACE__RGB_STAGE0 0xc1485000 -#define L_REPLACE__A_STAGE0 0x63230000 -#define LA_REPLACE__RGB_STAGE0 0xc1485000 -#define LA_REPLACE__A_STAGE0 0xc3230000 -#define I_REPLACE__RGB_STAGE0 0xc1485000 -#define I_REPLACE__A_STAGE0 0xc3230000 -#define RGB_REPLACE__RGB_STAGE0 0xc1485000 -#define RGB_REPLACE__A_STAGE0 0x63230000 -#define RGBA_REPLACE__RGB_STAGE0 0xc1485000 -#define RGBA_REPLACE__A_STAGE0 0xc3230000 - -#define A_MODULATE_RGB_STAGE0 0xa1485000 -#define A_MODULATE_A_STAGE0 0x63c30000 -#define L_MODULATE__RGB_STAGE0 0xa1705000 -#define L_MODULATE__A_STAGE0 0x63230000 -#define LA_MODULATE__RGB_STAGE0 0xa1705000 -#define LA_MODULATE__A_STAGE0 0x63c30000 -#define I_MODULATE__RGB_STAGE0 0xa1705000 -#define I_MODULATE__A_STAGE0 0x63c30000 -#define RGB_MODULATE__RGB_STAGE0 0xa1705000 -#define RGB_MODULATE__A_STAGE0 0x63230000 -#define RGBA_MODULATE__RGB_STAGE0 0xa1705000 -#define RGBA_MODULATE__A_STAGE0 0x63c30000 - -#define RGB_DECAL__RGB_STAGE0 0xc1485000 -#define RGB_DECAL__A_STAGE0 0x63230000 -#define RGBA_DECAL__RGB_STAGE0 0xc534c001 -#define RGBA_DECAL__A_STAGE0 0x63230000 - -#define A_BLEND_RGB_STAGE0 0xa1485000 -#define A_BLEND_A_STAGE0 0x63c30000 -#define L_BLEND__RGB_STAGE0 0x4530c001 -#define L_BLEND__A_STAGE0 0x63230000 -#define LA_BLEND__RGB_STAGE0 0x4530c001 -#define LA_BLEND__A_STAGE0 0x63c30000 -#define I_BLEND__RGB_STAGE0 0x4530c001 -#define I_BLEND__A_STAGE0 0x46c60001 -#define RGB_BLEND__RGB_STAGE0 0x4530c001 -#define RGB_BLEND__A_STAGE0 0x63230000 -#define RGBA_BLEND__RGB_STAGE0 0x4530c001 -#define RGBA_BLEND__A_STAGE0 0x63c30000 - -#define RGB_STAGE1 0xa1485000 -#define A_STAGE1 0xa3230000 - -#define A_REPLACE_RGB_STAGE1 0xa1485000 -#define A_REPLACE_A_STAGE1 0xe3230000 -#define L_REPLACE__RGB_STAGE1 0xe1485000 -#define L_REPLACE__A_STAGE1 0xa3230000 -#define LA_REPLACE__RGB_STAGE1 0xe1485000 -#define LA_REPLACE__A_STAGE1 0xe3230000 -#define I_REPLACE__RGB_STAGE1 0xe1485000 -#define I_REPLACE__A_STAGE1 0xe3230000 -#define RGB_REPLACE__RGB_STAGE1 0xe1485000 -#define RGB_REPLACE__A_STAGE1 0xa3230000 -#define RGBA_REPLACE__RGB_STAGE1 0xe1485000 -#define RGBA_REPLACE__A_STAGE1 0xe3230000 - -#define A_MODULATE_RGB_STAGE1 0xa1485000 -#define A_MODULATE_A_STAGE1 0xa3e30000 -#define L_MODULATE__RGB_STAGE1 0xa1785000 -#define L_MODULATE__A_STAGE1 0xa3230000 -#define LA_MODULATE__RGB_STAGE1 0xa1785000 -#define LA_MODULATE__A_STAGE1 0xa3e30000 -#define I_MODULATE__RGB_STAGE1 0xa1785000 -#define I_MODULATE__A_STAGE1 0xa3e30000 -#define RGB_MODULATE__RGB_STAGE1 0xa1785000 -#define RGB_MODULATE__A_STAGE1 0xa3230000 -#define RGBA_MODULATE__RGB_STAGE1 0xa1785000 -#define RGBA_MODULATE__A_STAGE1 0xa3e30000 - -#define RGB_DECAL__RGB_STAGE1 0xe1485000 -#define RGB_DECAL__A_STAGE1 0xa3230000 -#define RGBA_DECAL__RGB_STAGE1 0xe5394001 -#define RGBA_DECAL__A_STAGE1 0xa3230000 - -#define A_BLEND_RGB_STAGE1 0xa1485000 -#define A_BLEND_A_STAGE1 0xa3e30000 -#define L_BLEND__RGB_STAGE1 0x45394001 -#define L_BLEND__A_STAGE1 0xa3230000 -#define LA_BLEND__RGB_STAGE1 0x45394001 -#define LA_BLEND__A_STAGE1 0xa3e30000 -#define I_BLEND__RGB_STAGE1 0x45394001 -#define I_BLEND__A_STAGE1 0x4aea0001 -#define RGB_BLEND__RGB_STAGE1 0x45394001 -#define RGB_BLEND__A_STAGE1 0xa3230000 -#define RGBA_BLEND__RGB_STAGE1 0x45394001 -#define RGBA_BLEND__A_STAGE1 0xa3e30000 #endif 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_render.c Mon Aug 25 00:15:50 2003 @@ -32,8 +32,7 @@ * */ -#include "sis_ctx.h" -#include "sis_mesa.h" +#include "sis_context.h" #define SIS_SMOOTH 0x1 #define SIS_USE_W 0x2 @@ -46,14 +45,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; -/* export to sis_fastpath.c */ +static GLint AGP_EngineOffset; +static GLint *AGP_StartPtr; float *AGP_CurrentPtr; #define SIS_TAG(x) x##_flat @@ -179,7 +177,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 +188,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 +198,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 +252,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 +275,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 +286,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 +296,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 +337,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 +381,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 +413,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 { @@ -438,89 +436,17 @@ } } } - - /* fast path */ - 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; - } - else{ - hwcx->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; */ } -void -sis_StartAGP (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - DWORD start, end; - - start = *(hwcx->pAGPCmdBufNext); - end = start + AGP_ALLOC_SIZE; - if (end >= hwcx->AGPCmdBufSize) - { - start = 0; - end = AGP_ALLOC_SIZE; - } - - /* - * TODO: use AGP_EngineOffset to get a safe value and not query current - * postion processed every time - * ?? use < instead of <= - */ - do - { - AGP_EngineOffset = - *(DWORD volatile *) (GET_IOBase (hwcx) + REG_3D_AGPCmBase) - - (DWORD) hwcx->AGPCmdBufAddr; - } - while ((AGP_EngineOffset <= end) && (AGP_EngineOffset >= start) - && ((*(GET_IOBase (hwcx) + 0x8243) & 0xe0) != 0xe0)); - - AGP_StartPtr = (DWORD *) (start + hwcx->AGPCmdBufBase); - AGP_CurrentPtr = (float *) AGP_StartPtr; -} - -void -sis_FlushAGP (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - /* TODO: wait queue length */ - - if((DWORD *)AGP_CurrentPtr == AGP_StartPtr) - { - return; - } - - mWait3DCmdQueue (5); - mEndPrimitive (); - MMIO (REG_3D_AGPCmBase, ((DWORD) AGP_StartPtr - (DWORD) hwcx->AGPCmdBufBase) - + (DWORD) hwcx->AGPCmdBufAddr); - MMIO (REG_3D_AGPTtDwNum, - (((DWORD) AGP_CurrentPtr - (DWORD) AGP_StartPtr) >> 2) | 0x50000000); - MMIO (REG_3D_ParsingSet, hwcx->AGPParseSet); - - MMIO (REG_3D_AGPCmFire, (DWORD) (-1)); - mEndPrimitive (); - - *(hwcx->pAGPCmdBufNext) = - (DWORD) AGP_CurrentPtr - (DWORD) hwcx->AGPCmdBufBase; - *(hwcx->pAGPCmdBufNext) = (*(hwcx->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 Fri Aug 22 15:33:20 2003 @@ -0,0 +1,286 @@ +/* $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, 0, 7, 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; + sisScreen->sarea_priv_offset = sisDRIPriv->sarea_priv_offset; + + 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 = smesa->backOffset; + stEngPacket.dwSrcPitch = smesa->backPitch | + ((smesa->bytesPerPixel == 2) ? 0x80000000 : 0xc0000000); + stEngPacket.dwDestBaseAddr = smesa->frontOffset; + 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); + } + + 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; +} + +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 Wed Aug 20 01:48:03 2003 @@ -0,0 +1,61 @@ +/* $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 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_span.c Mon Aug 25 00:15:50 2003 @@ -32,8 +32,10 @@ * */ -#include "sis_ctx.h" -#include "sis_mesa.h" +#include "sis_context.h" +#include "sis_span.h" + +#include "swrast/swrast.h" #define DBG 0 @@ -42,11 +44,12 @@ * call this function without locking, or modify sis_Bitmap */ -#define LOCAL_VARS \ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; \ - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; \ - GLuint pitch = hwcx->swRenderPitch; \ - char *buf = (char *)hwcx->swRenderBase +#define LOCAL_VARS \ + sisContextPtr smesa = SIS_CONTEXT(ctx); \ + char *buf = (char *)(smesa->FbBase + smesa->drawOffset); \ + char *read_buf = (char *)(smesa->FbBase + smesa->readOffset); \ + GLuint p; \ + (void) read_buf; (void) buf; (void) p #define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \ _y >= miny && _y < maxy) @@ -61,43 +64,41 @@ if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \ } -#define HW_LOCK() do{}while(0); +#define HW_LOCK() do{} while(0); -#define HW_CLIPLOOP() \ - do { \ - BoxPtr _pExtents; \ - int _nc; \ - GLuint _x, _y; \ - sis_get_drawable_origin (xmesa, &_x, &_y); \ - sis_get_clip_rects (xmesa, &_pExtents, &_nc); \ - while (_nc--) { \ - int minx = _pExtents->x1 - _x; \ - int miny = _pExtents->y1 - _y; \ - int maxx = _pExtents->x2 - _x; \ - int maxy = _pExtents->y2 - _y; \ - _pExtents++; - -#define HW_ENDCLIPLOOP() \ - } \ - } while (0) +#define HW_CLIPLOOP() \ + do { \ + __DRIdrawablePrivate *dPriv = smesa->driDrawable; \ + int _nc = dPriv->numClipRects; \ + \ + while ( _nc-- ) { \ + int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \ + int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \ + int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \ + int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y; + +#define HW_ENDCLIPLOOP() \ + } \ + } while (0) #define HW_UNLOCK() do{}while(0); /* RGB565 */ -#define INIT_MONO_PIXEL(p) \ - GLushort p = hwcx->pixelValue; +#define INIT_MONO_PIXEL(p, color) \ + p = SISPACKCOLOR565( color[0], color[1], color[2] ) #define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = ( ((r & 0xf8) << 8) | \ - ((g & 0xfc) << 3) | \ - (b >> 3)) + *(GLushort *)(buf + _x*2 + _y*smesa->drawPitch) = \ + (((r & 0xf8) << 8) | \ + ((g & 0xfc) << 3) | \ + (b >> 3)) #define WRITE_PIXEL( _x, _y, p ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = p + *(GLushort *)(buf + _x*2 + _y*smesa->drawPitch) = p #define READ_RGBA( rgba, _x, _y ) \ do { \ - GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \ + GLushort p = *(GLushort *)(read_buf + _x*2 + _y*smesa->readPitch); \ rgba[0] = (p & 0xf800) >> 8; \ rgba[1] = (p & 0x07e0) >> 3; \ rgba[2] = (p & 0x001f) << 3; \ @@ -106,35 +107,26 @@ #define TAG(x) sis_##x##_565 #include "spantmp.h" -static void sis_Color_565( GLcontext *ctx, - GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - hwcx->pixelValue = ((red & 0xf8) << 8) | - ((green & 0xfc) << 3) | - (blue >> 3); -} /* ARGB8888 */ #undef INIT_MONO_PIXEL -#define INIT_MONO_PIXEL(p) \ - GLuint p = hwcx->pixelValue; +#define INIT_MONO_PIXEL(p, color) \ + p = SISPACKCOLOR8888( color[0], color[1], color[2], color[3] ) #define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLuint *)(buf + _x*4 + _y*pitch) = ( ((a) << 24) | \ - ((r) << 16) | \ - ((g) << 8) | \ - ((b))) + *(GLuint *)(buf + _x*4 + _y*smesa->drawPitch) = \ + (((a) << 24) | \ + ((r) << 16) | \ + ((g) << 8) | \ + ((b))) #define WRITE_PIXEL( _x, _y, p ) \ - *(GLuint *)(buf + _x*4 + _y*pitch) = p + *(GLuint *)(buf + _x*4 + _y*smesa->drawPitch) = p #define READ_RGBA( rgba, _x, _y ) \ do { \ - GLuint p = *(GLuint *)(buf + _x*4 + _y*pitch); \ + GLuint p = *(GLuint *)(read_buf + _x*4 + _y*smesa->readPitch); \ rgba[0] = (p >> 16) & 0xff; \ rgba[1] = (p >> 8) & 0xff; \ rgba[2] = (p >> 0) & 0xff; \ @@ -143,63 +135,14 @@ #define TAG(x) sis_##x##_8888 #include "spantmp.h" -static void sis_Color_8888( GLcontext *ctx, - GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - hwcx->pixelValue = (red << 16) | - (green << 8) | - (blue) | - (alpha << 24); -} - -void sis_sw_init_driver( GLcontext *ctx ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - if (hwcx->colorFormat == DST_FORMAT_RGB_565) { - ctx->Driver.Color = sis_Color_565; - ctx->Driver.WriteRGBASpan = sis_WriteRGBASpan_565; - ctx->Driver.WriteRGBSpan = sis_WriteRGBSpan_565; - ctx->Driver.WriteMonoRGBASpan = sis_WriteMonoRGBASpan_565; - ctx->Driver.WriteRGBAPixels = sis_WriteRGBAPixels_565; - ctx->Driver.WriteMonoRGBAPixels = sis_WriteMonoRGBAPixels_565; - ctx->Driver.ReadRGBASpan = sis_ReadRGBASpan_565; - ctx->Driver.ReadRGBAPixels = sis_ReadRGBAPixels_565; - } - else if(hwcx->colorFormat == DST_FORMAT_ARGB_8888){ - ctx->Driver.Color = sis_Color_8888; - ctx->Driver.WriteRGBASpan = sis_WriteRGBASpan_8888; - ctx->Driver.WriteRGBSpan = sis_WriteRGBSpan_8888; - ctx->Driver.WriteMonoRGBASpan = sis_WriteMonoRGBASpan_8888; - ctx->Driver.WriteRGBAPixels = sis_WriteRGBAPixels_8888; - ctx->Driver.WriteMonoRGBAPixels = sis_WriteMonoRGBAPixels_8888; - ctx->Driver.ReadRGBASpan = sis_ReadRGBASpan_8888; - ctx->Driver.ReadRGBAPixels = sis_ReadRGBAPixels_8888; - } - else{ - assert(0); - } - - ctx->Driver.WriteCI8Span =NULL; - ctx->Driver.WriteCI32Span =NULL; - ctx->Driver.WriteMonoCISpan =NULL; - ctx->Driver.WriteCI32Pixels =NULL; - ctx->Driver.WriteMonoCIPixels =NULL; - ctx->Driver.ReadCI32Span =NULL; - ctx->Driver.ReadCI32Pixels =NULL; -} /* Depth/Stencil Functions * use sizeof(GLdepth) to know the Z rnage of mesa is * 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 @@ -275,46 +218,106 @@ #undef SIS_SW_STENCIL_FUNC +/* + * This function is called to specify which buffer to read and write + * for software rasterization (swrast) fallbacks. This doesn't necessarily + * correspond to glDrawBuffer() or glReadBuffer() calls. + */ +static void sisDDSetBuffer( GLcontext *ctx, + GLframebuffer *colorBuffer, + GLuint bufferBit ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + switch ( bufferBit ) { + case FRONT_LEFT_BIT: + smesa->drawOffset = smesa->readOffset = smesa->frontOffset; + smesa->drawPitch = smesa->readPitch = smesa->frontPitch; + break; + case BACK_LEFT_BIT: + smesa->drawOffset = smesa->readOffset = smesa->backOffset; + smesa->drawPitch = smesa->readPitch = smesa->backPitch; + break; + default: + break; + } +} + void -sis_sw_set_zfuncs_static (GLcontext * ctx) +sisDDInitSpanFuncs( GLcontext *ctx ) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); + struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); + + swdd->SetBuffer = sisDDSetBuffer; - switch (hwcx->zFormat) - { - case Z_16: - ctx->Driver.ReadDepthSpan = sis_ReadDepthSpan_Z16; - ctx->Driver.ReadDepthPixels = sis_ReadDepthPixels_Z16; - ctx->Driver.WriteDepthSpan = sis_WriteDepthSpan_Z16; - ctx->Driver.WriteDepthPixels = sis_WriteDepthPixels_Z16; - - ctx->Driver.ReadStencilSpan = NULL; - ctx->Driver.ReadStencilPixels = NULL; - ctx->Driver.WriteStencilSpan = NULL; - ctx->Driver.WriteStencilPixels = NULL; + switch (smesa->zFormat) + { + case Z_16: + swdd->ReadDepthSpan = sis_ReadDepthSpan_Z16; + swdd->ReadDepthPixels = sis_ReadDepthPixels_Z16; + swdd->WriteDepthSpan = sis_WriteDepthSpan_Z16; + swdd->WriteDepthPixels = sis_WriteDepthPixels_Z16; + + swdd->ReadStencilSpan = NULL; + swdd->ReadStencilPixels = NULL; + swdd->WriteStencilSpan = NULL; + swdd->WriteStencilPixels = NULL; break; - case Z_32: - ctx->Driver.ReadDepthSpan = sis_ReadDepthSpan_Z32; - ctx->Driver.ReadDepthPixels = sis_ReadDepthPixels_Z32; - ctx->Driver.WriteDepthSpan = sis_WriteDepthSpan_Z32; - ctx->Driver.WriteDepthPixels = sis_WriteDepthPixels_Z32; - - ctx->Driver.ReadStencilSpan = NULL; - ctx->Driver.ReadStencilPixels = NULL; - ctx->Driver.WriteStencilSpan = NULL; - ctx->Driver.WriteStencilPixels = NULL; + case Z_32: + swdd->ReadDepthSpan = sis_ReadDepthSpan_Z32; + swdd->ReadDepthPixels = sis_ReadDepthPixels_Z32; + swdd->WriteDepthSpan = sis_WriteDepthSpan_Z32; + swdd->WriteDepthPixels = sis_WriteDepthPixels_Z32; + + swdd->ReadStencilSpan = NULL; + swdd->ReadStencilPixels = NULL; + swdd->WriteStencilSpan = NULL; + swdd->WriteStencilPixels = NULL; break; - case S_8_Z_24: - ctx->Driver.ReadDepthSpan = sis_ReadDepthSpan_S8Z24; - ctx->Driver.ReadDepthPixels = sis_ReadDepthPixels_S8Z24; - ctx->Driver.WriteDepthSpan = sis_WriteDepthSpan_S8Z24; - ctx->Driver.WriteDepthPixels = sis_WriteDepthPixels_S8Z24; - - ctx->Driver.ReadStencilSpan = sis_ReadStencilSpan_S8Z24; - ctx->Driver.ReadStencilPixels = sis_ReadStencilPixels_S8Z24; - ctx->Driver.WriteStencilSpan = sis_WriteStencilSpan_S8Z24; - ctx->Driver.WriteStencilPixels = sis_WriteStencilPixels_S8Z24; + case S_8_Z_24: + swdd->ReadDepthSpan = sis_ReadDepthSpan_S8Z24; + swdd->ReadDepthPixels = sis_ReadDepthPixels_S8Z24; + swdd->WriteDepthSpan = sis_WriteDepthSpan_S8Z24; + swdd->WriteDepthPixels = sis_WriteDepthPixels_S8Z24; + + swdd->ReadStencilSpan = sis_ReadStencilSpan_S8Z24; + swdd->ReadStencilPixels = sis_ReadStencilPixels_S8Z24; + swdd->WriteStencilSpan = sis_WriteStencilSpan_S8Z24; + swdd->WriteStencilPixels = sis_WriteStencilPixels_S8Z24; break; - } + } + + switch ( smesa->bytesPerPixel ) + { + case 2: + swdd->WriteRGBASpan = sis_WriteRGBASpan_565; + swdd->WriteRGBSpan = sis_WriteRGBSpan_565; + swdd->WriteMonoRGBASpan = sis_WriteMonoRGBASpan_565; + swdd->WriteRGBAPixels = sis_WriteRGBAPixels_565; + swdd->WriteMonoRGBAPixels = sis_WriteMonoRGBAPixels_565; + swdd->ReadRGBASpan = sis_ReadRGBASpan_565; + swdd->ReadRGBAPixels = sis_ReadRGBAPixels_565; + break; + case 4: + swdd->WriteRGBASpan = sis_WriteRGBASpan_8888; + swdd->WriteRGBSpan = sis_WriteRGBSpan_8888; + swdd->WriteMonoRGBASpan = sis_WriteMonoRGBASpan_8888; + swdd->WriteRGBAPixels = sis_WriteRGBAPixels_8888; + swdd->WriteMonoRGBAPixels = sis_WriteMonoRGBAPixels_8888; + swdd->ReadRGBASpan = sis_ReadRGBASpan_8888; + swdd->ReadRGBAPixels = sis_ReadRGBAPixels_8888; + break; + default: + assert(0); + break; + } + + swdd->WriteCI8Span = NULL; + swdd->WriteCI32Span = NULL; + swdd->WriteMonoCISpan = NULL; + swdd->WriteCI32Pixels = NULL; + swdd->WriteMonoCIPixels = NULL; + swdd->ReadCI32Span = NULL; + swdd->ReadCI32Pixels = NULL; } diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_span.h xc/lib/GL/mesa/src/drv/sis/sis_span.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_span.h Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_span.h Tue Aug 12 12:03:20 2003 @@ -0,0 +1,43 @@ +/************************************************************************** + +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 + * + */ + +#ifndef __SIS_SPAN_H__ +#define __SIS_SPAN_H__ + +#ifdef GLX_DIRECT_RENDERING + +extern void sisDDInitSpanFuncs( GLcontext *ctx ); + +#endif +#endif diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_state.c xc/lib/GL/mesa/src/drv/sis/sis_state.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_state.c Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_state.c Mon Aug 25 00:15:50 2003 @@ -0,0 +1,886 @@ +/************************************************************************** + +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_state.h" +#include "sis_tris.h" + +#include "context.h" +#include "enums.h" +#include "colormac.h" +#include "swrast/swrast.h" +#include "array_cache/acache.h" +#include "tnl/tnl.h" +#include "swrast_setup/swrast_setup.h" + +#include "tnl/t_pipeline.h" + +/* ============================================================= + * Alpha blending + */ + +static void +sisDDAlphaFunc( GLcontext * ctx, GLenum func, GLclampf ref ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + __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; + + /* Alpha Test function */ + current->hwAlpha &= ~MASK_AlphaTestMode; + switch (func) + { + case GL_NEVER: + current->hwAlpha |= SiS_ALPHA_NEVER; + break; + case GL_LESS: + current->hwAlpha |= SiS_ALPHA_LESS; + break; + case GL_EQUAL: + current->hwAlpha |= SiS_ALPHA_EQUAL; + break; + case GL_LEQUAL: + current->hwAlpha |= SiS_ALPHA_LEQUAL; + break; + case GL_GREATER: + current->hwAlpha |= SiS_ALPHA_GREATER; + break; + case GL_NOTEQUAL: + current->hwAlpha |= SiS_ALPHA_NOTEQUAL; + break; + case GL_GEQUAL: + current->hwAlpha |= SiS_ALPHA_GEQUAL; + break; + case GL_ALWAYS: + current->hwAlpha |= SiS_ALPHA_ALWAYS; + break; + } + + prev->hwAlpha = current->hwAlpha; + smesa->GlobalFlag |= GFLAG_ALPHASETTING; +} + +static void +sisDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + /* TODO: in ICD, if no blend, it will reset these value */ + /* blending enable */ + current->hwDstSrcBlend = 0x10000; /* Default destination alpha */ + + switch (dfactor) + { + case GL_ZERO: + current->hwDstSrcBlend |= SiS_D_ZERO; + break; + case GL_ONE: + current->hwDstSrcBlend |= SiS_D_ONE; + break; + case GL_SRC_COLOR: + current->hwDstSrcBlend |= SiS_D_SRC_COLOR; + break; + case GL_ONE_MINUS_SRC_COLOR: + current->hwDstSrcBlend |= SiS_D_ONE_MINUS_SRC_COLOR; + break; + case GL_SRC_ALPHA: + current->hwDstSrcBlend |= SiS_D_SRC_ALPHA; + break; + case GL_ONE_MINUS_SRC_ALPHA: + current->hwDstSrcBlend |= SiS_D_ONE_MINUS_SRC_ALPHA; + break; + case GL_DST_ALPHA: + current->hwDstSrcBlend |= SiS_D_DST_ALPHA; + break; + case GL_ONE_MINUS_DST_ALPHA: + current->hwDstSrcBlend |= SiS_D_ONE_MINUS_DST_ALPHA; + break; + } + + switch (sfactor) + { + case GL_ZERO: + current->hwDstSrcBlend |= SiS_S_ZERO; + break; + case GL_ONE: + current->hwDstSrcBlend |= SiS_S_ONE; + break; + case GL_SRC_ALPHA: + current->hwDstSrcBlend |= SiS_S_SRC_ALPHA; + break; + case GL_ONE_MINUS_SRC_ALPHA: + current->hwDstSrcBlend |= SiS_S_ONE_MINUS_SRC_ALPHA; + break; + case GL_DST_ALPHA: + current->hwDstSrcBlend |= SiS_S_DST_ALPHA; + break; + case GL_ONE_MINUS_DST_ALPHA: + current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_ALPHA; + break; + case GL_DST_COLOR: + current->hwDstSrcBlend |= SiS_S_DST_COLOR; + break; + case GL_ONE_MINUS_DST_COLOR: + current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_COLOR; + break; + case GL_SRC_ALPHA_SATURATE: + current->hwDstSrcBlend |= SiS_S_SRC_ALPHA_SATURATE; + break; + } + + if (current->hwDstSrcBlend ^ prev->hwDstSrcBlend) { + prev->hwDstSrcBlend = current->hwDstSrcBlend; + smesa->GlobalFlag |= GFLAG_DSTBLEND; + } +} + +/* ============================================================= + * Depth testing + */ + +static void +sisDDDepthFunc( GLcontext * ctx, GLenum func ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + GLuint hwZFunc = 0; + + switch (func) + { + case GL_LESS: + hwZFunc = SiS_Z_COMP_S_LT_B; + break; + case GL_GEQUAL: + hwZFunc = SiS_Z_COMP_S_GE_B; + break; + case GL_LEQUAL: + hwZFunc = SiS_Z_COMP_S_LE_B; + break; + case GL_GREATER: + hwZFunc = SiS_Z_COMP_S_GT_B; + break; + case GL_NOTEQUAL: + hwZFunc = SiS_Z_COMP_S_NE_B; + break; + case GL_EQUAL: + hwZFunc = SiS_Z_COMP_S_EQ_B; + break; + case GL_ALWAYS: + hwZFunc = SiS_Z_COMP_ALWAYS; + break; + case GL_NEVER: + hwZFunc = SiS_Z_COMP_NEVER; + break; + } + current->hwZ &= ~MASK_ZTestMode; + current->hwZ |= hwZFunc; + + if (current->hwZ ^ prev->hwZ) { + prev->hwZ = current->hwZ; + smesa->GlobalFlag |= GFLAG_ZSETTING; + } +} + +void +sisDDDepthMask( GLcontext * ctx, GLboolean flag ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + if (ctx->Visual.stencilBits) { + if (flag || ctx->Stencil.WriteMask) { + current->hwCapEnable |= MASK_ZWriteEnable; + if (flag && ctx->Stencil.WriteMask[0] == 0xff) { /* XXX WriteMask[0]? */ + current->hwCapEnable2 &= ~MASK_ZMaskWriteEnable; + } else { + current->hwCapEnable2 |= MASK_ZMaskWriteEnable; + current->hwZMask = ((GLint) ctx->Stencil.WriteMask << 24) | + ((flag) ? 0x00ffffff : 0); + + if (current->hwZMask ^ prev->hwZMask) { + prev->hwZMask = current->hwZMask; + smesa->GlobalFlag |= GFLAG_ZSETTING; + } + } + } else { + current->hwCapEnable &= ~MASK_ZWriteEnable; + } + } else { + if (flag) { + current->hwCapEnable |= MASK_ZWriteEnable; + current->hwCapEnable2 &= ~MASK_ZMaskWriteEnable; + } else { + current->hwCapEnable &= ~MASK_ZWriteEnable; + } + } +} + +/* ============================================================= + * Clipping + */ + +void +sisUpdateClipping( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + GLint x1, y1, x2, y2; + + /* ?? from context.c, do it 2 times */ + + x1 = 0; + y1 = 0; + x2 = smesa->width - 1; + y2 = smesa->height - 1; + + if (ctx->Scissor.Enabled) { + if (ctx->Scissor.X > x1) + x1 = ctx->Scissor.X; + if (ctx->Scissor.Y > y1) + y1 = ctx->Scissor.Y; + if (ctx->Scissor.X + ctx->Scissor.Width - 1 < x2) + x2 = ctx->Scissor.X + ctx->Scissor.Width - 1; + if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < y2) + y2 = ctx->Scissor.Y + ctx->Scissor.Height - 1; + } + + y1 = Y_FLIP (y1); + y2 = Y_FLIP (y2); + + current->clipTopBottom = (y2 << 13) | y1; + current->clipLeftRight = (x1 << 13) | x2; + + if ((current->clipTopBottom ^ prev->clipTopBottom) || + (current->clipLeftRight ^ prev->clipLeftRight)) + { + prev->clipTopBottom = current->clipTopBottom; + prev->clipLeftRight = current->clipLeftRight; + smesa->GlobalFlag |= GFLAG_CLIPPING; + } +} + +static void +sisDDScissor( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) +{ + if (ctx->Scissor.Enabled) + sisUpdateClipping( ctx ); +} + +/* ============================================================= + * Culling + */ + +static void +sisUpdateCull( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + GLint cullflag, frontface; + + cullflag = ctx->Polygon.CullFlag; + frontface = ctx->Polygon.FrontFace; + + if (cullflag == GL_FRONT_AND_BACK) { + FALLBACK(smesa, SIS_FALLBACK_CULL, 1); + return; + } else { + FALLBACK(smesa, SIS_FALLBACK_CULL, 0); + } + + smesa->AGPParseSet &= ~(MASK_PsCullDirection_CCW); + smesa->dwPrimitiveSet &= ~(MASK_CullDirection); + + if((cullflag == GL_FRONT && frontface == GL_CCW) || + (cullflag == GL_BACK && frontface == GL_CW)) + { + smesa->AGPParseSet |= 0x00008000; + smesa->dwPrimitiveSet |= OP_3D_CullDirection_CCW; + } +} + + +static void +sisDDCullFace( GLcontext *ctx, GLenum mode ) +{ + sisUpdateCull( ctx ); +} + +static void +sisDDFrontFace( GLcontext *ctx, GLenum mode ) +{ + sisUpdateCull( ctx ); +} + +/* ============================================================= + * Masks + */ + +static void sisDDColorMask( GLcontext *ctx, + GLboolean r, GLboolean g, + GLboolean b, GLboolean a ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + /* XXX */ + if (r & g & b & (!ctx->Visual.alphaBits | a)) { + current->hwCapEnable2 &= ~(MASK_AlphaMaskWriteEnable | + MASK_ColorMaskWriteEnable); + } else { + current->hwCapEnable2 |= (MASK_AlphaMaskWriteEnable | + MASK_ColorMaskWriteEnable); + + current->hwDstMask = (r) ? GET_RMASK(smesa) : 0 | + (g) ? GET_GMASK(smesa) : 0 | + (b) ? GET_BMASK(smesa) : 0 | + (a) ? GET_AMASK(smesa) : 0; + } + + if (current->hwDstMask != prev->hwDstMask) { + prev->hwDstMask = current->hwDstMask; + smesa->GlobalFlag |= GFLAG_DESTSETTING; + } +} + +/* ============================================================= + * Rendering attributes + */ + +/* ============================================================= + * Window position + */ + +/* ============================================================= + * Viewport + */ + +static void sisCalcViewport( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + const GLfloat *v = ctx->Viewport._WindowMap.m; + GLfloat *m = smesa->hw_viewport; + + /* See also sis_translate_vertex. + */ + m[MAT_SX] = v[MAT_SX]; + m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X; + m[MAT_SY] = - v[MAT_SY]; + m[MAT_TY] = - v[MAT_TY] + smesa->driDrawable->h + SUBPIXEL_Y; + m[MAT_SZ] = v[MAT_SZ] * smesa->depth_scale; + m[MAT_TZ] = v[MAT_TZ] * smesa->depth_scale; +} + +static void sisDDViewport( GLcontext *ctx, + GLint x, GLint y, + GLsizei width, GLsizei height ) +{ + sisCalcViewport( ctx ); +} + +static void sisDDDepthRange( GLcontext *ctx, + GLclampd nearval, GLclampd farval ) +{ + sisCalcViewport( ctx ); +} + +/* ============================================================= + * Miscellaneous + */ + +static void +sisDDLogicOpCode( GLcontext *ctx, GLenum opcode ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + if (!ctx->Color.ColorLogicOpEnabled) + return; + + current->hwDstSet &= ~MASK_ROP2; + switch (opcode) + { + case GL_CLEAR: + current->hwDstSet |= LOP_CLEAR; + break; + case GL_SET: + current->hwDstSet |= LOP_SET; + break; + case GL_COPY: + current->hwDstSet |= LOP_COPY; + break; + case GL_COPY_INVERTED: + current->hwDstSet |= LOP_COPY_INVERTED; + break; + case GL_NOOP: + current->hwDstSet |= LOP_NOOP; + break; + case GL_INVERT: + current->hwDstSet |= LOP_INVERT; + break; + case GL_AND: + current->hwDstSet |= LOP_AND; + break; + case GL_NAND: + current->hwDstSet |= LOP_NAND; + break; + case GL_OR: + current->hwDstSet |= LOP_OR; + break; + case GL_NOR: + current->hwDstSet |= LOP_NOR; + break; + case GL_XOR: + current->hwDstSet |= LOP_XOR; + break; + case GL_EQUIV: + current->hwDstSet |= LOP_EQUIV; + break; + case GL_AND_REVERSE: + current->hwDstSet |= LOP_AND_REVERSE; + break; + case GL_AND_INVERTED: + current->hwDstSet |= LOP_AND_INVERTED; + break; + case GL_OR_REVERSE: + current->hwDstSet |= LOP_OR_REVERSE; + break; + case GL_OR_INVERTED: + current->hwDstSet |= LOP_OR_INVERTED; + break; + } + + if (current->hwDstSet ^ prev->hwDstSet) { + prev->hwDstSet = current->hwDstSet; + smesa->GlobalFlag |= GFLAG_DESTSETTING; + } +} + +void sisDDDrawBuffer( GLcontext *ctx, GLenum mode ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + /* We want to update the s/w rast state too so that sisDDSetBuffer() + * gets called. + */ + _swrast_DrawBuffer(ctx, mode); + + current->hwOffsetDest = (smesa->drawOffset) >> 1; + current->hwDstSet &= ~MASK_DstBufferPitch; + current->hwDstSet |= smesa->drawPitch >> 2; + + if (current->hwDstSet != prev->hwDstSet) { + prev->hwDstSet = current->hwDstSet; + smesa->GlobalFlag |= GFLAG_DESTSETTING; + } + + if (current->hwOffsetDest != prev->hwOffsetDest) { + prev->hwOffsetDest = current->hwOffsetDest; + smesa->GlobalFlag |= GFLAG_DESTSETTING; + } +} + +/* ============================================================= + * Polygon stipple + */ + +/* ============================================================= + * Render mode + */ + +/* ============================================================= + * State enable/disable + */ + +static void +sisDDEnable( GLcontext * ctx, GLenum cap, GLboolean state ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + __GLSiSHardware *current = &smesa->current; + + switch (cap) + { + case GL_ALPHA_TEST: + if (state) + current->hwCapEnable |= MASK_AlphaTestEnable; + else + current->hwCapEnable &= ~MASK_AlphaTestEnable; + break; +/* + case GL_AUTO_NORMAL: + break; +*/ + case GL_BLEND: + /* TODO: */ + if (state) + /* if (state & !ctx->Color.ColorLogicOpEnabled) */ + current->hwCapEnable |= MASK_BlendEnable; + else + current->hwCapEnable &= ~MASK_BlendEnable; + break; +/* + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + break; + case GL_COLOR_MATERIAL: + break; +*/ + case GL_CULL_FACE: +#ifdef SIS_USE_HW_CULL + if (state) + current->hwCapEnable |= MASK_CullEnable; + else + current->hwCapEnable &= ~MASK_CullEnable; +#endif + break; + case GL_DEPTH_TEST: + if (state && smesa->depthbuffer) + current->hwCapEnable |= MASK_ZTestEnable; + else + current->hwCapEnable &= ~MASK_ZTestEnable; + break; + case GL_DITHER: + if (state) + current->hwCapEnable |= MASK_DitherEnable; + else + current->hwCapEnable &= ~MASK_DitherEnable; + break; + case GL_FOG: + if (state) + current->hwCapEnable |= MASK_FogEnable; + else + current->hwCapEnable &= ~MASK_FogEnable; + break; +/* + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + break; + case GL_LIGHTING: + break; + case GL_LINE_SMOOTH: + break; + case GL_LINE_STIPPLE: + break; + case GL_INDEX_LOGIC_OP: + break; +*/ + case GL_COLOR_LOGIC_OP: + if (state) + sisDDLogicOpCode( ctx, ctx->Color.LogicOp ); + else + sisDDLogicOpCode( ctx, GL_COPY ); + break; +/* + case GL_MAP1_COLOR_4: + break; + case GL_MAP1_INDEX: + break; + case GL_MAP1_NORMAL: + break; + case GL_MAP1_TEXTURE_COORD_1: + break; + case GL_MAP1_TEXTURE_COORD_2: + break; + case GL_MAP1_TEXTURE_COORD_3: + break; + case GL_MAP1_TEXTURE_COORD_4: + break; + case GL_MAP1_VERTEX_3: + break; + case GL_MAP1_VERTEX_4: + break; + case GL_MAP2_COLOR_4: + break; + case GL_MAP2_INDEX: + break; + case GL_MAP2_NORMAL: + break; + case GL_MAP2_TEXTURE_COORD_1: + break; + case GL_MAP2_TEXTURE_COORD_2: + break; + case GL_MAP2_TEXTURE_COORD_3: + break; + case GL_MAP2_TEXTURE_COORD_4: + break; + case GL_MAP2_VERTEX_3: + break; + case GL_MAP2_VERTEX_4: + break; + case GL_NORMALIZE: + break; + case GL_POINT_SMOOTH: + break; + case GL_POLYGON_SMOOTH: + break; + case GL_POLYGON_STIPPLE: + break; + case GL_POLYGON_OFFSET_POINT: + break; + case GL_POLYGON_OFFSET_LINE: + break; + case GL_POLYGON_OFFSET_FILL: + case GL_POLYGON_OFFSET_EXT: + break; + case GL_RESCALE_NORMAL_EXT: + break; +*/ + case GL_SCISSOR_TEST: + sisUpdateClipping( ctx ); + break; +/* + case GL_SHARED_TEXTURE_PALETTE_EXT: + break; +*/ + case GL_STENCIL_TEST: + if (state) + current->hwCapEnable |= (MASK_StencilTestEnable | + MASK_StencilWriteEnable); + else + current->hwCapEnable &= ~(MASK_StencilTestEnable | + MASK_StencilWriteEnable); + break; +/* + case GL_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_TEXTURE_3D: + break; + case GL_TEXTURE_GEN_Q: + break; + case GL_TEXTURE_GEN_R: + break; + case GL_TEXTURE_GEN_S: + break; + case GL_TEXTURE_GEN_T: + break; + + case GL_VERTEX_ARRAY: + break; + case GL_NORMAL_ARRAY: + break; + case GL_COLOR_ARRAY: + break; + case GL_INDEX_ARRAY: + break; + case GL_TEXTURE_COORD_ARRAY: + break; + case GL_EDGE_FLAG_ARRAY: + break; +*/ + } +} + +/* ============================================================= + * State initialization, management + */ + +static void sisDDInvalidateState( GLcontext *ctx, GLuint new_state ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + _swrast_InvalidateState( ctx, new_state ); + _swsetup_InvalidateState( ctx, new_state ); + _ac_InvalidateState( ctx, new_state ); + _tnl_InvalidateState( ctx, new_state ); + smesa->NewGLState |= new_state; + + /* NEW_TEXTURE_ENABLE depends on glEnable() instead of ReallyEnabled */ + /* if (ctx->NewState & NEW_TEXTURE_ENABLE) */ + if (1) { + if ( ctx->Texture.Unit[0]._ReallyEnabled & + (TEXTURE_1D_BIT | TEXTURE_2D_BIT) || + ctx->Texture.Unit[1]._ReallyEnabled & + (TEXTURE_1D_BIT | TEXTURE_2D_BIT) ) + { + current->hwCapEnable |= MASK_TextureEnable; + + current->hwCapEnable &= ~MASK_TextureNumUsed; + if (ctx->Texture.Unit[1]._ReallyEnabled) + current->hwCapEnable |= 0x00002000; + else + current->hwCapEnable |= 0x00001000; + } else { + current->hwCapEnable &= ~MASK_TextureEnable; + } + +#if 1 + /* TODO : if unmark these, error in multitexture */ /* XXX */ + if (new_state & _NEW_TEXTURE) { + int i; + + for (i = 0; i < SIS_MAX_TEXTURES; i++) + smesa->TexStates[i] |= (NEW_TEXTURING | NEW_TEXTURE_ENV); + } +#endif + } + + /* enable setting 1 */ + if (current->hwCapEnable ^ prev->hwCapEnable) { + prev->hwCapEnable = current->hwCapEnable; + smesa->GlobalFlag |= GFLAG_ENABLESETTING; + } + + /* enable setting 2 */ + if (current->hwCapEnable2 ^ prev->hwCapEnable2) { + prev->hwCapEnable2 = current->hwCapEnable2; + smesa->GlobalFlag |= GFLAG_ENABLESETTING2; + } + + /* TODO: if fog disable, don't check */ + if (current->hwCapEnable & MASK_FogEnable) { + /* fog setting */ + if (current->hwFog ^ prev->hwFog) { + prev->hwFog = current->hwFog; + smesa->GlobalFlag |= GFLAG_FOGSETTING; + } + if (current->hwFogFar ^ prev->hwFogFar) { + prev->hwFogFar = current->hwFogFar; + smesa->GlobalFlag |= GFLAG_FOGSETTING; + } + if (current->hwFogInverse ^ prev->hwFogInverse) { + prev->hwFogInverse = current->hwFogInverse; + smesa->GlobalFlag |= GFLAG_FOGSETTING; + } + if (current->hwFogDensity ^ prev->hwFogDensity) { + prev->hwFogDensity = current->hwFogDensity; + smesa->GlobalFlag |= GFLAG_FOGSETTING; + } + } + +#ifdef NOT_DONE + sis_set_render_vb_tabs(ctx); +#endif + + /* TODO: assume when isFullScreen/DrawBuffer changed, UpdateState + * will be called + */ +#if SIS_STEREO + if (smesa->isFullScreen && (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT) && + smesa->useStereo) + { + if (!smesa->stereoEnabled) + sis_init_stereo(ctx); + } else { + if (smesa->stereoEnabled) + sis_final_stereo(ctx); + } +#endif + + /* TODO : 1. where to handle SIS_SW_TEXTURE? + * 2. sw<->hw + * 3. sw-render only if next primitve need to do + */ +} + + +/* Initialize the driver's state functions. + */ +void sisDDInitStateFuncs( GLcontext *ctx ) +{ + ctx->Driver.UpdateState = sisDDInvalidateState; + + ctx->Driver.Clear = sisDDClear; + ctx->Driver.ClearColor = sisDDClearColor; + ctx->Driver.ClearDepth = sisDDClearDepth; + ctx->Driver.ClearStencil = sisDDClearStencil; + + ctx->Driver.AlphaFunc = sisDDAlphaFunc; + ctx->Driver.BlendFunc = sisDDBlendFunc; + ctx->Driver.ColorMask = sisDDColorMask; + ctx->Driver.CullFace = sisDDCullFace; + ctx->Driver.DepthMask = sisDDDepthMask; + ctx->Driver.DepthFunc = sisDDDepthFunc; + ctx->Driver.DepthRange = sisDDDepthRange; + ctx->Driver.DrawBuffer = sisDDDrawBuffer; + ctx->Driver.Enable = sisDDEnable; + ctx->Driver.FrontFace = sisDDFrontFace; + ctx->Driver.Fogfv = sisDDFogfv; + ctx->Driver.Hint = NULL; + ctx->Driver.Lightfv = NULL; + ctx->Driver.LogicOpcode = sisDDLogicOpCode; + ctx->Driver.PolygonMode = NULL; + ctx->Driver.PolygonStipple = NULL; + ctx->Driver.ReadBuffer = NULL; + ctx->Driver.RenderMode = NULL; + ctx->Driver.Scissor = sisDDScissor; + ctx->Driver.ShadeModel = NULL; + ctx->Driver.Viewport = sisDDViewport; + + /* Pixel path fallbacks. + */ + ctx->Driver.Accum = _swrast_Accum; + ctx->Driver.Bitmap = _swrast_Bitmap; + ctx->Driver.CopyPixels = _swrast_CopyPixels; + ctx->Driver.DrawPixels = _swrast_DrawPixels; + ctx->Driver.ReadPixels = _swrast_ReadPixels; /* XXX Accel draw/readpix */ + + /* Swrast hooks for imaging extensions: + */ + ctx->Driver.CopyColorTable = _swrast_CopyColorTable; + ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable; + ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; + ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; +} 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 Fri Aug 22 15:33:20 2003 @@ -0,0 +1,57 @@ +/* $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 sisDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all, + GLint x, GLint y, GLint width, GLint height ); +extern void sisDDClearColor( GLcontext * ctx, const GLfloat color[4] ); +extern void sisDDClearDepth( GLcontext * ctx, GLclampd d ); +extern void sisDDClearStencil( GLcontext * ctx, GLint s ); +extern void sisDDFogfv( GLcontext * ctx, GLenum pname, const GLfloat * params ); +extern void sisDDDepthMask( GLcontext * ctx, GLboolean flag ); + +extern void sisUpdateClipping( GLcontext * gc ); +extern void sisUpdateZStencilPattern( sisContextPtr smesa, GLclampd z, + int stencil ); +extern void sisDDDrawBuffer( GLcontext *ctx, GLenum mode ); + +#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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_stencil.c Mon Aug 25 00:15:50 2003 @@ -32,21 +32,21 @@ * */ -#include "sis_ctx.h" -#include "sis_mesa.h" +#include "sis_context.h" +#include "sis_state.h" +#include "sis_stencil.h" -void -sis_StencilFunc (GLcontext * ctx, GLenum func, GLint ref, GLuint mask) +static void +sisDDStencilFunc( 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; + current->hwStSetting &= ~MASK_StencilTestMode; switch (func) { case GL_NEVER: @@ -81,29 +81,29 @@ prev->hwStSetting = current->hwStSetting; prev->hwStSetting2 = current->hwStSetting2; - hwcx->GlobalFlag |= GFLAG_STENCILSETTING; + smesa->GlobalFlag |= GFLAG_STENCILSETTING; } } -void -sis_StencilMask (GLcontext * ctx, GLuint mask) +static void +sisDDStencilMask( GLcontext * ctx, GLuint mask ) { - if (!ctx->Visual->StencilBits) + if (!ctx->Visual.stencilBits) return; /* set Z buffer Write Enable */ - sis_DepthMask (ctx, ctx->Depth.Mask); + sisDDDepthMask (ctx, ctx->Depth.Mask); } -void -sis_StencilOp (GLcontext * ctx, GLenum fail, GLenum zfail, GLenum zpass) +static void +sisDDStencilOp( 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; + current->hwStSetting2 &= ~(MASK_StencilZPassOp | MASK_StencilZFailOp | + MASK_StencilFailOp); switch (fail) { @@ -177,7 +177,15 @@ prev->hwStSetting = current->hwStSetting; prev->hwStSetting2 = current->hwStSetting2; - hwcx->GlobalFlag |= GFLAG_STENCILSETTING; + smesa->GlobalFlag |= GFLAG_STENCILSETTING; } +} + +void +sisDDInitStencilFuncs( GLcontext *ctx ) +{ + ctx->Driver.StencilFunc = sisDDStencilFunc; + ctx->Driver.StencilMask = sisDDStencilMask; + ctx->Driver.StencilOp = sisDDStencilOp; } diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_stencil.h xc/lib/GL/mesa/src/drv/sis/sis_stencil.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_stencil.h Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_stencil.h Tue Aug 12 12:03:20 2003 @@ -0,0 +1,42 @@ +/* $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_STENCIL_H__ +#define __SIS_STENCIL_H__ + +#ifdef GLX_DIRECT_RENDERING + +extern void sisDDInitStencilFuncs( GLcontext *ctx ); + +#endif +#endif 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h Tue Aug 12 12:03:20 2003 @@ -36,8 +36,7 @@ GLint y, const GLdepth depth[], 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)); @@ -52,8 +51,7 @@ static void SIS_TAG (sis_ReadDepthSpan) (GLcontext * ctx, GLuint n, GLint x, 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)); @@ -69,8 +67,7 @@ const GLdepth depth[], const GLubyte mask[]) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIS_SW_DTYPE *base; @@ -89,8 +86,7 @@ const GLint x[], const GLint y[], GLdepth depth[]) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIS_SW_DTYPE *base; @@ -109,8 +105,7 @@ const GLstencil depth[], 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)); @@ -125,8 +120,7 @@ static void SIS_TAG (sis_ReadStencilSpan) (GLcontext * ctx, GLuint n, GLint x, 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)); @@ -143,8 +137,7 @@ const GLstencil depth[], const GLubyte mask[]) { - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; + sisContextPtr smesa = SIS_CONTEXT(ctx); SIS_SW_DTYPE *base; @@ -163,8 +156,7 @@ const GLint x[], const GLint y[], 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_tex.c xc/lib/GL/mesa/src/drv/sis/sis_tex.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_tex.c Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_tex.c Mon Aug 25 00:15:50 2003 @@ -0,0 +1,372 @@ +/************************************************************************** + +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_texture.c,v 1.5 2000/09/26 15:56:49 tsi Exp $ */ + +/* + * Authors: + * Sung-Ching Lin + * + */ + +#include "sis_context.h" +#include "sis_alloc.h" +#include "sis_tex.h" + +#include "swrast/swrast.h" +#include "imports.h" +#include "texformat.h" +#include "texstore.h" + +#define ALIGN(value, align) (char *)((long)(value + align - 1) & ~(align - 1)) + +#define TEXTURE_HW_ALIGNMENT 4 +#define TEXTURE_HW_PLUS (4 + 4) + +static sisTexObjPtr +sisAllocTexObj( struct gl_texture_object *texObj ) +{ + sisTexObjPtr t; + + t = (sisTexObjPtr) CALLOC_STRUCT( sis_tex_obj ); + texObj->DriverData = t; + if ( t != NULL ) { + + } + return t; +} + +static void +sisAllocTexImage( sisContextPtr smesa, sisTexObjPtr t, int level, + const struct gl_texture_image *image ) +{ + char *addr; + int size, texel_size; + + texel_size = image->TexFormat->TexelBytes; + size = image->Width * image->Height * texel_size + TEXTURE_HW_PLUS; + + addr = sisAllocFB( smesa, size, &t->image[level].handle ); + if (addr == NULL) { + addr = sisAllocAGP( smesa, size, &t->image[level].handle ); + if (addr == NULL) { + fprintf (stderr, "SIS driver : out of video/agp memory\n"); + sis_fatal_error(); + } + t->image[level].memType = AGP_TYPE; + } + else + t->image[level].memType = VIDEO_TYPE; + + t->image[level].Data = ALIGN(addr, TEXTURE_HW_ALIGNMENT); + t->image[level].pitch = image->Width * texel_size; + t->image[level].size = image->Width * image->Height * texel_size; + t->image[level].format = image->Format; + +} + +static void +sisFreeTexImage( sisContextPtr smesa, sisTexObjPtr t, int level ) +{ + if (t->image[level].Data != NULL) { + switch (t->image[level].memType) + { + case VIDEO_TYPE: + sisFreeFB( smesa, t->image[level].handle ); + break; + case AGP_TYPE: + sisFreeAGP( smesa, t->image[level].handle ); + break; + } + } + t->image[level].Data = NULL; + t->image[level].handle = NULL; +} + +static void +sisDDTexEnv( GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; +} + +static void +sisDDTexParameter( GLcontext *ctx, GLenum target, + struct gl_texture_object *texObj, GLenum pname, + const GLfloat *params ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; +} + +static void +sisDDBindTexture( GLcontext *ctx, GLenum target, + struct gl_texture_object *texObj ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + sisTexObjPtr t; + sisTexImage *image; + + if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) { + if ( texObj->DriverData == NULL ) { + sisAllocTexObj( texObj ); + } + } + + t = texObj->DriverData; + image = &t->image[texObj->BaseLevel]; /* XXX */ + + if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != image->format) { + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; + smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = image->format; + } + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; +} + +static void +sisDDDeleteTexture( GLcontext * ctx, struct gl_texture_object *texObj ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + sisTexObjPtr t; + int i; + + smesa->clearTexCache = GL_TRUE; + + t = texObj->DriverData; + if (t == NULL) { + /* + * this shows the texture is default object and never be a + * argument of sisDDTexImage* + */ + return; + } + for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { + sisFreeTexImage( smesa, t, i ); + } + + FREE(t); + texObj->DriverData = NULL; +} + +static GLboolean sisDDIsTextureResident( GLcontext * ctx, + struct gl_texture_object *texObj ) +{ + return (texObj->DriverData != NULL); +} + +static void +sisDDUpdateTexturePalette (GLcontext * ctx, struct gl_texture_object *tObj) +{ + +} + +static void +sisDDActiveTexture (GLcontext * ctx, GLuint texUnitNumber) +{ +} + +static const struct gl_texture_format * +sisDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat, + GLenum format, GLenum type ) +{ + /* XXX 16-bit internal texture formats? */ + switch ( internalFormat ) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return &_mesa_texformat_a8; + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return &_mesa_texformat_l8; + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return &_mesa_texformat_al88; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + return &_mesa_texformat_i8; + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case 3: + case GL_RGB: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return &_mesa_texformat_argb8888 /*_mesa_texformat_rgb888*/; /* XXX */ + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case 4: + case GL_RGBA: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return &_mesa_texformat_argb8888; + default: + _mesa_problem(ctx, "unexpected format in tdfxDDChooseTextureFormat: %d", + internalFormat); + return NULL; + } +} + +static void sisDDTexImage2D( GLcontext *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + sisTexObjPtr t; + + if ( texObj->DriverData == NULL ) + sisAllocTexObj( texObj ); + t = texObj->DriverData; + + /* Note, this will call sisDDChooseTextureFormat */ + _mesa_store_teximage2d(ctx, target, level, internalFormat, + width, height, border, format, type, pixels, + &ctx->Unpack, texObj, texImage); + + /* Allocate offscreen space for the texture */ + sisFreeTexImage(smesa, t, level); + sisAllocTexImage(smesa, t, level, texImage); + + /* Upload the texture */ + assert(texImage->TexFormat->TexelBytes== 4); + memcpy(t->image[level].Data, texImage->Data, t->image[level].size); + + if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->image[level].format) + { + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; + smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->image[level].format; + } + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; +} + +static void sisDDTexSubImage2D( GLcontext *ctx, + GLenum target, + GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + sisTexObjPtr t; + GLuint copySize; + GLint texelBytes; + char *src, *dst; + int j; + GLuint soffset; + + if ( texObj->DriverData == NULL ) + sisAllocTexObj( texObj ); + t = texObj->DriverData; + + _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, + height, format, type, pixels, packing, texObj, + texImage); + + /* Allocate offscreen space for the texture */ + sisFreeTexImage(smesa, t, level); + sisAllocTexImage(smesa, t, level, texImage); + + /* Upload the texture */ + texelBytes = texImage->TexFormat->TexelBytes; + assert(texelBytes== 4); + + copySize = width * texelBytes; + src = (char *)texImage->Data + (xoffset + yoffset * texImage->Width) * + texelBytes; + dst = t->image[level].Data + (xoffset + yoffset * texImage->Width) * + texelBytes; + soffset = texImage->Width * texelBytes; + + for (j = yoffset; j < yoffset + height; j++) { + memcpy( dst, src, copySize ); + src += soffset; + dst += soffset; + } + + smesa->clearTexCache = GL_TRUE; + + if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->image[level].format) + { + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; + smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->image[level].format; + } + smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; + +} + +void sisDDInitTextureFuncs( GLcontext *ctx ) +{ + ctx->Driver.TexEnv = sisDDTexEnv; + ctx->Driver.ChooseTextureFormat = sisDDChooseTextureFormat; + /*ctx->Driver.TexImage1D = r128TexImage1D; + ctx->Driver.TexSubImage1D = r128TexSubImage1D;*/ + ctx->Driver.TexImage2D = sisDDTexImage2D; + ctx->Driver.TexSubImage2D = sisDDTexSubImage2D; + ctx->Driver.TexImage3D = _mesa_store_teximage3d; + ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d; + ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d; + ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d; + ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d; + ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d; + ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d; + ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage; + ctx->Driver.TexParameter = sisDDTexParameter; + ctx->Driver.BindTexture = sisDDBindTexture; + ctx->Driver.DeleteTexture = sisDDDeleteTexture; + ctx->Driver.UpdateTexturePalette = sisDDUpdateTexturePalette; + ctx->Driver.ActiveTexture = sisDDActiveTexture; + ctx->Driver.IsTextureResident = sisDDIsTextureResident; + ctx->Driver.PrioritizeTexture = NULL; +} diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_tex.h xc/lib/GL/mesa/src/drv/sis/sis_tex.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_tex.h Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_tex.h Mon Aug 25 00:15:50 2003 @@ -0,0 +1,45 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +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: + * Gareth Hughes + * Kevin E. Martin + * + */ + +#ifndef __SIS_TEX_H__ +#define __SIS_TEX_H__ + +#ifdef GLX_DIRECT_RENDERING + +extern void sisDDInitTextureFuncs( GLcontext *ctx ); +extern void sisUpdateTextureState( GLcontext *ctx ); + +#endif /* GLX_DIRECT_RENDERING */ +#endif /* __SIS_TEX_H__ */ diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_texstate.c xc/lib/GL/mesa/src/drv/sis/sis_texstate.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_texstate.c Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_texstate.c Mon Aug 25 00:15:50 2003 @@ -0,0 +1,652 @@ +/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.7 2001/01/08 01:07:21 martin Exp $ */ +/************************************************************************** + +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 "glheader.h" +#include "imports.h" +#include "context.h" +#include "macros.h" +#include "texformat.h" + +#include "sis_context.h" +#include "sis_state.h" +#include "sis_tex.h" +#include "sis_tris.h" +#include "sis_alloc.h" + +static GLint TransferTexturePitch (GLint dwPitch); + +/* Handle texenv stuff, called from validate_texture (renderstart) */ +static void +sis_set_texture_env0( GLcontext *ctx, struct gl_texture_object *texObj, + int unit ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit]; + + sisTexObjPtr t = texObj->DriverData; + sisTexImage *sisImage = &t->image[texObj->BaseLevel]; + + /* + current->hwTexBlendClr0 = RGB_STAGE1; + current->hwTexBlendAlpha0 = A_STAGE1; + */ + + switch (texture_unit->EnvMode) + { + case GL_REPLACE: + switch (sisImage->format) + { + case GL_ALPHA: + current->hwTexBlendClr0 = A_REPLACE_RGB_STAGE0; + current->hwTexBlendAlpha0 = A_REPLACE_A_STAGE0; + break; + case GL_INTENSITY: + case GL_RGB: + current->hwTexBlendClr0 = RGB_REPLACE__RGB_STAGE0; + current->hwTexBlendAlpha0 = RGB_REPLACE__A_STAGE0; + break; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + current->hwTexBlendClr0 = RGBA_REPLACE__RGB_STAGE0; + current->hwTexBlendAlpha0 = RGBA_REPLACE__A_STAGE0; + break; + } + break; + + case GL_MODULATE: + switch (sisImage->format) + { + case GL_ALPHA: + current->hwTexBlendClr0 = A_MODULATE_RGB_STAGE0; + current->hwTexBlendAlpha0 = A_MODULATE_A_STAGE0; + break; + case GL_LUMINANCE: + case GL_RGB: + current->hwTexBlendClr0 = RGB_MODULATE__RGB_STAGE0; + current->hwTexBlendAlpha0 = RGB_MODULATE__A_STAGE0; + break; + case GL_INTENSITY: + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + current->hwTexBlendClr0 = RGBA_MODULATE__RGB_STAGE0; + current->hwTexBlendAlpha0 = RGBA_MODULATE__A_STAGE0; + break; + } + break; + + case GL_DECAL: + switch (sisImage->format) + { + case GL_RGB: + current->hwTexBlendClr0 = RGB_DECAL__RGB_STAGE0; + current->hwTexBlendAlpha0 = RGB_DECAL__A_STAGE0; + break; + case GL_RGBA: + current->hwTexBlendClr0 = RGBA_DECAL__RGB_STAGE0; + current->hwTexBlendAlpha0 = RGBA_DECAL__A_STAGE0; + break; + } + break; + + case GL_BLEND: + current->hwTexEnvColor = + ((GLint) (texture_unit->EnvColor[3])) << 24 | + ((GLint) (texture_unit->EnvColor[0])) << 16 | + ((GLint) (texture_unit->EnvColor[1])) << 8 | + ((GLint) (texture_unit->EnvColor[2])); + switch (sisImage->format) + { + case GL_ALPHA: + current->hwTexBlendClr0 = A_BLEND_RGB_STAGE0; + current->hwTexBlendAlpha0 = A_BLEND_A_STAGE0; + break; + case GL_LUMINANCE: + case GL_RGB: + current->hwTexBlendClr0 = RGB_BLEND__RGB_STAGE0; + current->hwTexBlendAlpha0 = RGB_BLEND__A_STAGE0; + break; + case GL_INTENSITY: + current->hwTexBlendClr0 = I_BLEND__RGB_STAGE0; + current->hwTexBlendAlpha0 = I_BLEND__A_STAGE0; + break; + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + current->hwTexBlendClr0 = RGBA_BLEND__RGB_STAGE0; + current->hwTexBlendAlpha0 = RGBA_BLEND__A_STAGE0; + break; + } + break; + } + + /*current->hwTexBlendClr0 = RGB_STAGE1; + current->hwTexBlendAlpha0 = A_STAGE1;*/ + + if ((current->hwTexBlendClr0 != prev->hwTexBlendClr0) || + (current->hwTexBlendAlpha0 != prev->hwTexBlendAlpha0) || + (current->hwTexEnvColor != prev->hwTexEnvColor)) + { + prev->hwTexEnvColor = current->hwTexEnvColor; + prev->hwTexBlendClr0 = current->hwTexBlendClr0; + prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0; + smesa->GlobalFlag |= GFLAG_TEXTUREENV; + } +} + +/* Handle texenv stuff, called from validate_texture (renderstart) */ +static void +sis_set_texture_env1( GLcontext *ctx, struct gl_texture_object *texObj, + int unit) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit]; + + sisTexObjPtr t = texObj->DriverData; + sisTexImage *sisImage = &t->image[texObj->BaseLevel]; + + /* + current->hwTexBlendClr1 = RGB_STAGE1; current->hwTexBlendAlpha1 = + A_STAGE1; + */ + + switch (texture_unit->EnvMode) + { + case GL_REPLACE: + switch (sisImage->format) + { + case GL_ALPHA: + current->hwTexBlendClr1 = A_REPLACE_RGB_STAGE1; + current->hwTexBlendAlpha1 = A_REPLACE_A_STAGE1; + break; + case GL_INTENSITY: + case GL_RGB: + current->hwTexBlendClr1 = RGB_REPLACE__RGB_STAGE1; + current->hwTexBlendAlpha1 = RGB_REPLACE__A_STAGE1; + break; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + current->hwTexBlendClr1 = RGBA_REPLACE__RGB_STAGE1; + current->hwTexBlendAlpha1 = RGBA_REPLACE__A_STAGE1; + break; + } + break; + + case GL_MODULATE: + switch (sisImage->format) + { + case GL_ALPHA: + current->hwTexBlendClr1 = A_MODULATE_RGB_STAGE1; + current->hwTexBlendAlpha1 = A_MODULATE_A_STAGE1; + break; + case GL_LUMINANCE: + case GL_RGB: + current->hwTexBlendClr1 = RGB_MODULATE__RGB_STAGE1; + current->hwTexBlendAlpha1 = RGB_MODULATE__A_STAGE1; + break; + case GL_INTENSITY: + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + current->hwTexBlendClr1 = RGBA_MODULATE__RGB_STAGE1; + current->hwTexBlendAlpha1 = RGBA_MODULATE__A_STAGE1; + break; + } + break; + + case GL_DECAL: + switch (sisImage->format) + { + case GL_RGB: + current->hwTexBlendClr1 = RGB_DECAL__RGB_STAGE1; + current->hwTexBlendAlpha1 = RGB_DECAL__A_STAGE1; + break; + case GL_RGBA: + current->hwTexBlendClr1 = RGBA_DECAL__RGB_STAGE1; + current->hwTexBlendAlpha1 = RGBA_DECAL__A_STAGE1; + break; + } + break; + + case GL_BLEND: + current->hwTexEnvColor = + ((GLint) (texture_unit->EnvColor[3])) << 24 | + ((GLint) (texture_unit->EnvColor[0])) << 16 | + ((GLint) (texture_unit->EnvColor[1])) << 8 | + ((GLint) (texture_unit->EnvColor[2])); + switch (sisImage->format) + { + case GL_ALPHA: + current->hwTexBlendClr1 = A_BLEND_RGB_STAGE1; + current->hwTexBlendAlpha1 = A_BLEND_A_STAGE1; + break; + case GL_LUMINANCE: + case GL_RGB: + current->hwTexBlendClr1 = RGB_BLEND__RGB_STAGE1; + current->hwTexBlendAlpha1 = RGB_BLEND__A_STAGE1; + break; + case GL_INTENSITY: + current->hwTexBlendClr1 = I_BLEND__RGB_STAGE1; + current->hwTexBlendAlpha1 = I_BLEND__A_STAGE1; + break; + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + current->hwTexBlendClr1 = RGBA_BLEND__RGB_STAGE1; + current->hwTexBlendAlpha1 = RGBA_BLEND__A_STAGE1; + break; + } + break; + } + + if ((current->hwTexBlendClr1 != prev->hwTexBlendClr1) || + (current->hwTexBlendAlpha1 != prev->hwTexBlendAlpha1) || + (current->hwTexEnvColor != prev->hwTexEnvColor)) + { + prev->hwTexBlendClr1 = current->hwTexBlendClr1; + prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1; + prev->hwTexEnvColor = current->hwTexEnvColor; + smesa->GlobalFlag |= GFLAG_TEXTUREENV_1; + } +} + +/* Returns 0 if a software fallback is necessary */ +static GLboolean +sis_set_texobj_parm( GLcontext *ctx, struct gl_texture_object *texObj, + int hw_unit ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + int ok = 1; + + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + sisTexObjPtr t = texObj->DriverData; + sisTexImage *sisImage = &t->image[texObj->BaseLevel]; + + GLint firstLevel, lastLevel; + GLint i; + + current->texture[hw_unit].hwTextureSet = 0UL; + current->texture[hw_unit].hwTextureMip = 0UL; + + switch (sisImage->format) + { + case GL_RGBA: + current->texture[hw_unit].hwTextureSet |= TEXEL_ABGR_8888_32; + break; + case GL_INTENSITY: + current->texture[hw_unit].hwTextureSet |= TEXEL_I8; + break; + case GL_ALPHA: + current->texture[hw_unit].hwTextureSet |= TEXEL_A8; + break; + case GL_LUMINANCE: + current->texture[hw_unit].hwTextureSet |= TEXEL_L8; + break; + case GL_LUMINANCE_ALPHA: + current->texture[hw_unit].hwTextureSet |= TEXEL_AL88; + break; + case GL_RGB: + current->texture[hw_unit].hwTextureSet |= TEXEL_ABGR_0888_32; + break; + default: + assert(0); + } + + if ((texObj->MinFilter == GL_NEAREST) || (texObj->MinFilter == GL_LINEAR)) { + firstLevel = lastLevel = texObj->BaseLevel; + } else { + /* Compute which mipmap levels we really want to send to the hardware. + * This depends on the base image size, GL_TEXTURE_MIN_LOD, + * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL and GL_TEXTURE_MAX_LEVEL. + * Yes, this looks overly complicated, but it's all needed. + */ + + firstLevel = texObj->BaseLevel + (GLint)(texObj->MinLod + 0.5); + firstLevel = MAX2(firstLevel, texObj->BaseLevel); + lastLevel = texObj->BaseLevel + (GLint)(texObj->MaxLod + 0.5); + lastLevel = MAX2(lastLevel, texObj->BaseLevel); + lastLevel = MIN2(lastLevel, texObj->BaseLevel + + texObj->Image[texObj->BaseLevel]->MaxLog2); + lastLevel = MIN2(lastLevel, texObj->MaxLevel); + lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */ + } + + current->texture[hw_unit].hwTextureSet |= (firstLevel << 8); /* XXX */ + + switch (texObj->MagFilter) + { + case GL_NEAREST: + current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_NEAREST; + break; + case GL_LINEAR: + current->texture[hw_unit].hwTextureMip |= (TEXTURE_FILTER_LINEAR << 3); + break; + } + + switch (texObj->MinFilter) + { + case GL_NEAREST: + current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_NEAREST; + break; + case GL_LINEAR: + current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_LINEAR; + break; + case GL_NEAREST_MIPMAP_NEAREST: + current->texture[hw_unit].hwTextureMip |= + TEXTURE_FILTER_NEAREST_MIP_NEAREST; + break; + case GL_NEAREST_MIPMAP_LINEAR: + current->texture[hw_unit].hwTextureMip |= + TEXTURE_FILTER_NEAREST_MIP_LINEAR; + break; + case GL_LINEAR_MIPMAP_NEAREST: + current->texture[hw_unit].hwTextureMip |= + TEXTURE_FILTER_LINEAR_MIP_NEAREST; + break; + case GL_LINEAR_MIPMAP_LINEAR: + current->texture[hw_unit].hwTextureMip |= + TEXTURE_FILTER_LINEAR_MIP_LINEAR; + break; + } + + switch (texObj->WrapS) + { + case GL_REPEAT: + current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapU; + break; + case GL_CLAMP: + current->texture[hw_unit].hwTextureSet |= MASK_TextureClampU; + break; + case GL_CLAMP_TO_EDGE: + /* + * ?? not support yet + */ + ok = 0; + break; + } + + switch (texObj->WrapT) + { + case GL_REPEAT: + current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapV; + break; + case GL_CLAMP: + current->texture[hw_unit].hwTextureSet |= MASK_TextureClampV; + break; + case GL_CLAMP_TO_EDGE: + /* + * ?? not support yet + */ + ok = 0; + break; + } + +/* + if (current->texture[hw_unit].hwTextureSet & MASK_TextureClampU) { + current->texture[hw_unit].hwTextureSet &= ~MASK_TextureClampU; + current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderU; + } + + if (current->texture[hw_unit].hwTextureSet & MASK_TextureClampV) { + current->texture[hw_unit].hwTextureSet &= ~MASK_TextureClampV; + current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderV; + } +*/ + current->texture[hw_unit].hwTextureBorderColor = + ((GLuint) texObj->BorderColor[3] << 24) + + ((GLuint) texObj->BorderColor[0] << 16) + + ((GLuint) texObj->BorderColor[1] << 8) + + ((GLuint) texObj->BorderColor[2]); + + if (current->texture[hw_unit].hwTextureBorderColor != + prev->texture[hw_unit].hwTextureBorderColor) + { + prev->texture[hw_unit].hwTextureBorderColor = + current->texture[hw_unit].hwTextureBorderColor; + if (hw_unit == 1) + smesa->GlobalFlag |= GFLAG_TEXBORDERCOLOR_1; + else + smesa->GlobalFlag |= GFLAG_TEXBORDERCOLOR; + } + + current->texture[hw_unit].hwTextureSet |= + texObj->Image[firstLevel]->WidthLog2 << 4; + current->texture[hw_unit].hwTextureSet |= + texObj->Image[firstLevel]->HeightLog2; + + if (hw_unit == 0) + smesa->GlobalFlag |= GFLAG_TEXTUREADDRESS; + else + smesa->GlobalFlag |= GFLAG_TEXTUREADDRESS_1; + + for (i = firstLevel; i <= lastLevel; i++) + { + GLuint texOffset; + GLuint texPitch = TransferTexturePitch( sisImage->pitch ); + + switch (t->image[i].memType) + { + case VIDEO_TYPE: + texOffset = ((unsigned long)t->image[i].Data - (unsigned long)smesa->FbBase); + break; + case AGP_TYPE: + texOffset = ((unsigned long)t->image[i].Data - (unsigned long)smesa->AGPBase) + + (unsigned long) smesa->AGPAddr; + current->texture[hw_unit].hwTextureMip |= (0x40000 << i); + break; + } + + switch (i) + { + case 0: + prev->texture[hw_unit].texOffset0 = texOffset; + prev->texture[hw_unit].texPitch01 = texPitch << 16; + break; + case 1: + prev->texture[hw_unit].texOffset1 = texOffset; + prev->texture[hw_unit].texPitch01 |= texPitch; + break; + case 2: + prev->texture[hw_unit].texOffset2 = texOffset; + prev->texture[hw_unit].texPitch23 = texPitch << 16; + break; + case 3: + prev->texture[hw_unit].texOffset3 = texOffset; + prev->texture[hw_unit].texPitch23 |= texPitch; + break; + case 4: + prev->texture[hw_unit].texOffset4 = texOffset; + prev->texture[hw_unit].texPitch45 = texPitch << 16; + break; + case 5: + prev->texture[hw_unit].texOffset5 = texOffset; + prev->texture[hw_unit].texPitch45 |= texPitch; + break; + case 6: + prev->texture[hw_unit].texOffset6 = texOffset; + prev->texture[hw_unit].texPitch67 = texPitch << 16; + break; + case 7: + prev->texture[hw_unit].texOffset7 = texOffset; + prev->texture[hw_unit].texPitch67 |= texPitch; + break; + case 8: + prev->texture[hw_unit].texOffset8 = texOffset; + prev->texture[hw_unit].texPitch89 = texPitch << 16; + break; + case 9: + prev->texture[hw_unit].texOffset9 = texOffset; + prev->texture[hw_unit].texPitch89 |= texPitch; + break; + case 10: + prev->texture[hw_unit].texOffset10 = texOffset; + prev->texture[hw_unit].texPitch10 = texPitch << 16; + break; + case 11: + prev->texture[hw_unit].texOffset11 = texOffset; + prev->texture[hw_unit].texPitch10 |= texPitch; + break; + } + } + + if (current->texture[hw_unit].hwTextureSet != + prev->texture[hw_unit].hwTextureSet) + { + prev->texture[hw_unit].hwTextureSet = + current->texture[hw_unit].hwTextureSet; + if (hw_unit == 1) + smesa->GlobalFlag |= CFLAG_TEXTURERESET_1; + else + smesa->GlobalFlag |= CFLAG_TEXTURERESET; + } + if (current->texture[hw_unit].hwTextureMip != + prev->texture[hw_unit].hwTextureMip) + { + prev->texture[hw_unit].hwTextureMip = + current->texture[hw_unit].hwTextureMip; + if (hw_unit == 1) + smesa->GlobalFlag |= GFLAG_TEXTUREMIPMAP_1; + else + smesa->GlobalFlag |= GFLAG_TEXTUREMIPMAP; + } + + return ok; +} + +/* Disable a texture unit, called from validate_texture */ +static void +sis_reset_texture_env (GLcontext *ctx, int hw_unit) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + __GLSiSHardware *prev = &smesa->prev; + __GLSiSHardware *current = &smesa->current; + + if (hw_unit == 1) + { + current->hwTexBlendClr1 = RGB_STAGE1; + current->hwTexBlendAlpha1 = A_STAGE1; + + if ((current->hwTexBlendClr1 != prev->hwTexBlendClr1) || + (current->hwTexBlendAlpha1 != prev->hwTexBlendAlpha1) || + (current->hwTexEnvColor != prev->hwTexEnvColor)) + { + prev->hwTexBlendClr1 = current->hwTexBlendClr1; + prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1; + prev->hwTexEnvColor = current->hwTexEnvColor; + smesa->GlobalFlag |= GFLAG_TEXTUREENV_1; + } + } else { + current->hwTexBlendClr0 = RGB_STAGE1; + current->hwTexBlendAlpha0 = A_STAGE1; + + if ((current->hwTexBlendClr0 != prev->hwTexBlendClr0) || + (current->hwTexBlendAlpha0 != prev->hwTexBlendAlpha0) || + (current->hwTexEnvColor != prev->hwTexEnvColor)) + { + prev->hwTexBlendClr0 = current->hwTexBlendClr0; + prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0; + prev->hwTexEnvColor = current->hwTexEnvColor; + smesa->GlobalFlag |= GFLAG_TEXTUREENV; + } + } +} + +static GLboolean updateTextureUnit( GLcontext *ctx, int unit ) +{ + sisContextPtr smesa = SIS_CONTEXT( ctx ); + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + struct gl_texture_object *texObj = texUnit->_Current; + + if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) { + GLboolean ok = GL_TRUE; /* XXX */ + if (smesa->TexStates[unit] & NEW_TEXTURING) + ok = sis_set_texobj_parm (ctx, texObj, unit); + if (smesa->TexStates[unit] & NEW_TEXTURE_ENV) { + if (unit == 0) + sis_set_texture_env0( ctx, texObj, unit ); + else + sis_set_texture_env1( ctx, texObj, unit ); + } + smesa->TexStates[unit] = 0; + return ok; + } else if ( texUnit->_ReallyEnabled ) { + /* fallback */ + return GL_FALSE; + } else { + sis_reset_texture_env( ctx, unit ); + return GL_TRUE; + } +} + + +void sisUpdateTextureState( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT( ctx ); + GLboolean ok; + + ok = (updateTextureUnit( ctx, 0 ) && + updateTextureUnit( ctx, 1 )); + + FALLBACK( smesa, SIS_FALLBACK_TEXTURE, !ok ); +} + +static GLint +BitScanForward (GLshort w) +{ + GLint i; + + for (i = 0; i < 16; i++) { + if (w & (1 << i)) + break; + } + return (i); +} + +static GLint +TransferTexturePitch (GLint dwPitch) +{ + GLint dwRet, i; + + i = BitScanForward ((GLshort) dwPitch); + dwRet = dwPitch >> i; + dwRet |= i << 9; + return (dwRet); +} 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_texture.c Wed Dec 31 16:00:00 1969 @@ -1,928 +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_texture.c,v 1.5 2000/09/26 15:56:49 tsi Exp $ */ - -/* - * Authors: - * Sung-Ching Lin - * - */ - -#include "sis_ctx.h" -#include "sis_mesa.h" - -static void -sis_set_texture_env0 (GLcontext * ctx, GLtextureObject * object, int unit); - -static void -sis_set_texture_env1 (GLcontext * ctx, GLtextureObject * object, int unit); - -static void -sis_set_texobj_parm (GLcontext * ctx, GLtextureObject * object, int hw_unit); - -static void sis_reset_texture_env (GLcontext * ctx, int hw_unit); - -static DWORD TransferTexturePitch (DWORD dwPitch); - -void -sis_validate_texture (GLcontext * ctx) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - struct gl_texture_unit *tex_unit; - struct gl_texture_object *tObj; - sisTexobjInfo *texObjArea; - - if(ctx->Texture.ReallyEnabled & (TEXTURE0_3D | TEXTURE1_3D)) - { - hwcx->swRenderFlag |= SIS_SW_TEXTURE_DIM; - return; - } - else - { - hwcx->swRenderFlag &= ~SIS_SW_TEXTURE_DIM; - } - - if ((ctx->Texture.ReallyEnabled & TEXTURE0_ANY) && - (ctx->Texture.ReallyEnabled & TEXTURE1_ANY)) - { - int unit; - - for (unit = 0; unit <= 1; unit++) - { - tex_unit = &ctx->Texture.Unit[unit]; - tObj = tex_unit->Current; - texObjArea = (sisTexobjInfo *) tObj->DriverData; - - if (hwcx->TexStates[unit] & NEW_TEXTURING) - { - hwcx->swRenderFlag &= ~(SIS_SW_TEXTURE_OBJ << unit); - sis_set_texobj_parm (ctx, tObj, unit); - } - - if (hwcx->TexStates[unit] & NEW_TEXTURE_ENV) - { - hwcx->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; - } - } - else - { - int unit = (ctx->Texture.ReallyEnabled & TEXTURE0_ANY) ? 0 : 1; - - tex_unit = &ctx->Texture.Unit[unit]; - tObj = tex_unit->Current; - texObjArea = (sisTexobjInfo *) tObj->DriverData; - - if (hwcx->TexStates[unit] & NEW_TEXTURING) - sis_set_texobj_parm (ctx, tObj, unit); - - if (hwcx->TexStates[unit] & NEW_TEXTURE_ENV) - { - if(unit == 0){ - sis_set_texture_env0 (ctx, tObj, unit); - sis_reset_texture_env (ctx, 1); - } - else{ - sis_set_texture_env1 (ctx, tObj, unit); - sis_reset_texture_env (ctx, 0); - } - } - - hwcx->TexStates[unit] = 0; - } -} - -void -sis_TexEnv( GLcontext *ctx, GLenum target, GLenum pname, - const GLfloat *param ) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; -} - -void -sis_TexImage (GLcontext * ctx, GLenum target, - 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; - - SIStextureArea *area; - - if (target == GL_TEXTURE_3D || image->Border) - return; - - if (!tObj->DriverData) - { - sisTexobjInfo *info; - - info = (sisTexobjInfo *)calloc (1, sizeof (sisTexobjInfo)); - - /* TODO */ - assert(info); - - info->prev = info->next = NULL; - info->valid = GL_FALSE; - tObj->DriverData = info; - } - - if (image->DriverData) - { - /* image has a copy in video memory, and it may be in the cache */ - - ((sisTexobjInfo *) tObj->DriverData)->dirtyFlag |= SIS_TEX_ALL; - } - else - { - /* Optimize */ - ((sisTexobjInfo *) tObj->DriverData)->dirtyFlag |= (SIS_TEX_PARAMETER - | SIS_TEX_ENV); - } - - sis_alloc_texture_image (ctx, (struct gl_texture_image *) image); - - area = (SIStextureArea *) image->DriverData; - assert (area->Data); - - if (area->Format == GL_RGB8) - { - int i; - GLbyte *src = (GLbyte *)image->Data; - GLbyte *dst = area->Data; - - for (i = 0; i < area->Size / 4; i++) - { - *(DWORD *)dst = *(DWORD *)src & 0x00ffffff; - src += 3; - dst += 4; - } - } - else - { - memcpy (area->Data, image->Data, area->Size); - } - - if (hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] != area->Format) - { - hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; - hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] = area->Format; - } - hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING; -} - -void -sis_TexSubImage (GLcontext * ctx, GLenum target, - struct gl_texture_object *tObj, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, GLint - internalFormat, const struct gl_texture_image *image) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - SIStextureArea *area; - int i, j; - GLbyte *src, *dst; - GLuint soffset, doffset; - - area = (SIStextureArea *) image->DriverData; - - hwcx->clearTexCache = GL_TRUE; - - { - /* - * Optimize - */ - WaitEngIdle (hwcx); - } - - if (area->Format == GL_RGB8) - { - src = (GLbyte *)image->Data + (xoffset + yoffset * image->Width) * 3; - dst = area->Data + (xoffset + yoffset * image->Width) * 4; - soffset = (image->Width - width) * 3; - doffset = (image->Width - width) * 4; - for (j = yoffset; j < yoffset + height; j++) - { - for (i = xoffset; i < xoffset + width; i++) - { - *(DWORD *)dst = *(DWORD *)src & 0x00ffffff; - src += 3; - dst += 4; - } - src += soffset; - dst += doffset; - } - } - else - { - GLuint texelSize = area->texelSize; - GLuint copySize = texelSize * width; - - src = (GLbyte *)image->Data + - (xoffset + yoffset * image->Width) * texelSize; - dst = area->Data + (xoffset + yoffset * image->Width) * texelSize; - soffset = image->Width * texelSize; - - for (j = yoffset; j < yoffset + height; j++) - { - memcpy (dst, src, copySize); - src += soffset; - dst += soffset; - } - } -} - -void -sis_TexParameter (GLcontext * ctx, GLenum target, - struct gl_texture_object *tObj, GLenum pname, const - GLfloat * params) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - if (tObj->DriverData) - ((sisTexobjInfo *) tObj->DriverData)->dirtyFlag |= SIS_TEX_PARAMETER; - - hwcx->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; - SIStextureArea *area; - - if (!tObj->Image[0]) - return; - - if (!(area = (SIStextureArea *) tObj->Image[0]->DriverData)) - return; - - if (hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] != area->Format) - { - hwcx->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV; - hwcx->PrevTexFormat[ctx->Texture.CurrentUnit] = area->Format; - } - hwcx->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; - - int i; - - for (i = 0; i < MAX_TEXTURE_LEVELS; i++) - { - if (tObj->Image[i]) - sis_free_texture_image (tObj->Image[i]); - } - - if (tObj->DriverData) - { - free (tObj->DriverData); - tObj->DriverData = NULL; - } - else - { - /* - * this shows the texture is default object and never be a - * argument of sis_TexImage - */ - } - - hwcx->clearTexCache = GL_TRUE; -} - -void -sis_UpdateTexturePalette (GLcontext * ctx, struct gl_texture_object *tObj) -{ - -} - -void -sis_UseGlobalTexturePalette (GLcontext * ctx, GLboolean state) -{ - -} - -void -sis_ActiveTexture (GLcontext * ctx, GLuint texUnitNumber) -{ -} - -GLboolean sis_IsTextureResident (GLcontext * ctx, struct gl_texture_object *t) -{ - return GL_TRUE; -} - -void -sis_PrioritizeTexture (GLcontext * ctx, - struct gl_texture_object *t, GLclampf priority) -{ -} - -static void -sis_set_texture_env0 (GLcontext * ctx, GLtextureObject * object, int unit) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit]; - - GLtextureImage *image = object->Image[0]; - SIStextureArea *area = (SIStextureArea *) image->DriverData; - - /* - current->hwTexBlendClr1 = RGB_STAGE1; - current->hwTexBlendAlpha1 = A_STAGE1; - */ - - switch (texture_unit->EnvMode) - { - case GL_REPLACE: - switch (area->Format) - { - case GL_ALPHA8: - current->hwTexBlendClr0 = A_REPLACE_RGB_STAGE0; - current->hwTexBlendAlpha0 = A_REPLACE_A_STAGE0; - break; - case GL_INTENSITY8: - case GL_RGB8: - current->hwTexBlendClr0 = RGB_REPLACE__RGB_STAGE0; - current->hwTexBlendAlpha0 = RGB_REPLACE__A_STAGE0; - break; - case GL_LUMINANCE8: - case GL_LUMINANCE8_ALPHA8: - case GL_RGBA8: - current->hwTexBlendClr0 = RGBA_REPLACE__RGB_STAGE0; - current->hwTexBlendAlpha0 = RGBA_REPLACE__A_STAGE0; - break; - } - break; - - case GL_MODULATE: - switch (area->Format) - { - case GL_ALPHA8: - current->hwTexBlendClr0 = A_MODULATE_RGB_STAGE0; - current->hwTexBlendAlpha0 = A_MODULATE_A_STAGE0; - break; - case GL_LUMINANCE8: - case GL_RGB8: - current->hwTexBlendClr0 = RGB_MODULATE__RGB_STAGE0; - current->hwTexBlendAlpha0 = RGB_MODULATE__A_STAGE0; - break; - case GL_INTENSITY8: - case GL_LUMINANCE8_ALPHA8: - case GL_RGBA8: - current->hwTexBlendClr0 = RGBA_MODULATE__RGB_STAGE0; - current->hwTexBlendAlpha0 = RGBA_MODULATE__A_STAGE0; - break; - } - break; - - case GL_DECAL: - switch (area->Format) - { - case GL_RGB8: - current->hwTexBlendClr0 = RGB_DECAL__RGB_STAGE0; - current->hwTexBlendAlpha0 = RGB_DECAL__A_STAGE0; - break; - case GL_RGBA8: - current->hwTexBlendClr0 = RGBA_DECAL__RGB_STAGE0; - current->hwTexBlendAlpha0 = RGBA_DECAL__A_STAGE0; - break; - } - break; - - 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])); - switch (area->Format) - { - case GL_ALPHA8: - current->hwTexBlendClr0 = A_BLEND_RGB_STAGE0; - current->hwTexBlendAlpha0 = A_BLEND_A_STAGE0; - break; - case GL_LUMINANCE8: - case GL_RGB8: - current->hwTexBlendClr0 = RGB_BLEND__RGB_STAGE0; - current->hwTexBlendAlpha0 = RGB_BLEND__A_STAGE0; - break; - case GL_INTENSITY8: - current->hwTexBlendClr0 = I_BLEND__RGB_STAGE0; - current->hwTexBlendAlpha0 = I_BLEND__A_STAGE0; - break; - case GL_LUMINANCE8_ALPHA8: - case GL_RGBA8: - current->hwTexBlendClr0 = RGBA_BLEND__RGB_STAGE0; - current->hwTexBlendAlpha0 = RGBA_BLEND__A_STAGE0; - break; - } - break; - } - - if ((current->hwTexBlendClr0 ^ prev->hwTexBlendClr0) || - (current->hwTexBlendAlpha0 ^ prev->hwTexBlendAlpha0) || - (current->hwTexEnvColor ^ prev->hwTexEnvColor)) - { - prev->hwTexEnvColor = current->hwTexEnvColor; - prev->hwTexBlendClr0 = current->hwTexBlendClr0; - prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0; - hwcx->GlobalFlag |= GFLAG_TEXTUREENV; - } -} - -void -sis_set_texture_env1 (GLcontext * ctx, GLtextureObject * object, int unit) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit]; - GLtextureImage *image = object->Image[0]; - SIStextureArea *area = (SIStextureArea *) image->DriverData; - - /* - current->hwTexBlendClr1 = RGB_STAGE1; current->hwTexBlendAlpha1 = - A_STAGE1; - */ - - switch (texture_unit->EnvMode) - { - case GL_REPLACE: - switch (area->Format) - { - case GL_ALPHA8: - current->hwTexBlendClr1 = A_REPLACE_RGB_STAGE1; - current->hwTexBlendAlpha1 = A_REPLACE_A_STAGE1; - break; - case GL_INTENSITY8: - case GL_RGB8: - current->hwTexBlendClr1 = RGB_REPLACE__RGB_STAGE1; - current->hwTexBlendAlpha1 = RGB_REPLACE__A_STAGE1; - break; - case GL_LUMINANCE8: - case GL_LUMINANCE8_ALPHA8: - case GL_RGBA8: - current->hwTexBlendClr1 = RGBA_REPLACE__RGB_STAGE1; - current->hwTexBlendAlpha1 = RGBA_REPLACE__A_STAGE1; - break; - } - break; - - case GL_MODULATE: - switch (area->Format) - { - case GL_ALPHA8: - current->hwTexBlendClr1 = A_MODULATE_RGB_STAGE1; - current->hwTexBlendAlpha1 = A_MODULATE_A_STAGE1; - break; - case GL_LUMINANCE8: - case GL_RGB8: - current->hwTexBlendClr1 = RGB_MODULATE__RGB_STAGE1; - current->hwTexBlendAlpha1 = RGB_MODULATE__A_STAGE1; - break; - case GL_INTENSITY8: - case GL_LUMINANCE8_ALPHA8: - case GL_RGBA8: - current->hwTexBlendClr1 = RGBA_MODULATE__RGB_STAGE1; - current->hwTexBlendAlpha1 = RGBA_MODULATE__A_STAGE1; - break; - } - break; - - case GL_DECAL: - - switch (area->Format) - { - case GL_RGB8: - current->hwTexBlendClr1 = RGB_DECAL__RGB_STAGE1; - current->hwTexBlendAlpha1 = RGB_DECAL__A_STAGE1; - break; - case GL_RGBA8: - current->hwTexBlendClr1 = RGBA_DECAL__RGB_STAGE1; - current->hwTexBlendAlpha1 = RGBA_DECAL__A_STAGE1; - break; - } - break; - - 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])); - switch (area->Format) - { - case GL_ALPHA8: - current->hwTexBlendClr1 = A_BLEND_RGB_STAGE1; - current->hwTexBlendAlpha1 = A_BLEND_A_STAGE1; - break; - case GL_LUMINANCE8: - case GL_RGB8: - current->hwTexBlendClr1 = RGB_BLEND__RGB_STAGE1; - current->hwTexBlendAlpha1 = RGB_BLEND__A_STAGE1; - break; - case GL_INTENSITY8: - current->hwTexBlendClr1 = I_BLEND__RGB_STAGE1; - current->hwTexBlendAlpha1 = I_BLEND__A_STAGE1; - break; - case GL_LUMINANCE8_ALPHA8: - case GL_RGBA8: - current->hwTexBlendClr1 = RGBA_BLEND__RGB_STAGE1; - current->hwTexBlendAlpha1 = RGBA_BLEND__A_STAGE1; - break; - } - break; - } - - if ((current->hwTexBlendClr1 ^ prev->hwTexBlendClr1) || - (current->hwTexBlendAlpha1 ^ prev->hwTexBlendAlpha1) || - (current->hwTexEnvColor ^ prev->hwTexEnvColor)) - { - prev->hwTexBlendClr1 = current->hwTexBlendClr1; - prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1; - prev->hwTexEnvColor = current->hwTexEnvColor; - hwcx->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; - - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - GLtextureImage *image = object->Image[0]; - SIStextureArea *area = (SIStextureArea *) image->DriverData; - - GLint TxLevel; - GLint i; - - current->texture[hw_unit].hwTextureSet = 0UL; - current->texture[hw_unit].hwTextureMip = 0UL; - - switch (area->Format) - { - case GL_RGBA8: - current->texture[hw_unit].hwTextureSet |= TEXEL_ABGR_8888_32; - break; - case GL_INTENSITY8: - current->texture[hw_unit].hwTextureSet |= TEXEL_I8; - break; - case GL_ALPHA8: - current->texture[hw_unit].hwTextureSet |= TEXEL_A8; - break; - case GL_LUMINANCE8: - current->texture[hw_unit].hwTextureSet |= TEXEL_L8; - break; - case GL_LUMINANCE8_ALPHA8: - current->texture[hw_unit].hwTextureSet |= TEXEL_AL88; - break; - case GL_RGB8: - current->texture[hw_unit].hwTextureSet |= TEXEL_ABGR_0888_32; - break; - default: - hwcx->swRenderFlag |= SIS_SW_TEXTURE_OBJ; - } - - if ((object->MinFilter == GL_NEAREST) || (object->MinFilter == GL_LINEAR)) - { - TxLevel = 0; - } - else - { - TxLevel = object->P; - } - - if (TxLevel < SIS_MAX_MIPMAP_LEVEL) - { - current->texture[hw_unit].hwTextureSet |= (TxLevel << 8); - } - else - { - /* can i limit capacity */ - hwcx->swRenderFlag |= SIS_SW_TEXTURE_OBJ; - } - - switch (object->MagFilter) - { - case GL_NEAREST: - current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_NEAREST; - break; - - case GL_LINEAR: - current->texture[hw_unit].hwTextureMip |= (TEXTURE_FILTER_LINEAR << 3); - break; - } - - switch (object->MinFilter) - { - case GL_NEAREST: - current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_NEAREST; - break; - - case GL_LINEAR: - current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_LINEAR; - break; - - case GL_NEAREST_MIPMAP_NEAREST: - current->texture[hw_unit].hwTextureMip |= - TEXTURE_FILTER_NEAREST_MIP_NEAREST; - break; - - case GL_NEAREST_MIPMAP_LINEAR: - current->texture[hw_unit].hwTextureMip |= - TEXTURE_FILTER_NEAREST_MIP_LINEAR; - break; - - case GL_LINEAR_MIPMAP_NEAREST: - current->texture[hw_unit].hwTextureMip |= - TEXTURE_FILTER_LINEAR_MIP_NEAREST; - break; - - case GL_LINEAR_MIPMAP_LINEAR: - current->texture[hw_unit].hwTextureMip |= - TEXTURE_FILTER_LINEAR_MIP_LINEAR; - break; - } - - switch (object->WrapS) - { - case GL_REPEAT: - current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapU; - break; - case GL_CLAMP: - current->texture[hw_unit].hwTextureSet |= MASK_TextureClampU; - break; - case GL_CLAMP_TO_EDGE: - /* - * ?? not support yet - */ - break; - } - - switch (object->WrapT) - { - case GL_REPEAT: - current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapV; - break; - case GL_CLAMP: - current->texture[hw_unit].hwTextureSet |= MASK_TextureClampV; - break; - case GL_CLAMP_TO_EDGE: - /* - * ?? not support yet - */ - break; - } - -/* - if (current->texture[hw_unit].hwTextureSet & MASK_TextureClampU) { - current->texture[hw_unit].hwTextureSet &= ~MASK_TextureClampU; - current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderU; - } - - if (current->texture[hw_unit].hwTextureSet & MASK_TextureClampV) { - current->texture[hw_unit].hwTextureSet &= ~MASK_TextureClampV; - current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderV; - } -*/ - current->texture[hw_unit].hwTextureBorderColor = - ((GLuint) object->BorderColor[3] << 24) + - ((GLuint) object->BorderColor[0] << 16) + - ((GLuint) object->BorderColor[1] << 8) + - ((GLuint) object->BorderColor[2]); - - if (current->texture[hw_unit].hwTextureBorderColor ^ - prev->texture[hw_unit].hwTextureBorderColor) - { - prev->texture[hw_unit].hwTextureBorderColor = - current->texture[hw_unit].hwTextureBorderColor; - if (hw_unit == 1) - hwcx->GlobalFlag |= GFLAG_TEXBORDERCOLOR_1; - else - hwcx->GlobalFlag |= GFLAG_TEXBORDERCOLOR; - } - - current->texture[hw_unit].hwTextureSet |= (image->WidthLog2 << 4); - current->texture[hw_unit].hwTextureSet |= (image->HeightLog2); - - { - if (hw_unit == 0) - hwcx->GlobalFlag |= GFLAG_TEXTUREADDRESS; - else - hwcx->GlobalFlag |= GFLAG_TEXTUREADDRESS_1; - - for (i = 0; i < TxLevel + 1; i++) - { - SIStextureArea *area = (SIStextureArea *) object->Image[i]->DriverData; - GLuint texOffset; - GLuint texPitch = TransferTexturePitch (area->Pitch); - - switch(area->memType){ - case VIDEO_TYPE: - texOffset = ((char *) area->Data - (char *) GET_FbBase (hwcx)); - break; - case AGP_TYPE: - texOffset = ((char *) area->Data - (char *) GET_AGPBase (hwcx)) + - (unsigned long) hwcx->AGPAddr; - current->texture[hw_unit].hwTextureMip |= (0x40000 << i); - break; - default: - assert(0); - } - - switch (i) - { - case 0: - prev->texture[hw_unit].texOffset0 = texOffset; - prev->texture[hw_unit].texPitch01 = texPitch << 16; - break; - case 1: - prev->texture[hw_unit].texOffset1 = texOffset; - prev->texture[hw_unit].texPitch01 |= texPitch; - break; - case 2: - prev->texture[hw_unit].texOffset2 = texOffset; - prev->texture[hw_unit].texPitch23 = texPitch << 16; - break; - case 3: - prev->texture[hw_unit].texOffset3 = texOffset; - prev->texture[hw_unit].texPitch23 |= texPitch; - break; - case 4: - prev->texture[hw_unit].texOffset4 = texOffset; - prev->texture[hw_unit].texPitch45 = texPitch << 16; - break; - case 5: - prev->texture[hw_unit].texOffset5 = texOffset; - prev->texture[hw_unit].texPitch45 |= texPitch; - break; - case 6: - prev->texture[hw_unit].texOffset6 = texOffset; - prev->texture[hw_unit].texPitch67 = texPitch << 16; - break; - case 7: - prev->texture[hw_unit].texOffset7 = texOffset; - prev->texture[hw_unit].texPitch67 |= texPitch; - break; - case 8: - prev->texture[hw_unit].texOffset8 = texOffset; - prev->texture[hw_unit].texPitch89 = texPitch << 16; - break; - case 9: - prev->texture[hw_unit].texOffset9 = texOffset; - prev->texture[hw_unit].texPitch89 |= texPitch; - break; - case 10: - prev->texture[hw_unit].texOffset10 = texOffset; - prev->texture[hw_unit].texPitch10 = texPitch << 16; - break; - case 11: - prev->texture[hw_unit].texOffset11 = texOffset; - prev->texture[hw_unit].texPitch10 |= texPitch; - break; - } - } - } - - if (current->texture[hw_unit].hwTextureSet ^ - prev->texture[hw_unit].hwTextureSet) - { - prev->texture[hw_unit].hwTextureSet = - current->texture[hw_unit].hwTextureSet; - if (hw_unit == 1) - hwcx->GlobalFlag |= CFLAG_TEXTURERESET_1; - else - hwcx->GlobalFlag |= CFLAG_TEXTURERESET; - } - if (current->texture[hw_unit].hwTextureMip ^ - prev->texture[hw_unit].hwTextureMip) - { - prev->texture[hw_unit].hwTextureMip = - current->texture[hw_unit].hwTextureMip; - if (hw_unit == 1) - hwcx->GlobalFlag |= GFLAG_TEXTUREMIPMAP_1; - else - hwcx->GlobalFlag |= GFLAG_TEXTUREMIPMAP; - } -} - -static void -sis_reset_texture_env (GLcontext * ctx, int hw_unit) -{ - XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __GLSiSHardware *prev = &hwcx->prev; - __GLSiSHardware *current = &hwcx->current; - - if (hw_unit == 1) - { - current->hwTexBlendClr1 = RGB_STAGE1; - current->hwTexBlendAlpha1 = A_STAGE1; - - if ((current->hwTexBlendClr1 ^ prev->hwTexBlendClr1) || - (current->hwTexBlendAlpha1 ^ prev->hwTexBlendAlpha1) || - (current->hwTexEnvColor ^ prev->hwTexEnvColor)) - { - prev->hwTexBlendClr1 = current->hwTexBlendClr1; - prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1; - prev->hwTexEnvColor = current->hwTexEnvColor; - hwcx->GlobalFlag |= GFLAG_TEXTUREENV_1; - } - } - else - { - current->hwTexBlendClr0 = RGB_STAGE1; - current->hwTexBlendAlpha0 = A_STAGE1; - - if ((current->hwTexBlendClr0 ^ prev->hwTexBlendClr0) || - (current->hwTexBlendAlpha0 ^ prev->hwTexBlendAlpha0) || - (current->hwTexEnvColor ^ prev->hwTexEnvColor)) - { - prev->hwTexBlendClr0 = current->hwTexBlendClr0; - prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0; - prev->hwTexEnvColor = current->hwTexEnvColor; - hwcx->GlobalFlag |= GFLAG_TEXTUREENV; - } - } -} - -static DWORD -BitScanForward (WORD w) -{ - DWORD i; - - for (i = 0; i < 16; i++) - { - if (w & (1 << i)) - break; - } - return (i); -} - -static DWORD -TransferTexturePitch (DWORD dwPitch) -{ - DWORD dwRet, i; - - i = BitScanForward ((WORD) 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h Tue Aug 12 12:03:20 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_tris.c xc/lib/GL/mesa/src/drv/sis/sis_tris.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_tris.c Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_tris.c Mon Aug 25 00:15:50 2003 @@ -0,0 +1,841 @@ +/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.c,v 1.8 2002/10/30 12:51:43 alanh Exp $ */ /* -*- c-basic-offset: 3 -*- */ +/************************************************************************** + +Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and + VA Linux Systems Inc., Fremont, California. + +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, 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: + * Keith Whitwell + * + */ + +#include "glheader.h" +#include "mtypes.h" +#include "colormac.h" +#include "macros.h" + +#include "swrast/swrast.h" +#include "swrast_setup/swrast_setup.h" +#include "tnl/tnl.h" +#include "tnl/t_context.h" +#include "tnl/t_pipeline.h" + +#include "sis_tris.h" +#include "sis_state.h" +#include "sis_vb.h" +#include "sis_lock.h" +#include "sis_tex.h" + +static const GLuint hw_prim[GL_POLYGON+1] = { + OP_3D_POINT_DRAW, /* GL_POINTS */ + OP_3D_LINE_DRAW, /* GL_LINES */ + OP_3D_LINE_DRAW, /* GL_LINE_LOOP */ + OP_3D_LINE_DRAW, /* GL_LINE_STRIP */ + OP_3D_TRIANGLE_DRAW, /* GL_TRIANGLES */ + OP_3D_TRIANGLE_DRAW, /* GL_TRIANGLE_STRIP */ + OP_3D_TRIANGLE_DRAW, /* GL_TRIANGLE_FAN */ + OP_3D_TRIANGLE_DRAW, /* GL_QUADS */ + OP_3D_TRIANGLE_DRAW, /* GL_QUAD_STRIP */ + OP_3D_TRIANGLE_DRAW /* GL_POLYGON */ +}; + +static const GLuint hw_prim_fire[OP_3D_TRIANGLE_DRAW+1] = { + OP_3D_FIRE_TSARGBa, + OP_3D_FIRE_TSARGBb, + OP_3D_FIRE_TSARGBc +}; + +static const GLuint hw_prim_shade_flat[OP_3D_TRIANGLE_DRAW+1] = { + SHADE_FLAT_VertexA, + SHADE_FLAT_VertexB, + SHADE_FLAT_VertexC +}; + +static const GLuint hw_prim_ps_type[OP_3D_TRIANGLE_DRAW+1] = { + MASK_PsPointList, + MASK_PsLineList, + MASK_PsTriangleList +}; + +static void sisRasterPrimitive( GLcontext *ctx, GLenum prim, GLuint hwprim ); +static void sisRenderPrimitive( GLcontext *ctx, GLenum prim ); + + +/*********************************************************************** + * Emit primitives as inline vertices * + ***********************************************************************/ + +#define SIS_MMIO_WRITE_VERTEX(_v, i, lastvert) \ +do { \ + MMIOBase[(REG_3D_TSXa+(i)*0x30)/4] = _v->v.x; \ + MMIOBase[(REG_3D_TSYa+(i)*0x30)/4] = _v->v.y; \ + MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = _v->v.z; \ + MMIOBase[(REG_3D_TSWGa+(i)*0x30)/4] = _v->v.w; \ + ((GLint *) MMIOBase)[(REG_3D_TSFSa+(i)*0x30)/4] = _v->ui[8]; \ + MMIOBase[(REG_3D_TSUAa+(i)*0x30)/4] = _v->v.u0; \ + MMIOBase[(REG_3D_TSVAa+(i)*0x30)/4] = _v->v.v0; \ + MMIOBase[(REG_3D_TSUBa+(i)*0x30)/4] = _v->v.u1; \ + MMIOBase[(REG_3D_TSVBa+(i)*0x30)/4] = _v->v.v1; \ + /*MMIOBase[(REG_3D_TSUCa+(i)*0x30)/4] = _v->v.u2; \ + MMIOBase[(REG_3D_TSVCa+(i)*0x30)/4] = _v->v.v2;*/ \ +/*printf("%f/%f/%f/%f\n", _v->v.u0, _v->v.v0, _v->v.u1, _v->v.v1);*/ \ + /* the ARGB write of the last vertex of the primitive fires the 3d engine*/ \ + if (lastvert) \ + ((GLint *) MMIOBase)[(REG_3D_TSARGBa+(i)*0x30)/4] = _v->ui[4]; \ +} while (0); + +#define MMIO_VERT_REG_COUNT 10 + +static __inline void sis_draw_quad_mmio( sisContextPtr smesa, + sisVertexPtr v0, + sisVertexPtr v1, + sisVertexPtr v2, + sisVertexPtr v3 ) +{ + float *MMIOBase = (float *)GET_IOBase (smesa); + + mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 6 + 1); + ((GLint *) MMIOBase)[REG_3D_PrimitiveSet / 4] = smesa->dwPrimitiveSet; + SIS_MMIO_WRITE_VERTEX(v0, 0, 0); + SIS_MMIO_WRITE_VERTEX(v1, 1, 0); + SIS_MMIO_WRITE_VERTEX(v3, 2, 1); + SIS_MMIO_WRITE_VERTEX(v1, 0, 0); + SIS_MMIO_WRITE_VERTEX(v2, 1, 0); + SIS_MMIO_WRITE_VERTEX(v3, 2, 1); +} + +static __inline void sis_draw_triangle_mmio( sisContextPtr smesa, + sisVertexPtr v0, + sisVertexPtr v1, + sisVertexPtr v2 ) +{ + float *MMIOBase = (float *)GET_IOBase (smesa); + + mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 3 + 1); + ((GLint *) MMIOBase)[REG_3D_PrimitiveSet / 4] = smesa->dwPrimitiveSet; + SIS_MMIO_WRITE_VERTEX(v0, 0, 0); + SIS_MMIO_WRITE_VERTEX(v1, 1, 0); + SIS_MMIO_WRITE_VERTEX(v2, 2, 1); +} + +static __inline void sis_draw_line_mmio( sisContextPtr smesa, + sisVertexPtr v0, + sisVertexPtr v1 ) +{ + float *MMIOBase = (float *)GET_IOBase (smesa); + + mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 2 + 1); + ((GLint *) MMIOBase)[REG_3D_PrimitiveSet / 4] = smesa->dwPrimitiveSet; + SIS_MMIO_WRITE_VERTEX(v0, 0, 0); + SIS_MMIO_WRITE_VERTEX(v1, 1, 1); +} + +static __inline void sis_draw_point_mmio( sisContextPtr smesa, + sisVertexPtr v0 ) +{ + float *MMIOBase = (float *)GET_IOBase (smesa); + + mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 1 + 1); + ((GLint *) MMIOBase)[REG_3D_PrimitiveSet / 4] = smesa->dwPrimitiveSet; + SIS_MMIO_WRITE_VERTEX(v0, 1, 1); +} + +/*********************************************************************** + * Macros for t_dd_tritmp.h to draw basic primitives * + ***********************************************************************/ + +#define TRI( a, b, c ) \ +do { \ + if (DO_FALLBACK) \ + smesa->draw_tri( smesa, a, b, c ); \ + else \ + sis_draw_triangle_mmio( smesa, a, b, c ); \ +} while (0) + +#define QUAD( a, b, c, d ) \ +do { \ + if (DO_FALLBACK) { \ + smesa->draw_tri( smesa, a, b, d ); \ + smesa->draw_tri( smesa, b, c, d ); \ + } else \ + sis_draw_quad_mmio( smesa, a, b, c, d ); \ +} while (0) + +#define LINE( v0, v1 ) \ +do { \ + if (DO_FALLBACK) \ + smesa->draw_line( smesa, v0, v1 ); \ + else \ + sis_draw_line_mmio( smesa, v0, v1 ); \ +} while (0) + +#define POINT( v0 ) \ +do { \ + if (DO_FALLBACK) \ + smesa->draw_point( smesa, v0 ); \ + else \ + sis_draw_point_mmio( smesa, v0 ); \ +} while (0) + + +/*********************************************************************** + * Build render functions from dd templates * + ***********************************************************************/ + +#define SIS_OFFSET_BIT 0x01 +#define SIS_TWOSIDE_BIT 0x02 +#define SIS_UNFILLED_BIT 0x04 +#define SIS_FALLBACK_BIT 0x08 +#define SIS_MAX_TRIFUNC 0x10 + + +static struct { + points_func points; + line_func line; + triangle_func triangle; + quad_func quad; +} rast_tab[SIS_MAX_TRIFUNC]; + + +#define DO_FALLBACK (IND & SIS_FALLBACK_BIT) +#define DO_OFFSET (IND & SIS_OFFSET_BIT) +#define DO_UNFILLED (IND & SIS_UNFILLED_BIT) +#define DO_TWOSIDE (IND & SIS_TWOSIDE_BIT) +#define DO_FLAT 0 +#define DO_TRI 1 +#define DO_QUAD 1 +#define DO_LINE 1 +#define DO_POINTS 1 +#define DO_FULL_QUAD 1 + +#define HAVE_RGBA 1 +#define HAVE_SPEC 1 +#define HAVE_BACK_COLORS 0 +#define HAVE_HW_FLATSHADE 1 +#define VERTEX sisVertex +#define TAB rast_tab + +#define DEPTH_SCALE 1.0 +#define UNFILLED_TRI unfilled_tri +#define UNFILLED_QUAD unfilled_quad +#define VERT_X(_v) _v->v.x +#define VERT_Y(_v) _v->v.y +#define VERT_Z(_v) _v->v.z +#define AREA_IS_CCW( a ) (a > 0) +#define GET_VERTEX(e) (smesa->verts + (e << smesa->vertex_stride_shift)) + +#define VERT_SET_RGBA( v, c ) \ + do { \ + sis_color_t *vc = (sis_color_t *)&(v)->ui[coloroffset]; \ + vc->blue = (c)[2]; \ + vc->green = (c)[1]; \ + vc->red = (c)[0]; \ + vc->alpha = (c)[3]; \ + } while (0) +#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset] +#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset] +#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx] + +#define VERT_SET_SPEC( v0, c ) \ + if (havespec) { \ + (v0)->v.specular.red = (c)[0]; \ + (v0)->v.specular.green = (c)[1]; \ + (v0)->v.specular.blue = (c)[2]; \ + } +#define VERT_COPY_SPEC( v0, v1 ) \ + if (havespec) { \ + (v0)->v.specular.red = v1->v.specular.red; \ + (v0)->v.specular.green = v1->v.specular.green; \ + (v0)->v.specular.blue = v1->v.specular.blue; \ + } + +#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5] +#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx] + +#define LOCAL_VARS(n) \ + sisContextPtr smesa = SIS_CONTEXT(ctx); \ + GLuint color[n], spec[n]; \ + GLuint coloroffset = (smesa->vertex_size == 4 ? 3 : 4); \ + GLboolean havespec = (smesa->vertex_size == 4 ? 0 : 1); \ + (void) color; (void) spec; (void) coloroffset; (void) havespec; + +/*********************************************************************** + * Helpers for rendering unfilled primitives * + ***********************************************************************/ + +#define RASTERIZE(x) if (smesa->raster_primitive != x) \ + sisRasterPrimitive( ctx, x, hw_prim[x] ) +#define RENDER_PRIMITIVE smesa->render_primitive +#define IND SIS_FALLBACK_BIT +#define TAG(x) x +#include "tnl_dd/t_dd_unfilled.h" +#undef IND + + +/*********************************************************************** + * Generate GL render functions * + ***********************************************************************/ + + +#define IND (0) +#define TAG(x) x +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_OFFSET_BIT) +#define TAG(x) x##_offset +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_TWOSIDE_BIT) +#define TAG(x) x##_twoside +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_TWOSIDE_BIT | SIS_OFFSET_BIT) +#define TAG(x) x##_twoside_offset +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_UNFILLED_BIT) +#define TAG(x) x##_unfilled +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_OFFSET_BIT | SIS_UNFILLED_BIT) +#define TAG(x) x##_offset_unfilled +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_TWOSIDE_BIT | SIS_UNFILLED_BIT) +#define TAG(x) x##_twoside_unfilled +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_TWOSIDE_BIT | SIS_OFFSET_BIT | SIS_UNFILLED_BIT) +#define TAG(x) x##_twoside_offset_unfilled +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_FALLBACK_BIT) +#define TAG(x) x##_fallback +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_OFFSET_BIT | SIS_FALLBACK_BIT) +#define TAG(x) x##_offset_fallback +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_TWOSIDE_BIT | SIS_FALLBACK_BIT) +#define TAG(x) x##_twoside_fallback +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_TWOSIDE_BIT | SIS_OFFSET_BIT | SIS_FALLBACK_BIT) +#define TAG(x) x##_twoside_offset_fallback +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_UNFILLED_BIT | SIS_FALLBACK_BIT) +#define TAG(x) x##_unfilled_fallback +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_OFFSET_BIT | SIS_UNFILLED_BIT | SIS_FALLBACK_BIT) +#define TAG(x) x##_offset_unfilled_fallback +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_TWOSIDE_BIT | SIS_UNFILLED_BIT | SIS_FALLBACK_BIT) +#define TAG(x) x##_twoside_unfilled_fallback +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (SIS_TWOSIDE_BIT | SIS_OFFSET_BIT | SIS_UNFILLED_BIT | \ + SIS_FALLBACK_BIT) +#define TAG(x) x##_twoside_offset_unfilled_fallback +#include "tnl_dd/t_dd_tritmp.h" + + +static void init_rast_tab( void ) +{ + init(); + init_offset(); + init_twoside(); + init_twoside_offset(); + init_unfilled(); + init_offset_unfilled(); + init_twoside_unfilled(); + init_twoside_offset_unfilled(); + init_fallback(); + init_offset_fallback(); + init_twoside_fallback(); + init_twoside_offset_fallback(); + init_unfilled_fallback(); + init_offset_unfilled_fallback(); + init_twoside_unfilled_fallback(); + init_twoside_offset_unfilled_fallback(); +} + + + +/*********************************************************************** + * Rasterization fallback helpers * + ***********************************************************************/ + + +/* This code is hit only when a mix of accelerated and unaccelerated + * primitives are being drawn, and only for the unaccelerated + * primitives. + */ +static void +sis_fallback_tri( sisContextPtr smesa, + sisVertex *v0, + sisVertex *v1, + sisVertex *v2 ) +{ + GLcontext *ctx = smesa->glCtx; + SWvertex v[3]; + sis_translate_vertex( ctx, v0, &v[0] ); + sis_translate_vertex( ctx, v1, &v[1] ); + sis_translate_vertex( ctx, v2, &v[2] ); + _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); +} + + +static void +sis_fallback_line( sisContextPtr smesa, + sisVertex *v0, + sisVertex *v1 ) +{ + GLcontext *ctx = smesa->glCtx; + SWvertex v[2]; + sis_translate_vertex( ctx, v0, &v[0] ); + sis_translate_vertex( ctx, v1, &v[1] ); + _swrast_Line( ctx, &v[0], &v[1] ); +} + + +static void +sis_fallback_point( sisContextPtr smesa, + sisVertex *v0 ) +{ + GLcontext *ctx = smesa->glCtx; + SWvertex v[1]; + sis_translate_vertex( ctx, v0, &v[0] ); + _swrast_Point( ctx, &v[0] ); +} + + + +/**********************************************************************/ +/* Render unclipped begin/end objects */ +/**********************************************************************/ + +#define VERT(x) (sisVertex *)(sisverts + (x << shift)) +#define RENDER_POINTS( start, count ) \ + for ( ; start < count ; start++) \ + sis_draw_point_mmio( smesa, VERT(start) ) +#define RENDER_LINE( v0, v1 ) \ + sis_draw_line_mmio( smesa, VERT(v0), VERT(v1) ) +#define RENDER_TRI( v0, v1, v2 ) \ + sis_draw_triangle_mmio( smesa, VERT(v0), VERT(v1), VERT(v2) ) +#define RENDER_QUAD( v0, v1, v2, v3 ) \ + sis_draw_quad_mmio( smesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) +#define INIT(x) do { \ + if (0) \ + fprintf(stderr, "%s\n", __FUNCTION__); \ + sisRenderPrimitive( ctx, x ); \ +} while (0) +#undef LOCAL_VARS +#define LOCAL_VARS \ + sisContextPtr smesa = SIS_CONTEXT(ctx); \ + const GLuint shift = smesa->vertex_stride_shift; \ + const char *sisverts = (char *)smesa->verts; \ + const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ + (void) elt; +#define RESET_STIPPLE +#define RESET_OCCLUSION +#define PRESERVE_VB_DEFS +#define ELT(x) (x) +#define TAG(x) sis_##x##_verts +#include "tnl/t_vb_rendertmp.h" +#undef ELT +#undef TAG +#define TAG(x) sis_##x##_elts +#define ELT(x) elt[x] +#include "tnl/t_vb_rendertmp.h" + + +/**********************************************************************/ +/* Render clipped primitives */ +/**********************************************************************/ + +static void sisRenderClippedPoly( GLcontext *ctx, const GLuint *elts, GLuint n ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + + /* Render the new vertices as an unclipped polygon. + */ + { + GLuint *tmp = VB->Elts; + VB->Elts = (GLuint *)elts; + tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END ); + VB->Elts = tmp; + } +} + +static void sisRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + tnl->Driver.Render.Line( ctx, ii, jj ); +} + +#if 0 +static void sisFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts, + GLuint n ) +{ + sisContextPtr smesa = SIS_CONTEXT( ctx ); + GLuint vertsize = smesa->vertex_size; + GLuint *vb = r128AllocDmaLow( rmesa, (n-2) * 3 * 4 * vertsize ); + GLubyte *sisverts = (GLubyte *)smesa->verts; + const GLuint shift = smesa->vertex_stride_shift; + const GLuint *start = (const GLuint *)VERT(elts[0]); + int i,j; + + smesa->num_verts += (n-2) * 3; + + for (i = 2 ; i < n ; i++) { + COPY_DWORDS( j, vb, vertsize, (sisVertexPtr) VERT(elts[i-1]) ); + COPY_DWORDS( j, vb, vertsize, (sisVertexPtr) VERT(elts[i]) ); + COPY_DWORDS( j, vb, vertsize, (sisVertexPtr) start ); + } +} +#endif + + + + +/**********************************************************************/ +/* Choose render functions */ +/**********************************************************************/ + +/* XXX */ +#define _SIS_NEW_RENDER_STATE (_DD_NEW_LINE_STIPPLE | \ + _DD_NEW_LINE_SMOOTH | \ + _DD_NEW_POINT_SMOOTH | \ + _DD_NEW_TRI_SMOOTH | \ + _DD_NEW_TRI_UNFILLED | \ + _DD_NEW_TRI_LIGHT_TWOSIDE | \ + _DD_NEW_TRI_OFFSET) \ + + +#define POINT_FALLBACK (DD_POINT_SMOOTH) +#define LINE_FALLBACK (DD_LINE_STIPPLE|DD_LINE_SMOOTH) +#define TRI_FALLBACK (DD_TRI_SMOOTH) +#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK) +#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED) + + +static void sisChooseRenderState(GLcontext *ctx) +{ + sisContextPtr smesa = SIS_CONTEXT( ctx ); + GLuint flags = ctx->_TriangleCaps; + GLuint index = 0; + + if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) { + smesa->draw_point = sis_draw_point_mmio; + smesa->draw_line = sis_draw_line_mmio; + smesa->draw_tri = sis_draw_triangle_mmio; + + if (flags & ANY_RASTER_FLAGS) { + if (flags & DD_TRI_LIGHT_TWOSIDE) index |= SIS_TWOSIDE_BIT; + if (flags & DD_TRI_OFFSET) index |= SIS_OFFSET_BIT; + if (flags & DD_TRI_UNFILLED) index |= SIS_UNFILLED_BIT; + } + + /* Hook in fallbacks for specific primitives. + */ + if (flags & (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)) { + if (flags & POINT_FALLBACK) + smesa->draw_point = sis_fallback_point; + if (flags & LINE_FALLBACK) + smesa->draw_line = sis_fallback_line; + if (flags & TRI_FALLBACK) + smesa->draw_tri = sis_fallback_tri; + index |= SIS_FALLBACK_BIT; + } + } + + if (index != smesa->RenderIndex) { + TNLcontext *tnl = TNL_CONTEXT(ctx); + tnl->Driver.Render.Points = rast_tab[index].points; + tnl->Driver.Render.Line = rast_tab[index].line; + tnl->Driver.Render.Triangle = rast_tab[index].triangle; + tnl->Driver.Render.Quad = rast_tab[index].quad; + + if (index == 0) { + tnl->Driver.Render.PrimTabVerts = sis_render_tab_verts; + tnl->Driver.Render.PrimTabElts = sis_render_tab_elts; + tnl->Driver.Render.ClippedLine = rast_tab[index].line; + /*XXX: sisFastRenderClippedPoly*/ + tnl->Driver.Render.ClippedPolygon = sisRenderClippedPoly; + } else { + tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; + tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; + tnl->Driver.Render.ClippedLine = sisRenderClippedLine; + tnl->Driver.Render.ClippedPolygon = sisRenderClippedPoly; + } + + smesa->RenderIndex = index; + } +} + +/**********************************************************************/ +/* Validate state at pipeline start */ +/**********************************************************************/ + +static void sisRunPipeline( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT( ctx ); + + /* XXX TODO: change this to sisDDUpdateHwState like other drivers */ + if (smesa->NewGLState & _NEW_TEXTURE) + sisUpdateTextureState( ctx ); + + LOCK_HARDWARE(); + if (smesa->GlobalFlag & GFLAG_RENDER_STATES) + sis_update_render_state( smesa ); + + if (smesa->GlobalFlag & GFLAG_TEXTURE_STATES) + sis_update_texture_state( smesa ); + UNLOCK_HARDWARE(); + + if (!smesa->Fallback && smesa->NewGLState) { + if (smesa->NewGLState & _SIS_NEW_VERTEX_STATE) + sisChooseVertexState( ctx ); + + if (smesa->NewGLState & _SIS_NEW_RENDER_STATE) + sisChooseRenderState( ctx ); + + smesa->NewGLState = 0; + } + + _tnl_run_pipeline( ctx ); +} + +/**********************************************************************/ +/* High level hooks for t_vb_render.c */ +/**********************************************************************/ + +/* This is called when Mesa switches between rendering triangle + * primitives (such as GL_POLYGON, GL_QUADS, GL_TRIANGLE_STRIP, etc), + * and lines, points and bitmaps. + * + * As the r128 uses triangles to render lines and points, it is + * necessary to turn off hardware culling when rendering these + * primitives. XXX + */ + +static void sisRasterPrimitive( GLcontext *ctx, GLenum prim, GLuint hwprim ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + if (smesa->hw_primitive != hwprim) { + if (smesa->UseAGPCmdMode) { + sisFlushAGP (ctx); + sisStartAGP (ctx); + } else { + mEndPrimitive(); + } + + smesa->dwPrimitiveSet &= ~(MASK_DrawPrimitiveCommand | + MASK_SetFirePosition | MASK_ShadingMode); + smesa->AGPParseSet &= ~(MASK_PsDataType); + if (ctx->Polygon.SmoothFlag) /* XXX */ + smesa->dwPrimitiveSet |= SHADE_GOURAUD; + else + smesa->dwPrimitiveSet |= hw_prim_shade_flat[hwprim]; + smesa->dwPrimitiveSet |= hwprim | hw_prim_fire[hwprim]; + smesa->AGPParseSet |= hw_prim_ps_type[hwprim]; + } + smesa->raster_primitive = prim; + smesa->hw_primitive = hwprim; +} + +static void sisRenderPrimitive( GLcontext *ctx, GLenum prim ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + smesa->render_primitive = prim; + if (prim >= GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) + return; + sisRasterPrimitive( ctx, prim, hw_prim[prim] ); +} + + +static void sisRenderStart( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + /* Check for projective texturing. Make sure all texcoord + * pointers point to something. (fix in mesa?) + */ + sisCheckTexSizes( ctx ); + LOCK_HARDWARE(); + if (smesa->UseAGPCmdMode) + sisStartAGP( ctx ); +} + +static void sisRenderFinish( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + if (SIS_CONTEXT(ctx)->RenderIndex & SIS_FALLBACK_BIT) + _swrast_flush( ctx ); + + if (smesa->UseAGPCmdMode) + sisFlushAGP( ctx ); + else + mEndPrimitive(); /* XXX: necessary? */ + UNLOCK_HARDWARE(); +} + +/* + * 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 GLint AGP_EngineOffset; +static GLint *AGP_StartPtr; +float *AGP_CurrentPtr; + +void +sisStartAGP( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + GLint start, end; + + start = *(smesa->pAGPCmdBufNext); + end = start + AGP_ALLOC_SIZE; + if (end >= smesa->AGPCmdBufSize) { + start = 0; + end = AGP_ALLOC_SIZE; + } + + /* + * TODO: use AGP_EngineOffset to get a safe value and not query current + * postion processed every time + * ?? use < instead of <= + */ + do { + AGP_EngineOffset = + *(GLint volatile *)(GET_IOBase (smesa) + REG_3D_AGPCmBase) - + (GLint) smesa->AGPCmdBufAddr; + } while ((AGP_EngineOffset <= end) && (AGP_EngineOffset >= start) && + ((*(GET_IOBase (smesa) + 0x8243) & 0xe0) != 0xe0)); + + AGP_StartPtr = (GLint *) (start + smesa->AGPCmdBufBase); + AGP_CurrentPtr = (float *) AGP_StartPtr; +} + +void +sisFlushAGP( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + /* TODO: wait queue length */ + + if((GLint *)AGP_CurrentPtr == AGP_StartPtr) + return; + + mWait3DCmdQueue (5); + mEndPrimitive (); + MMIO(REG_3D_AGPCmBase, ((GLint) AGP_StartPtr - + (GLint) smesa->AGPCmdBufBase) + (GLint) smesa->AGPCmdBufAddr); + MMIO(REG_3D_AGPTtDwNum, + (((GLint) AGP_CurrentPtr - (GLint) AGP_StartPtr) >> 2) | 0x50000000); + MMIO(REG_3D_ParsingSet, smesa->AGPParseSet); + + MMIO(REG_3D_AGPCmFire, (GLint) (-1)); + mEndPrimitive (); + + *(smesa->pAGPCmdBufNext) = (GLint) AGP_CurrentPtr - + (GLint) smesa->AGPCmdBufBase; + *(smesa->pAGPCmdBufNext) = (*(smesa->pAGPCmdBufNext) + 0xf) & ~0xf; +} + + +/**********************************************************************/ +/* Transition to/from hardware rasterization. */ +/**********************************************************************/ + +void sisFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + sisContextPtr smesa = SIS_CONTEXT(ctx); + GLuint oldfallback = smesa->Fallback; + + if (mode) { + smesa->Fallback |= bit; + if (oldfallback == 0) { + _swsetup_Wakeup( ctx ); + smesa->RenderIndex = ~0; + printf("software!\n"); + } + } + else { + smesa->Fallback &= ~bit; + if (oldfallback == bit) { + _swrast_flush( ctx ); + tnl->Driver.Render.Start = sisRenderStart; + tnl->Driver.Render.PrimitiveNotify = sisRenderPrimitive; + tnl->Driver.Render.Finish = sisRenderFinish; + tnl->Driver.Render.BuildVertices = sisBuildVertices; + smesa->NewGLState |= (_SIS_NEW_RENDER_STATE| + _SIS_NEW_VERTEX_STATE); + printf("hardware!\n"); + } + } +} + + +/**********************************************************************/ +/* Initialization. */ +/**********************************************************************/ + +void sisInitTriFuncs( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT(ctx); + TNLcontext *tnl = TNL_CONTEXT(ctx); + static int firsttime = 1; + + if (firsttime) { + init_rast_tab(); + firsttime = 0; + } + + tnl->Driver.RunPipeline = sisRunPipeline; + tnl->Driver.Render.Start = sisRenderStart; + tnl->Driver.Render.Finish = sisRenderFinish; + tnl->Driver.Render.PrimitiveNotify = sisRenderPrimitive; + tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; + tnl->Driver.Render.BuildVertices = sisBuildVertices; + + sisFallback(ctx, SIS_FALLBACK_FORCE, 0); + smesa->RenderIndex = ~0; + smesa->NewGLState |= (_SIS_NEW_RENDER_STATE| + _SIS_NEW_VERTEX_STATE); +} diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_tris.h xc/lib/GL/mesa/src/drv/sis/sis_tris.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_tris.h Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_tris.h Tue Aug 12 12:03:20 2003 @@ -0,0 +1,48 @@ +/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.h,v 1.8 2002/10/30 12:51:43 alanh Exp $ */ +/************************************************************************** + +Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and + VA Linux Systems Inc., Fremont, California. + +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, 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: + * Keith Whitwell + * + */ + +#ifndef __SIS_TRIS_H__ +#define __SIS_TRIS_H__ + +#include "mtypes.h" + +extern void sisInitTriFuncs( GLcontext *ctx ); + + +extern void sisFallback( GLcontext *ctx, GLuint bit, GLboolean mode ); +#define FALLBACK( smesa, bit, mode ) sisFallback( smesa->glCtx, bit, mode ) + + +#endif /* __SIS_TRIS_H__ */ diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_vb.c xc/lib/GL/mesa/src/drv/sis/sis_vb.c --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_vb.c Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_vb.c Mon Aug 25 00:15:50 2003 @@ -0,0 +1,484 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and + VA Linux Systems Inc., Fremont, California. + +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, 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: + * Keith Whitwell + * + */ + +#include "glheader.h" +#include "mtypes.h" +#include "imports.h" +#include "macros.h" +#include "colormac.h" + +#include "swrast_setup/swrast_setup.h" +#include "tnl/t_context.h" + +#include "sis_context.h" +#include "sis_vb.h" +#include "sis_tris.h" +#include "sis_state.h" + + +#define SIS_TEX1_BIT 0x1 +#define SIS_TEX0_BIT 0x2 +#define SIS_RGBA_BIT 0x4 +#define SIS_SPEC_BIT 0x8 +#define SIS_FOG_BIT 0x10 +#define SIS_XYZW_BIT 0x20 +#define SIS_PTEX_BIT 0x40 +#define SIS_MAX_SETUP 0x80 + +static struct { + void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint ); + interp_func interp; + copy_pv_func copy_pv; + GLboolean (*check_tex_sizes)( GLcontext *ctx ); + GLuint vertex_size; + GLuint vertex_stride_shift; + GLuint vertex_format; +} setup_tab[SIS_MAX_SETUP]; +/* +#define TINY_VERTEX_FORMAT (R128_CCE_VC_FRMT_DIFFUSE_ARGB) + +#define NOTEX_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \ + R128_CCE_VC_FRMT_DIFFUSE_ARGB |\ + R128_CCE_VC_FRMT_SPEC_FRGB) + +#define TEX0_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \ + R128_CCE_VC_FRMT_DIFFUSE_ARGB |\ + R128_CCE_VC_FRMT_SPEC_FRGB | \ + R128_CCE_VC_FRMT_S_T) + +#define TEX1_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \ + R128_CCE_VC_FRMT_DIFFUSE_ARGB |\ + R128_CCE_VC_FRMT_SPEC_FRGB | \ + R128_CCE_VC_FRMT_S_T | \ + R128_CCE_VC_FRMT_S2_T2) +*/ +#define TEX0_VERTEX_FORMAT 1 +#define TEX1_VERTEX_FORMAT 2 + +#define TINY_VERTEX_FORMAT 0 +#define NOTEX_VERTEX_FORMAT 0 +#define PROJ_TEX1_VERTEX_FORMAT 0 +#define TEX2_VERTEX_FORMAT 0 +#define TEX3_VERTEX_FORMAT 0 +#define PROJ_TEX3_VERTEX_FORMAT 0 + +#define DO_XYZW (IND & SIS_XYZW_BIT) +#define DO_RGBA (IND & SIS_RGBA_BIT) +#define DO_SPEC (IND & SIS_SPEC_BIT) +#define DO_FOG (IND & SIS_FOG_BIT) +#define DO_TEX0 (IND & SIS_TEX0_BIT) +#define DO_TEX1 (IND & SIS_TEX1_BIT) +#define DO_TEX2 0 +#define DO_TEX3 0 +#define DO_PTEX (IND & SIS_PTEX_BIT) + +#define VERTEX sisVertex +#define VERTEX_COLOR sis_color_t +#define LOCALVARS sisContextPtr smesa = SIS_CONTEXT(ctx); +#define GET_VIEWPORT_MAT() smesa->hw_viewport +#define GET_TEXSOURCE(n) n +#define GET_VERTEX_FORMAT() smesa->vertex_format +#define GET_VERTEX_STORE() smesa->verts +#define GET_VERTEX_STRIDE_SHIFT() smesa->vertex_stride_shift +#define GET_UBYTE_COLOR_STORE() &smesa->UbyteColor +#define GET_UBYTE_SPEC_COLOR_STORE() &smesa->UbyteSecondaryColor + +#define HAVE_HW_VIEWPORT 0 +#define HAVE_HW_DIVIDE 0 +#define HAVE_RGBA_COLOR 0 +#define HAVE_TINY_VERTICES 0 +#define HAVE_NOTEX_VERTICES 0 +#define HAVE_TEX0_VERTICES 1 +#define HAVE_TEX1_VERTICES 1 +#define HAVE_TEX2_VERTICES 0 +#define HAVE_TEX3_VERTICES 0 +#define HAVE_PTEX_VERTICES 0 + +#define UNVIEWPORT_VARS GLfloat h = SIS_CONTEXT(ctx)->driDrawable->h +#define UNVIEWPORT_X(x) x - SUBPIXEL_X +#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y +#define UNVIEWPORT_Z(z) z / smesa->depth_scale + +#define PTEX_FALLBACK() FALLBACK(smesa, SIS_FALLBACK_TEXTURE, 1) + +#define IMPORT_FLOAT_COLORS sis_import_float_colors +#define IMPORT_FLOAT_SPEC_COLORS sis_import_float_spec_colors + +#define INTERP_VERTEX setup_tab[smesa->SetupIndex].interp +#define COPY_PV_VERTEX setup_tab[smesa->SetupIndex].copy_pv + +/*********************************************************************** + * Generate pv-copying and translation functions * + ***********************************************************************/ + +#define TAG(x) sis_##x +#include "tnl_dd/t_dd_vb.c" + +/*********************************************************************** + * Generate vertex emit and interp functions * + ***********************************************************************/ + + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT) +#define TAG(x) x##_wg +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_SPEC_BIT) +#define TAG(x) x##_wgs +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_TEX0_BIT) +#define TAG(x) x##_wgt0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_TEX0_BIT|SIS_TEX1_BIT) +#define TAG(x) x##_wgt0t1 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_TEX0_BIT|SIS_PTEX_BIT) +#define TAG(x) x##_wgpt0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT) +#define TAG(x) x##_wgst0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT|\ + SIS_TEX1_BIT) +#define TAG(x) x##_wgst0t1 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT|\ + SIS_PTEX_BIT) +#define TAG(x) x##_wgspt0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT) +#define TAG(x) x##_wgf +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT) +#define TAG(x) x##_wgfs +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_TEX0_BIT) +#define TAG(x) x##_wgft0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_TEX0_BIT|\ + SIS_TEX1_BIT) +#define TAG(x) x##_wgft0t1 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_TEX0_BIT|\ + SIS_PTEX_BIT) +#define TAG(x) x##_wgfpt0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT|\ + SIS_TEX0_BIT) +#define TAG(x) x##_wgfst0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT|\ + SIS_TEX0_BIT|SIS_TEX1_BIT) +#define TAG(x) x##_wgfst0t1 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT|\ + SIS_TEX0_BIT|SIS_PTEX_BIT) +#define TAG(x) x##_wgfspt0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_TEX0_BIT) +#define TAG(x) x##_t0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_TEX0_BIT|SIS_TEX1_BIT) +#define TAG(x) x##_t0t1 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_FOG_BIT) +#define TAG(x) x##_f +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_FOG_BIT|SIS_TEX0_BIT) +#define TAG(x) x##_ft0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_FOG_BIT|SIS_TEX0_BIT|SIS_TEX1_BIT) +#define TAG(x) x##_ft0t1 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT) +#define TAG(x) x##_g +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT|SIS_SPEC_BIT) +#define TAG(x) x##_gs +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT|SIS_TEX0_BIT) +#define TAG(x) x##_gt0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT|SIS_TEX0_BIT|SIS_TEX1_BIT) +#define TAG(x) x##_gt0t1 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT) +#define TAG(x) x##_gst0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT|SIS_TEX1_BIT) +#define TAG(x) x##_gst0t1 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT|SIS_FOG_BIT) +#define TAG(x) x##_gf +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT) +#define TAG(x) x##_gfs +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT|SIS_FOG_BIT|SIS_TEX0_BIT) +#define TAG(x) x##_gft0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT|SIS_FOG_BIT|SIS_TEX0_BIT|SIS_TEX1_BIT) +#define TAG(x) x##_gft0t1 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT) +#define TAG(x) x##_gfst0 +#include "tnl_dd/t_dd_vbtmp.h" + +#define IND (SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT|\ + SIS_TEX1_BIT) +#define TAG(x) x##_gfst0t1 +#include "tnl_dd/t_dd_vbtmp.h" + + +static void init_setup_tab( void ) +{ + init_wg(); + init_wgs(); + init_wgt0(); + init_wgt0t1(); + init_wgpt0(); + init_wgst0(); + init_wgst0t1(); + init_wgspt0(); + init_wgf(); + init_wgfs(); + init_wgft0(); + init_wgft0t1(); + init_wgfpt0(); + init_wgfst0(); + init_wgfst0t1(); + init_wgfspt0(); + init_t0(); + init_t0t1(); + init_f(); + init_ft0(); + init_ft0t1(); + init_g(); + init_gs(); + init_gt0(); + init_gt0t1(); + init_gst0(); + init_gst0t1(); + init_gf(); + init_gfs(); + init_gft0(); + init_gft0t1(); + init_gfst0(); + init_gfst0t1(); +} + + + +void sisPrintSetupFlags(char *msg, GLuint flags ) +{ + fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n", + msg, + (int)flags, + (flags & SIS_XYZW_BIT) ? " xyzw," : "", + (flags & SIS_RGBA_BIT) ? " rgba," : "", + (flags & SIS_SPEC_BIT) ? " spec," : "", + (flags & SIS_FOG_BIT) ? " fog," : "", + (flags & SIS_TEX0_BIT) ? " tex-0," : "", + (flags & SIS_TEX1_BIT) ? " tex-1," : ""); +} + + + +void sisCheckTexSizes( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT( ctx ); + + if (!setup_tab[smesa->SetupIndex].check_tex_sizes(ctx)) { + TNLcontext *tnl = TNL_CONTEXT(ctx); + + /* Invalidate stored verts + */ + smesa->SetupNewInputs = ~0; + smesa->SetupIndex |= SIS_PTEX_BIT; + + if (!smesa->Fallback && + !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { + tnl->Driver.Render.Interp = setup_tab[smesa->SetupIndex].interp; + tnl->Driver.Render.CopyPV = setup_tab[smesa->SetupIndex].copy_pv; + } + } +} + +void sisBuildVertices( GLcontext *ctx, + GLuint start, + GLuint count, + GLuint newinputs ) +{ + sisContextPtr smesa = SIS_CONTEXT( ctx ); + GLubyte *v = ((GLubyte *)smesa->verts + (start<vertex_stride_shift)); + GLuint stride = 1 << smesa->vertex_stride_shift; + + newinputs |= smesa->SetupNewInputs; + smesa->SetupNewInputs = 0; + + if (!newinputs) + return; + + if (newinputs & VERT_BIT_CLIP) { + setup_tab[smesa->SetupIndex].emit( ctx, start, count, v, stride ); + } else { + GLuint ind = 0; + + if (newinputs & VERT_BIT_COLOR0) + ind |= SIS_RGBA_BIT; + + if (newinputs & VERT_BIT_COLOR1) + ind |= SIS_SPEC_BIT; + + if (newinputs & VERT_BIT_TEX0) + ind |= SIS_TEX0_BIT; + + if (newinputs & VERT_BIT_TEX1) + ind |= SIS_TEX1_BIT; + + if (newinputs & VERT_BIT_FOG) + ind |= SIS_FOG_BIT; + + if (smesa->SetupIndex & SIS_PTEX_BIT) + ind = ~0; + + ind &= smesa->SetupIndex; + + if (ind) { + setup_tab[ind].emit( ctx, start, count, v, stride ); + } + } +} + +void sisChooseVertexState( GLcontext *ctx ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + sisContextPtr smesa = SIS_CONTEXT( ctx ); + GLuint ind = SIS_XYZW_BIT | SIS_RGBA_BIT; + + if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) + ind |= SIS_SPEC_BIT; + + if (ctx->Fog.Enabled) + ind |= SIS_FOG_BIT; + + if (ctx->Texture._EnabledUnits) { + ind |= SIS_TEX0_BIT; + if (ctx->Texture.Unit[0]._ReallyEnabled && + ctx->Texture.Unit[1]._ReallyEnabled) + ind |= SIS_TEX1_BIT; + } + + smesa->SetupIndex = ind; + + if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE | DD_TRI_UNFILLED)) { + tnl->Driver.Render.Interp = sis_interp_extras; + tnl->Driver.Render.CopyPV = sis_copy_pv_extras; + } else { + tnl->Driver.Render.Interp = setup_tab[ind].interp; + tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv; + } + + if (setup_tab[ind].vertex_format != smesa->vertex_format) { + smesa->vertex_format = setup_tab[ind].vertex_format; + smesa->vertex_size = setup_tab[ind].vertex_size; + smesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift; + } +} + + +void sisInitVB( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT( ctx ); + GLuint size = TNL_CONTEXT(ctx)->vb.Size; + static int firsttime = 1; + + smesa->verts = (char *)ALIGN_MALLOC(size * 4 * 16, 32); + + if (firsttime) { + init_setup_tab(); + firsttime = 0; + } +} + +void sisFreeVB( GLcontext *ctx ) +{ + sisContextPtr smesa = SIS_CONTEXT( ctx ); + if (smesa->verts) { + ALIGN_FREE(smesa->verts); + smesa->verts = NULL; + } + + + if (smesa->UbyteSecondaryColor.Ptr) { + ALIGN_FREE(smesa->UbyteSecondaryColor.Ptr); + smesa->UbyteSecondaryColor.Ptr = NULL; + } + + if (smesa->UbyteColor.Ptr) { + ALIGN_FREE(smesa->UbyteColor.Ptr); + smesa->UbyteColor.Ptr = NULL; + } +} diff -ruN ../xc/xc/lib/GL/mesa/src/drv/sis/sis_vb.h xc/lib/GL/mesa/src/drv/sis/sis_vb.h --- ../xc/xc/lib/GL/mesa/src/drv/sis/sis_vb.h Wed Dec 31 16:00:00 1969 +++ xc/lib/GL/mesa/src/drv/sis/sis_vb.h Wed Aug 20 20:59:24 2003 @@ -0,0 +1,66 @@ +/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.h,v 1.8 2002/10/30 12:51:46 alanh Exp $ */ +/************************************************************************** + +Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and + VA Linux Systems Inc., Fremont, California. + +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, 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: + * Keith Whitwell + * + */ + +#ifndef __SIS_VB_H__ +#define __SIS_VB_H__ + +#include "mtypes.h" +#include "swrast/swrast.h" +#include "sis_context.h" + +#define _SIS_NEW_VERTEX_STATE (_DD_NEW_SEPARATE_SPECULAR | \ + _DD_NEW_TRI_LIGHT_TWOSIDE | \ + _DD_NEW_TRI_UNFILLED | \ + _NEW_TEXTURE | \ + _NEW_FOG) + +extern void sisCheckTexSizes( GLcontext *ctx ); +extern void sisChooseVertexState( GLcontext *ctx ); + +extern void sisBuildVertices( GLcontext *ctx, GLuint start, GLuint count, + GLuint newinputs ); + +extern void sisPrintSetupFlags( char *msg, GLuint flags ); + +extern void sisInitVB( GLcontext *ctx ); +extern void sisFreeVB( GLcontext *ctx ); + +extern void sis_translate_vertex( GLcontext *ctx, + const sisVertex *src, + SWvertex *dst ); + +extern void sis_print_vertex( GLcontext *ctx, const sisVertex *v ); + +#endif 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 Tue Aug 12 12:03:56 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 Fri Aug 22 17:42:03 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c Wed Dec 31 16:00:00 1969 @@ -1,495 +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_xmesa.c,v 1.10 2001/05/19 18:29:18 dawes Exp $ */ - -/* - * Authors: - * Sung-Ching Lin - * - */ - -#include -#include -#include "sis_dri.h" - -#include "sis_ctx.h" -#include "sis_mesa.h" - -#include -#include "context.h" -#include "macros.h" -#include "matrix.h" -#include "mmath.h" -#include "vbxform.h" -#include "types.h" - -#if 0 -void *sis_debug_malloc(x){ - static char buf[2000000]; - static int count = 0; - void *retval; - - retval = &(buf[count]); - count += x; - return retval; -} -#endif - -static XMesaContext XMesa = NULL; /* Current X/Mesa context pointer */ - -#ifndef SIS_VERBOSE -int SIS_VERBOSE = 0 -/* | VERBOSE_SIS_MEMORY */ -/* | VERBOSE_SIS_BUFFER */ -; -#endif - -static GLboolean IsDriverInit = GL_FALSE; -static sisRegion global_regs, global_agp; -static GLubyte *global_FbBase; - -GLboolean XMesaInitDriver (__DRIscreenPrivate * driScrnPriv) -{ - SISDRIPtr priv = (SISDRIPtr) driScrnPriv->pDevPriv; - - - /* Check the DRI externsion version */ - if ( sPriv->driMajor != 4 || sPriv->driMinor < 0 ) { - __driUtilMessage( "sis DRI driver expected DRI version 4.0.x " - "but got version %d.%d.%d", - sPriv->driMajor, sPriv->driMinor, sPriv->driPatch ); - return NULL; - } - - /* Check that the DDX driver version is compatible */ - if (driScrnPriv->ddxMajor != 0 || - driScrnPriv->ddxMinor != 1 || - driScrnPriv->ddxPatch < 0) { - char msg[1000]; - sprintf(msg, "sis DRI driver expected DDX driver version 0.1.x but got version %d.%d.%d", driScrnPriv->ddxMajor, driScrnPriv->ddxMinor, driScrnPriv->ddxPatch); - __driMesaMessage(msg); - return GL_FALSE; - } - - /* Check that the DRM driver version is compatible */ - if (driScrnPriv->drmMajor != 1 || - driScrnPriv->drmMinor != 0 || - driScrnPriv->drmPatch < 0) { - char msg[1000]; - sprintf(msg, "sis DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", driScrnPriv->drmMajor, driScrnPriv->drmMinor, driScrnPriv->drmPatch); - __driMesaMessage(msg); - return GL_FALSE; - } - - assert (driScrnPriv->devPrivSize == sizeof (SISDRIRec)); - - /* Fixme: in quake3, when context changed, XMesaInitDriver is called - * but XMesaResetDriver isn't. so i must check if regions are - * mapped two times. - * I can't use .map to know if they are mapped - */ - if(IsDriverInit){ - priv->regs = global_regs; - priv->agp = global_agp; - /* XXX */ - driScrnPriv->pFB = global_FbBase; - return GL_TRUE; - } - - if (drmMap (driScrnPriv->fd, priv->regs.handle, priv->regs.size, - &priv->regs.map)) - { - return GL_FALSE; - } - - if (priv->agp.size) - { - if (drmMap (driScrnPriv->fd, priv->agp.handle, priv->agp.size, - &priv->agp.map)) - { - priv->agp.size = 0; - } - } - - IsDriverInit = GL_TRUE; - global_regs = priv->regs; - global_agp = priv->agp; - global_FbBase = driScrnPriv->pFB; - - gDRMSubFD = driScrnPriv->fd; - - return GL_TRUE; -} - -void -XMesaResetDriver (__DRIscreenPrivate * driScrnPriv) -{ - SISDRIPtr priv = (SISDRIPtr) driScrnPriv->pDevPriv; - - drmUnmap (priv->regs.map, priv->regs.size); - priv->regs.map = 0; - - if (priv->agp.size) - { - drmUnmap (priv->agp.map, priv->agp.size); - priv->agp.map = 0; - } - - IsDriverInit = GL_FALSE; -} - - -GLvisual *XMesaCreateVisual(Display *dpy, - __DRIscreenPrivate *driScrnPriv, - const XVisualInfo *visinfo, - const __GLXvisualConfig *config) -{ - /* Drivers may change the args to _mesa_create_visual() in order to - * setup special visuals. - */ - return _mesa_create_visual( config->rgba, - config->doubleBuffer, - config->stereo, - _mesa_bitcount(visinfo->red_mask), - _mesa_bitcount(visinfo->green_mask), - _mesa_bitcount(visinfo->blue_mask), - config->alphaSize, - 0, /* index bits */ - config->depthSize, - config->stencilSize, - config->accumRedSize, - config->accumGreenSize, - config->accumBlueSize, - config->accumAlphaSize, - 0 /* num samples */ ); -} - -GLboolean XMesaCreateContext(GLvisual *mesaVis, - __DRIcontextPrivate *driContextPriv) -{ - XMesaContext c; - - if (SIS_VERBOSE){ - fprintf(stderr, "XMesaCreateContext\n"); - } - - c = (XMesaContext) calloc (1, sizeof (struct xmesa_context)); - if (!c) - return GL_FALSE; - - c->xm_visual = (XMesaVisual) calloc (1, sizeof (struct xmesa_visual)); - if (!c->xm_visual) - return GL_FALSE; - c->xm_visual->gl_visual = mesaVis; - - c->gl_ctx = driContextPriv->mesaContext; - - c->xm_buffer = NULL; - - c->gl_ctx->Driver.UpdateState = sis_UpdateState; - - c->driContextPriv = driContextPriv; - - c->gl_ctx->DriverCtx = (void *)c; - - SiSCreateContext (c); - - /* Fixme */ - if (c->gl_ctx->NrPipelineStages) - c->gl_ctx->NrPipelineStages = - sis_RegisterPipelineStages( c->gl_ctx->PipelineStage, - c->gl_ctx->PipelineStage, - c->gl_ctx->NrPipelineStages); - - driContextPriv->driverPrivate = (void *) c; - - /* TODO, to make VB->Win.data[][2] ranges 0 - 1.0 */ - /* Fixme, software render, z span seems all 0 */ - mesaVis->DepthMax = 1; - mesaVis->DepthMaxF = 1.0f; - - return GL_TRUE; -} - -void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) -{ - XMesaContext c = (XMesaContext) driContextPriv->driverPrivate; - - SiSDestroyContext (c); - - if (c->xm_buffer) - c->xm_buffer->xm_context = NULL; - - if (XMesa == c) - XMesa = NULL; - - free(c->xm_visual); - free (c); -} - -GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, - __DRIscreenPrivate *driScrnPriv, - __DRIdrawablePrivate *driDrawPriv, - GLvisual *mesaVis) -{ - if (mesaVis->RGBAflag){ - return gl_create_framebuffer (mesaVis, GL_FALSE, GL_FALSE, - (mesaVis->AccumRedBits) ? GL_TRUE : GL_FALSE, - GL_FALSE); - } - else{ - return gl_create_framebuffer (mesaVis, - (mesaVis->DepthBits) ? GL_TRUE : GL_FALSE, - (mesaVis->StencilBits) ? GL_TRUE : GL_FALSE, - (mesaVis->AccumRedBits) ? GL_TRUE : GL_FALSE, - GL_FALSE); - } -} - -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; - - if(!XMesa) - return; - - FLUSH_VB( XMesa->gl_ctx, "swap buffers" ); - - hwcx = (__GLSiScontext *) XMesa->private; - (hwcx->SwapBuffers)(XMesa->xm_buffer); -} - -GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv) -{ - /* TODO */ - 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h Wed Dec 31 16:00:00 1969 @@ -1,114 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 3.3 - * - * Copyright (C) 1999-2000 Brian Paul 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 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 - * BRIAN PAUL 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_xmesaP.h,v 1.5 2000/09/26 15:56:49 tsi Exp $ */ - -#ifndef XMESAP_H -#define XMESAP_H - - -#ifdef XFree86Server -# include "GL/xf86glx.h" -# include "xf86glx_util.h" -#else -# ifdef GLX_DIRECT_RENDERING -# include "dri_mesa.h" -# endif -#endif - -#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 */ - XMesaDisplay *display; /* The X11 display */ - XMesaVisualInfo visinfo; /* X's visual info */ -}; - -struct xmesa_context { - GLcontext *gl_ctx; /* the core library context */ - XMesaVisual xm_visual; /* Describes the buffers */ - XMesaBuffer xm_buffer; /* current draw framebuffer */ - XMesaBuffer xm_read_buffer; /* current read framebuffer */ - GLboolean use_read_buffer; /* read from the xm_read_buffer/ */ - - XMesaDisplay *display; /* == xm_visual->display */ - -#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server) - __DRIcontextPrivate *driContextPriv; /* back pointer to DRI context - * used for locking - */ -#endif - void *private; /* device-specific private context */ -}; - -struct xmesa_buffer { - GLboolean wasCurrent; /* was ever the current buffer? */ - GLframebuffer *gl_buffer; /* depth, stencil, accum, etc buffers */ - XMesaVisual xm_visual; /* the X/Mesa visual */ - - XMesaContext xm_context; /* the context associated with this buffer */ - XMesaDisplay *display; - GLboolean pixmap_flag; /* is the buffer a Pixmap? */ - XMesaDrawable frontbuffer; /* either a window or pixmap */ - XMesaImage *backimage; /* back buffer simulated XImage */ - - GLvoid *depthbuffer; - - GLboolean db_state; /* GL_FALSE = single buffered */ - - GLuint width, height; /* size of buffer */ - - GLint bottom; /* used for FLIP macro below */ - -#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server) - __DRIdrawablePrivate *driDrawPriv; /* back pointer to DRI drawable - * used for direct access to framebuffer - */ -#endif - - void *private; /* device-specific private drawable */ - - struct xmesa_buffer *Next; /* Linked list pointer: */ -}; - -#endif 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 Tue Aug 12 12:03:56 2003 +++ xc/lib/GL/mesa/src/drv/sis/sis_xwin.c Wed Dec 31 16:00:00 1969 @@ -1,205 +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_xwin.c,v 1.3 2000/09/26 15:56:49 tsi Exp $ */ - -/* - * Authors: - * Sung-Ching Lin - * - */ - -#include "sis_ctx.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) -{ - __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv; - -/* - if (!sis_is_window (xmesa)) - { - return GL_FALSE; - } -*/ - -/* - XMESA_VALIDATE_DRAWABLE_INFO (xmesa->display, - xmesa->driContextPriv->driScreenPriv, - dPriv); -*/ - - *ppExtents = (BoxPtr) dPriv->pClipRects; - *pCount = dPriv->numClipRects; - - return GL_TRUE; -} - -void * -sis_get_drawable_pos (XMesaContext xmesa) -{ - __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; - - __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv; - -/* - XMESA_VALIDATE_DRAWABLE_INFO (xmesa->display, - xmesa->driContextPriv->driScreenPriv, - dPriv); -*/ - - return GET_FbBase (hwcx) + (dPriv->x) * GET_DEPTH (hwcx) + - (dPriv->y) * GET_PITCH (hwcx); -} - -void -sis_get_drawable_origin (XMesaContext xmesa, GLuint * x, GLuint * y) -{ - __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv; - -/* - XMESA_VALIDATE_DRAWABLE_INFO (xmesa->display, - xmesa->driContextPriv->driScreenPriv, - dPriv); -*/ - - *x = dPriv->x; - *y = dPriv->y; -} - -void -sis_get_drawable_size (XMesaContext xmesa, GLuint * w, GLuint * h) -{ - __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv; - -/* - XMESA_VALIDATE_DRAWABLE_INFO (xmesa->display, - xmesa->driContextPriv->driScreenPriv, - dPriv); -*/ - - *w = dPriv->w; - *h = dPriv->h; -} - -void -sis_get_drawable_box (XMesaContext xmesa, BoxPtr pBox) -{ - __DRIdrawablePrivate *dPriv = xmesa->driContextPriv->driDrawablePriv; - -/* - XMESA_VALIDATE_DRAWABLE_INFO (xmesa->display, - xmesa->driContextPriv->driScreenPriv, - dPriv); -*/ - - pBox->x1 = dPriv->x; - pBox->y1 = dPriv->y; - 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 Tue Aug 12 12:03:34 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.c xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c --- ../xc/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c Fri Aug 22 17:42:04 2003 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c Fri Aug 22 17:42:02 2003 @@ -240,9 +240,9 @@ ((pciConfigPtr)pSIS->PciInfo->thisCard)->busnum, ((pciConfigPtr)pSIS->PciInfo->thisCard)->devnum, ((pciConfigPtr)pSIS->PciInfo->thisCard)->funcnum); - pDRIInfo->ddxDriverMajorVersion = 0; - pDRIInfo->ddxDriverMinorVersion = 1; - pDRIInfo->ddxDriverPatchVersion = 0; + pDRIInfo->ddxDriverMajorVersion = SIS_MAJOR_VERSION; + pDRIInfo->ddxDriverMinorVersion = SIS_MINOR_VERSION; + pDRIInfo->ddxDriverPatchVersion = SIS_PATCHLEVEL; pDRIInfo->frameBufferPhysicalAddress = pSIS->FbAddress; @@ -501,6 +501,7 @@ /* TODO */ pSISDRI->scrnX=pSISDRI->width; pSISDRI->scrnY=pSISDRI->height; + pSISDRI->sarea_priv_offset = sizeof(XF86DRISAREARec); /* pSISDRI->textureOffset=pSiS->texOffset; @@ -518,7 +519,7 @@ assert(saPriv); - saPriv->CtxOwner = -1; + saPriv->ctxOwner = -1; saPriv->QueueLength = 0; pSiS->cmdQueueLenPtr = &(saPriv->QueueLength); saPriv->AGPCmdBufNext = 0; 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 Tue Aug 12 12:04:07 2003 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h Fri Aug 22 17:53:13 2003 @@ -7,16 +7,11 @@ #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 #define SIS_DEPTH 2 @@ -45,6 +40,7 @@ unsigned int AGPCmdBufSize; int irqEnabled; unsigned int scrnX, scrnY; + unsigned int sarea_priv_offset; } SISDRIRec, *SISDRIPtr; typedef struct { 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 Tue Aug 12 12:03:34 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_ */