diff options
author | daryll <daryll> | 1999-12-07 23:06:36 +0000 |
---|---|---|
committer | daryll <daryll> | 1999-12-07 23:06:36 +0000 |
commit | 43096de75c224cb1828b136bae0ce742d00f6674 (patch) | |
tree | 5f592f09e4be205e8a056e219be351197fb3ed8a /xc/lib/GL | |
parent | e6ede7701fe5eaefe281ffaed0daf28f3a84c5a0 (diff) |
Adding some files that got left out of the DRI checkin.
Diffstat (limited to 'xc/lib/GL')
-rw-r--r-- | xc/lib/GL/mesa/src/X86/Imakefile | 105 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/tdfx/Imakefile | 87 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.c | 110 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h | 225 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c | 106 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c | 355 |
6 files changed, 988 insertions, 0 deletions
diff --git a/xc/lib/GL/mesa/src/X86/Imakefile b/xc/lib/GL/mesa/src/X86/Imakefile new file mode 100644 index 000000000..0eec94570 --- /dev/null +++ b/xc/lib/GL/mesa/src/X86/Imakefile @@ -0,0 +1,105 @@ +XCOMM $XFree86: xc/lib/GL/mesa/src/Imakefile,v 1.3 1999/06/27 14:07:25 dawes Exp $ +XCOMM $PI: xc/lib/GL/mesa/src/Imakefile,v 1.5 1999/06/21 05:13:55 martin Exp $ + +#define DoNormalLib NormalLibGlx +#define DoSharedLib SharedLibGlx +#define DoExtraLib SharedLibGlx +#define DoDebugLib DebugLibGlx +#define DoProfileLib ProfileLibGlx + +/* #define HAVE_3DNOW 1 */ +#define HAVE_MMX_ 1 + +LinkSourceFile(3dnow.c, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(3dnow.h, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(3dnow_norm_raw.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(3dnow_xform_masked1.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(3dnow_xform_masked2.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(3dnow_xform_masked3.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(3dnow_xform_masked4.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(3dnow_xform_raw1.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(3dnow_xform_raw2.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(3dnow_xform_raw3.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(3dnow_xform_raw4.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(vertex_3dnow.S, ../../../../../extras/Mesa/src/X86) + +LinkSourceFile(mmx.h, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(mmx_blend.S, ../../../../../extras/Mesa/src/X86) + +LinkSourceFile(x86a.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(assyntax.h, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(common_x86.c, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(common_x86asm.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(common_x86asm.h, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(x86.c, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(x86.h, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(vertex.S, ../../../../../extras/Mesa/src/X86) + +LinkSourceFile(x86flatregs.m4, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(x86a.S.m4, ../../../../../extras/Mesa/src/X86) + +#if Malloc0ReturnsNull +ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL +#endif + +#if HAVE_3DNOW + 3DNOW_SRCS = 3dnow.c 3dnow_norm_raw.S 3dnow_xform_masked1.S \ + 3dnow_xform_masked2.S 3dnow_xform_masked3.S \ + 3dnow_xform_masked3.S 3dnow_xform_raw1.S \ + 3dnow_xform_raw2.S 3dnow_xform_raw3.S 3dnow_xform_raw4.S \ + vertex_3dnow.S + + 3DNOW_OBJS = 3dnow.o 3dnow_norm_raw.o 3dnow_xform_masked1.o \ + 3dnow_xform_masked2.o 3dnow_xform_masked3.o \ + 3dnow_xform_masked3.o 3dnow_xform_raw1.o \ + 3dnow_xform_raw2.o 3dnow_xform_raw3.o 3dnow_xform_raw4.o \ + vertex_3dnow.o + + 3DNOW_DEFS = -DUSE_3DNOW_ASM +#endif + +#if HAVE_MMX_ + MMX_SRCS = mmx_blend.S + + MMX_OBJS = mmx_blend.o + + MMX_DEFS = -DUSE_MMX_ASM +#endif + + X86_SRCS = x86a.S common_x86.c common_x86asm.S x86.c vertex.S \ + $(MMX_SRCS) $(3DNOW_SRCS) + + X86_OBJS = x86a.o common_x86.o common_x86asm.o x86.o vertex.o \ + $(MMX_OBJS) $(3DNOW_OBJS) + + X86_DEFS = -DUSE_X86_ASM $(MXX_DEFS) $(3DNOW_DEFS) + + DEFINES = $(ALLOC_DEFINES) GlxDefines -DFX $(X86_DEFS) $(3DNOW_DEFS) $(MMX_DEFS) + INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) -I../include -I../../dri -I.. + SRCS = $(X86_SRCS) $(3DNOW_SRCS) $(MMX_SRCS) + OBJS = $(X86_OBJS) $(3DNOW_OBJS) $(MMX_OBJS) + +#if !GlxUseBuiltInDRIDriver +#undef DoNormalLib NormalLibGlx +#undef DoExtraLib SharedLibGlx +#undef DoDebugLib DebugLibGlx +#undef DoProfileLib ProfileLibGlx +#endif + +#include <Library.tmpl> + +LibraryObjectRule() + +SubdirLibraryRule($(OBJS)) +NormalLintTarget($(SRCS)) +#if 1 +#endif + +DependTarget() + +x86a.S: x86flatregs.m4 +x86a.S: x86a.S.m4 + m4 $< >$@ + +x86a.asm: x86a.S + gcc -E -P -DNASM_ASSEMBLER $< >$@ diff --git a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile new file mode 100644 index 000000000..dc940bab3 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile @@ -0,0 +1,87 @@ +XCOMM $PI:$ + +#define DoNormalLib NormalLibGlx +#define DoSharedLib SharedLibGlx +#define DoExtraLib SharedLibGlx +#define DoDebugLib DebugLibGlx +#define DoProfileLib ProfileLibGlx + +#if Malloc0ReturnsNull +ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL +#endif + +#if BuildXF86DRI + DRI_DEFINES = GlxDefines -DFX -DFX_GLIDE3 -DGLIDE3 -DDRIVERTS + DRI_INCLUDES = -I../../../../dri -I../../../../glx \ + -I$(TOP)/include -I$(TOP)/include/GL \ + -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \ + -I$(XF86DRIVERSRC)/tdfx \ + -I../../../include -I../.. -I../../X +#endif + +MESA_INCLUDES = -I. -I.. -I../../include + +LinkSourceFile(fxclip.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxcliptmp.h, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxcva.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxcva.h, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxcvatmp.h, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxdd.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxddspan.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxddtex.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxdrv.h, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxfastpath.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxfasttmp.h, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxglidew.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxglidew.h, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxpipeline.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxrender.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxsanity.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxsdettmp.h, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxsetup.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxstripdet.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxtexman.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxtrifuncs.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxtritmp.h, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxvsetup.c, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxvsetup.h, ../../../../../../extras/Mesa/src/FX) +LinkSourceFile(fxvs_tmp.h, ../../../../../../extras/Mesa/src/FX) + + DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) + INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) \ + -I/usr/include/glide + DRISRCS = tdfx_xmesa.c tdfx_init.c tdfx_inithw.c + DRIOBJS = tdfx_xmesa.o tdfx_init.o tdfx_inithw.o + MESASRCS = fxclip.c fxcva.c fxdd.c fxddspan.c fxddtex.c fxfastpath.c \ + fxglidew.c fxpipeline.c fxrender.c fxsanity.c fxsetup.c \ + fxtexman.c fxtrifuncs.c fxvsetup.c + MESAOBJS = fxclip.o fxcva.o fxdd.o fxddspan.o fxddtex.o fxfastpath.o \ + fxglidew.o fxpipeline.o fxrender.o fxsanity.o fxsetup.o \ + fxtexman.o fxtrifuncs.o fxvsetup.o + + SRCS = $(DRISRCS) $(MESASRCS) + OBJS = $(DRIOBJS) $(MESAOBJS) + +#if !GlxUseBuiltInDRIDriver +#undef DoNormalLib NormalLibGlx +#undef DoExtraLib SharedLibGlx +#undef DoDebugLib DebugLibGlx +#undef DoProfileLib ProfileLibGlx +#endif + +#include <Library.tmpl> + +LibraryObjectRule() + +SubdirLibraryRule($(OBJS)) +NormalLintTarget($(SRCS)) + +#if !GlxUseBuiltInDRIDriver +LIBNAME = tdfx_dri.so +ALL_OBJS = $(OBJS) +ALL_DEPS = DONE +SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS)) +InstallDynamicModule($(LIBNAME),$(MODULEDIR),.) +#endif + +DependTarget() diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.c new file mode 100644 index 000000000..eb505b8a3 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.c @@ -0,0 +1,110 @@ +/************************************************************************** + +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: + * Daryll Strauss <daryll@precisioninsight.com> + * + * $PI: # + */ + +#ifdef GLX_DIRECT_RENDERING + +#include <X11/Xlibint.h> +#include "xf86dri.h" +#include "tdfx_dri.h" +#include "tdfx_init.h" + +#ifdef DEBUG_LOCKING +char *prevLockFile=0; +int prevLockLine=0; +#endif + +static void performMagic(__DRIscreenPrivate *driScrnPriv) +{ + tdfxScreenPrivate *gPriv = (tdfxScreenPrivate *)driScrnPriv->private; + TDFXDRIPtr gDRIPriv = (TDFXDRIPtr)driScrnPriv->pDevPriv; + + gPriv->regs.handle=gDRIPriv->regs; + gPriv->regs.size=gDRIPriv->regsSize; + gPriv->deviceID=gDRIPriv->deviceID; + gPriv->width=gDRIPriv->width; + gPriv->height=gDRIPriv->height; + gPriv->mem=gDRIPriv->mem; + gPriv->cpp=gDRIPriv->cpp; + gPriv->stride=gDRIPriv->stride; + gPriv->fifoOffset=gDRIPriv->priv1; + gPriv->fifoSize=gDRIPriv->priv2; + gPriv->fbOffset=gDRIPriv->fbOffset; + gPriv->backOffset=gDRIPriv->backOffset; + gPriv->depthOffset=gDRIPriv->depthOffset; + gPriv->textureOffset=gDRIPriv->textureOffset; + gPriv->textureSize=gDRIPriv->textureSize; +} + +GLboolean tdfxMapAllRegions(__DRIscreenPrivate *driScrnPriv) +{ + tdfxScreenPrivate *gPriv = (tdfxScreenPrivate *)driScrnPriv->private; + + /* First, pick apart pDevPriv & friends */ + performMagic(driScrnPriv); + + if (drmMap(driScrnPriv->fd, gPriv->regs.handle, gPriv->regs.size, + &gPriv->regs.map)) { + return GL_FALSE; + } + + return GL_TRUE; +} + +void tdfxUnmapAllRegions(__DRIscreenPrivate *driScrnPriv) +{ + tdfxScreenPrivate *gPriv = (tdfxScreenPrivate *)driScrnPriv->private; + + drmUnmap(gPriv->regs.map, gPriv->regs.size); +} + +/* + * Shutdown Glide library + */ +void fxCloseHardware(void) +{ + if (getenv("MESA_FX_INFO")) { + GrSstPerfStats_t st; + + FX_grSstPerfStats(&st); + fprintf(stderr,"Pixels Stats:\n"); + fprintf(stderr," # pixels processed (minus buffer clears): %u\n",(unsigned)st.pixelsIn); + fprintf(stderr," # pixels not drawn due to chroma key test failure: %u\n",(unsigned)st.chromaFail); + fprintf(stderr," # pixels not drawn due to depth test failure: %u\n",(unsigned)st.zFuncFail); + fprintf(stderr," # pixels not drawn due to alpha test failure: %u\n",(unsigned)st.aFuncFail); + fprintf(stderr," # pixels drawn (including buffer clears and LFB writes): %u\n",(unsigned)st.pixelsOut); + } + FX_grGlideShutdown(); +} + +#endif diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h new file mode 100644 index 000000000..f0b3f4131 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h @@ -0,0 +1,225 @@ +/************************************************************************** + +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: + * Daryll Strauss <daryll@precisioninsight.com> + * + * $PI: $ + */ + +#ifndef _TDFX_INIT_H_ +#define _TDFX_INIT_H_ + +#ifdef GLX_DIRECT_RENDERING + +#include <sys/time.h> +#include <glide.h> +#include "dri_tmm.h" +#include "dri_mesaint.h" +#include "dri_mesa.h" +#include "types.h" +#include "xmesaP.h" +/* #include "fxdrv.h" */ + +typedef struct { + drmHandle handle; + drmSize size; + drmAddress map; +} tdfxRegion, *tdfxRegionPtr; + +typedef struct { + tdfxRegion regs; + int deviceID; + int width; + int height; + int mem; + int cpp; + int stride; + int fifoOffset; + int fifoSize; + int fbOffset; + int backOffset; + int depthOffset; + int textureOffset; + int textureSize; + __DRIscreenPrivate *driScrnPriv; +} tdfxScreenPrivate; + +typedef struct { + volatile int *fifoPtr; + volatile int *fifoRead; + volatile int fifoOwner; + volatile int ctxOwner; + volatile int texOwner; +} TDFXSAREAPriv; + +/* KW: The extra stuff we need to add to an fxContext to make it + * equivalent to a tdfxContextPrivate struct. It may be nice to + * package this up in a struct, but in the meantime this means we + * don't have to be merging stuff by hand between unrelated files. + * + * PLEASE NOTE: if you add stuff here, you have to make sure you only + * try to access it from places which are protected by tests for + * defined(GLX_DIRECT_RENDERING) or defined(XFree86Server). + */ +#define DRI_FX_CONTEXT \ + drmContext hHWContext; \ + int numClipRects; \ + XF86DRIClipRectPtr pClipRects; \ + tdfxScreenPrivate *tdfxScrnPriv; + +typedef struct tfxMesaContext tdfxContextPrivate; + +#include "fxdrv.h" + +extern GLboolean tdfxMapAllRegions(__DRIscreenPrivate *driScrnPriv); +extern void tdfxUnmapAllRegions(__DRIscreenPrivate *driScrnPriv); +extern GLboolean tdfxInitHW(XMesaContext c); + +extern void XMesaWindowMoved(void); +extern void XMesaUpdateState(int windowMoved); +extern void XMesaSetSAREA(void); + +/* This is the private interface between Glide and DRI */ +extern void grDRIOpen(char *pFB, char *pRegs, int deviceID, + int width, int height, + int mem, int cpp, int stride, + int fifoOffset, int fifoSize, + int fbOffset, int backOffset, int depthOffset, + int textureOffset, int textureSize, + volatile int *fifoPtr, volatile int *fifoRead); +extern void grDRIPosition(int x, int y, int w, int h, + int numClip, XF86DRIClipRectPtr pClip); +extern void grDRILostContext(void); +extern void grDRIImportFifo(int fifoPtr, int fifoRead); +extern void grDRIInvalidateAll(void); +extern void grDRIResetSAREA(void); + +extern XMesaContext gCC; +extern tdfxContextPrivate *gCCPriv; + +/* +You can turn this on to find locking conflicts. +#define DEBUG_LOCKING +*/ + +#ifdef DEBUG_LOCKING +extern char *prevLockFile; +extern int prevLockLine; +#define DEBUG_LOCK() \ + do { \ + prevLockFile=(__FILE__); \ + prevLockLine=(__LINE__); \ + } while (0) +#define DEBUG_RESET() \ + do { \ + prevLockFile=0; \ + prevLockLine=0; \ + } while (0) +#define DEBUG_CHECK_LOCK() \ + do { \ + if (prevLockFile) { \ + fprintf(stderr, "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \ + prevLockFile, prevLockLine, __FILE__, __LINE__); \ + exit(1); \ + } \ + } while (0) +#else +#define DEBUG_LOCK() +#define DEBUG_RESET() +#define DEBUG_CHECK_LOCK() +#endif + +/* !!! We may want to separate locks from locks with validation. + This could be used to improve performance for those things + commands that do not do any drawing !!! */ + +#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 = gCC->driContextPriv->driDrawablePriv; \ + __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \ + DEBUG_CHECK_LOCK(); \ + DRM_LIGHT_LOCK_RETURN(sPriv->fd, &sPriv->pSAREA->lock, \ + dPriv->driContextPriv->hHWContext, __ret); \ + if (__ret) __ret=1; \ + stamp=dPriv->lastStamp; \ + XMESA_VALIDATE_DRAWABLE_INFO(gCC->display, sPriv, dPriv); \ + if (*(dPriv->pStamp)!=stamp) __ret=2; \ + if (__ret) XMesaUpdateState(__ret==2); \ + DEBUG_LOCK(); \ + } while (0) + +/* Unlock the hardware using the global current context */ +#define UNLOCK_HARDWARE() \ + do { \ + __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; \ + __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \ + XMesaSetSAREA(); \ + DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, \ + dPriv->driContextPriv->hHWContext); \ + DEBUG_RESET(); \ + } while (0) + +#define BEGIN_BOARD_LOCK() LOCK_HARDWARE() +#define END_BOARD_LOCK() UNLOCK_HARDWARE() + +/* + This pair of macros makes a loop over the drawing operations + so it is not self contained and doesn't have the nice single + statement semantics of most macros +*/ +#define BEGIN_CLIP_LOOP() \ + do { \ + __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; \ + int _nc = dPriv->numClipRects; \ + LOCK_HARDWARE(); \ + while (_nc--) { \ + if (gCCPriv->needClip) { \ + gCCPriv->clipMinX=dPriv->pClipRects[_nc].x1; \ + gCCPriv->clipMaxX=dPriv->pClipRects[_nc].x2; \ + gCCPriv->clipMinY=dPriv->pClipRects[_nc].y1; \ + gCCPriv->clipMaxY=dPriv->pClipRects[_nc].y2; \ + fxSetScissorValues(gCCPriv->glCtx); \ + } + +#define END_CLIP_LOOP() \ + } \ + UNLOCK_HARDWARE(); \ + } while (0) + +#endif +#endif diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c new file mode 100644 index 000000000..065d33338 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c @@ -0,0 +1,106 @@ +/************************************************************************** + +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: + * Daryll Strauss <daryll@precisioninsight.com> + * + * $PI: $ + */ + +#ifdef GLX_DIRECT_RENDERING + +#include "tdfx_init.h" +#include <glide.h> + +GLboolean tdfxInitHW(XMesaContext c) +{ + /* KW: Would be nice to make one of these a member of the other. + */ + tdfxContextPrivate *cPriv = (tdfxContextPrivate*)c->private; + tdfxContextPrivate *fxMesa = cPriv; + __DRIdrawablePrivate *driDrawPriv = c->driContextPriv->driDrawablePriv; + __DRIscreenPrivate *driScrnPriv = driDrawPriv->driScreenPriv; + tdfxScreenPrivate *sPriv = (tdfxScreenPrivate*)driScrnPriv->private; + +#ifdef DEBUG_LOCKING + fprintf(stderr, "Debug locking enabled\n"); +#endif + + if (cPriv->initDone) return GL_TRUE; + + cPriv->width=driDrawPriv->w; + cPriv->height=driDrawPriv->h; + + /* We have to use a light lock here, because we can't do any glide + operations yet. No use of FX_* functions in this function. */ + DRM_LIGHT_LOCK(driScrnPriv->fd, &driScrnPriv->pSAREA->lock, + driDrawPriv->driContextPriv->hHWContext); + FX_grGlideInit_NoLock(); + + fxMesa->board = 0; + FX_grSstSelect_NoLock(fxMesa->board); + + if (sPriv->deviceID==0x3) + fxMesa->haveTwoTMUs=GL_FALSE; + else + fxMesa->haveTwoTMUs=GL_TRUE; + + /* !!! We are forcing these !!! */ + fxMesa->haveDoubleBuffer=GL_TRUE; + fxMesa->haveAlphaBuffer=GL_FALSE; + fxMesa->haveZBuffer=GL_TRUE; + fxMesa->haveGlobalPaletteTexture=GL_FALSE; + + fxMesa->glideContext = FX_grSstWinOpen_NoLock((FxU32)-1, GR_RESOLUTION_NONE, + GR_REFRESH_NONE, +#if FXMESA_USE_ARGB + GR_COLORFORMAT_ARGB, +#else + GR_COLORFORMAT_ABGR, +#endif + GR_ORIGIN_LOWER_LEFT, 2, 1); + + grDRIResetSAREA(); + DRM_UNLOCK(driScrnPriv->fd, &driScrnPriv->pSAREA->lock, + driDrawPriv->driContextPriv->hHWContext); + + fxMesa->needClip=1; + + if (!fxMesa->glideContext || !fxDDInitFxMesaContext( fxMesa )) + return GL_FALSE; + + cPriv->initDone=GL_TRUE; + return GL_TRUE; + +} + +#endif + + + + diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c new file mode 100644 index 000000000..dca2d806d --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c @@ -0,0 +1,355 @@ +/************************************************************************** + +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: + * Daryll Strauss <daryll@precisioninsight.com> + * + * $PI: $ + */ + +#ifdef GLX_DIRECT_RENDERING + +#include <X11/Xlibint.h> +#include <glide.h> +#include "tdfx_init.h" +#include "context.h" +#include "vbxform.h" +#include "matrix.h" + +XMesaContext nullCC = 0; +XMesaContext gCC = 0; +tdfxContextPrivate *gCCPriv = 0; + +static int count_bits(unsigned int n) +{ + int bits = 0; + + while (n > 0) { + if (n & 1) bits++; + n >>= 1; + } + return bits; +} + +GLboolean XMesaInitDriver(__DRIscreenPrivate *driScrnPriv) +{ + tdfxScreenPrivate *gsp; + + /* Allocate the private area */ + gsp = (tdfxScreenPrivate *)Xmalloc(sizeof(tdfxScreenPrivate)); + if (!gsp) return GL_FALSE; + + gsp->driScrnPriv = driScrnPriv; + + driScrnPriv->private = (void *)gsp; + + if (!tdfxMapAllRegions(driScrnPriv)) { + Xfree(driScrnPriv->private); + return GL_FALSE; + } + + return GL_TRUE; +} + +void XMesaResetDriver(__DRIscreenPrivate *driScrnPriv) +{ + tdfxUnmapAllRegions(driScrnPriv); + Xfree(driScrnPriv->private); +} + +XMesaVisual XMesaCreateVisual(XMesaDisplay *display, + XMesaVisualInfo visinfo, + GLboolean rgb_flag, + GLboolean alpha_flag, + GLboolean db_flag, + GLboolean stereo_flag, + GLboolean ximage_flag, + GLint depth_size, + GLint stencil_size, + GLint accum_size, + GLint level) +{ + XMesaVisual v; + + /* Only RGB visuals are supported on the TDFX boards */ + if (!rgb_flag) return 0; + + v = (XMesaVisual)Xmalloc(sizeof(struct xmesa_visual)); + if (!v) return 0; + + v->visinfo = (XVisualInfo *)Xmalloc(sizeof(*visinfo)); + if(!v->visinfo) { + Xfree(v); + return 0; + } + memcpy(v->visinfo, visinfo, sizeof(*visinfo)); + + v->display = display; + v->level = level; + + v->gl_visual = (GLvisual *)Xmalloc(sizeof(GLvisual)); + if (!v->gl_visual) { + Xfree(v->visinfo); + XFree(v); + return 0; + } + + v->gl_visual->RGBAflag = rgb_flag; + v->gl_visual->DBflag = db_flag; + v->gl_visual->StereoFlag = stereo_flag; + + v->gl_visual->RedBits = count_bits(visinfo->red_mask); + v->gl_visual->GreenBits = count_bits(visinfo->green_mask); + v->gl_visual->BlueBits = count_bits(visinfo->blue_mask); + v->gl_visual->AlphaBits = 0; /* Not currently supported */ + + v->gl_visual->AccumBits = accum_size; + v->gl_visual->DepthBits = depth_size; + v->gl_visual->StencilBits = stencil_size; + + return v; +} + +void XMesaDestroyVisual(XMesaVisual v) +{ + Xfree(v->gl_visual); + Xfree(v->visinfo); + Xfree(v); +} + +XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, + __DRIcontextPrivate *driContextPriv) +{ + XMesaContext c; + tdfxContextPrivate *cPriv; + __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv; + tdfxScreenPrivate *sPriv = (tdfxScreenPrivate *)driScrnPriv->private; + TDFXSAREAPriv *saPriv; + GLcontext *shareCtx; + int **fifoPtr; + + c = (XMesaContext)Xmalloc(sizeof(struct xmesa_context)); + if (!c) return 0; + + c->driContextPriv = driContextPriv; + c->xm_visual = v; + c->xm_buffer = 0; /* Set by MakeCurrent */ + c->display = v->display; + + cPriv = (tdfxContextPrivate *)Xmalloc(sizeof(tdfxContextPrivate)); + if (!cPriv) { + Xfree(c); + return NULL; + } + + cPriv->hHWContext = driContextPriv->hHWContext; + cPriv->tdfxScrnPriv = sPriv; + c->private = (void *)cPriv; + + cPriv->glVis=v->gl_visual; + cPriv->glBuffer=gl_create_framebuffer(v->gl_visual); + cPriv->screen_width=sPriv->width; + cPriv->screen_height=sPriv->height; + + cPriv->new_state = ~0; + + if (share_list) + shareCtx=((tdfxContextPrivate*)(share_list->private))->glCtx; + else + shareCtx=0; + cPriv->glCtx=gl_create_context(v->gl_visual, shareCtx, (void*)cPriv, GL_TRUE); + cPriv->initDone=GL_FALSE; + + saPriv=(TDFXSAREAPriv*)((void*)driScrnPriv->pSAREA+sizeof(XF86DRISAREARec)); + grDRIOpen(driScrnPriv->pFB, sPriv->regs.map, sPriv->deviceID, + sPriv->width, sPriv->height, sPriv->mem, sPriv->cpp, sPriv->stride, + sPriv->fifoOffset, sPriv->fifoSize, sPriv->fbOffset, + sPriv->backOffset, sPriv->depthOffset, sPriv->textureOffset, + sPriv->textureSize, &saPriv->fifoPtr, &saPriv->fifoRead); + + return c; +} + +void XMesaDestroyContext(XMesaContext c) +{ + tdfxContextPrivate *cPriv; + + cPriv=(tdfxContextPrivate*)c->private; + if (cPriv) { + gl_destroy_context(cPriv->glCtx); + gl_destroy_framebuffer(cPriv->glBuffer); + } +} + +XMesaBuffer XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w, + __DRIdrawablePrivate *driDrawPriv) +{ + return (XMesaBuffer)1; +} + +XMesaBuffer XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, + XMesaColormap c, __DRIdrawablePrivate *driDrawPriv) +{ + return (XMesaBuffer)1; +} + +void XMesaDestroyBuffer(XMesaBuffer b) +{ +} + +void XMesaSwapBuffers(XMesaBuffer b) +{ + FxI32 result; + /* + ** NOT_DONE: This assumes buffer is currently bound to a context. + ** This needs to be able to swap buffers when not currently bound. + */ + if (gCC == NULL || gCCPriv == NULL) return; + + FLUSH_VB( gCCPriv->glCtx, "swap buffers" ); + + if (gCCPriv->haveDoubleBuffer) { + FX_grDRIBufferSwap(gCCPriv->swapInterval); + do { + result=FX_grGetInteger(FX_PENDING_BUFFERSWAPS); + } while (result>gCCPriv->maxPendingSwapBuffers); + gCCPriv->stats.swapBuffer++; + } else { + fprintf(stderr, "No double buffer\n"); + } +} + +GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) +{ + __DRIdrawablePrivate *driDrawPriv; + + if (c) { + if (c==gCC) return GL_TRUE; + if (gCCPriv) FX_grGlideGetState((GrState*)gCCPriv->state); + gCC = c; + gCCPriv = (tdfxContextPrivate *)c->private; + + fprintf(stderr, "Make current\n"); + driDrawPriv = gCC->driContextPriv->driDrawablePriv; + if (!gCCPriv->initDone) { + gCCPriv->width=driDrawPriv->w; + gCCPriv->height=driDrawPriv->h; + if (!tdfxInitHW(c)) return GL_FALSE; + /* Zap the width to force XMesaWindowMoved to execute */ + gCCPriv->width=0; + } + FX_grSstSelect(gCCPriv->board); + XMesaWindowMoved(); + + FX_grGlideSetState((GrState*)gCCPriv->state); + gl_make_current(gCCPriv->glCtx, gCCPriv->glBuffer); + fxSetupDDPointers(gCCPriv->glCtx); + if (!gCCPriv->glCtx->Viewport.Width) + gl_Viewport(gCCPriv->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h); + } else { + gl_make_current(0,0); + gCC = NULL; + gCCPriv = NULL; + } + return GL_TRUE; +} + +void +XMesaWindowMoved() { + __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; + GLcontext *ctx; + + ctx=gCCPriv->glCtx; + grDRIPosition(dPriv->x, dPriv->y, dPriv->w, dPriv->h, + dPriv->numClipRects, dPriv->pClipRects); + gCCPriv->numClipRects=dPriv->numClipRects; + gCCPriv->pClipRects=dPriv->pClipRects; + if (dPriv->x!=gCCPriv->x_offset || dPriv->y!=gCCPriv->y_offset || + dPriv->w!=gCCPriv->width || dPriv->h!=gCCPriv->height) { + gCCPriv->x_offset=dPriv->x; + gCCPriv->y_offset=dPriv->y; + gCCPriv->width=dPriv->w; + gCCPriv->height=dPriv->h; + gCCPriv->y_delta=gCCPriv->screen_height-gCCPriv->y_offset-gCCPriv->height; + } + switch (dPriv->numClipRects) { + case 0: + gCCPriv->clipMinX=dPriv->x; + gCCPriv->clipMaxX=dPriv->x+dPriv->w; + gCCPriv->clipMinY=dPriv->y; + gCCPriv->clipMaxY=dPriv->y+dPriv->h; + fxSetScissorValues(ctx); + gCCPriv->needClip=0; + break; + case 1: + gCCPriv->clipMinX=dPriv->pClipRects[0].x1; + gCCPriv->clipMaxX=dPriv->pClipRects[0].x2; + gCCPriv->clipMinY=dPriv->pClipRects[0].y1; + gCCPriv->clipMaxY=dPriv->pClipRects[0].y2; + fxSetScissorValues(ctx); + gCCPriv->needClip=0; + break; + default: + gCCPriv->needClip=1; + } +} + +void XMesaUpdateState(int windowMoved) { + __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; + __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; + TDFXSAREAPriv *saPriv=(TDFXSAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec)); + + /* fprintf(stderr, "In FifoPtr=%d FifoRead=%d\n", saPriv->fifoPtr, saPriv->fifoRead); */ + if (saPriv->fifoOwner!=dPriv->driContextPriv->hHWContext) { + grDRIImportFifo(saPriv->fifoPtr, saPriv->fifoRead); + } + if (saPriv->ctxOwner!=dPriv->driContextPriv->hHWContext) { + grDRIInvalidateAll(); + /* This shouldn't be needed if the state is reset by Glide */ + /* FX_grConstantColorValue_NoLock(FXCOLOR4(&gCCPriv->constColor)); */ + } + if (saPriv->texOwner!=dPriv->driContextPriv->hHWContext) { + fxTMRestoreTextures(gCCPriv); + } + if (windowMoved) + XMesaWindowMoved(); +} + +void XMesaSetSAREA() { + __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; + __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; + TDFXSAREAPriv *saPriv=(TDFXSAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec)); + + saPriv->fifoOwner=dPriv->driContextPriv->hHWContext; + saPriv->ctxOwner=dPriv->driContextPriv->hHWContext; + saPriv->texOwner=dPriv->driContextPriv->hHWContext; + grDRIResetSAREA(); + /* fprintf(stderr, "Out FifoPtr=%d FifoRead=%d\n", saPriv->fifoPtr, saPriv->fifoRead); */ +} + +#endif |