From 660ac4eef41c6220134453d54529c69aa051efcf Mon Sep 17 00:00:00 2001 From: joseph <> Date: Fri, 17 Nov 2000 21:31:08 +0000 Subject: [PATCH] Restored changes that were lost when I imported new sources from 3dfx's internal source repository. --- glide3x/h5/glide3/src/cpudtect.s | 7 ++++ glide3x/h5/glide3/src/glfb.c | 53 +++++++++++++++++++++------- glide3x/h5/glide3/src/gsst.c | 31 +++++++++++++--- glide3x/h5/glide3/src/makefile.linux | 29 +++++++++++---- glide3x/h5/glide3/src/xdraw2.inc.s | 14 ++++++-- glide3x/h5/glide3/src/xdraw2.s | 8 +++++ glide3x/h5/glide3/src/xtexdl.s | 8 +++++ glide3x/h5/minihwc/linhwc.c | 38 ++++++++++++++++---- 8 files changed, 156 insertions(+), 32 deletions(-) diff --git a/glide3x/h5/glide3/src/cpudtect.s b/glide3x/h5/glide3/src/cpudtect.s index c2a23ef..e1bc133 100644 --- a/glide3x/h5/glide3/src/cpudtect.s +++ b/glide3x/h5/glide3/src/cpudtect.s @@ -20,6 +20,13 @@ /* $Header$ * /* $Log$ +/* Revision 1.3 2000/11/15 23:32:52 joseph +/* Syncing up with 3dfx internal source repository. These changes contain a +/* number of bug fixes. +/* Revision 1.2 2000/06/27 19:59:34 joseph +/* Previous checkin of asm files were already preprocessed. +/* Fixed build rules for 3DNow optimized assembly. +/* /* Revision 1.1 2000/06/15 00:27:42 josep /* Initial checkin into SourceForge / diff --git a/glide3x/h5/glide3/src/glfb.c b/glide3x/h5/glide3/src/glfb.c index 23f7c13..575eb20 100644 --- a/glide3x/h5/glide3/src/glfb.c +++ b/glide3x/h5/glide3/src/glfb.c @@ -604,7 +604,7 @@ GR_ENTRY(grLfbLock, FxBool,(GrLock_t type, GrBuffer_t buffer, /* Get the current lfb buffer */ { /* FixMe: Is this true if we're triple buffering? */ - FxU32 colBufferIndex; + FxU32 colBufferIndex = 0; switch(buffer) { case GR_BUFFER_FRONTBUFFER: @@ -644,15 +644,17 @@ GR_ENTRY(grLfbLock, FxBool,(GrLock_t type, GrBuffer_t buffer, if (rv) { #ifdef __linux__ - if (!colBufferIndex) - info->strideInBytes = driInfo.stride; - else - info->strideInBytes = 0x1000; /* This is the default for 3D LFBs, - * which are always 2048 - pixels wide. */ + if (!colBufferIndex) { + info->strideInBytes = driInfo.stride; + } else { + info->strideInBytes = gc->bInfo->buffInfo.bufLfbStride; + } #else /* defined(__linux__) */ - info->strideInBytes = 0x1000; /* This is the default for 3D LFBs, - * which are always 2048 pixels wide. */ + /* + * This is the default for 3D LFBs, + * which are always 2048 pixels wide. + */ + info->strideInBytes = 0x1000; #endif /* defined(__linux__) */ info->origin = origin; @@ -697,10 +699,17 @@ GR_ENTRY(grLfbLock, FxBool,(GrLock_t type, GrBuffer_t buffer, } #endif else { - info->lfbPtr = (void *)gc->lfb_ptr; #ifdef __linux__ - info->strideInBytes = 0x1000; -#endif /* defined(__linux__) */ + /* + * For Linux, we just return the correct address and + * stride. + */ + info->strideInBytes = gc->bInfo->buffInfo.bufLfbStride; + info->lfbPtr = (void *)gc->lfbBuffers[colBufferIndex]; +#else /* defined(__linux__) */ + info->lfbPtr = (void *)gc->lfb_ptr; +#endif /* defined(__linux__) */ +#ifndef __linux__ switch (writeMode) { case GR_LFBWRITEMODE_565_DEPTH: case GR_LFBWRITEMODE_555_DEPTH: @@ -711,6 +720,7 @@ GR_ENTRY(grLfbLock, FxBool,(GrLock_t type, GrBuffer_t buffer, info->strideInBytes <<= 1; break; } +#endif /* defined(__linux__) */ } REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 2, 0x3); REG_GROUP_SET(hw, colBufferAddr, gc->textureBuffer.addr ); @@ -719,7 +729,15 @@ GR_ENTRY(grLfbLock, FxBool,(GrLock_t type, GrBuffer_t buffer, } else /* else !gc->textureBuffer.on */ { if (type == GR_LFB_READ_ONLY) { info->lfbPtr = (void *)gc->lfbBuffers[colBufferIndex]; +#if defined(__linux__) + if (colBufferIndex == 0) { + info->strideInBytes = driInfo.stride; + } else { + info->strideInBytes = gc->bInfo->buffInfo.bufLfbStride; + } +#else /* defined(__linux__) */ info->strideInBytes = gc->bInfo->buffInfo.bufLfbStride; +#endif /* defined(__linux__) */ #if __POWERPC__ if(IS_NAPALM(gc->bInfo->pciInfo.deviceID)) { if(gc->grPixelSize == 2) { @@ -769,8 +787,18 @@ GR_ENTRY(grLfbLock, FxBool,(GrLock_t type, GrBuffer_t buffer, /* Make sure dither rotation is disabled for 3D LFBs. */ _3dlfb = FXTRUE; +#if defined(__linux__) + /* + * For Linux, we just return the correct address and + * stride. + */ + info->strideInBytes = gc->bInfo->buffInfo.bufLfbStride; + info->lfbPtr = (void *)gc->lfbBuffers[colBufferIndex]; +#else /* defined(__linux__) */ info->lfbPtr = (void *)gc->lfb_ptr; +#endif /* defined(__linux__) */ +#ifndef __linux__ switch (writeMode) { case GR_LFBWRITEMODE_565_DEPTH: case GR_LFBWRITEMODE_555_DEPTH: @@ -781,6 +809,7 @@ GR_ENTRY(grLfbLock, FxBool,(GrLock_t type, GrBuffer_t buffer, info->strideInBytes <<= 1; break; } +#endif /* defined(__linux__) */ } } diff --git a/glide3x/h5/glide3/src/gsst.c b/glide3x/h5/glide3/src/gsst.c index 1c66c8a..a04a7ec 100644 --- a/glide3x/h5/glide3/src/gsst.c +++ b/glide3x/h5/glide3/src/gsst.c @@ -2800,7 +2800,12 @@ GR_EXT_ENTRY(grSstWinOpenExt, GrContext_t, ( FxU32 hWnd, REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 4, 0xf); { REG_GROUP_SET(hw, colBufferAddr, gc->state.shadow.colBufferAddr); - REG_GROUP_SET(hw, colBufferStride, gc->state.shadow.colBufferStride); +#ifdef __linux__ + REG_GROUP_SET(hw, colBufferStride, (!gc->curBuffer) ? driInfo.stride : + gc->state.shadow.colBufferStride ); +#else + REG_GROUP_SET(hw, colBufferStride, gc->state.shadow.colBufferStride ); +#endif REG_GROUP_SET(hw, auxBufferAddr, gc->state.shadow.auxBufferAddr); REG_GROUP_SET(hw, auxBufferStride, gc->state.shadow.auxBufferStride); } @@ -2811,7 +2816,15 @@ GR_EXT_ENTRY(grSstWinOpenExt, GrContext_t, ( FxU32 hWnd, REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 4, 0xf); { REG_GROUP_SET(hw, colBufferAddr, gc->buffers1[gc->curBuffer] | SST_BUFFER_BASE_SELECT); - REG_GROUP_SET(hw, colBufferStride, gc->state.shadow.colBufferStride); +#ifdef __linux__ + REG_GROUP_SET(hw, colBufferStride, (!gc->curBuffer) ? driInfo.stride : + gc->state.shadow.colBufferStride ); +#else + REG_GROUP_SET(hw, colBufferStride, gc->state.shadow.colBufferStride ); +#endif + + + REG_GROUP_SET(hw, auxBufferAddr, gc->buffers1[nColBuffers] | SST_BUFFER_BASE_SELECT); REG_GROUP_SET(hw, auxBufferStride, gc->state.shadow.auxBufferStride); } @@ -2872,7 +2885,12 @@ GR_EXT_ENTRY(grSstWinOpenExt, GrContext_t, ( FxU32 hWnd, REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 4, 0xf); { REG_GROUP_SET(hw, colBufferAddr, gc->state.shadow.colBufferAddr); - REG_GROUP_SET(hw, colBufferStride, gc->state.shadow.colBufferStride); +#ifdef __linux__ + REG_GROUP_SET(hw, colBufferStride, (!gc->curBuffer) ? driInfo.stride : + gc->state.shadow.colBufferStride ); +#else + REG_GROUP_SET(hw, colBufferStride, gc->state.shadow.colBufferStride ); +#endif REG_GROUP_SET(hw, auxBufferAddr, gc->state.shadow.auxBufferAddr); REG_GROUP_SET(hw, auxBufferStride, gc->state.shadow.auxBufferStride); } @@ -2881,7 +2899,12 @@ GR_EXT_ENTRY(grSstWinOpenExt, GrContext_t, ( FxU32 hWnd, REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 4, 0xf); { REG_GROUP_SET(hw, colBufferAddr, gc->buffers1[gc->curBuffer] | SST_BUFFER_BASE_SELECT); - REG_GROUP_SET(hw, colBufferStride, gc->state.shadow.colBufferStride); +#ifdef __linux__ + REG_GROUP_SET(hw, colBufferStride, (!gc->curBuffer) ? driInfo.stride : + gc->state.shadow.colBufferStride ); +#else + REG_GROUP_SET(hw, colBufferStride, gc->state.shadow.colBufferStride ); +#endif REG_GROUP_SET(hw, auxBufferAddr, gc->buffers1[nColBuffers] | SST_BUFFER_BASE_SELECT); REG_GROUP_SET(hw, auxBufferStride, gc->state.shadow.auxBufferStride); } diff --git a/glide3x/h5/glide3/src/makefile.linux b/glide3x/h5/glide3/src/makefile.linux index eeac492..94fc573 100644 --- a/glide3x/h5/glide3/src/makefile.linux +++ b/glide3x/h5/glide3/src/makefile.linux @@ -222,7 +222,7 @@ OTHER_CFILES = fxgasm.c fxbldno.c fxinline.h # targets LDIRT = fxgasm.o fxgasm fxgasm.h fxinline.h fxbldno.o fxbldno fxbldno.h -LIBRARIES = libglide3x.a +LIBRARIES = libglide3.a SHARED_LIBRARY = libglide3.so.3.1 SUBLIBRARIES = $(BUILD_ROOT_SWLIBS)/lib/libfxmisc.a \ $(BUILD_ROOT_SWLIBS)/lib/libfxpci.a \ @@ -273,7 +273,7 @@ endif PREPROCESSOR=cpp %.o: %.s - $(PREPROCESSOR) $< > $*.tmp.s + $(PREPROCESSOR) $(PREPROCESSOR_FLAGS) $< > $*.tmp.s $(CC) $(AFLAGS) -c -o $@ $*.tmp.s $(RM) -f $*.tmp.s @@ -284,20 +284,35 @@ cpudtect.o: cpudtect.s # 3DNow!(tm) dependencies # XXX_def.obj targets are the default targets + ifneq ($(GL_AMD3D),) +# I have to copy the build rule from above, because the _def/_3dnow +# causes the object file names not to match up with the source file names. +# And I need to selectively enable the 3DNow flags. + xdraw2_def.o: xdraw2.s xdraw2.inc.s fxgasm.h - $(CC) $(AFLAGS) -c -o $@ xdraw2.s + $(PREPROCESSOR) $< > $*.tmp.s + $(CC) $(AFLAGS) -c -o $@ $*.tmp.s + $(RM) -f $*.tmp.s xdraw2_3dnow.o: xdraw2.s xdraw2.inc.s fxgasm.h - $(CC) $(AFLAGS) -DGL_AMD3D -DUSE_PACKET_FIFO=1 -c -o $@ xdraw2.s + $(PREPROCESSOR) -DGL_AMD3D -DUSE_PACKET_FIFO=1 $< > $*.tmp.s + $(CC) $(AFLAGS) -c -o $@ $*.tmp.s + $(RM) -f $*.tmp.s xdraw3_def.o: xdraw3.s fxgasm.h - $(CC) $(AFLAGS) -c -o $@ xdraw3.s + $(PREPROCESSOR) $< > $*.tmp.s + $(CC) $(AFLAGS) -c -o $@ $*.tmp.s + $(RM) -f $*.tmp.s xdraw3_3dnow.o: xdraw3.s fxgasm.h - $(CC) $(AFLAGS) -DGL_AMD3D -DUSE_PACKET_FIFO=1 -c -o $@ xdraw3.s + $(PREPROCESSOR) -DGL_AMD3D -DUSE_PACKET_FIFO=1 $< > $*.tmp.s + $(CC) $(AFLAGS) -c -o $@ $*.tmp.s + $(RM) -f $*.tmp.s xtexdl_3dnow.o: xtexdl.s fxgasm.h - $(CC) $(AFLAGS) -DGL_AMD3D -DUSE_PACKET_FIFO=1 -c -o $@ xtexdl.s + $(PREPROCESSOR) -DGL_AMD3D -DUSE_PACKET_FIFO=1 $< > $*.tmp.s + $(CC) $(AFLAGS) -c -o $@ $*.tmp.s + $(RM) -f $*.tmp.s endif # GL_AMD3D diff --git a/glide3x/h5/glide3/src/xdraw2.inc.s b/glide3x/h5/glide3/src/xdraw2.inc.s index 95988c2..4e3852d 100644 --- a/glide3x/h5/glide3/src/xdraw2.inc.s +++ b/glide3x/h5/glide3/src/xdraw2.inc.s @@ -23,12 +23,22 @@ /* $Header$ * /* $Revision$ * /* $Log$ +/* Revision 1.4 2000/11/15 23:32:54 joseph +/* Syncing up with 3dfx internal source repository. These changes contain a +/* number of bug fixes. +/* /* Revision 1.1 2000/06/15 00:27:43 joseph /* Initial checkin into SourceForge. -/ +/* /* Revision 1.1.1.1 2000/04/26 20:35:32 poppa /* Initial Napalm Glide from Precision Insight /* +/* Revision 1.3 2000/10/20 19:07:00 billwhite +/* 1.) Added changes for AMD 3DNow instructions in h5/glide3 and +/* h3/glide3. +/* 2.) Fixed a typographical error in configure.in. The default +/* texture utility library is texus2, not texus. +/* /* Revision 1.2 2000/04/18 15:58:15 poppa /* h5/glide3/src/glide.h: Define grSwapBuffers as grDRISwapBuffers. This /* may not be right. @@ -143,7 +153,7 @@ push %esi /* save caller's register variable */ push %ebx /* save caller's register variable */ - mov _gc(%esp), gc + mov _gc-4(%esp), gc mov _vb-4(%esp) , fb /* get base address of vertex B */ push %ebp /* save frame pointer */ diff --git a/glide3x/h5/glide3/src/xdraw2.s b/glide3x/h5/glide3/src/xdraw2.s index c7aaf4d..d5edaea 100644 --- a/glide3x/h5/glide3/src/xdraw2.s +++ b/glide3x/h5/glide3/src/xdraw2.s @@ -21,6 +21,14 @@ /* $Header$ * /* $Revision$ * /* $Log$ +/* Revision 1.3 2000/11/15 23:32:54 joseph +/* Syncing up with 3dfx internal source repository. These changes contain a +/* number of bug fixes. +/* +/* Revision 1.2 2000/06/27 19:59:34 joseph +/* Previous checkin of asm files were already preprocessed. +/* Fixed build rules for 3DNow optimized assembly. +/* /* Revision 1.1 2000/06/15 00:27:43 joseph /* Initial checkin into SourceForge. /* diff --git a/glide3x/h5/glide3/src/xtexdl.s b/glide3x/h5/glide3/src/xtexdl.s index 2355055..51b0a0b 100644 --- a/glide3x/h5/glide3/src/xtexdl.s +++ b/glide3x/h5/glide3/src/xtexdl.s @@ -21,6 +21,14 @@ /* $Header$ * /* $Revision$ * /* $Log$ +/* Revision 1.3 2000/11/15 23:32:54 joseph +/* Syncing up with 3dfx internal source repository. These changes contain a +/* number of bug fixes. +/* +/* Revision 1.2 2000/06/27 19:59:34 joseph +/* Previous checkin of asm files were already preprocessed. +/* Fixed build rules for 3DNow optimized assembly. +/* /* Revision 1.1 2000/06/15 00:27:43 josep /* Initial checkin into SourceForge / diff --git a/glide3x/h5/minihwc/linhwc.c b/glide3x/h5/minihwc/linhwc.c index 368d136..6fdf0d1 100644 --- a/glide3x/h5/minihwc/linhwc.c +++ b/glide3x/h5/minihwc/linhwc.c @@ -119,8 +119,8 @@ void grDRIOpen(char *pFB, char *pRegs, int deviceID, int width, int height, driInfo.depthOffset=depthOffset; driInfo.textureOffset=textureOffset; driInfo.textureSize=textureSize; - driInfo.fifoPtr=fifoPtr; - driInfo.fifoRead=fifoRead; + driInfo.fifoPtr=(volatile int **)fifoPtr; + driInfo.fifoRead=(volatile int **)fifoRead; } void grDRIPosition(int x, int y, int w, int h, @@ -138,7 +138,8 @@ static void loadEnvFile() { char data[128]; char *env, *val; envitem *item; - int first=1; + unsigned int sawError=0; + envitem *first=(envitem *)0; if (envinit) return; envinit=1; @@ -150,9 +151,9 @@ static void loadEnvFile() { if (*data=='\n') continue; val=strchr(data, '='); if (!val) { - if (first) { + if (sawError) { fprintf(stderr, "In config file /etc/conf.3dfx/voodoo3:\n"); - first=0; + sawError=1; } fprintf(stderr, "Malformed line: %s\n", data); continue; @@ -224,6 +225,8 @@ hwcInit(FxU32 vID, FxU32 dID) { } } +extern int getpid(); + FxBool hwcMapBoard(hwcBoardInfo *bInfo, FxU32 bAddrMask) { if (bInfo->pciInfo.initialized == FXFALSE) { @@ -324,6 +327,11 @@ hwcBufferLfbAddr(const hwcBoardInfo *bInfo, FxU32 physAddress) FxU32 tileScanline; FxU32 tileRow; FxU32 lfbAddress; + /* + * This is the tile aperture stride. It should be + * a power of two between 1k and 16k. + */ + FxU32 lfbBufferStride = bInfo->buffInfo.bufLfbStride; FxU32 lfbYOffset; if (bInfo->vidInfo.tiled) { @@ -357,7 +365,7 @@ hwcBufferLfbAddr(const hwcBoardInfo *bInfo, FxU32 physAddress) lfbYOffset = ((tileRow * 32 + tileScanline) << (bInfo->h3nwaySli >> 1)); /* Compute LFB address of tile start */ - lfbAddress = bInfo->primaryOffset + lfbYOffset * HWC_LFB_STRIDE + tileXOffset * 128; + lfbAddress = bInfo->primaryOffset + lfbYOffset * lfbBufferStride + tileXOffset * 128; GDBG_INFO(80, "\tlfbAddress: %08lx\n", lfbAddress); retVal = lfbAddress; @@ -367,6 +375,20 @@ hwcBufferLfbAddr(const hwcBoardInfo *bInfo, FxU32 physAddress) return retVal; } +static FxU32 +calculateLfbStride(FxU32 screenWidth) +{ +#if 1 + int TileAperturePitch; + for (TileAperturePitch = 1024; + (TileAperturePitch < (16 << 10)) && (TileAperturePitch < screenWidth); + TileAperturePitch <<= 1); + return(TileAperturePitch); +#else + return(0x1000); +#endif +} + FxBool hwcAllocBuffers(hwcBoardInfo *bInfo, FxU32 nColBuffers, FxU32 nAuxBuffers) { @@ -395,6 +417,7 @@ hwcAllocBuffers(hwcBoardInfo *bInfo, FxU32 nColBuffers, FxU32 nAuxBuffers) bInfo->buffInfo.bufStride = bufStride; bInfo->buffInfo.bufSize = bufSize; + bInfo->buffInfo.bufLfbStride = calculateLfbStride(bufStride); if (bInfo->vidInfo.tiled) { bInfo->buffInfo.bufStrideInTiles = (bufStride >> 7); @@ -451,6 +474,7 @@ hwcAllocBuffers(hwcBoardInfo *bInfo, FxU32 nColBuffers, FxU32 nAuxBuffers) GDBG_INFO(80, "\tbufStride: 0x%x\n", bInfo->buffInfo.bufStride); GDBG_INFO(80, "\tbufStrideInTiles:0x%x\n", bInfo->buffInfo.bufStrideInTiles); GDBG_INFO(80, "\tbufHeightInTiles:0x%x\n", bInfo->buffInfo.bufHeightInTiles); + GDBG_INFO(80, "\tbufLfbStride :0x%x\n", bInfo->buffInfo.bufLfbStride); GDBG_INFO(80, "\tnColBuffers: 0x%x\n", bInfo->buffInfo.nColBuffers); GDBG_INFO(80, "\tcolBuffStart0[0]: 0x%x\n", bInfo->buffInfo.colBuffStart0[0]); GDBG_INFO(80, "\tcolBuffEnd0[0]: 0x%x\n", bInfo->buffInfo.colBuffEnd0[0]); @@ -575,7 +599,7 @@ calcBufferStride(hwcBoardInfo *bInfo, FxU32 xres, FxBool tiled) if (tiled == FXTRUE) { /* Calculate tile width stuff */ strideInTiles = (xres << shift) >> 7; - if ((xres << 1) & (HWC_TILE_WIDTH - 1)) + if ((xres << shift) & (HWC_TILE_WIDTH - 1)) strideInTiles++; return (strideInTiles * HWC_TILE_WIDTH);