#if defined(FX_GLIDE3) && defined(XF86DRI)
+static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
+ FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
+ FxU32 src_width, FxU32 src_height, FxI32 src_stride,
+ void *src_data);
+
FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
FxU32 src_width, FxU32 src_height, FxI32 src_stride,
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
- GLint bottom=fxMesa->y_delta-1;
+ GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n");
#include "fxdrv.h"
+void fxPrintTextureData(tfxTexInfo *ti)
+{
+ fprintf(stderr, "Texture Data:\n");
+ if (ti->tObj) {
+ fprintf(stderr, "\tName: %d\n", ti->tObj->Name);
+ fprintf(stderr, "\tBaseLevel: %d\n", ti->tObj->BaseLevel);
+ fprintf(stderr, "\tSize: %d x %d\n",
+ ti->tObj->Image[ti->tObj->BaseLevel]->Width,
+ ti->tObj->Image[ti->tObj->BaseLevel]->Height);
+ } else
+ fprintf(stderr, "\tName: UNNAMED\n");
+ fprintf(stderr, "\tLast used: %d\n", ti->lastTimeUsed);
+ fprintf(stderr, "\tTMU: %d\n", ti->whichTMU);
+ fprintf(stderr, "\t%s\n", (ti->isInTM)?"In TMU":"Not in TMU");
+ if (ti->tm[0])
+ fprintf(stderr, "\tMem0: %x-%x\n", ti->tm[0]->startAddr,
+ ti->tm[0]->endAddr);
+ if (ti->tm[1])
+ fprintf(stderr, "\tMem1: %x-%x\n", ti->tm[1]->startAddr,
+ ti->tm[1]->endAddr);
+ fprintf(stderr, "\tMipmaps: %d-%d\n", ti->minLevel, ti->maxLevel);
+ fprintf(stderr, "\tFilters: min %d min %d\n", ti->minFilt, ti->maxFilt);
+ fprintf(stderr, "\tClamps: s %d t %d\n", ti->sClamp, ti->tClamp);
+ fprintf(stderr, "\tScales: s %f t %f\n", ti->sScale, ti->tScale);
+ fprintf(stderr, "\tInt Scales: s %d t %d\n",
+ ti->int_sScale/0x800000, ti->int_tScale/0x800000);
+ fprintf(stderr, "\t%s\n", (ti->fixedPalette)?"Fixed palette":"Non fixed palette");
+ fprintf(stderr, "\t%s\n", (ti->validated)?"Validated":"Not validated");
+}
+
+
/************************************************************************/
/*************************** Texture Mapping ****************************/
/************************************************************************/
fxTMMoveOutTM(fxMesa,tObj); /* TO DO: SLOW but easy to write */
- ti=(tfxTexInfo *)tObj->DriverData;
+ ti=fxTMGetTexInfo(tObj);
ti->validated=GL_FALSE;
fxMesa->new_state|=FX_NEW_TEXTURING;
ctx->Driver.RenderStart = fxSetupFXUnits;
}
ti->validated=GL_FALSE;
- ti->tmi.isInTM=GL_FALSE;
+ ti->isInTM=GL_FALSE;
- ti->tmi.whichTMU=FX_TMU_NONE;
+ ti->whichTMU=FX_TMU_NONE;
- ti->tmi.tm[FX_TMU0]=NULL;
- ti->tmi.tm[FX_TMU1]=NULL;
+ ti->tm[FX_TMU0]=NULL;
+ ti->tm[FX_TMU1]=NULL;
ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
ti->maxFilt=GR_TEXTUREFILTER_BILINEAR;
}
for(i=0;i<MAX_TEXTURE_LEVELS;i++) {
- ti->tmi.mipmapLevel[i].used=GL_FALSE;
- ti->tmi.mipmapLevel[i].data=NULL;
+ ti->mipmapLevel[i].used=GL_FALSE;
+ ti->mipmapLevel[i].data=NULL;
}
return ti;
if(target!=GL_TEXTURE_2D)
return;
- if(!tObj->DriverData)
+ if (!tObj->DriverData) {
tObj->DriverData=fxAllocTexObjData(fxMesa);
+ }
- ti=(tfxTexInfo *)tObj->DriverData;
+ ti=fxTMGetTexInfo(tObj);
fxMesa->texBindNumber++;
- ti->tmi.lastTimeUsed=fxMesa->texBindNumber;
+ ti->lastTimeUsed=fxMesa->texBindNumber;
fxMesa->new_state|=FX_NEW_TEXTURING;
ctx->Driver.RenderStart = fxSetupFXUnits;
if(target!=GL_TEXTURE_2D)
return;
- if(!tObj->DriverData)
+ if (!tObj->DriverData)
tObj->DriverData=fxAllocTexObjData(fxMesa);
- ti=(tfxTexInfo *)tObj->DriverData;
+ ti=fxTMGetTexInfo(tObj);
switch(pname) {
void fxDDTexDel(GLcontext *ctx, struct gl_texture_object *tObj)
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxTexInfo *ti=(tfxTexInfo *)tObj->DriverData;
+ tfxTexInfo *ti=fxTMGetTexInfo(tObj);
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDTexDel(%d,%x)\n",tObj->Name,(GLuint)ti);
return;
}
- if(!tObj->DriverData)
+ if (!tObj->DriverData)
tObj->DriverData=fxAllocTexObjData(fxMesa);
- ti=(tfxTexInfo *)tObj->DriverData;
+ ti=fxTMGetTexInfo(tObj);
for(i=0;i<tObj->Palette.Size;i++) {
r=tObj->Palette.Table[i*4];
if((ctx->Texture.Unit[0].Current==ctx->Texture.Unit[0].CurrentD[2]) &&
(ctx->Texture.Unit[0].Current!=NULL)) {
struct gl_texture_object *tObj=ctx->Texture.Unit[0].Current;
- tfxTexInfo *ti;
- if(!tObj->DriverData)
+ if (!tObj->DriverData)
tObj->DriverData=fxAllocTexObjData(fxMesa);
- ti=(tfxTexInfo *)tObj->DriverData;
-
fxTexInvalidate(ctx,tObj);
}
}
tfxTexInfo *ti;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: (%d) fxDDTexImg(...,%d,%x,%d,%d...)\n",tObj->Name,
- target,internalFormat,image->Width,image->Height);
+ fprintf(stderr,
+ "fxmesa: (%d) fxDDTexImg(...,level=%d,target=%d,format=%x,width=%d,height=%d...)\n",
+ tObj->Name, level, target, internalFormat, image->Width,
+ image->Height);
}
if(target!=GL_TEXTURE_2D)
return;
- if(!tObj->DriverData)
+ if (!tObj->DriverData)
tObj->DriverData=fxAllocTexObjData(fxMesa);
- ti=(tfxTexInfo *)tObj->DriverData;
+ ti=fxTMGetTexInfo(tObj);
if(fxIsTexSupported(target,internalFormat,image)) {
GrTextureFormat_t gldformat;
- tfxMipMapLevel *mml=&ti->tmi.mipmapLevel[level];
+ tfxMipMapLevel *mml=&ti->mipmapLevel[level];
fxTexGetFormat(internalFormat,&gldformat,NULL);
fxTexBuildImageMap(image,internalFormat,&(mml->data),
&(mml->translated));
- if(ti->validated && ti->tmi.isInTM)
+ if(ti->validated && ti->isInTM)
fxTMReloadMipMapLevel(fxMesa,tObj,level);
else
fxTexInvalidate(ctx,tObj);
tfxMipMapLevel *mml;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: (%d) fxDDTexSubImg(...,%d,%x,%d,%d...)\n",tObj->Name,
- target,internalFormat,image->Width,image->Height);
+ fprintf(stderr,
+ "fxmesa: (%d) fxDDTexSubImg(level=%d,target=%d,format=%x,width=%d,height=%d)\n",
+ tObj->Name, level, target, internalFormat, image->Width,
+ image->Height);
}
if(target!=GL_TEXTURE_2D)
return;
- if(!tObj->DriverData)
+ if (!tObj->DriverData)
return;
- ti=(tfxTexInfo *)tObj->DriverData;
- mml=&ti->tmi.mipmapLevel[level];
+ ti=fxTMGetTexInfo(tObj);
+ mml=&ti->mipmapLevel[level];
fxTexGetFormat(internalFormat,&gldformat,NULL);
fxTexBuildSubImageMap(image,internalFormat,xoffset,yoffset,
width,height,mml->data);
- if(ti->validated && ti->tmi.isInTM)
+ if(ti->validated && ti->isInTM)
fxTMReloadSubMipMapLevel(fxMesa,tObj,level,yoffset,height);
else
fxTexInvalidate(ctx,tObj);
typedef void (*tfxRenderVBFunc)(GLcontext *);
-typedef struct tfxTMFreeListNode {
- struct tfxTMFreeListNode *next;
- FxU32 startAddress, endAddress;
-} tfxTMFreeNode;
-
-typedef struct tfxTMAllocListNode {
- struct tfxTMAllocListNode *next;
- FxU32 startAddress, endAddress;
- struct gl_texture_object *tObj;
-} tfxTMAllocNode;
+/*
+ Memory range from startAddr to endAddr-1
+*/
+typedef struct MemRange_t {
+ struct MemRange_t *next;
+ FxU32 startAddr, endAddr;
+} MemRange;
typedef struct {
GLsizei width, height;
GLboolean translated, used;
} tfxMipMapLevel;
-typedef struct {
- GLuint lastTimeUsed;
+typedef struct tfxTexInfo_t {
+ struct tfxTexInfo *next;
+ struct gl_texture_object *tObj;
+ GLuint lastTimeUsed;
FxU32 whichTMU;
-
- tfxTMAllocNode *tm[FX_NUM_TMU];
+ GLboolean isInTM;
tfxMipMapLevel mipmapLevel[MAX_TEXTURE_LEVELS];
- GLboolean isInTM;
-} tfxTMInfo;
-typedef struct {
- tfxTMInfo tmi;
+ MemRange *tm[FX_NUM_TMU];
GLint minLevel, maxLevel;
GLint baseLevelInternalFormat;
#define FX_DRIVER_DATA(vb) ((struct tfxMesaVertexBuffer *)((vb)->driver_data))
#define FX_CONTEXT(ctx) ((fxMesaContext)((ctx)->DriverCtx))
-#define FX_TEXTURE_DATA(t) ((tfxTexInfo *) ((t)->Current->DriverData))
+#define FX_TEXTURE_DATA(t) fxTMGetTexInfo((t)->Current)
#if defined(XFree86Server) || defined(GLX_DIRECT_RENDERING)
#include "tdfx_init.h"
GLuint texBindNumber;
GLint tmuSrc;
GLuint lastUnitsMode;
+ GLuint texStart[FX_NUM_TMU];
GLuint freeTexMem[FX_NUM_TMU];
- tfxTMFreeNode *tmFree[FX_NUM_TMU];
- tfxTMAllocNode *tmAlloc[FX_NUM_TMU];
+ MemRange *tmPool;
+ MemRange *tmFree[FX_NUM_TMU];
GLenum fogTableMode;
GLfloat fogDensity;
int clipMinY;
int clipMaxY;
int needClip;
- int numClipRects;
-#ifdef FX86DRI
- XF86DRIClipRectPtr pClipRects;
-#endif
- DRI_FX_CONTEXT
+ DRI_FX_CONTEXT
};
typedef void (*tfxSetupFunc)(struct vertex_buffer *, GLuint, GLuint);
extern void fxDDBufferSize(GLcontext *, GLuint *, GLuint *);
+extern void fxPrintTextureData(tfxTexInfo *ti);
extern void fxDDTexEnv(GLcontext *, GLenum, const GLfloat *);
extern void fxDDTexImg(GLcontext *, GLenum, struct gl_texture_object *,
GLint, GLint, const struct gl_texture_image *);
extern void fxDDInitExtensions( GLcontext *ctx );
+#define fxTMGetTexInfo(o) ((tfxTexInfo*)((o)->DriverData))
extern void fxTMInit(fxMesaContext ctx);
extern void fxTMClose(fxMesaContext ctx);
extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint);
#include <stdlib.h>
#include <string.h>
-FxI32 grGetInteger(FxU32 pname)
+static FxI32 FX_grGetInteger_NoLock(FxU32 pname)
{
#if !defined(FX_GLIDE3)
switch (pname)
int result;
BEGIN_BOARD_LOCK();
- result=grGetInteger(pname);
+ result=FX_grGetInteger_NoLock(pname);
END_BOARD_LOCK();
return result;
}
#if FX_USE_PARGB
void FX_setupGrVertexLayout(void)
{
- grReset(GR_VERTEX_PARAMETER);
+ BEGIN_BOARD_LOCK();
+ grReset(GR_VERTEX_PARAMETER);
- grCoordinateSpace(GR_WINDOW_COORDS);
- grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
- grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
- grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
+ grCoordinateSpace(GR_WINDOW_COORDS);
+ grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
+ grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
+ grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
+ END_BOARD_LOCK();
}
#else /* FX_USE_PARGB */
void FX_setupGrVertexLayout(void)
{
- grReset(GR_VERTEX_PARAMETER);
+ BEGIN_BOARD_LOCK();
+ grReset(GR_VERTEX_PARAMETER);
- grCoordinateSpace(GR_WINDOW_COORDS);
- grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
- /* grVertexLayout(GR_PARAM_Z, GR_VERTEX_Z_OFFSET << 2, GR_PARAM_ENABLE); */
- grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
- grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
- grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
+ grCoordinateSpace(GR_WINDOW_COORDS);
+ grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
+ grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
+ grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
+ END_BOARD_LOCK();
}
#endif
return 1;
}
+#else
+
+int FX_grSstScreenWidth()
+{
+ int i;
+ BEGIN_BOARD_LOCK();
+ i = grSstScreenWidth();
+ END_BOARD_LOCK();
+ return i;
+}
+
+int FX_grSstScreenHeight()
+{
+ int i;
+ BEGIN_BOARD_LOCK();
+ i = grSstScreenHeight();
+ END_BOARD_LOCK();
+ return i;
+}
+
+int FX_grSstQueryHardware(GrHwConfiguration *c)
+{
+ int i;
+ BEGIN_BOARD_LOCK();
+ i = grSstQueryHardware(c);
+ END_BOARD_LOCK();
+ return i;
+}
FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd,
GrScreenResolution_t screen_resolution,
return i;
}
-#else /* FX_GLIDE3 */
-
-int FX_grSstScreenWidth()
-{
- return grSstScreenWidth();
-}
-
-int FX_grSstScreenHeight()
-{
- return grSstScreenHeight();
-}
-
-int FX_grSstQueryHardware(GrHwConfiguration *config)
-{
- return grSstQueryHardware(config);
-}
-
-FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd,
- GrScreenResolution_t screen_resolution,
- GrScreenRefresh_t refresh_rate,
- GrColorFormat_t color_format,
- GrOriginLocation_t origin_location,
- int nColBuffers,
- int nAuxBuffers)
-{
- return grSstWinOpen(hWnd, screen_resolution, refresh_rate,
- color_format, origin_location, nColBuffers, nAuxBuffers);
-}
-
-#endif /* FX_GLIDE3 */
+#endif
#else
/*