diff options
-rw-r--r-- | xc/config/cf/host.def | 40 | ||||
-rw-r--r-- | xc/extras/Mesa/src/FX/fxglidew.c | 48 | ||||
-rw-r--r-- | xc/extras/Mesa/src/FX/fxglidew.h | 119 | ||||
-rw-r--r-- | xc/extras/Mesa/src/FX/fxrender.c | 31 | ||||
-rw-r--r-- | xc/lib/GL/Imakefile | 241 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/Imakefile | 42 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/X86/Imakefile | 62 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/tdfx/Imakefile | 55 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h | 66 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c | 358 | ||||
-rw-r--r-- | xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile | 18 | ||||
-rw-r--r-- | xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c | 91 | ||||
-rw-r--r-- | xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c | 426 |
13 files changed, 1087 insertions, 510 deletions
diff --git a/xc/config/cf/host.def b/xc/config/cf/host.def new file mode 100644 index 000000000..0cd688c3b --- /dev/null +++ b/xc/config/cf/host.def @@ -0,0 +1,40 @@ + +#define DefaultGcc2i386Opt -g -O2 +#define LibraryCDebugFlags -g -O2 +#define BuildServersOnly YES +#define XF86CardDrivers vga tdfx i810 mga r128 glint +#define LinuxDistribution LinuxRedHat +#define GccWarningOptions -Wall -Wpointer-arith -Wstrict-prototypes \ + -Wmissing-prototypes -Wmissing-declarations \ + -Wnested-externs +#define DefaultCCOptions -ansi GccWarningOptions -pipe -g +#define NormalLibGlx NO + +#define BuildXF86DRI YES +#define HasGlide3 YES + +#ifdef i386Architecture +#define MesaUse3DNow +#endif + +/* To do profiling turn on this plus one of the builtin drivers*/ +/* #define ProfileLibGlx YES */ + +/* Optionally turn these on for debugging */ +/* #define GlxBuiltInTdfx YES */ +/* #define GlxBuiltInI810 YES */ +/* #define GlxBuiltInMga YES */ +/* #define GlxBuiltInR128 YES */ +#define DoLoadableServer NO + +/* Optionally turn this on to change the place where you install the build */ +/* #define ProjectRoot /usr/XF86-main */ + +/* Optionally turn this on to force the kernel modules to build */ +/* #define BuildXF86DRM YES */ + +#define SharedLibFont NO +#define XnestServer NO +#define XVirtualFramebufferServer NO +#define XprtServer NO + diff --git a/xc/extras/Mesa/src/FX/fxglidew.c b/xc/extras/Mesa/src/FX/fxglidew.c index 790e5c923..57b35ad4d 100644 --- a/xc/extras/Mesa/src/FX/fxglidew.c +++ b/xc/extras/Mesa/src/FX/fxglidew.c @@ -55,6 +55,13 @@ #include <stdlib.h> #include <string.h> + +grStencilFunc_t grStencilFuncPtr = NULL; +grStencilMask_t grStencilMaskPtr = NULL; +grStencilOp_t grStencilOpPtr = NULL; +grBufferClearExt_t grBufferClearExtPtr = NULL; + + FxI32 FX_grGetInteger_NoLock(FxU32 pname) { #if !defined(FX_GLIDE3) @@ -71,6 +78,8 @@ FxI32 FX_grGetInteger_NoLock(FxU32 pname) case FX_TEXTURE_ALIGN: /* This is a guess from reading the glide3 docs */ return 8; + case FX_ZDEPTH_MAX: + return 0xFFFF; default: if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n"); @@ -90,6 +99,12 @@ FxI32 FX_grGetInteger_NoLock(FxU32 pname) case FX_TEXTURE_ALIGN: grname = pname; break; + case FX_ZDEPTH_MAX: { + int zvals[2]; + + grGet(GR_ZDEPTH_MIN_MAX, 8, zvals); + return zvals[0]; + } default: if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n"); @@ -154,7 +169,17 @@ extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu) { FxBool FX_grSstControl(FxU32 code) { #if defined(FX_GLIDE3) - (void) code; + /* The glide 3 sources call for grEnable/grDisable to be called in exchange + * for grSstControl. */ + switch(code) { + case GR_CONTROL_ACTIVATE: + grEnable(GR_PASSTHRU); + break; + case GR_CONTROL_DEACTIVATE: + grDisable(GR_PASSTHRU); + break; + } + /* Appearently GR_CONTROL_RESIZE can be ignored. */ return 1; /* OK? */ #else FxU32 result; @@ -225,12 +250,12 @@ void FX_grGlideGetVersion(char *buf) void FX_grSstPerfStats(GrSstPerfStats_t *st) { - /* ToDo */ - st->pixelsIn = 0; - st->chromaFail = 0; - st->zFuncFail = 0; - st->aFuncFail = 0; - st->pixelsOut = 0; + FxI32 n; + grGet(GR_STATS_PIXELS_IN, 4, &n); st->pixelsIn = n; + grGet(GR_STATS_PIXELS_CHROMA_FAIL, 4, &n); st->chromaFail = n; + grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, 4, &n); st->zFuncFail = n; + grGet(GR_STATS_PIXELS_AFUNC_FAIL, 4, &n); st->aFuncFail = n; + grGet(GR_STATS_PIXELS_OUT, 4, &n); st->pixelsOut = n; } void FX_grAADrawLine(GrVertex *a,GrVertex *b) @@ -385,6 +410,10 @@ int FX_grSstQueryHardware(GrHwConfiguration *c) return i; } + +#endif /* FX_GLIDE3 */ + +/* It appears to me that this function is needed either way. */ FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd, GrScreenResolution_t screen_resolution, GrScreenRefresh_t refresh_rate, @@ -403,6 +432,7 @@ FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd, nColBuffers, nAuxBuffers ); + /* fprintf(stderr, "grSstWinOpen( win %d res %d ref %d fmt %d\n" " org %d ncol %d naux %d )\n" @@ -415,13 +445,11 @@ FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd, nColBuffers, nAuxBuffers, i); + */ END_BOARD_LOCK(); return i; } - - -#endif #else /* diff --git a/xc/extras/Mesa/src/FX/fxglidew.h b/xc/extras/Mesa/src/FX/fxglidew.h index 28556d8c5..f188c263d 100644 --- a/xc/extras/Mesa/src/FX/fxglidew.h +++ b/xc/extras/Mesa/src/FX/fxglidew.h @@ -47,7 +47,51 @@ #define __FX_GLIDE_WARPER__ #include <glide.h> +#include <g3ext.h> +/* + * These are glide extension definitions. These are not + * defined in glide.h. They should really be defined in + * g3ext.h, but they are not. + */ +#if 0 +FX_ENTRY void FX_CALL +grStencilFunc(GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask); + +FX_ENTRY void FX_CALL +grStencilMask(GrStencil_t write_mask); + +FX_ENTRY void FX_CALL +grStencilOp( + GrStencilOp_t stencil_fail, + GrStencilOp_t depth_fail, + GrStencilOp_t depth_pass); + +FX_ENTRY void FX_CALL +grBufferClearExt( + GrColor_t color, + GrAlpha_t alpha, + FxU32 depth, + GrStencil_t stencil); +#endif + + +typedef void (*grStencilFunc_t)(GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask); +typedef void (*grStencilMask_t)(GrStencil_t write_mask); +typedef void (*grStencilOp_t)(GrStencilOp_t stencil_fail, GrStencilOp_t depth_fail, GrStencilOp_t depth_pass); +typedef void (*grBufferClearExt_t)(GrColor_t color, GrAlpha_t alpha, FxU32 depth, GrStencil_t stencil); + +extern grStencilFunc_t grStencilFuncPtr; +extern grStencilMask_t grStencilMaskPtr; +extern grStencilOp_t grStencilOpPtr; +extern grBufferClearExt_t grBufferClearExtPtr; + + +FX_ENTRY void FX_CALL +grEnable(GrEnableMode_t mode); + +FX_ENTRY void FX_CALL +grEnable(GrEnableMode_t mode); /* * General context: */ @@ -74,12 +118,13 @@ #define FX_PENDING_BUFFERSWAPS GR_PENDING_BUFFERSWAPS #define FX_TEXTURE_ALIGN GR_TEXTURE_ALIGN #endif +#define FX_ZDEPTH_MAX 0x100 /* * Genral warper functions for Glide2/Glide3: */ -extern FxI32 FX_grGetInteger(FxU32 pname); extern FxI32 FX_grGetInteger_NoLock(FxU32 pname); +extern FxI32 FX_grGetInteger(FxU32 pname); /* * Glide2 emulation on Glide3: @@ -253,7 +298,6 @@ typedef struct #endif - /* * Glide2 functions for Glide3 */ @@ -334,10 +378,11 @@ typedef struct /* * Draw triangle */ +#define FX_grDrawTriangle_NoLock(a,b,c) grDrawTriangle(a,b,c) #define FX_grDrawTriangle(a,b,c) \ do { \ BEGIN_CLIP_LOOP(); \ - grDrawTriangle(a,b,c); \ + FX_grDrawTriangle_NoLock(a,b,c); \ END_CLIP_LOOP(); \ } while (0) @@ -521,17 +566,19 @@ extern FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd, int nAuxBuffers); +#define FX_grDrawLine_NoLock(v1, v2) grDrawLine(v1, v2) #define FX_grDrawLine(v1, v2) \ do { \ BEGIN_CLIP_LOOP(); \ - grDrawLine(v1, v2); \ + FX_grDrawLine_NoLock(v1, v2);\ END_CLIP_LOOP(); \ } while (0) +#define FX_grDrawPoint_NoLock(p) grDrawPoint(p) #define FX_grDrawPoint(p) \ do { \ BEGIN_CLIP_LOOP(); \ - grDrawPoint(p); \ + FX_grDrawPoint_NoLock(p); \ END_CLIP_LOOP(); \ } while (0) @@ -567,6 +614,55 @@ extern void FX_grDrawPolygonVertexList(int n, GrVertex *v); END_CLIP_LOOP(); \ } while (0) +#define FX_grBufferClearExt(c, a, d, s) \ + do { \ + BEGIN_CLIP_LOOP(); \ + (*grBufferClearExtPtr)(c, a, d, s); \ + END_CLIP_LOOP(); \ + } while (0) + +/* + * Enable/Disable + */ +#define FX_grEnable(m) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grEnable(m); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grDisable(m) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grDisable(m); \ + END_BOARD_LOCK(); \ + } while (0) + +/* + * Stencil operations. + */ +#define FX_grStencilFunc(fnc, ref, mask) \ + do { \ + BEGIN_BOARD_LOCK(); \ + (*grStencilFuncPtr)((fnc), (ref), (mask)); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grStencilMask(write_mask) \ + do { \ + BEGIN_BOARD_LOCK(); \ + (*grStencilMaskPtr)(write_mask); \ + END_BOARD_LOCK(); \ + } while (0) + + +#define FX_grStencilOp(stencil_fail, depth_fail, depth_pass) \ + do { \ + BEGIN_BOARD_LOCK(); \ + (*grStencilOpPtr)((stencil_fail), (depth_fail), (depth_pass)); \ + END_BOARD_LOCK(); \ + } while (0) + #define FX_grDepthMask(m) \ do { \ BEGIN_BOARD_LOCK(); \ @@ -821,9 +917,18 @@ extern FxU32 FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info); #define FX_grGlideShutdown() \ do { \ - BEGIN_CLIP_LOOP(); \ + BEGIN_BOARD_LOCK(); \ grGlideShutdown(); \ - END_CLIP_LOOP(); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grTexLodBiasValue_NoLock(t, v) grTexLodBiasValue(t, v) + +#define FX_grTexLodBiasValue(t, v) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grTexLodBiasValue(t, v); \ + END_BOARD_LOCK(); \ } while (0) #define FX_grGlideInit_NoLock grGlideInit diff --git a/xc/extras/Mesa/src/FX/fxrender.c b/xc/extras/Mesa/src/FX/fxrender.c index 8ce4b0618..9c5329fff 100644 --- a/xc/extras/Mesa/src/FX/fxrender.c +++ b/xc/extras/Mesa/src/FX/fxrender.c @@ -533,43 +533,44 @@ static INLINE void fxSafeClippedTriangle3( struct vertex_buffer *VB, do { \ GLuint e; \ for(e=start;e<=count;e++) { \ - FX_grDrawPoint((GrVertex *)gWin[elt[e]].f); \ + FX_grDrawPoint_NoLock((GrVertex *)gWin[elt[e]].f);\ } \ } while (0) #define RENDER_LINE( i1, i ) \ do { \ GLuint e1 = elt[i1], e = elt[i]; \ - FX_grDrawLine((GrVertex *)gWin[e1].f, (GrVertex *)gWin[e].f); \ + FX_grDrawLine_NoLock((GrVertex *)gWin[e1].f, (GrVertex *)gWin[e].f);\ } while (0) #define RENDER_TRI( i2, i1, i, pv, parity) \ do { \ GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \ - if (parity) {GLuint tmp = e2; e2 = e1; e1 = tmp;} \ - FX_grDrawTriangle((GrVertex *)gWin[e2].f, \ - (GrVertex *)gWin[e1].f, \ - (GrVertex *)gWin[e].f); \ + if (parity) {GLuint tmp = e2; e2 = e1; e1 = tmp;} \ + FX_grDrawTriangle_NoLock((GrVertex *)gWin[e2].f, \ + (GrVertex *)gWin[e1].f, \ + (GrVertex *)gWin[e].f); \ } while (0) #define RENDER_QUAD( i3, i2, i1, i, pv) \ do { \ GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\ - FX_grDrawTriangle((GrVertex *)gWin[e3].f, \ - (GrVertex *)gWin[e2].f, \ - (GrVertex *)gWin[e].f); \ - FX_grDrawTriangle((GrVertex *)gWin[e2].f, \ - (GrVertex *)gWin[e1].f, \ - (GrVertex *)gWin[e].f); \ + FX_grDrawTriangle_NoLock((GrVertex *)gWin[e3].f, \ + (GrVertex *)gWin[e2].f, \ + (GrVertex *)gWin[e].f); \ + FX_grDrawTriangle_NoLock((GrVertex *)gWin[e2].f, \ + (GrVertex *)gWin[e1].f, \ + (GrVertex *)gWin[e].f); \ } while (0) #define LOCAL_VARS \ fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \ const GLuint *elt = VB->EltPtr->data; -#define INIT(x) +#define INIT(x) BEGIN_CLIP_LOOP(); +#define POSTFIX END_CLIP_LOOP(); #define TAG(x) x##_fx_smooth_indirect #undef RVB_COLOR @@ -722,8 +723,8 @@ render_func **fxDDChooseRenderVBTables(GLcontext *ctx) return null_tables; switch (fxMesa->render_index) { - case FX_FLAT: - return fxDDRenderVBFlat_tables; +/* case FX_FLAT: */ +/* return fxDDRenderVBFlat_tables; */ case 0: return fxDDRenderVBSmooth_tables; default: diff --git a/xc/lib/GL/Imakefile b/xc/lib/GL/Imakefile index a185089e4..e085fc937 100644 --- a/xc/lib/GL/Imakefile +++ b/xc/lib/GL/Imakefile @@ -11,26 +11,25 @@ XCOMM $XFree86: xc/lib/GL/Imakefile,v 1.16 2000/03/02 16:07:30 martin Exp $ #define DoDebugLib DebugLibGlx #define DoProfileLib ProfileLibGlx -#if BuildXF86DRI -DRIDIRS = dri -MESADIRS = mesa/dri mesa/include/GL mesa/src -#endif -SUBDIRS = glx $(DRIDIRS) $(MESADIRS) + LIBNAME = GL + SOREV = $(SOGLREV) #ifdef SharedGLReqs REQUIREDLIBS = SharedGLReqs #endif -MakeSubdirs($(SUBDIRS)) -DependSubdirs($(SUBDIRS)) +#if 0 + LOWSRC = lowpc.c + LOWOBJ = lowpc.o - LIBNAME = GL - SOREV = $(SOGLREV) + HISRC = highpc.c + HIOBJ = highpc.o +#endif GLXOBJS = glx/?*.o - GLXUOBJS = glx/unshared/?*.o - GLXDOBJS = glx/debugger/?*.o - GLXPOBJS = glx/profiled/?*.o + GLXUOBJS = glx/unshared/?*.o glx/glapi_x86.o + GLXDOBJS = glx/debugger/?*.o glx/glapi_x86.o + GLXPOBJS = glx/profiled/?*.o glx/glapi_x86.o GLXDONES = glx/DONE #if BuildXF86DRI @@ -40,19 +39,51 @@ DependSubdirs($(SUBDIRS)) DRIPOBJS = dri/profiled/XF86dri.o dri/profiled/dri_glx.o DRIDONES = dri/DONE -#if !GlxUseSGISI -#if GlxBuiltInGamma DRMOBJS = dri/drm/?*.o DRMUOBJS = dri/drm/unshared/?*.o DRMDOBJS = dri/drm/debugger/?*.o DRMPOBJS = dri/drm/profiled/?*.o DRMDONES = dri/drm/DONE - GAMMAOBJS = mesa/src/drv/gamma/?*.o - GAMMAUOBJS = mesa/src/drv/gamma/unshared/?*.o - GAMMADOBJS = mesa/src/drv/gamma/debugger/?*.o - GAMMAPOBJS = mesa/src/drv/gamma/profiled/?*.o - GAMMADONES = mesa/src/drv/gamma/DONE +#ifdef i386Architecture + ASM_OBJS = mesa/src/X86/common_x86asm.o \ + mesa/src/X86/mmx_blend.o \ + mesa/src/X86/vertex.o \ + mesa/src/X86/x86a.o +#ifdef MesaUse3DNow + ASM_OBJS += mesa/src/X86/3dnow_norm.o \ + mesa/src/X86/3dnow_norm_raw.o \ + mesa/src/X86/3dnow_xform_masked1.o \ + mesa/src/X86/3dnow_xform_masked2.o \ + mesa/src/X86/3dnow_xform_masked3.o \ + mesa/src/X86/3dnow_xform_masked4.o \ + mesa/src/X86/3dnow_xform_raw1.o \ + mesa/src/X86/3dnow_xform_raw2.o \ + mesa/src/X86/3dnow_xform_raw3.o \ + mesa/src/X86/3dnow_xform_raw4.o \ + mesa/src/X86/vertex_3dnow.o +#endif +#ifdef MesaUseKatmai + ASM_OBJS += mesa/src/X86/katmai_norm.o \ + mesa/src/X86/katmai_norm_raw.o \ + mesa/src/X86/katmai_xform_masked1.o \ + mesa/src/X86/katmai_xform_masked2.o \ + mesa/src/X86/katmai_xform_masked3.o \ + mesa/src/X86/katmai_xform_masked4.o \ + mesa/src/X86/katmai_xform_raw1.o \ + mesa/src/X86/katmai_xform_raw2.o \ + mesa/src/X86/katmai_xform_raw3.o \ + mesa/src/X86/katmai_xform_raw4.o \ + mesa/src/X86/vertex_katmai.o +#endif + +#endif + + MESAOBJS = mesa/src/?*.o mesa/src/X86/?*.o + MESAUOBJS = mesa/src/unshared/?*.o mesa/src/X86/unshared/?*.o $(ASM_OBJS) + MESADOBJS = mesa/src/debugger/?*.o mesa/src/X86/debugger/?*.o $(ASM_OBJS) + MESAPOBJS = mesa/src/profiled/?*.o mesa/src/X86/profiled/?*.o $(ASM_OBJS) + MESADONES = mesa/src/DONE mesa/src/X86/DONE DRIMESAOBJS = mesa/dri/?*.o DRIMESAUOBJS = mesa/dri/unshared/?*.o @@ -60,18 +91,34 @@ DRIMESADOBJS = mesa/dri/debugger/?*.o DRIMESAPOBJS = mesa/dri/profiled/?*.o DRIMESADONES = mesa/dri/DONE + COMMONOBJS = mesa/src/drv/common/?*.o + COMMONUOBJS = mesa/src/drv/common/unshared/?*.o + COMMONDOBJS = mesa/src/drv/common/debugger/?*.o + COMMONPOBJS = mesa/src/drv/common/profiled/?*.o + COMMONDONES = mesa/src/drv/common/DONE + + +#if GlxUseSGISI + +XCOMM nothing + +#elif GlxBuiltInGamma + + GAMMAOBJS = mesa/src/drv/gamma/?*.o + GAMMAUOBJS = mesa/src/drv/gamma/unshared/?*.o + GAMMADOBJS = mesa/src/drv/gamma/debugger/?*.o + GAMMAPOBJS = mesa/src/drv/gamma/profiled/?*.o + GAMMADONES = mesa/src/drv/gamma/DONE + DRVOBJS = $(GAMMAOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) DRVUOBJS = $(GAMMAUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) DRVDOBJS = $(GAMMADOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) DRVPOBJS = $(GAMMAPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) DRVDONES = $(GAMMADONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src + #elif GlxBuiltInTdfx - DRMOBJS = dri/drm/?*.o - DRMUOBJS = dri/drm/unshared/?*.o - DRMDOBJS = dri/drm/debugger/?*.o - DRMPOBJS = dri/drm/profiled/?*.o - DRMDONES = dri/drm/DONE TDFXOBJS = mesa/src/drv/tdfx/?*.o TDFXUOBJS = mesa/src/drv/tdfx/unshared/?*.o @@ -79,51 +126,131 @@ DRIMESADONES = mesa/dri/DONE TDFXPOBJS = mesa/src/drv/tdfx/profiled/?*.o TDFXDONES = mesa/src/drv/tdfx/DONE - MESAOBJS = mesa/src/?*.o mesa/src/X86/?*.o - MESAUOBJS = mesa/src/unshared/?*.o mesa/src/X86/unshared/?*.o - MESADOBJS = mesa/src/debugger/?*.o mesa/src/X86/debugger/?*.o - MESAPOBJS = mesa/src/profiled/?*.o mesa/src/X86/profiled/?*.o - MESADONES = mesa/src/DONE mesa/src/X86/DONE - - DRIMESAOBJS = mesa/dri/?*.o -DRIMESAUOBJS = mesa/dri/unshared/?*.o -DRIMESADOBJS = mesa/dri/debugger/?*.o -DRIMESAPOBJS = mesa/dri/profiled/?*.o -DRIMESADONES = mesa/dri/DONE - DRVOBJS = $(TDFXOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) DRVUOBJS = $(TDFXUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) DRVDOBJS = $(TDFXDOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) DRVPOBJS = $(TDFXPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) DRVDONES = $(TDFXDONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) - REQUIREDLIBS += -lglide3x +REQUIREDLIBS += -lglide3x -ldl + + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src + +#elif GlxBuiltInI810 + + I810OBJS = mesa/src/drv/i810/?*.o + I810UOBJS = mesa/src/drv/i810/unshared/?*.o + I810DOBJS = mesa/src/drv/i810/debugger/?*.o + I810POBJS = mesa/src/drv/i810/profiled/?*.o + I810DONES = mesa/src/drv/i810/DONE + + DRVOBJS = $(I810OBJS) $(COMMONOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) + DRVUOBJS = $(I810UOBJS) $(COMMONUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) + DRVDOBJS = $(I810DOBJS) $(COMMONDOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) + DRVPOBJS = $(I810POBJS) $(COMMONPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) + DRVDONES = $(I810DONES) $(COMMONDONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) + + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src + +#elif GlxBuiltInMga + + MGAOBJS = mesa/src/drv/mga/?*.o + MGAUOBJS = mesa/src/drv/mga/unshared/?*.o + MGADOBJS = mesa/src/drv/mga/debugger/?*.o + MGAPOBJS = mesa/src/drv/mga/profiled/?*.o + MGADONES = mesa/src/drv/mga/DONE + + DRVOBJS = $(MGAOBJS) $(COMMONOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) + DRVUOBJS = $(MGAUOBJS) $(COMMONUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) + DRVDOBJS = $(MGADOBJS) $(COMMONDOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) + DRVPOBJS = $(MGAPOBJS) $(COMMONPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) + DRVDONES = $(MGADONES) $(COMMONDONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) + + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src + +#elif GlxBuiltInR128 + + R128OBJS = mesa/src/drv/r128/?*.o + R128UOBJS = mesa/src/drv/r128/unshared/?*.o + R128DOBJS = mesa/src/drv/r128/debugger/?*.o + R128POBJS = mesa/src/drv/r128/profiled/?*.o + R128DONES = mesa/src/drv/r128/DONE + + DRVOBJS = $(R128OBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) + DRVUOBJS = $(R128UOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) + DRVDOBJS = $(R128DOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) + DRVPOBJS = $(R128POBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) + DRVDONES = $(R128DONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) + + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src + #elif GlxBuiltInMesa + #ifndef GlxDriverUsesMesa - DRVOBJS = mesa/src/?*.o mesa/src/X/?*.o - DRVUOBJS = mesa/src/unshared/?*.o mesa/src/X/unshared/?*.o - DRVDOBJS = mesa/src/debugger/?*.o mesa/src/X/debugger/?*.o - DRVPOBJS = mesa/src/profiled/?*.o mesa/src/X/profiled/?*.o - DRVDONES = mesa/src/DONE mesa/src/X/DONE + DRVOBJS = mesa/src/?*.o + DRVUOBJS = mesa/src/unshared/?*.o + DRVDOBJS = mesa/src/debugger/?*.o + DRVPOBJS = mesa/src/profiled/?*.o + DRVDONES = mesa/src/DONE + + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src #endif + +#else + +XCOMM No built-in drivers. This is the usual case. +GLXSUBDIRS = glx dri + #endif + +#else + +XCOMM BuildXF86DRI was not defined. Just build an indirect-only libGL. +GLXSUBDIRS = glx + #endif + + + + +#if BuildXF86DRI +SUBDIRS = $(GLXSUBDIRS) +OTHERSUBDIRS = mesa/dri mesa/include/GL mesa/src +#else +SUBDIRS = glx #endif +MakeSubdirs($(SUBDIRS)) +MakefileSubdirs($(OTHERSUBDIRS)) +DependSubdirs($(SUBDIRS) $(OTHERSUBDIRS)) + + + #ifdef OS2Architecture OBJS = $(LIBNAME).a #else - OBJS = $(GLXOBJS) $(DRIOBJS) $(DRVOBJS) + OBJS = $(LOWOBJ) $(GLXOBJS) $(DRIOBJS) $(DRVOBJS) $(HIOBJ) #endif + #if HasSharedLibraries +#if 1 UOBJS = $(GLXUOBJS) $(DRIUOBJS) $(DRVUOBJS) #else UOBJS = $(OBJS) #endif +#else + UOBJS = $(OBJS) +#endif + DOBJS = $(GLXDOBJS) $(DRIDOBJS) $(DRVDOBJS) POBJS = $(GLXPOBJS) $(DRIPOBJS) $(DRVPOBJS) DONES = $(GLXDONES) $(DRIDONES) $(DRVDONES) +#if 0 +SubdirLibraryRule(highpc.o lowpc.o) +NormalLintTarget(highpc.c lowpc.c) +#endif + #if LocalThreads THREADOBJS = $(THREADS_LIBS) #endif @@ -134,19 +261,39 @@ DRIMESADONES = mesa/dri/DONE #define _LinkBuildLibrary(lib) LinkBuildLibrary(lib) #if NormalLibGlx -NormalDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(UOBJS)) +NormalDepLibraryTarget($(LIBNAME),$(GLXSUBDIRS) $(DONES),$(UOBJS)) InstallLibrary($(LIBNAME),$(USRLIBDIR)) #endif #if SharedLibGlx -SharedDepLibraryTarget($(LIBNAME),$(SOREV),$(SUBDIRS) $(DONES),$(OBJS) $(THREADOBJS),.,.) +SharedDepLibraryTarget($(LIBNAME),$(SOREV),$(GLXSUBDIRS) $(DONES),$(OBJS) $(THREADOBJS),.,.) InstallSharedLibrary($(LIBNAME),$(SOREV),$(SHLIBDIR)) +#if LinkGLToUsrLib && AlternateUsrLibDir +install:: + $(RM) $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so + $(LN) $(SHLIBDIR)/lib$(LIBNAME).so $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so + $(RM) $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1 + $(LN) $(SHLIBDIR)/lib$(LIBNAME).so.1 $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1 +#endif #endif #if DebugLibGlx -DebuggedDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(DOBJS)) +DebuggedDepLibraryTarget($(LIBNAME),$(GLXSUBDIRS) $(DONES),$(DOBJS)) InstallLibrary($(LIBNAME)_d,$(USRLIBDIR)) #endif #if ProfileLibGlx -ProfiledDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(POBJS)) +ProfiledDepLibraryTarget($(LIBNAME),$(GLXSUBDIRS) $(DONES),$(POBJS)) InstallLibrary($(LIBNAME)_p,$(USRLIBDIR)) #endif + + +XCOMM libGL has now been made, continue with building the drivers. + +#if BuildXF86DRI && !GlxBuiltInGamma && !GlxBuiltInTdfx && !GlxBuiltInI810 && !GlxBuiltInMga && !GlxBuiltInMesa + +DRIVERSUBDIRS = mesa/dri mesa/include/GL mesa/src + +MakeSubdirs($(DRIVERSUBDIRS)) +DependSubdirs($(DRIVERSUBDIRS)) +InstallSubdirs($(DRIVERSUBDIRS)) + +#endif diff --git a/xc/lib/GL/mesa/src/Imakefile b/xc/lib/GL/mesa/src/Imakefile index d93aa3f7e..4622bbfe3 100644 --- a/xc/lib/GL/mesa/src/Imakefile +++ b/xc/lib/GL/mesa/src/Imakefile @@ -16,6 +16,9 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL TDFX_DEFS = -DFX #endif +LinkSourceFile(aatriangle.c, ../../../../extras/Mesa/src) +LinkSourceFile(aatriangle.h, ../../../../extras/Mesa/src) +LinkSourceFile(aatritemp.h, ../../../../extras/Mesa/src) LinkSourceFile(accum.c, ../../../../extras/Mesa/src) LinkSourceFile(accum.h, ../../../../extras/Mesa/src) LinkSourceFile(all.h, ../../../../extras/Mesa/src) @@ -120,6 +123,8 @@ LinkSourceFile(pipeline.c, ../../../../extras/Mesa/src) LinkSourceFile(pipeline.h, ../../../../extras/Mesa/src) LinkSourceFile(pixel.c, ../../../../extras/Mesa/src) LinkSourceFile(pixel.h, ../../../../extras/Mesa/src) +LinkSourceFile(pixeltex.c, ../../../../extras/Mesa/src) +LinkSourceFile(pixeltex.h, ../../../../extras/Mesa/src) LinkSourceFile(points.c, ../../../../extras/Mesa/src) LinkSourceFile(points.h, ../../../../extras/Mesa/src) LinkSourceFile(polygon.c, ../../../../extras/Mesa/src) @@ -156,6 +161,8 @@ LinkSourceFile(texstate.c, ../../../../extras/Mesa/src) LinkSourceFile(texstate.h, ../../../../extras/Mesa/src) LinkSourceFile(texture.c, ../../../../extras/Mesa/src) LinkSourceFile(texture.h, ../../../../extras/Mesa/src) +LinkSourceFile(texutil.c, ../../../../extras/Mesa/src) +LinkSourceFile(texutil.h, ../../../../extras/Mesa/src) LinkSourceFile(trans_tmp.h, ../../../../extras/Mesa/src) LinkSourceFile(translate.c, ../../../../extras/Mesa/src) LinkSourceFile(translate.h, ../../../../extras/Mesa/src) @@ -189,7 +196,8 @@ LinkSourceFile(xform_tmp.h, ../../../../extras/Mesa/src) LinkSourceFile(zoom.c, ../../../../extras/Mesa/src) LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) - CORE_SRCS = accum.c \ + CORE_SRCS = aatriangle.c \ + accum.c \ alpha.c \ alphabuf.c \ attrib.c \ @@ -220,7 +228,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) hash.c \ hint.c \ image.c \ - imaging.o \ + imaging.c \ light.c \ lines.c \ logic.c \ @@ -231,6 +239,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) pb.c \ pipeline.c \ pixel.c \ + pixeltex.c \ points.c \ polygon.c \ quads.c \ @@ -247,6 +256,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) texobj.c \ texstate.c \ texture.c \ + texutil.c \ translate.c \ triangle.c \ varray.c \ @@ -262,7 +272,8 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) xform.c \ zoom.c - CORE_OBJS = accum.o \ + CORE_OBJS = aatriangle.o \ + accum.o \ alpha.o \ alphabuf.o \ attrib.o \ @@ -301,6 +312,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) pb.o \ pipeline.o \ pixel.o \ + pixeltex.o \ points.o \ polygon.o \ quads.o \ @@ -317,6 +329,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) texobj.o \ texstate.o \ texture.o \ + texutil.o \ translate.o \ triangle.o \ varray.o \ @@ -335,7 +348,13 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) #ifdef i386Architecture ASM_SRCS = ASM_OBJS = - ASM_DEFS = -DUSE_MMX_ASM -DUSE_X86_ASM +#ifdef MesaUse3DNow + 3DNOW_DEFS = -DUSE_3DNOW_ASM +#endif +#ifdef MesaUseKatmai + KATMAI_DEFS = -DUSE_KATMAI_ASM +#endif + ASM_DEFS = -DUSE_MMX_ASM -DUSE_X86_ASM $(3DNOW_DEFS) $(KATMAI_DEFS) #endif DEFINES = $(ALLOC_DEFINES) GlxDefines $(TDFX_DEFS) $(ASM_DEFS) @@ -351,9 +370,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) #endif #if GlxBuiltInMesa || GlxDriverUsesMesa || !GlxUseBuiltInDRIDriver -# We have to go into X to make the xmesaP.h symbolic link - MESASUBDIRS = X - + MESASUBDIRS = ASMSUBDIRS = X86 #include <Library.tmpl> @@ -367,17 +384,8 @@ NormalLintTarget($(SRCS)) #define IHaveSubdirs #define PassCDebugFlags -SUBDIRS = $(MESASUBDIRS) $(ASMSUBDIRS) drv +SUBDIRS = $(MESASUBDIRS) $(ASMSUBDIRS) drv OSmesa MakeSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) - -#if !GlxUseBuiltInDRIDriver && !GlxDriverUsesMesa -LIBNAME = mesa_dri.so -ALL_OBJS = $(CORE_OBJS) X/?*.o X86/?*.o -ALL_DEPS = $(SUBDIRS) DONE X/DONE X86/DONE -SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS)) -InstallDynamicModule($(LIBNAME),$(MODULEDIR)/dri,.) -#endif - DependTarget() diff --git a/xc/lib/GL/mesa/src/X86/Imakefile b/xc/lib/GL/mesa/src/X86/Imakefile index 858f0cd73..9e18239c5 100644 --- a/xc/lib/GL/mesa/src/X86/Imakefile +++ b/xc/lib/GL/mesa/src/X86/Imakefile @@ -16,7 +16,6 @@ LinkSourceFile(x86.h, ../../../../../extras/Mesa/src/X86) LinkSourceFile(x86a.S, ../../../../../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) LinkSourceFile(mmx.h, ../../../../../extras/Mesa/src/X86) LinkSourceFile(mmx_blend.S, ../../../../../extras/Mesa/src/X86) @@ -34,6 +33,19 @@ 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(katmai.c, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(katmai.h, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(katmai_norm_raw.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(katmai_xform_masked1.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(katmai_xform_masked2.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(katmai_xform_masked3.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(katmai_xform_masked4.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(katmai_xform_raw1.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(katmai_xform_raw2.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(katmai_xform_raw3.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(katmai_xform_raw4.S, ../../../../../extras/Mesa/src/X86) +LinkSourceFile(vertex_katmai.S, ../../../../../extras/Mesa/src/X86) + LinkSourceFile(glapioffsets.h, ../../../../../extras/Mesa/src) #if Malloc0ReturnsNull @@ -41,7 +53,7 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL #endif #ifdef i386Architecture -XCOMM We'll learn at runtime whether 3dNow, MMX, etc are really present. +XCOMM Determine at runtime whether 3dNow, Katmai, MMX, etc are really present. X86_SRCS = x86a.S common_x86.c common_x86asm.S glapi_x86.S x86.c vertex.S X86_OBJS = x86a.o common_x86.o common_x86asm.o x86.o vertex.o @@ -55,9 +67,7 @@ XCOMM We'll learn at runtime whether 3dNow, MMX, etc are really present. MMX_DEFS = -DUSE_MMX_ASM - -XCOMM Disabling 3DNow code for the time being -#if 0 +#ifdef MesaUse3DNow 3DNOW_SRCS = 3dnow.c 3dnow_norm_raw.S 3dnow_xform_masked1.S \ 3dnow_xform_masked2.S 3dnow_xform_masked3.S \ 3dnow_xform_masked4.S 3dnow_xform_raw1.S \ @@ -73,12 +83,28 @@ XCOMM Disabling 3DNow code for the time being 3DNOW_DEFS = -DUSE_3DNOW_ASM #endif +#ifdef MesaUseKatmai + KATMAI_SRCS = katmai.c katmai_norm_raw.S katmai_xform_masked1.S \ + katmai_xform_masked2.S katmai_xform_masked3.S \ + katmai_xform_masked4.S katmai_xform_raw1.S \ + katmai_xform_raw2.S katmai_xform_raw3.S katmai_xform_raw4.S \ + vertex_katmai.S + + KATMAI_OBJS = katmai.o katmai_norm_raw.o katmai_xform_masked1.o \ + katmai_xform_masked2.o katmai_xform_masked3.o \ + katmai_xform_masked4.o katmai_xform_raw1.o \ + katmai_xform_raw2.o katmai_xform_raw3.o katmai_xform_raw4.o \ + vertex_katmai.o + + KATMAI_DEFS = -DUSE_KATMAI_ASM #endif - DEFINES = $(ALLOC_DEFINES) GlxDefines -DFX $(X86_DEFS) $(MMX_DEFS) $(3DNOW_DEFS) +#endif + + DEFINES = $(ALLOC_DEFINES) GlxDefines -DFX $(X86_DEFS) $(MMX_DEFS) $(3DNOW_DEFS) $(KATMAI_DEFS) INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) -I../include -I../../include -I../../dri -I.. - SRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) - OBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) + SRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS) + OBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS) #if !GlxUseBuiltInDRIDriver #undef DoNormalLib NormalLibGlx @@ -96,7 +122,7 @@ STD_CPP_DEFINES = StandardDefines $(PROJECT_DEFINES) SubdirLibraryRule($(OBJS)) NormalLintTarget($(SRCS)) -#ifdef HAVE_3DNOW +#ifdef MesaUse3DNow ObjectFromAsmSource(3dnow_norm_raw, NullParameter) ObjectFromAsmSource(3dnow_xform_masked1, NullParameter) ObjectFromAsmSource(3dnow_xform_masked2, NullParameter) @@ -109,16 +135,24 @@ ObjectFromAsmSource(3dnow_xform_raw4, NullParameter) ObjectFromAsmSource(vertex_3dnow, NullParameter) #endif -#ifdef HAVE_MMX -ObjectFromAsmSource(mmx_blend, NullParameter) +#ifdef MesaUseKatmai +ObjectFromAsmSource(katmai_norm_raw, NullParameter) +ObjectFromAsmSource(katmai_xform_masked1, NullParameter) +ObjectFromAsmSource(katmai_xform_masked2, NullParameter) +ObjectFromAsmSource(katmai_xform_masked3, NullParameter) +ObjectFromAsmSource(katmai_xform_masked4, NullParameter) +ObjectFromAsmSource(katmai_xform_raw1, NullParameter) +ObjectFromAsmSource(katmai_xform_raw2, NullParameter) +ObjectFromAsmSource(katmai_xform_raw3, NullParameter) +ObjectFromAsmSource(katmai_xform_raw4, NullParameter) +ObjectFromAsmSource(vertex_katmai, NullParameter) #endif +ObjectFromAsmSource(mmx_blend, NullParameter) + ObjectFromAsmSource(common_x86asm, NullParameter) ObjectFromAsmSource(vertex, NullParameter) ObjectFromAsmSource(x86a, NullParameter) DependTarget() -x86a.S: x86flatregs.m4 -x86a.S: x86a.S.m4 - m4 $< >$@ diff --git a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile index c159a8e76..cf188c09f 100644 --- a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile +++ b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile @@ -79,7 +79,8 @@ LinkSourceFile(fxvs_tmp.h, ../../../../../../extras/Mesa/src/FX) fxglidew.o fxpipeline.o fxrender.o fxsanity.o fxsetup.o \ fxtexman.o fxtrifuncs.o fxvsetup.o - MESASRCS = ../../accum.c \ + MESASRCS = ../../aatriangle.c \ + ../../accum.c \ ../../alpha.c \ ../../alphabuf.c \ ../../attrib.c \ @@ -109,7 +110,7 @@ LinkSourceFile(fxvs_tmp.h, ../../../../../../extras/Mesa/src/FX) ../../glthread.c \ ../../hash.c \ ../../image.c \ - ../../imaging.o \ + ../../imaging.c \ ../../light.c \ ../../lines.c \ ../../logic.c \ @@ -120,6 +121,7 @@ LinkSourceFile(fxvs_tmp.h, ../../../../../../extras/Mesa/src/FX) ../../pb.c \ ../../pipeline.c \ ../../pixel.c \ + ../../pixeltex.c \ ../../points.c \ ../../polygon.c \ ../../quads.c \ @@ -136,6 +138,7 @@ LinkSourceFile(fxvs_tmp.h, ../../../../../../extras/Mesa/src/FX) ../../texobj.c \ ../../texstate.c \ ../../texture.c \ + ../../texutil.c \ ../../translate.c \ ../../triangle.c \ ../../varray.c \ @@ -152,7 +155,8 @@ LinkSourceFile(fxvs_tmp.h, ../../../../../../extras/Mesa/src/FX) ../../zoom.c \ ../../X86/common_x86.c - MESAOBJS = ../../accum.o \ + MESAOBJS = ../../aatriangle.o \ + ../../accum.o \ ../../alpha.o \ ../../alphabuf.o \ ../../attrib.o \ @@ -191,6 +195,7 @@ LinkSourceFile(fxvs_tmp.h, ../../../../../../extras/Mesa/src/FX) ../../pb.o \ ../../pipeline.o \ ../../pixel.o \ + ../../pixeltex.o \ ../../points.o \ ../../polygon.o \ ../../quads.o \ @@ -207,6 +212,7 @@ LinkSourceFile(fxvs_tmp.h, ../../../../../../extras/Mesa/src/FX) ../../texobj.o \ ../../texstate.o \ ../../texture.o \ + ../../texutil.o \ ../../translate.o \ ../../triangle.o \ ../../varray.o \ @@ -239,8 +245,7 @@ LinkSourceFile(fxvs_tmp.h, ../../../../../../extras/Mesa/src/FX) MMX_OBJS = ../../X86/mmx_blend.o -XCOMM Disabling 3Dnow code for the time being. -#if 0 +#ifdef MesaUse3DNow 3DNOW_SRCS = ../../X86/3dnow.c \ ../../X86/3dnow_norm_raw.S \ ../../X86/3dnow_xform_masked1.S \ @@ -266,15 +271,45 @@ XCOMM Disabling 3Dnow code for the time being. ../../X86/vertex_3dnow.o #endif +#ifdef MesaUseKatmai + KATMAI_SRCS = ../../X86/katmai.c \ + ../../X86/katmai_norm_raw.S \ + ../../X86/katmai_xform_masked1.S \ + ../../X86/katmai_xform_masked2.S \ + ../../X86/katmai_xform_masked3.S \ + ../../X86/katmai_xform_masked4.S \ + ../../X86/katmai_xform_raw1.S \ + ../../X86/katmai_xform_raw2.S \ + ../../X86/katmai_xform_raw3.S \ + ../../X86/katmai_xform_raw4.S \ + ../../X86/vertex_katmai.S + + KATMAI_OBJS = ../../X86/katmai.o \ + ../../X86/katmai_norm_raw.o \ + ../../X86/katmai_xform_masked1.o \ + ../../X86/katmai_xform_masked2.o \ + ../../X86/katmai_xform_masked3.o \ + ../../X86/katmai_xform_masked4.o \ + ../../X86/katmai_xform_raw1.o \ + ../../X86/katmai_xform_raw2.o \ + ../../X86/katmai_xform_raw3.o \ + ../../X86/katmai_xform_raw4.o \ + ../../X86/vertex_katmai.o +#endif + #endif - ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) - ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) + ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS) + ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS) + + SRCS = $(DRISRCS) $(DRMSRCS) $(TDFXSRCS) $(MESASRCS) $(ASMSRCS) + OBJS = $(DRIOBJS) $(DRMOBJS) $(TDFXOBJS) $(MESAOBJS) $(ASMOBJS) - SRCS = $(DRISRCS) $(DRMSRCS) $(TDFXSRCS) $(MESASRCS) $(ASMSRCS) - OBJS = $(DRIOBJS) $(DRMOBJS) $(TDFXOBJS) $(MESAOBJS) $(ASMOBJS) +REQUIREDLIBS = -lglide3x -lm +#if !GlxBuiltInTdfx +REQUIREDLIBS += -L../../../.. -lGL +#endif -REQUIREDLIBS += -lglide3x #if !GlxUseBuiltInDRIDriver #undef DoNormalLib NormalLibGlx diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h index 3759512ee..20a5fec67 100644 --- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h +++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h @@ -41,9 +41,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "dri_tmm.h" #include "dri_mesaint.h" #include "dri_mesa.h" -#include "types.h" -#include "xmesaP.h" -/* #include "fxdrv.h" */ +#include "dri_xmesaapi.h" + typedef struct { drmHandle handle; @@ -98,7 +97,8 @@ typedef struct tfxMesaContext tdfxContextPrivate; extern GLboolean tdfxMapAllRegions(__DRIscreenPrivate *driScrnPriv); extern void tdfxUnmapAllRegions(__DRIscreenPrivate *driScrnPriv); -extern GLboolean tdfxInitHW(XMesaContext c); +extern GLboolean tdfxInitHW(__DRIdrawablePrivate *driDrawPrivate, + tdfxContextPrivate *cPriv); extern void XMesaWindowMoved(void); extern void XMesaUpdateState(int windowMoved); @@ -119,8 +119,8 @@ extern void grDRIImportFifo(int fifoPtr, int fifoRead); extern void grDRIInvalidateAll(void); extern void grDRIResetSAREA(void); -extern XMesaContext gCC; -extern tdfxContextPrivate *gCCPriv; +extern __DRIcontextPrivate *gCC; +/*000extern tdfxContextPrivate *gCCPriv;*/ /* You can turn this on to find locking conflicts. #define DEBUG_LOCKING @@ -163,11 +163,12 @@ extern int prevLockLine; if (__ret) drmGetLock(fd,context,0); \ } while(0) +#if 0 /* Lock the hardware using the global current context */ #define LOCK_HARDWARE() \ do { \ char __ret=0; \ - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; \ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; \ __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \ DEBUG_CHECK_LOCK(); \ DRM_CAS(&sPriv->pSAREA->lock, dPriv->driContextPriv->hHWContext, \ @@ -182,13 +183,26 @@ extern int prevLockLine; } \ DEBUG_LOCK(); \ } while (0) +#else +#define LOCK_HARDWARE() \ + do { \ + char __ret=0; \ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; \ + __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \ + DEBUG_CHECK_LOCK(); \ + DRM_CAS(&sPriv->pSAREA->lock, dPriv->driContextPriv->hHWContext, \ + DRM_LOCK_HELD|dPriv->driContextPriv->hHWContext, __ret); \ + if (__ret) XMesaUpdateState(GL_FALSE); \ + DEBUG_LOCK(); \ + } while (0) +#endif /* Unlock the hardware using the global current context */ #define UNLOCK_HARDWARE() \ do { \ - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; \ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; \ __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \ - XMesaSetSAREA(); \ + /* XMesaSetSAREA(); */ \ DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, \ dPriv->driContextPriv->hHWContext); \ DEBUG_RESET(); \ @@ -202,24 +216,26 @@ extern int prevLockLine; 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; \ - LOCK_HARDWARE(); \ - _nc = dPriv->numClipRects; \ - 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 BEGIN_CLIP_LOOP() \ + do { \ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; \ + tdfxContextPrivate *gCCPriv = \ + (tdfxContextPrivate *) gCC->driverPrivate; \ + int _nc; \ + LOCK_HARDWARE(); \ + _nc = dPriv->numClipRects; \ + 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(); \ +#define END_CLIP_LOOP() \ + } \ + UNLOCK_HARDWARE(); \ } while (0) #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 index 7fc55cb16..392d7cb3e 100644 --- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c @@ -28,7 +28,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Daryll Strauss <daryll@precisioninsight.com> - * + * Brian E. Paul <brian@precisioninsight.com> */ #ifdef GLX_DIRECT_RENDERING @@ -37,201 +37,199 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <glide.h> #include "tdfx_init.h" #include "context.h" -#include "vbxform.h" #include "matrix.h" +#include "mmath.h" +#include "vbxform.h" -XMesaContext nullCC = 0; -XMesaContext gCC = 0; -tdfxContextPrivate *gCCPriv = 0; -static int count_bits(unsigned int n) -{ - int bits = 0; +__DRIcontextPrivate *gCC = 0; - while (n > 0) { - if (n & 1) bits++; - n >>= 1; - } - return bits; -} -GLboolean XMesaInitDriver(__DRIscreenPrivate *driScrnPriv) +GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) { - tdfxScreenPrivate *gsp; - - /* Allocate the private area */ - gsp = (tdfxScreenPrivate *)Xmalloc(sizeof(tdfxScreenPrivate)); - if (!gsp) return GL_FALSE; - - gsp->driScrnPriv = driScrnPriv; - - driScrnPriv->private = (void *)gsp; + tdfxScreenPrivate *gsp; - if (!tdfxMapAllRegions(driScrnPriv)) { - Xfree(driScrnPriv->private); - return GL_FALSE; - } - - return GL_TRUE; -} - -void XMesaResetDriver(__DRIscreenPrivate *driScrnPriv) -{ - tdfxUnmapAllRegions(driScrnPriv); - Xfree(driScrnPriv->private); -} + /* Check the DRI version */ + { + int major, minor, patch; + if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) { + if (major != 3 || minor != 0 || patch < 0) { + char msg[1000]; + sprintf(msg, "3dfx DRI driver expected DRI version 3.0.x but got version %d.%d.%d", major, minor, patch); + __driMesaMessage(msg); + return GL_FALSE; + } + } + } -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; + /* Check that the DDX driver version is compatible */ + if (sPriv->ddxMajor != 1 || + sPriv->ddxMinor != 0 || + sPriv->ddxPatch < 0) { + char msg[1000]; + sprintf(msg, "3dfx DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch); + __driMesaMessage(msg); + return GL_FALSE; + } - /* Only RGB visuals are supported on the TDFX boards */ - if (!rgb_flag) return 0; + /* Check that the DRM driver version is compatible */ + if (sPriv->drmMajor != 1 || + sPriv->drmMinor != 0 || + sPriv->drmPatch < 0) { + char msg[1000]; + sprintf(msg, "3dfx DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch); + __driMesaMessage(msg); + return GL_FALSE; + } - v = (XMesaVisual)Xmalloc(sizeof(struct xmesa_visual)); - if (!v) return 0; + /* Allocate the private area */ + gsp = (tdfxScreenPrivate *)Xmalloc(sizeof(tdfxScreenPrivate)); + if (!gsp) + return GL_FALSE; - 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; - } + gsp->driScrnPriv = sPriv; - v->gl_visual->RGBAflag = rgb_flag; - v->gl_visual->DBflag = db_flag; - v->gl_visual->StereoFlag = stereo_flag; + sPriv->private = (void *) gsp; - 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 */ + if (!tdfxMapAllRegions(sPriv)) { + Xfree(gsp); + sPriv->private = NULL; + return GL_FALSE; + } - v->gl_visual->AccumBits = accum_size; - v->gl_visual->DepthBits = depth_size; - v->gl_visual->StencilBits = stencil_size; + return GL_TRUE; +} - return v; +void XMesaResetDriver(__DRIscreenPrivate *sPriv) +{ + tdfxUnmapAllRegions(sPriv); + Xfree(sPriv->private); + sPriv->private = NULL; } -void XMesaDestroyVisual(XMesaVisual v) +GLvisual *XMesaCreateVisual(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config) { - Xfree(v->gl_visual); - Xfree(v->visinfo); - Xfree(v); + /* 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 */ ); } -XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, - __DRIcontextPrivate *driContextPriv) + +GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis, + __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; + /*int **fifoPtr;*/ cPriv = (tdfxContextPrivate *)Xmalloc(sizeof(tdfxContextPrivate)); if (!cPriv) { - Xfree(c); - return NULL; + return GL_FALSE; } cPriv->hHWContext = driContextPriv->hHWContext; cPriv->tdfxScrnPriv = sPriv; - c->private = (void *)cPriv; - - cPriv->glVis=v->gl_visual; - cPriv->glBuffer=gl_create_framebuffer(v->gl_visual, - GL_FALSE, /* software depth buffer? */ - v->gl_visual->StencilBits > 0, - v->gl_visual->AccumBits > 0, - v->gl_visual->AlphaBits > 0 - ); + /* deviceID = 0x05 = Voodoo3 */ + /* deviceID = 0x09 = Voodoo5 (and Voodoo5?) */ + cPriv->haveHwStencil = sPriv->deviceID == 0x9 && sPriv->cpp == 4; + + cPriv->glVis=mesaVis; + cPriv->glBuffer=gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0 && !cPriv->haveHwStencil, + mesaVis->AccumRedBits > 0, + GL_FALSE /* software alpha channel */ + ); 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->glCtx = driContextPriv->mesaContext; cPriv->initDone=GL_FALSE; - saPriv=(TDFXSAREAPriv*)((void*)driScrnPriv->pSAREA+sizeof(XF86DRISAREARec)); + saPriv=(TDFXSAREAPriv*)((char*)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; + driContextPriv->driverPrivate = (void *) cPriv; + + return GL_TRUE; } -void XMesaDestroyContext(XMesaContext c) +void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) { - tdfxContextPrivate *cPriv; - - cPriv=(tdfxContextPrivate*)c->private; + tdfxContextPrivate *cPriv = (tdfxContextPrivate *) driContextPriv->driverPrivate; if (cPriv) { - gl_destroy_context(cPriv->glCtx); - gl_destroy_framebuffer(cPriv->glBuffer); + XFree(cPriv); + driContextPriv->driverPrivate = NULL; } - if (c==gCC) { - gCC=0; - gCCPriv=0; + + if (driContextPriv == gCC) { + gCC = 0; } } -XMesaBuffer XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w, - __DRIdrawablePrivate *driDrawPriv) -{ - return (XMesaBuffer)1; -} -XMesaBuffer XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, - XMesaColormap c, __DRIdrawablePrivate *driDrawPriv) +GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { - return (XMesaBuffer)1; + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + GL_FALSE /* software alpha channel? */ + ); } -void XMesaDestroyBuffer(XMesaBuffer b) + +GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { +#if 0 + /* Different drivers may have different combinations of hardware and + * software ancillary buffers. + */ + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); +#else + return NULL; /* not implemented yet */ +#endif } -void XMesaSwapBuffers(XMesaBuffer b) + +void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv) { FxI32 result; #ifdef STATS @@ -239,15 +237,20 @@ void XMesaSwapBuffers(XMesaBuffer b) extern int texSwaps; static int prevStalls=0; #endif + tdfxContextPrivate *gCCPriv; + /* ** 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; + if (gCC == NULL) + return; + + gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; FLUSH_VB( gCCPriv->glCtx, "swap buffers" ); - if (gCCPriv->haveDoubleBuffer) { + if (gCC->mesaContext->Visual->DBflag) { #ifdef STATS stalls=grFifoGetStalls(); if (stalls!=prevStalls) { @@ -260,60 +263,68 @@ void XMesaSwapBuffers(XMesaBuffer b) } #endif FX_grDRIBufferSwap(gCCPriv->swapInterval); +#if 0 do { - result=FX_grGetInteger(FX_PENDING_BUFFERSWAPS); - } while (result>gCCPriv->maxPendingSwapBuffers); + result = FX_grGetInteger(FX_PENDING_BUFFERSWAPS); + } while (result > gCCPriv->maxPendingSwapBuffers); +#endif gCCPriv->stats.swapBuffer++; - } else { - fprintf(stderr, "No double buffer\n"); } } -GLboolean XMesaUnbindContext(XMesaContext c) +GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv) { - if (c && c==gCC && gCCPriv) FX_grGlideGetState((GrState*)gCCPriv->state); - return GL_TRUE; + if (driContextPriv && driContextPriv == gCC) { + tdfxContextPrivate *gCCPriv; + gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; + FX_grGlideGetState((GrState*)gCCPriv->state); + } + return GL_TRUE; } -GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) +GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) { - __DRIdrawablePrivate *driDrawPriv; + if (driContextPriv) { + tdfxContextPrivate *gCCPriv; - if (c) { - if (c==gCC) return GL_TRUE; - gCC = c; - gCCPriv = (tdfxContextPrivate *)c->private; + gCC = driContextPriv; + gCCPriv = (tdfxContextPrivate *)driContextPriv->driverPrivate; - driDrawPriv = gCC->driContextPriv->driDrawablePriv; if (!gCCPriv->initDone) { - if (!tdfxInitHW(c)) return GL_FALSE; + if (!tdfxInitHW(driDrawPriv, gCCPriv)) + return GL_FALSE; gCCPriv->width=0; XMesaWindowMoved(); FX_grGlideGetState((GrState*)gCCPriv->state); - } else { + } + else { FX_grSstSelect(gCCPriv->board); FX_grGlideSetState((GrState*)gCCPriv->state); XMesaWindowMoved(); } - gl_make_current(gCCPriv->glCtx, gCCPriv->glBuffer); + gl_make_current2(gCCPriv->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer); + fxSetupDDPointers(gCCPriv->glCtx); if (!gCCPriv->glCtx->Viewport.Width) gl_Viewport(gCCPriv->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h); - } else { + } + else { gl_make_current(0,0); - gCC = NULL; - gCCPriv = NULL; + gCC = NULL; } return GL_TRUE; } -void -XMesaWindowMoved() { - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; - GLcontext *ctx; - - ctx=gCCPriv->glCtx; + +void XMesaWindowMoved(void) +{ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; + tdfxContextPrivate *gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; + GLcontext *ctx = gCCPriv->glCtx; + grDRIPosition(dPriv->x, dPriv->y, dPriv->w, dPriv->h, dPriv->numClipRects, dPriv->pClipRects); gCCPriv->numClipRects=dPriv->numClipRects; @@ -326,6 +337,7 @@ XMesaWindowMoved() { gCCPriv->height=dPriv->h; gCCPriv->y_delta=gCCPriv->screen_height-gCCPriv->y_offset-gCCPriv->height; } + gCCPriv->needClip=1; switch (dPriv->numClipRects) { case 0: gCCPriv->clipMinX=dPriv->x; @@ -344,16 +356,21 @@ XMesaWindowMoved() { gCCPriv->needClip=0; break; default: - gCCPriv->needClip=1; } } /* This is called from within the LOCK_HARDWARE routine */ -void XMesaUpdateState(int windowMoved) { - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; +void XMesaUpdateState(int windowMoved) +{ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; + tdfxContextPrivate *gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; TDFXSAREAPriv *saPriv=(TDFXSAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec)); + int stamp; + drmGetLock(sPriv->fd, dPriv->driContextPriv->hHWContext, 0); + stamp=dPriv->lastStamp; + XMESA_VALIDATE_DRAWABLE_INFO(gCC->display, sPriv, dPriv); /* fprintf(stderr, "In FifoPtr=%d FifoRead=%d\n", saPriv->fifoPtr, saPriv->fifoRead); */ if (saPriv->fifoOwner!=dPriv->driContextPriv->hHWContext) { grDRIImportFifo(saPriv->fifoPtr, saPriv->fifoRead); @@ -372,12 +389,13 @@ void XMesaUpdateState(int windowMoved) { if (saPriv->texOwner!=dPriv->driContextPriv->hHWContext) { fxTMRestoreTextures_NoLock(gCCPriv); } - if (windowMoved) + if (*dPriv->pStamp!=stamp) XMesaWindowMoved(); } -void XMesaSetSAREA() { - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; +void XMesaSetSAREA(void) +{ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; TDFXSAREAPriv *saPriv=(TDFXSAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile index 4fe4392cb..9840074ce 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile @@ -12,22 +12,16 @@ XCOMM #if BuildXF86DRI DRISRCS = tdfx_dri.c DRIOBJS = tdfx_dri.o -DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri +DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri -I$(TOP)/include + DRIDEFINES = $(GLX_DEFINES) #endif -# -# Uncomment these only if you have the proprietary sources -# -PRIVSRCS = tdfx_priv.c -PRIVOBJS = tdfx_priv.o -PRIVDEFINES = -DPROP_3DFX - SRCS = tdfx_driver.c tdfx_io.c tdfx_hwcurs.c tdfx_accel.c \ - tdfx_dga.c $(DRISRCS) $(PRIVSRCS) + tdfx_dga.c tdfx_priv.c tdfx_sli.c $(DRISRCS) OBJS = tdfx_driver.o tdfx_io.o tdfx_hwcurs.o tdfx_accel.o \ - tdfx_dga.o $(DRIOBJS) $(PRIVOBJS) + tdfx_dga.o tdfx_priv.o tdfx_sli.o $(DRIOBJS) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include @@ -43,7 +37,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ $(DRIINCLUDES) #endif -DEFINES = $(DRIDEFINES) $(PRIVDEFINES) +DEFINES = -DPROP_3DFX $(DRIDEFINES) #if MakeHasPosixVariableSubstitutions SubdirLibraryRule($(OBJS)) @@ -74,5 +68,7 @@ InstallDriverSDKNonExecFile(tdfx_dripriv.h,$(DRIVERSDKDIR)/drivers/tdfx) InstallDriverSDKNonExecFile(tdfx_driver.c,$(DRIVERSDKDIR)/drivers/tdfx) InstallDriverSDKNonExecFile(tdfx_hwcurs.c,$(DRIVERSDKDIR)/drivers/tdfx) InstallDriverSDKNonExecFile(tdfx_io.c,$(DRIVERSDKDIR)/drivers/tdfx) +InstallDriverSDKNonExecFile(tdfx_priv.c,$(DRIVERSDKDIR)/drivers/tdfx) +InstallDriverSDKNonExecFile(tdfx_priv.h,$(DRIVERSDKDIR)/drivers/tdfx) InstallDriverSDKObjectModule(tdfx,$(DRIVERSDKMODULEDIR),drivers) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c index 14365b441..babdc09d1 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c @@ -79,15 +79,20 @@ void TDFXNeedSync(ScrnInfoPtr pScrn) { TDFXPtr pTDFX = TDFXPTR(pScrn); pTDFX->syncDone=FALSE; + pTDFX->AccelInfoRec->NeedToSync = TRUE; } -static void +void TDFXFirstSync(ScrnInfoPtr pScrn) { TDFXPtr pTDFX = TDFXPTR(pScrn); if (!pTDFX->syncDone) { - pTDFX->sync(pScrn); + if (pTDFX->directRenderingEnabled) { + DRILock(screenInfo.screens[pScrn->scrnIndex], 0); + TDFXSwapContextPrivate(screenInfo.screens[pScrn->scrnIndex]); + } pTDFX->syncDone=TRUE; + pTDFX->sync(pScrn); } } @@ -98,12 +103,15 @@ TDFXCheckSync(ScrnInfoPtr pScrn) { if (pTDFX->syncDone) { pTDFX->sync(pScrn); pTDFX->syncDone=FALSE; + if (pTDFX->directRenderingEnabled) { + TDFXLostContext(screenInfo.screens[pScrn->scrnIndex]); + DRIUnlock(screenInfo.screens[pScrn->scrnIndex]); + } } } void TDFXSelectBuffer(TDFXPtr pTDFX, int which) { -#ifdef XF86DRI int fmt; TDFXMakeRoom(pTDFX, 4); @@ -118,14 +126,20 @@ TDFXSelectBuffer(TDFXPtr pTDFX, int which) { TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt); break; case TDFX_BACK: - fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */ + if (pTDFX->cpp==2) + fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */ + else + fmt=((pTDFX->stride+127)/128)|(5<<16); /* Tiled 32bpp */ TDFXWriteLong(pTDFX, SST_2D_DSTBASEADDR, pTDFX->backOffset|BIT(31)); TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt); TDFXWriteLong(pTDFX, SST_2D_SRCBASEADDR, pTDFX->backOffset|BIT(31)); TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt); break; case TDFX_DEPTH: - fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */ + if (pTDFX->cpp==2) + fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */ + else + fmt=((pTDFX->stride+127)/128)|(5<<16); /* Tiled 32bpp */ TDFXWriteLong(pTDFX, SST_2D_DSTBASEADDR, pTDFX->depthOffset|BIT(31)); TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt); TDFXWriteLong(pTDFX, SST_2D_SRCBASEADDR, pTDFX->depthOffset|BIT(31)); @@ -133,14 +147,27 @@ TDFXSelectBuffer(TDFXPtr pTDFX, int which) { break; default: } -#endif } void TDFXSetLFBConfig(TDFXPtr pTDFX) { - TDFXWriteLongMMIO(pTDFX, LFBMEMORYCONFIG, (pTDFX->backOffset>>12) | - SST_RAW_LFB_ADDR_STRIDE_4K | - ((pTDFX->stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT); + if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) { + TDFXWriteLongMMIO(pTDFX, LFBMEMORYCONFIG, (pTDFX->backOffset>>12) | + SST_RAW_LFB_ADDR_STRIDE_4K | + ((pTDFX->stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT); + } else { + int chip; + int stride, bits; + if (pTDFX->cpp==2) stride=pTDFX->stride; + else stride=4*pTDFX->stride/pTDFX->cpp; + bits=pTDFX->backOffset>>12; + for (chip=0; chip<pTDFX->numChips; chip++) { + TDFXWriteChipLongMMIO(pTDFX, chip, LFBMEMORYCONFIG, (bits&0x1FFF) | + SST_RAW_LFB_ADDR_STRIDE_4K | + ((bits&0x6000)<<10) | + ((stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT); + } + } } Bool @@ -265,8 +292,11 @@ static void TDFXMakeRoomNoProp(TDFXPtr pTDFX, int size) { } } -static void TDFXSendNOPNoProp(TDFXPtr pTDFX) +static void TDFXSendNOPNoProp(ScrnInfoPtr pScrn) { + TDFXPtr pTDFX; + + pTDFX=TDFXPTR(pScrn); TDFXMakeRoomNoProp(pTDFX, 1); TDFXWriteLongMMIO(pTDFX, SST_2D_COMMAND, SST_2D_NOP); } @@ -280,7 +310,7 @@ void TDFXSync(ScrnInfoPtr pScrn) TDFXTRACEACCEL("TDFXSync\n"); pTDFX=TDFXPTR(pScrn); - TDFXSendNOPNoProp(pTDFX); + TDFXSendNOPNoProp(pScrn); i=0; do { stat=TDFXReadLongMMIO(pTDFX, 0); @@ -322,10 +352,15 @@ TDFXMatchState(TDFXPtr pTDFX) } static void -TDFXClearState(TDFXPtr pTDFX) +TDFXClearState(ScrnInfoPtr pScrn) { + TDFXPtr pTDFX; + + pTDFX=TDFXPTR(pScrn); pTDFX->Cmd=0; pTDFX->DrawState&=~DRAW_STATE_TRANSPARENT; + /* Make sure we've done a sync */ + TDFXFirstSync(pScrn); } static void @@ -366,8 +401,7 @@ TDFXSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, "rop=%d planemask=%d trans_color=%d\n", xdir, ydir, rop, planemask, trans_color); pTDFX=TDFXPTR(pScrn); - TDFXFirstSync(pScrn); - TDFXClearState(pTDFX); + TDFXClearState(pScrn); if (trans_color!=-1) { TDFXMakeRoom(pTDFX, 3); @@ -410,7 +444,7 @@ TDFXSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int srcX, int srcY, } if ((srcY>=dstY-32 && srcY<=dstY)|| (srcY>=pTDFX->prevBlitDest.y1-32 && srcY<=pTDFX->prevBlitDest.y1)) { - TDFXSendNOP(pTDFX); + TDFXSendNOP(pScrn); } pTDFX->sync(pScrn); @@ -434,8 +468,7 @@ TDFXSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, TDFXTRACEACCEL("TDFXSetupForSolidFill color=%d rop=%d planemask=%d\n", color, rop, planemask); pTDFX=TDFXPTR(pScrn); - TDFXClearState(pTDFX); - TDFXFirstSync(pScrn); + TDFXClearState(pScrn); pTDFX->Cmd=TDFXROPCvt[rop]<<24; if (pTDFX->cpp==1) fmt=(1<<16)|pTDFX->stride; @@ -479,8 +512,7 @@ TDFXSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, " bg=%d rop=%d planemask=%d\n", patx, paty, fg, bg, rop, planemask); pTDFX=TDFXPTR(pScrn); - TDFXClearState(pTDFX); - TDFXFirstSync(pScrn); + TDFXClearState(pScrn); pTDFX->Cmd = (TDFXROPCvt[rop+ROP_PATTERN_OFFSET]<<24) | SST_2D_MONOCHROME_PATTERN; @@ -525,8 +557,7 @@ TDFXSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, TDFXTRACEACCEL("TDFXSetupForSolidLine\n"); pTDFX=TDFXPTR(pScrn); - TDFXClearState(pTDFX); - TDFXFirstSync(pScrn); + TDFXClearState(pScrn); pTDFX->Cmd = (TDFXROPCvt[rop]<<24); @@ -591,8 +622,7 @@ TDFXNonTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int n, TDFXTRACEACCEL("TDFXNonTEGlyphRenderer\n"); pTDFX=TDFXPTR(pScrn); - TDFXFirstSync(pScrn); - TDFXClearState(pTDFX); + TDFXClearState(pScrn); /* Don't bother fixing clip1, we're going to change it anyway */ pTDFX->DrawState&=~DRAW_STATE_CLIP1CHANGED; TDFXMatchState(pTDFX); @@ -608,8 +638,8 @@ TDFXNonTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int n, SSTCP_SRCXY|SSTCP_COLORFORE|SSTCP_COMMAND); TDFXWriteLong(pTDFX, SST_2D_CLIP1MIN, ((pbox->y1&0x1FFF)<<16) | (pbox->x1&0x1FFF)); - TDFXWriteLong(pTDFX, SST_2D_CLIP1MAX, (((pbox->y2+1)&0x1FFF)<<16) | - ((pbox->x2+1)&0x1FFF)); + TDFXWriteLong(pTDFX, SST_2D_CLIP1MAX, ((pbox->y2&0x1FFF)<<16) | + (pbox->x2&0x1FFF)); TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, SST_2D_PIXFMT_1BPP | SST_2D_SOURCE_PACKING_DWORD); TDFXWriteLong(pTDFX, SST_2D_SRCXY, 0); @@ -657,8 +687,7 @@ TDFXSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, TDFXTRACEACCEL("TDFXSetupForDashedLine\n"); pTDFX=TDFXPTR(pScrn); - TDFXClearState(pTDFX); - TDFXFirstSync(pScrn); + TDFXClearState(pScrn); pTDFX->Cmd = (TDFXROPCvt[rop]<<24) | SST_2D_STIPPLE_LINE; if(bg == -1) { @@ -701,8 +730,7 @@ TDFXSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, TDFXTRACEACCEL("TDFXSetupForScreenToScreenColorExpandFill\n"); pTDFX=TDFXPTR(pScrn); - TDFXClearState(pTDFX); - TDFXFirstSync(pScrn); + TDFXClearState(pScrn); TDFXMatchState(pTDFX); pTDFX->Cmd|=SST_2D_SCRNTOSCRNBLIT|(TDFXROPCvt[rop]<<24); @@ -736,7 +764,7 @@ TDFXSubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, pTDFX->DrawState|=DRAW_STATE_CLIP1CHANGED; if (srcy>=pTDFX->prevBlitDest.y1-8 && srcy<=pTDFX->prevBlitDest.y1) { - TDFXSendNOP(pTDFX); + TDFXSendNOP(pScrn); } if (pTDFX->cpp==1) fmt=(1<<16)|pTDFX->stride; @@ -767,8 +795,7 @@ TDFXSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, TDFXTRACEACCEL("SetupForCPUToScreenColorExpandFill bg=%x fg=%x rop=%d\n", bg, fg, rop); pTDFX=TDFXPTR(pScrn); - TDFXClearState(pTDFX); - TDFXFirstSync(pScrn); + TDFXClearState(pScrn); pTDFX->Cmd|=SST_2D_HOSTTOSCRNBLIT|(TDFXROPCvt[rop]<<24); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c index ec2729055..c32199b06 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c @@ -35,10 +35,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * This server does not support these XFree 4.0 features yet - * DDC1 & DDC2 (requires I2C) + * DDC2 (requires I2C) * shadowFb (if requested or acceleration is off) * Overlay planes - * DGA */ /* @@ -147,20 +146,14 @@ static void TDFXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagermentMode, int flags); #endif -#define VERSION 4000 -#define TDFX_NAME "TDFX" -#define TDFX_DRIVER_NAME "tdfx" -#define TDFX_MAJOR_VERSION 1 -#define TDFX_MINOR_VERSION 0 -#define TDFX_PATCHLEVEL 0 #define PCI_SUBDEVICE_ID_VOODOO3_2000 0x0036 #define PCI_SUBDEVICE_ID_VOODOO3_3000 0x003a DriverRec TDFX = { - VERSION, + TDFX_VERSION, TDFX_DRIVER_NAME, #if 0 - "Accelerated driver for 3dfx Voodoo Banshee and Voodoo3 cards", + "Accelerated driver for 3dfx cards", #endif TDFXIdentify, TDFXProbe, @@ -172,12 +165,14 @@ DriverRec TDFX = { static SymTabRec TDFXChipsets[] = { { PCI_CHIP_BANSHEE, "3dfx Banshee"}, { PCI_CHIP_VOODOO3, "3dfx Voodoo3"}, + { PCI_CHIP_VOODOO5, "3dfx Voodoo5"}, { -1, NULL } }; static PciChipsets TDFXPciChipsets[] = { { PCI_CHIP_BANSHEE, PCI_CHIP_BANSHEE, RES_SHARED_VGA }, { PCI_CHIP_VOODOO3, PCI_CHIP_VOODOO3, RES_SHARED_VGA }, + { PCI_CHIP_VOODOO5, PCI_CHIP_VOODOO5, RES_SHARED_VGA }, { -1, -1, RES_UNDEFINED } }; @@ -187,13 +182,15 @@ static PciChipsets TDFXPciChipsets[] = { typedef enum { OPTION_NOACCEL, OPTION_SW_CURSOR, - OPTION_USE_PIO + OPTION_USE_PIO, + OPTION_NO_SLI } TDFXOpts; static OptionInfoRec TDFXOptions[] = { { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_USE_PIO, "UsePIO", OPTV_BOOLEAN, {0}, FALSE}, + { OPTION_NO_SLI, "NoSLI", OPTV_BOOLEAN, {0}, FALSE}, { -1, NULL, OPTV_NONE, {0}, FALSE} }; @@ -420,9 +417,9 @@ TDFXProbe(DriverPtr drv, int flags) { TDFXChipsets, TDFXPciChipsets, devSections, numDevSections, drv, &usedChips); + if (devSections) xfree(devSections); - devSections=NULL; if (numUsed<=0) return FALSE; if (flags & PROBE_DETECT) @@ -433,7 +430,7 @@ TDFXProbe(DriverPtr drv, int flags) { /* Allocate new ScrnInfoRec and claim the slot */ pScrn = xf86AllocateScreen(drv, 0); - pScrn->driverVersion = VERSION; + pScrn->driverVersion = TDFX_VERSION; pScrn->driverName = TDFX_DRIVER_NAME; pScrn->name = TDFX_NAME; pScrn->Probe = TDFXProbe; @@ -450,6 +447,7 @@ TDFXProbe(DriverPtr drv, int flags) { xf86ConfigActivePciEntity(pScrn, usedChips[i], TDFXPciChipsets, 0, 0, 0, 0, 0); } xfree(usedChips); + if (devSections) xfree(devSections); return foundScreen; } @@ -463,10 +461,11 @@ TDFXCountRam(ScrnInfoPtr pScrn) { pTDFX = TDFXPTR(pScrn); TDFXTRACE("TDFXCountRam start\n"); memSize=0; - if (pTDFX->PIOBase) { + if (pTDFX->PIOBase[0]) { CARD32 partSize, /* size of SGRAM chips in Mbits */ nChips, /* # chips of SDRAM/SGRAM */ + banks, /* Number of banks of chips */ dramInit0_strap, dramInit1_strap, dramInit1, @@ -492,23 +491,28 @@ TDFXCountRam(ScrnInfoPtr pScrn) { /* determine memory size from strapping pins (dramInit0 and dramInit1) */ dramInit0_strap = pTDFX->readLong(pTDFX, DRAMINIT0); - dramInit0_strap &= SST_SGRAM_TYPE | SST_SGRAM_NUM_CHIPSETS; - - if ( memType == MEM_TYPE_SDRAM ) { - memSize = 16; - } else { - nChips = ((dramInit0_strap & SST_SGRAM_NUM_CHIPSETS) == 0) ? 4 : 8; - - if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_8MBIT ) { - partSize = 8; - } else if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_16MBIT) { - partSize = 16; + if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) { /* Banshee/V3 */ + if (memType == MEM_TYPE_SDRAM) { + memSize = 16; } else { - ErrorF("Invalid sgram type = 0x%x", - (dramInit0_strap & SST_SGRAM_TYPE) << SST_SGRAM_TYPE_SHIFT ); - return 0; + nChips = ((dramInit0_strap & SST_SGRAM_NUM_CHIPSETS) == 0) ? 4 : 8; + + if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_8MBIT ) { + partSize = 8; + } else if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_16MBIT) { + partSize = 16; + } else { + ErrorF("Invalid sgram type = 0x%x", + (dramInit0_strap & SST_SGRAM_TYPE) << SST_SGRAM_TYPE_SHIFT ); + return 0; + } + memSize = (nChips * partSize) / 8; /* in MBytes */ } - memSize = (nChips * partSize) / 8; /* in MBytes */ + } else { /* V4, V5 */ + nChips = ((dramInit0_strap & SST_SGRAM_NUM_CHIPSETS)==0) ? 4 : 8; + partSize=1<<((dramInit0_strap&0x38000000)>>28); + banks=((dramInit0_strap&BIT(30))==0) ? 2 : 4; + memSize=nChips*partSize*banks; } TDFXTRACEREG("dramInit0 = %x dramInit1 = %x\n", dramInit0_strap, dramInit1_strap); TDFXTRACEREG("MemConfig %d chips %d size %d total\n", nChips, partSize, memSize); @@ -530,7 +534,7 @@ TDFXCountRam(ScrnInfoPtr pScrn) { extern xf86MonPtr ConfiguredMonitor; -void +static void TDFXProbeDDC(ScrnInfoPtr pScrn, int index) { vbeInfoPtr pVbe; @@ -540,6 +544,85 @@ TDFXProbeDDC(ScrnInfoPtr pScrn, int index) } } +static int TDFXCfgToSize(int cfg) +{ + if (cfg<4) return 0x8000000<<cfg; + return 0x4000000>>(cfg-4); +} + +static int TDFXSizeToCfg(int size) +{ + switch (size) { + case 0x40000000: return 3; + case 0x20000000: return 2; + case 0x10000000: return 1; + case 0x08000000: return 0; + case 0x04000000: return 4; + case 0x02000000: return 5; + case 0x01000000: return 6; + case 0x00800000: return 7; + case 0x00400000: return 8; + default: + return -1; + } +} + +static void +TDFXFindChips(ScrnInfoPtr pScrn, pciVideoPtr match) +{ + TDFXPtr pTDFX; + pciVideoPtr *ppPci; + + pTDFX=TDFXPTR(pScrn); + pTDFX->numChips=0; + pTDFX->ChipType=match->chipType; + for (ppPci = xf86GetPciVideoInfo(); *ppPci != NULL; ppPci++) { + if ((*ppPci)->bus == match->bus && + (*ppPci)->device == match->device) { + pTDFX->PciTag[pTDFX->numChips] = pciTag((*ppPci)->bus, + (*ppPci)->device, + (*ppPci)->func); + pTDFX->PIOBase[pTDFX->numChips] = (*ppPci)->ioBase[2]&0xFFFFFFFC; + pTDFX->numChips++; + } + } + /* Disable the secondary chips for now */ + pTDFX->numChips=1; +} + +static void +TDFXInitChips(ScrnInfoPtr pScrn) +{ + TDFXPtr pTDFX; + int i, cfgbits, initbits; + int mem0base, mem1base, mem0size, mem0bits, mem1size, mem1bits; + + pTDFX=TDFXPTR(pScrn); + cfgbits=pciReadLong(pTDFX->PciTag[0], CFG_PCI_DECODE); + mem0base=pciReadLong(pTDFX->PciTag[0], CFG_MEM0BASE); + mem1base=pciReadLong(pTDFX->PciTag[0], CFG_MEM1BASE); + mem0size=32*1024*1024; /* Registers are always 32MB */ + mem1size=pScrn->videoRam*1024*2; /* Linear mapping is 2x memory */ + mem0bits=TDFXSizeToCfg(mem0size); + mem1bits=TDFXSizeToCfg(mem1size)<<4; + cfgbits=(cfgbits&~(0xFF))|mem0bits|mem1bits; + for (i=0; i<pTDFX->numChips; i++) { + initbits=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE); + initbits|=BIT(10); + pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, initbits); + pTDFX->MMIOAddr[i]=mem0base+i*mem0size; + pciWriteLong(pTDFX->PciTag[i], CFG_MEM0BASE, 0xFFFFFFFF); + pciWriteLong(pTDFX->PciTag[i], CFG_MEM0BASE, pTDFX->MMIOAddr[i]); + pTDFX->MMIOAddr[i]&=0xFFFFFF00; + pTDFX->LinearAddr[i]=mem1base+i*mem1size; + pciWriteLong(pTDFX->PciTag[i], CFG_MEM1BASE, 0xFFFFFFFF); + pciWriteLong(pTDFX->PciTag[i], CFG_MEM1BASE, pTDFX->LinearAddr[i]); + pTDFX->LinearAddr[i]&=0xFFFFFF00; + pciWriteLong(pTDFX->PciTag[i], CFG_PCI_DECODE, cfgbits); + initbits&=~BIT(10); + pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, initbits); + } +} /* * TDFXPreInit -- @@ -549,8 +632,8 @@ TDFXProbeDDC(ScrnInfoPtr pScrn, int index) * */ static Bool -TDFXPreInit(ScrnInfoPtr pScrn, int flags) { - vgaHWPtr hwp; +TDFXPreInit(ScrnInfoPtr pScrn, int flags) +{ TDFXPtr pTDFX; ClockRangePtr clockRanges; int i; @@ -558,6 +641,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { char *mod=0, *reqSym=0; int flags24; rgb defaultWeight = {0, 0, 0}; + pciVideoPtr match; TDFXTRACE("TDFXPreInit start\n"); if (pScrn->numEntities != 1) return FALSE; @@ -569,10 +653,24 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { pTDFX = TDFXPTR(pScrn); + pTDFX->initDone=FALSE; pTDFX->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (pTDFX->pEnt->location.type != BUS_PCI) return FALSE; + if (flags & PROBE_DETECT) { + TDFXProbeDDC(pScrn, pTDFX->pEnt->index); + return TRUE; + } + + /* The vgahw module should be loaded here when needed */ + if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; + + xf86LoaderReqSymLists(vgahwSymbols, NULL); + + /* Allocate a vgaHWRec */ + if (!vgaHWGetHWRec(pScrn)) return FALSE; + if (xf86LoadSubModule(pScrn, "int10")) { xf86Int10InfoPtr pInt; xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -591,9 +689,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { } } - pTDFX->PciInfo = xf86GetPciInfoForEntity(pTDFX->pEnt->index); - pTDFX->PciTag = pciTag(pTDFX->PciInfo->bus, pTDFX->PciInfo->device, - pTDFX->PciInfo->func); + match=pTDFX->PciInfo=xf86GetPciInfoForEntity(pTDFX->pEnt->index); + TDFXFindChips(pScrn, match); if (xf86RegisterResources(pTDFX->pEnt->index, 0, ResNone)) return FALSE; @@ -602,11 +699,6 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { else pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; - if (flags & PROBE_DETECT) { - TDFXProbeDDC(pScrn, pTDFX->pEnt->index); - return FALSE; - } - /* Set pScrn->monitor */ pScrn->monitor = pScrn->confScreen->monitor; @@ -634,7 +726,6 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { return FALSE; } - pScrn->rgbBits=8; if (!xf86SetDefaultVisual(pScrn, -1)) { return FALSE; } else { @@ -647,18 +738,9 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { } } - /* The vgahw module should be loaded here when needed */ - if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; - - xf86LoaderReqSymLists(vgahwSymbols, NULL); - - /* Allocate a vgaHWRec */ - if (!vgaHWGetHWRec(pScrn)) return FALSE; - /* We use a programamble clock */ pScrn->progClock = TRUE; - hwp = VGAHWPTR(pScrn); pTDFX->cpp = pScrn->bitsPerPixel/8; /* Process the options */ @@ -679,7 +761,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { pTDFX->pEnt->device->chipID); } else { from = X_PROBED; - pScrn->chipset = (char *)xf86TokenToString(TDFXChipsets, pTDFX->PciInfo->chipType); + pScrn->chipset = (char *)xf86TokenToString(TDFXChipsets, match->chipType); } if (pTDFX->pEnt->device->chipRev >= 0) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", @@ -689,11 +771,11 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset); if (pTDFX->pEnt->device->MemBase != 0) { - pTDFX->LinearAddr = pTDFX->pEnt->device->MemBase; + pTDFX->LinearAddr[0] = pTDFX->pEnt->device->MemBase; from = X_CONFIG; } else { - if (pTDFX->PciInfo->memBase[1] != 0) { - pTDFX->LinearAddr = pTDFX->PciInfo->memBase[1]; + if (match->memBase[1] != 0) { + pTDFX->LinearAddr[0] = match->memBase[1]; from = X_PROBED; } else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, @@ -703,14 +785,14 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { } } xf86DrvMsg(pScrn->scrnIndex, from, "Linear framebuffer at 0x%lX\n", - (unsigned long)pTDFX->LinearAddr); + (unsigned long)pTDFX->LinearAddr[0]); if (pTDFX->pEnt->device->IOBase != 0) { - pTDFX->MMIOAddr = pTDFX->pEnt->device->IOBase; + pTDFX->MMIOAddr[0] = pTDFX->pEnt->device->IOBase; from = X_CONFIG; } else { - if (pTDFX->PciInfo->memBase[0]) { - pTDFX->MMIOAddr = pTDFX->PciInfo->memBase[0]; + if (match->memBase[0]) { + pTDFX->MMIOAddr[0] = match->memBase[0]; from = X_PROBED; } else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, @@ -722,8 +804,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at addr 0x%lX\n", (unsigned long)pTDFX->MMIOAddr); - if (pTDFX->PciInfo->ioBase[2]) { - pTDFX->PIOBase = pTDFX->PciInfo->ioBase[2]&0xFFFFFFFC; + if (match->ioBase[2]) { + pTDFX->PIOBase[0] = match->ioBase[2]&0xFFFFFFFC; } else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid PIO address in PCI config space\n"); @@ -731,7 +813,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { return FALSE; } xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "PIO registers at addr 0x%lX\n", - (unsigned long)pTDFX->PIOBase); + (unsigned long)pTDFX->PIOBase[0]); /* We have to use PIO to probe, because we haven't mappend yet */ TDFXSetPIOAccess(pTDFX); @@ -744,6 +826,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { from = X_CONFIG; } + TDFXInitChips(pScrn); + /* Multiple by two because tiled access requires more address space */ pTDFX->FbMapSize = pScrn->videoRam*1024*2; xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte Mapping %d kByte\n", @@ -778,12 +862,12 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { pTDFX->MaxClock = pTDFX->pEnt->device->dacSpeeds[0]; from = X_CONFIG; } else { - switch (pTDFX->PciInfo->chipType) { + switch (pTDFX->ChipType) { case PCI_CHIP_BANSHEE: pTDFX->MaxClock = 270000; break; case PCI_CHIP_VOODOO3: - switch(pTDFX->PciInfo->subsysCard) { + switch(match->subsysCard) { case PCI_SUBDEVICE_ID_VOODOO3_2000: pTDFX->MaxClock = 300000; break; @@ -795,6 +879,9 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { break; } break; + case PCI_CHIP_VOODOO5: + pTDFX->MaxClock = 350000; + break; } } clockRanges = xnfalloc(sizeof(ClockRange)); @@ -802,7 +889,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { clockRanges->minClock= 12000; /* !!! What's the min clock? !!! */ clockRanges->maxClock=pTDFX->MaxClock; clockRanges->clockIndex = -1; - clockRanges->interlaceAllowed = TRUE; + clockRanges->interlaceAllowed = FALSE; clockRanges->doubleScanAllowed = TRUE; i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, @@ -887,21 +974,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { xf86SetDDCproperties(pScrn,xf86PrintEDID(pMon)); } - - /* We wont be using the VGA access after the probe */ - if (!xf86ReturnOptValBool(TDFXOptions, OPTION_USE_PIO, FALSE)) { - resRange vgaio[] = { {ResShrIoBlock,0x3B0,0x3BB}, - {ResShrIoBlock,0x3C0,0x3DF}, - _END }; - resRange vgamem[] = {{ResShrMemBlock,0xA0000,0xAFFFF}, - {ResShrMemBlock,0xB8000,0xBFFFF}, - {ResShrMemBlock,0xB0000,0xB7FFF}, - _END }; - - pTDFX->usePIO=FALSE; - xf86SetOperatingState(vgaio, pTDFX->pEnt->index, ResUnusedOpr); - xf86SetOperatingState(vgamem, pTDFX->pEnt->index, ResDisableOpr); - } else { + if (xf86ReturnOptValBool(TDFXOptions, OPTION_USE_PIO, FALSE)) { pTDFX->usePIO=TRUE; } @@ -911,7 +984,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { static Bool TDFXMapMem(ScrnInfoPtr pScrn) { - int mmioFlags; + int mmioFlags, i; TDFXPtr pTDFX; TDFXTRACE("TDFXMapMem start\n"); @@ -919,15 +992,18 @@ TDFXMapMem(ScrnInfoPtr pScrn) mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT; - pTDFX->MMIOBase = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, - pTDFX->PciTag, - pTDFX->MMIOAddr, - TDFXIOMAPSIZE); - if (!pTDFX->MMIOBase) return FALSE; + for (i=0; i<pTDFX->numChips; i++) { + pTDFX->MMIOBase[i] = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, + pTDFX->PciTag[i], + pTDFX->MMIOAddr[i], + TDFXIOMAPSIZE); + + if (!pTDFX->MMIOBase[i]) return FALSE; + } pTDFX->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, - pTDFX->PciTag, - pTDFX->LinearAddr, + pTDFX->PciTag[0], + pTDFX->LinearAddr[0], pTDFX->FbMapSize); if (!pTDFX->FbBase) return FALSE; @@ -938,12 +1014,16 @@ static Bool TDFXUnmapMem(ScrnInfoPtr pScrn) { TDFXPtr pTDFX; + int i; TDFXTRACE("TDFXUnmapMem start\n"); pTDFX = TDFXPTR(pScrn); - xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->MMIOBase, TDFXIOMAPSIZE); - pTDFX->MMIOBase=0; + for (i=0; i<pTDFX->numChips; i++) { + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->MMIOBase[i], + TDFXIOMAPSIZE); + pTDFX->MMIOBase[i]=0; + } xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->FbBase, pTDFX->FbMapSize); pTDFX->FbBase = 0; @@ -1118,12 +1198,20 @@ TDFXRestore(ScrnInfoPtr pScrn) { #define REFFREQ 14318.18 static int -CalcPLL(int freq, int *f_out) { +CalcPLL(int freq, int *f_out, int isBanshee) { int m, n, k, best_m, best_n, best_k, f_cur, best_error; + int minm, maxm; TDFXTRACE("CalcPLL start\n"); best_error=freq; best_n=best_m=best_k=0; + if (isBanshee) { + minm=24; + maxm=24; + } else { + minm=1; + maxm=64; + } for (n=1; n<256; n++) { f_cur=REFFREQ*(n+2); if (f_cur<freq) { @@ -1136,7 +1224,7 @@ CalcPLL(int freq, int *f_out) { continue; } } - for (m=1; m<64; m++) { + for (m=minm; m<maxm; m++) { for (k=0; k<4; k++) { f_cur=REFFREQ*(n+2)/(m+2)/(1<<k); if (abs(f_cur-freq)<best_error) { @@ -1175,7 +1263,7 @@ SetupVidPLL(ScrnInfoPtr pScrn, DisplayModePtr mode) { tdfxReg->dacmode|=SST_DAC_MODE_2X; tdfxReg->vidcfg|=SST_VIDEO_2X_MODE_EN; } - tdfxReg->vidpll=CalcPLL(freq, &f_out); + tdfxReg->vidpll=CalcPLL(freq, &f_out, 0); TDFXTRACEREG("Vid PLL freq=%d f_out=%d reg=%x\n", freq, f_out, tdfxReg->vidpll); return TRUE; @@ -1207,7 +1295,10 @@ SetupGfxPLL(int freq) { TDFXTRACE("SetupGfxPLL start\n"); pTDFX=TDFXPTR(); tdfxReg=(vgaTDFXPtr)vgaNewVideoState; - tdfxReg->gfxpll=CalcPLL(freq, &f_out); + if (pTDFX->chipType==PCI_CHIP_BANSHEE) + tdfxReg->gfxpll=CalcPLL(freq, &f_out, 1); + else + tdfxReg->gfxpll=CalcPLL(freq, &f_out, 0); pTDFX->writeLong(pTDFX, PLLCTRL2, tdfxReg->gfxpll); TDFXTRACEREG("Gfx PLL freq=%d f_out=%d reg=%x\n", freq, f_out, tdfxReg->gfxpll); @@ -1218,14 +1309,13 @@ SetupGfxPLL(int freq) { static Bool TDFXInitVGA(ScrnInfoPtr pScrn) { - static Bool initDone=FALSE; TDFXPtr pTDFX; TDFXRegPtr tdfxReg; TDFXTRACE("TDFXInitVGA start\n"); - if (initDone) return TRUE; - initDone=TRUE; pTDFX=TDFXPTR(pScrn); + if (pTDFX->initDone) return TRUE; + pTDFX->initDone=TRUE; tdfxReg = &pTDFX->ModeReg; tdfxReg->vgainit0 = 0; tdfxReg->vgainit0 |= SST_VGA0_EXTENSIONS; @@ -1240,8 +1330,9 @@ TDFXInitVGA(ScrnInfoPtr pScrn) tdfxReg->vidcfg = SST_VIDEO_PROCESSOR_EN | SST_CURSOR_X11 | SST_DESKTOP_EN | (pTDFX->cpp-1)<<SST_DESKTOP_PIXEL_FORMAT_SHIFT; - if (pTDFX->cpp!=1) tdfxReg->vidcfg |= SST_DESKTOP_CLUT_BYPASS; + /* tdfxReg->vidcfg |= SST_DESKTOP_CLUT_BYPASS; */ + tdfxReg->stride = pTDFX->stride; tdfxReg->clip0min = tdfxReg->clip1min = 0; @@ -1377,8 +1468,9 @@ TDFXModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) #endif DoRestore(pScrn, &hwp->ModeReg, &pTDFX->ModeReg, FALSE); #ifdef XF86DRI - if (pTDFX->directRenderingEnabled) + if (pTDFX->directRenderingEnabled) { DRIUnlock(screenInfo.screens[pScrn->scrnIndex]); + } #endif return TRUE; @@ -1388,30 +1480,37 @@ static void TDFXLoadPalette16(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, short visualClass) { TDFXPtr pTDFX; - vgaHWPtr hwp; - int i, index; - unsigned char r, g, b; + int i, j, index, v, repeat, max; TDFXTRACE("TDFXLoadPalette16 start\n"); pTDFX = TDFXPTR(pScrn); - hwp = VGAHWPTR(pScrn); for (i=0; i<numColors; i++) { - index=indices[i/2]; - r=colors[index].red; - b=colors[index].blue; - index=indices[i]; - g=colors[index].green; - hwp->writeDacWriteAddr(hwp, index<<2); - hwp->writeDacData(hwp, r); - hwp->writeDacData(hwp, g); - hwp->writeDacData(hwp, b); - i++; index=indices[i]; - g=colors[index].green; - hwp->writeDacWriteAddr(hwp, index<<2); - hwp->writeDacData(hwp, r); - hwp->writeDacData(hwp, g); - hwp->writeDacData(hwp, b); + v=(colors[index/2].red<<16)|(colors[index].green<<8)|colors[index/2].blue; + if (i<numColors-1) max=indices[i+1]<<2; + else max=256; + for (j=index<<2; j<max; j++) { + repeat=100; + do { + pTDFX->writeLong(pTDFX, DACADDR, j); + } while (--repeat && pTDFX->readLong(pTDFX, DACADDR)!=j); + if (!repeat) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac index, " + "bypassing CLUT\n"); + pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS; + return; + } + repeat=100; + do { + pTDFX->writeLong(pTDFX, DACDATA, v); + } while (--repeat && pTDFX->readLong(pTDFX, DACDATA)!=v); + if (!repeat) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac value, " + "bypassing CLUT\n"); + pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS; + return; + } + } } } @@ -1419,23 +1518,33 @@ static void TDFXLoadPalette24(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, short visualClass) { TDFXPtr pTDFX; - vgaHWPtr hwp; - int i, index; - unsigned char r, g, b; + int i, index, v, repeat; TDFXTRACE("TDFXLoadPalette24 start\n"); pTDFX = TDFXPTR(pScrn); - hwp = VGAHWPTR(pScrn); for (i=0; i<numColors; i++) { index=indices[i]; - r=colors[index].red; - b=colors[index].blue; - index=indices[i]; - g=colors[index].green; - hwp->writeDacWriteAddr(hwp, index); - hwp->writeDacData(hwp, r); - hwp->writeDacData(hwp, g); - hwp->writeDacData(hwp, b); + v=(colors[index].red<<16)|(colors[index].green<<8)|colors[index].blue; + repeat=100; + do { + pTDFX->writeLong(pTDFX, DACADDR, index); + } while (--repeat && pTDFX->readLong(pTDFX, DACADDR)!=index); + if (!repeat) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac index, " + "bypassing CLUT\n"); + pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS; + return; + } + repeat=100; + do { + pTDFX->writeLong(pTDFX, DACDATA, v); + } while (--repeat && pTDFX->readLong(pTDFX, DACDATA)!=v); + if (!repeat) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac value, " + "bypassing CLUT\n"); + pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS; + return; + } } } @@ -1443,20 +1552,17 @@ TDFXLoadPalette24(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, #define TILE_HEIGHT 32 static int -calcBufferStride(int xres, Bool tiled) +calcBufferStride(int xres, Bool tiled, int cpp) { int strideInTiles; if (tiled == TRUE) { /* Calculate tile width stuff */ - strideInTiles = (xres << 1) >> 7; - if ((xres << 1) & (TILE_WIDTH - 1)) - strideInTiles++; + strideInTiles = (xres+TILE_WIDTH-1)/TILE_WIDTH; - return (strideInTiles * TILE_WIDTH); - + return strideInTiles*cpp*TILE_WIDTH; } else { - return (xres << 1); + return xres*cpp; } } /* calcBufferStride */ @@ -1477,26 +1583,26 @@ calcBufferHeightInTiles(int yres) } /* calcBufferHeightInTiles */ static int -calcBufferSizeInTiles(int xres, int yres) { +calcBufferSizeInTiles(int xres, int yres, int cpp) { int bufSizeInTiles; /* Size of buffer in tiles */ bufSizeInTiles = - calcBufferHeightInTiles(yres) * (calcBufferStride(xres, TRUE) >> 7); + calcBufferHeightInTiles(yres) * (calcBufferStride(xres, TRUE, cpp) >> 7); return bufSizeInTiles; } /* calcBufferSizeInTiles */ static int -calcBufferSize(int xres, int yres, Bool tiled) +calcBufferSize(int xres, int yres, Bool tiled, int cpp) { int stride, height, bufSize; if (tiled) { - stride = calcBufferStride(xres, tiled); + stride = calcBufferStride(xres, tiled, cpp); height = TILE_HEIGHT * calcBufferHeightInTiles(yres); } else { - stride = xres << 1; + stride = xres*cpp; height = yres; } @@ -1522,7 +1628,15 @@ static void allocateMemory(ScrnInfoPtr pScrn) { /* Remove one scanline for page alignment */ memRemaining-=4095; /* Remove the back and Z buffers */ - screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, TRUE); + if (pTDFX->cpp!=3) { + screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, + TRUE, pTDFX->cpp); + } + else { + /* cpp==3 needs to bump up to 4 */ + screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, + TRUE, 4); + } memRemaining-=screenSizeInTiles*2; /* Give all the rest to textures, rounded down to a page */ @@ -1578,20 +1692,26 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { hwp = VGAHWPTR(pScrn); if (!TDFXMapMem(pScrn)) return FALSE; - pScrn->memPhysBase = (int)pTDFX->LinearAddr; + pScrn->memPhysBase = (int)pTDFX->LinearAddr[0]; - if (!pTDFX->usePIO) { - TDFXSetMMIOAccess(pTDFX); - hwp->IOBase = ((hwp->readMiscOut(hwp) & 0x01) ? - VGA_IOBASE_COLOR : VGA_IOBASE_MONO) + (unsigned long)pTDFX->MMIOBase - - 0x300; - } else { - vgaHWGetIOBase(hwp); - } + if (!pTDFX->usePIO) TDFXSetMMIOAccess(pTDFX); + vgaHWGetIOBase(hwp); if (!vgaHWMapMem(pScrn)) return FALSE; allocateMemory(pScrn); + if (pTDFX->numChips>1) { + if (xf86ReturnOptValBool(TDFXOptions, OPTION_NO_SLI, FALSE)) { + TDFXSetupSLI(pScrn, FALSE, 0); + } else { + TDFXSetupSLI(pScrn, TRUE, 0); + } + } + + TDFXSetLFBConfig(pTDFX); + + /* We initialize in the state that our FIFO is up to date */ + pTDFX->syncDone=TRUE; #ifdef PROP_3DFX if (!TDFXInitPrivate(pScreen)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to initialize private\n"); @@ -1739,7 +1859,6 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { } if (pTDFX->directRenderingEnabled) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering enabled\n"); - TDFXSetLFBConfig(pTDFX); } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n"); } @@ -1806,6 +1925,7 @@ TDFXEnterVT(int scrnIndex, int flags) { if (pTDFX->directRenderingEnabled) { pScreen = screenInfo.screens[scrnIndex]; DRIUnlock(pScreen); + TDFXLostContext(pScreen); } #endif if (!TDFXModeInit(pScrn, pScrn->currentMode)) return FALSE; @@ -1832,6 +1952,7 @@ TDFXLeaveVT(int scrnIndex, int flags) { pTDFX = TDFXPTR(pScrn); if (pTDFX->directRenderingEnabled) { DRILock(pScreen, 0); + TDFXSwapContextPrivate(pScreen); } #endif } @@ -1978,3 +2099,4 @@ TDFXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, pTDFX->writeLong(pTDFX, DACMODE, dacmode); } #endif + |