summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/glide/fxapi.c901
-rw-r--r--src/mesa/drivers/glide/fxdd.c1176
-rw-r--r--src/mesa/drivers/glide/fxddspan.c727
-rw-r--r--src/mesa/drivers/glide/fxddtex.c1447
-rw-r--r--src/mesa/drivers/glide/fxdrv.h313
-rw-r--r--src/mesa/drivers/glide/fxglidew.c461
-rw-r--r--src/mesa/drivers/glide/fxglidew.h231
-rw-r--r--src/mesa/drivers/glide/fxsetup.c2889
-rw-r--r--src/mesa/drivers/glide/fxtexman.c1269
-rw-r--r--src/mesa/drivers/glide/fxtris.c198
-rw-r--r--src/mesa/drivers/glide/fxvb.c188
-rw-r--r--src/mesa/drivers/glide/fxvbtmp.h111
-rw-r--r--src/mesa/drivers/glide/fxwgl.c1313
13 files changed, 5758 insertions, 5466 deletions
diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c
index 40b1d5d79c..9ca044d0a5 100644
--- a/src/mesa/drivers/glide/fxapi.c
+++ b/src/mesa/drivers/glide/fxapi.c
@@ -50,42 +50,45 @@
#if defined(FX)
#include "fxdrv.h"
-static fxMesaContext fxMesaCurrentCtx=NULL;
+static fxMesaContext fxMesaCurrentCtx = NULL;
/*
* Status of 3Dfx hardware initialization
*/
-static int glbGlideInitialized=0;
-static int glb3DfxPresent=0;
-static int glbTotNumCtx=0;
+static int glbGlideInitialized = 0;
+static int glb3DfxPresent = 0;
+static int glbTotNumCtx = 0;
GrHwConfiguration glbHWConfig;
-int glbCurrentBoard=0;
+int glbCurrentBoard = 0;
#if defined(__WIN32__)
-static int cleangraphics(void)
+static int
+cleangraphics(void)
{
- glbTotNumCtx=1;
- fxMesaDestroyContext(fxMesaCurrentCtx);
+ glbTotNumCtx = 1;
+ fxMesaDestroyContext(fxMesaCurrentCtx);
- return 0;
+ return 0;
}
#elif defined(__linux__)
-static void cleangraphics(void)
+static void
+cleangraphics(void)
{
- glbTotNumCtx=1;
- fxMesaDestroyContext(fxMesaCurrentCtx);
+ glbTotNumCtx = 1;
+ fxMesaDestroyContext(fxMesaCurrentCtx);
}
-static void cleangraphics_handler(int s)
+static void
+cleangraphics_handler(int s)
{
- fprintf(stderr,"fxmesa: Received a not handled signal %d\n",s);
+ fprintf(stderr, "fxmesa: Received a not handled signal %d\n", s);
- cleangraphics();
+ cleangraphics();
/* abort(); */
- exit(1);
+ exit(1);
}
#endif
@@ -94,22 +97,24 @@ static void cleangraphics_handler(int s)
* Select the Voodoo board to use when creating
* a new context.
*/
-GLboolean GLAPIENTRY fxMesaSelectCurrentBoard(int n)
+GLboolean GLAPIENTRY
+fxMesaSelectCurrentBoard(int n)
{
- fxQueryHardware();
+ fxQueryHardware();
- if((n<0) || (n>=glbHWConfig.num_sst))
- return GL_FALSE;
+ if ((n < 0) || (n >= glbHWConfig.num_sst))
+ return GL_FALSE;
- glbCurrentBoard=n;
+ glbCurrentBoard = n;
- return GL_TRUE;
+ return GL_TRUE;
}
-fxMesaContext GLAPIENTRY fxMesaGetCurrentContext(void)
+fxMesaContext GLAPIENTRY
+fxMesaGetCurrentContext(void)
{
- return fxMesaCurrentCtx;
+ return fxMesaCurrentCtx;
}
@@ -118,206 +123,213 @@ fxMesaContext GLAPIENTRY fxMesaGetCurrentContext(void)
* More a trick than a real extesion, use the shared global
* palette extension.
*/
-extern void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal); /* silence warning */
-void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal)
+extern void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint * pal); /* silence warning */
+void GLAPIENTRY
+gl3DfxSetPaletteEXT(GLuint * pal)
{
- fxMesaContext fxMesa =fxMesaCurrentCtx;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- int i;
-
- fprintf(stderr,"fxmesa: gl3DfxSetPaletteEXT()\n");
-
- for(i=0;i<256;i++)
- fprintf(stderr,"%x\n",pal[i]);
- }
-
- if(fxMesa) {
- fxMesa->haveGlobalPaletteTexture=1;
-
- FX_grTexDownloadTable(GR_TMU0,GR_TEXTABLE_PALETTE,(GuTexPalette *)pal);
- if (fxMesa->haveTwoTMUs)
- FX_grTexDownloadTable(GR_TMU1,GR_TEXTABLE_PALETTE,(GuTexPalette *)pal);
- }
+ fxMesaContext fxMesa = fxMesaCurrentCtx;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ int i;
+
+ fprintf(stderr, "fxmesa: gl3DfxSetPaletteEXT()\n");
+
+ for (i = 0; i < 256; i++)
+ fprintf(stderr, "%x\n", pal[i]);
+ }
+
+ if (fxMesa) {
+ fxMesa->haveGlobalPaletteTexture = 1;
+
+ FX_grTexDownloadTable(GR_TMU0, GR_TEXTABLE_PALETTE,
+ (GuTexPalette *) pal);
+ if (fxMesa->haveTwoTMUs)
+ FX_grTexDownloadTable(GR_TMU1, GR_TEXTABLE_PALETTE,
+ (GuTexPalette *) pal);
+ }
}
-static GrScreenResolution_t fxBestResolution(int width, int height, int aux)
+static GrScreenResolution_t
+fxBestResolution(int width, int height, int aux)
{
- static int resolutions[][5]={
- { 320, 200, GR_RESOLUTION_320x200, 2, 2 },
- { 320, 240, GR_RESOLUTION_320x240, 2, 2 },
- { 512, 384, GR_RESOLUTION_512x384, 2, 2 },
- { 640, 400, GR_RESOLUTION_640x400, 2, 2 },
- { 640, 480, GR_RESOLUTION_640x480, 2, 2 },
- { 800, 600, GR_RESOLUTION_800x600, 4, 2 },
- { 960, 720, GR_RESOLUTION_960x720, 6, 4 }
+ static int resolutions[][5] = {
+ {320, 200, GR_RESOLUTION_320x200, 2, 2},
+ {320, 240, GR_RESOLUTION_320x240, 2, 2},
+ {512, 384, GR_RESOLUTION_512x384, 2, 2},
+ {640, 400, GR_RESOLUTION_640x400, 2, 2},
+ {640, 480, GR_RESOLUTION_640x480, 2, 2},
+ {800, 600, GR_RESOLUTION_800x600, 4, 2},
+ {960, 720, GR_RESOLUTION_960x720, 6, 4}
#ifdef GR_RESOLUTION_1024x768
- ,{ 1024, 768, GR_RESOLUTION_1024x768, 8, 4 }
+ , {1024, 768, GR_RESOLUTION_1024x768, 8, 4}
#endif
#ifdef GR_RESOLUTION_1280x1024
- ,{ 1280, 1024, GR_RESOLUTION_1280x1024, 8, 8 }
+ , {1280, 1024, GR_RESOLUTION_1280x1024, 8, 8}
#endif
#ifdef GR_RESOLUTION_1600x1200
- ,{ 1600, 1200, GR_RESOLUTION_1600x1200, 16, 8 }
+ , {1600, 1200, GR_RESOLUTION_1600x1200, 16, 8}
#endif
- };
- int NUM_RESOLUTIONS = sizeof(resolutions) / (sizeof(int)*5);
- int i,fbmem;
- GrScreenResolution_t lastvalidres=resolutions[4][2];
+ };
+ int NUM_RESOLUTIONS = sizeof(resolutions) / (sizeof(int) * 5);
+ int i, fbmem;
+ GrScreenResolution_t lastvalidres = resolutions[4][2];
- fxQueryHardware();
+ fxQueryHardware();
- if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) {
- fbmem=glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam;
+ if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) {
+ fbmem = glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam;
- if(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect)
- fbmem*=2;
- } else if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96)
- fbmem=glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.fbRam;
- else
- fbmem=2;
+ if (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect)
+ fbmem *= 2;
+ }
+ else if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_SST96)
+ fbmem = glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.fbRam;
+ else
+ fbmem = 2;
- /* A work around for BZFlag */
+ /* A work around for BZFlag */
- if((width==1) && (height==1)) {
- width=640;
- height=480;
- }
+ if ((width == 1) && (height == 1)) {
+ width = 640;
+ height = 480;
+ }
- for(i=0;i<NUM_RESOLUTIONS;i++)
- if(resolutions[i][4-aux]<=fbmem) {
- if((width<=resolutions[i][0]) && (height<=resolutions[i][1]))
- return resolutions[i][2];
+ for (i = 0; i < NUM_RESOLUTIONS; i++)
+ if (resolutions[i][4 - aux] <= fbmem) {
+ if ((width <= resolutions[i][0]) && (height <= resolutions[i][1]))
+ return resolutions[i][2];
- lastvalidres=resolutions[i][2];
- }
+ lastvalidres = resolutions[i][2];
+ }
- return lastvalidres;
+ return lastvalidres;
}
-fxMesaContext GLAPIENTRY fxMesaCreateBestContext(GLuint win,GLint width, GLint height,
- const GLint attribList[])
+fxMesaContext GLAPIENTRY
+fxMesaCreateBestContext(GLuint win, GLint width, GLint height,
+ const GLint attribList[])
{
- GrScreenRefresh_t refresh;
- int i;
- int res,aux;
- refresh=GR_REFRESH_75Hz;
-
- if(getenv("SST_SCREENREFRESH")) {
- if(!strcmp(getenv("SST_SCREENREFRESH"),"60"))
- refresh=GR_REFRESH_60Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"70"))
- refresh=GR_REFRESH_70Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"72"))
- refresh=GR_REFRESH_72Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"75"))
- refresh=GR_REFRESH_75Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"80"))
- refresh=GR_REFRESH_80Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"85"))
- refresh=GR_REFRESH_85Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"90"))
- refresh=GR_REFRESH_90Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"100"))
- refresh=GR_REFRESH_100Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"120"))
- refresh=GR_REFRESH_120Hz;
- }
-
- aux=0;
- for(i=0;attribList[i]!=FXMESA_NONE;i++)
- if((attribList[i]==FXMESA_ALPHA_SIZE) ||
- (attribList[i]==FXMESA_DEPTH_SIZE)) {
- if(attribList[++i]>0) {
- aux=1;
- break;
+ GrScreenRefresh_t refresh;
+ int i;
+ int res, aux;
+ refresh = GR_REFRESH_75Hz;
+
+ if (getenv("SST_SCREENREFRESH")) {
+ if (!strcmp(getenv("SST_SCREENREFRESH"), "60"))
+ refresh = GR_REFRESH_60Hz;
+ if (!strcmp(getenv("SST_SCREENREFRESH"), "70"))
+ refresh = GR_REFRESH_70Hz;
+ if (!strcmp(getenv("SST_SCREENREFRESH"), "72"))
+ refresh = GR_REFRESH_72Hz;
+ if (!strcmp(getenv("SST_SCREENREFRESH"), "75"))
+ refresh = GR_REFRESH_75Hz;
+ if (!strcmp(getenv("SST_SCREENREFRESH"), "80"))
+ refresh = GR_REFRESH_80Hz;
+ if (!strcmp(getenv("SST_SCREENREFRESH"), "85"))
+ refresh = GR_REFRESH_85Hz;
+ if (!strcmp(getenv("SST_SCREENREFRESH"), "90"))
+ refresh = GR_REFRESH_90Hz;
+ if (!strcmp(getenv("SST_SCREENREFRESH"), "100"))
+ refresh = GR_REFRESH_100Hz;
+ if (!strcmp(getenv("SST_SCREENREFRESH"), "120"))
+ refresh = GR_REFRESH_120Hz;
+ }
+
+ aux = 0;
+ for (i = 0; attribList[i] != FXMESA_NONE; i++)
+ if ((attribList[i] == FXMESA_ALPHA_SIZE) ||
+ (attribList[i] == FXMESA_DEPTH_SIZE)) {
+ if (attribList[++i] > 0) {
+ aux = 1;
+ break;
+ }
}
- }
- res=fxBestResolution(width,height,aux);
+ res = fxBestResolution(width, height, aux);
- return fxMesaCreateContext(win,res,refresh,attribList);
+ return fxMesaCreateContext(win, res, refresh, attribList);
}
#if 0
-void fxsignals()
+void
+fxsignals()
{
- signal(SIGINT,SIG_IGN);
- signal(SIGHUP,SIG_IGN);
- signal(SIGPIPE,SIG_IGN);
- signal(SIGFPE,SIG_IGN);
- signal(SIGBUS,SIG_IGN);
- signal(SIGILL,SIG_IGN);
- signal(SIGSEGV,SIG_IGN);
- signal(SIGTERM,SIG_IGN);
+ signal(SIGINT, SIG_IGN);
+ signal(SIGHUP, SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
+ signal(SIGFPE, SIG_IGN);
+ signal(SIGBUS, SIG_IGN);
+ signal(SIGILL, SIG_IGN);
+ signal(SIGSEGV, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
}
#endif
/*
* Create a new FX/Mesa context and return a handle to it.
*/
-fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
- GrScreenResolution_t res,
- GrScreenRefresh_t ref,
- const GLint attribList[])
+fxMesaContext GLAPIENTRY
+fxMesaCreateContext(GLuint win,
+ GrScreenResolution_t res,
+ GrScreenRefresh_t ref, const GLint attribList[])
{
fxMesaContext fxMesa = NULL;
- int i,type;
+ int i, type;
int aux;
- GLboolean doubleBuffer=GL_FALSE;
- GLboolean alphaBuffer=GL_FALSE;
- GLboolean verbose=GL_FALSE;
- GLint depthSize=0;
- GLint stencilSize=0;
- GLint accumSize=0;
+ GLboolean doubleBuffer = GL_FALSE;
+ GLboolean alphaBuffer = GL_FALSE;
+ GLboolean verbose = GL_FALSE;
+ GLint depthSize = 0;
+ GLint stencilSize = 0;
+ GLint accumSize = 0;
GLcontext *shareCtx = NULL;
GLcontext *ctx = 0;
- /*FX_GrContext_t glideContext = 0;*/
+ /*FX_GrContext_t glideContext = 0; */
char *errorstr;
GLboolean useBGR;
char *system = NULL;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaCreateContext() Start\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxMesaCreateContext() Start\n");
}
- if(getenv("MESA_FX_INFO"))
- verbose=GL_TRUE;
+ if (getenv("MESA_FX_INFO"))
+ verbose = GL_TRUE;
- aux=0;
- i=0;
- while(attribList[i]!=FXMESA_NONE) {
+ aux = 0;
+ i = 0;
+ while (attribList[i] != FXMESA_NONE) {
switch (attribList[i]) {
case FXMESA_DOUBLEBUFFER:
- doubleBuffer=GL_TRUE;
+ doubleBuffer = GL_TRUE;
break;
case FXMESA_ALPHA_SIZE:
i++;
- alphaBuffer=attribList[i]>0;
- if(alphaBuffer)
- aux=1;
+ alphaBuffer = attribList[i] > 0;
+ if (alphaBuffer)
+ aux = 1;
break;
case FXMESA_DEPTH_SIZE:
i++;
- depthSize=attribList[i];
- if(depthSize) {
- aux=1;
- depthSize = 16;
- }
+ depthSize = attribList[i];
+ if (depthSize) {
+ aux = 1;
+ depthSize = 16;
+ }
break;
case FXMESA_STENCIL_SIZE:
i++;
- stencilSize=attribList[i];
+ stencilSize = attribList[i];
break;
case FXMESA_ACCUM_SIZE:
i++;
- accumSize=attribList[i];
+ accumSize = attribList[i];
break;
/* XXX ugly hack here for sharing display lists */
-#define FXMESA_SHARE_CONTEXT 990099 /* keep in sync with xmesa1.c! */
+#define FXMESA_SHARE_CONTEXT 990099 /* keep in sync with xmesa1.c! */
case FXMESA_SHARE_CONTEXT:
i++;
{
@@ -327,8 +339,8 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
}
break;
default:
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaCreateContext() End (defualt)\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxMesaCreateContext() End (defualt)\n");
}
return NULL;
}
@@ -336,50 +348,54 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
}
/* A workaround for Linux GLQuake */
- if(depthSize && alphaBuffer)
- alphaBuffer=0;
+ if (depthSize && alphaBuffer)
+ alphaBuffer = 0;
- if ((type=fxQueryHardware()) < 0) {
- fprintf(stderr,"fx Driver: ERROR no Voodoo1/2 Graphics or Voodoo Rush !\n");
+ if ((type = fxQueryHardware()) < 0) {
+ fprintf(stderr,
+ "fx Driver: ERROR no Voodoo1/2 Graphics or Voodoo Rush !\n");
return NULL;
}
- if(type==GR_SSTTYPE_VOODOO)
- win=0;
+ if (type == GR_SSTTYPE_VOODOO)
+ win = 0;
grSstSelect(glbCurrentBoard);
- fxMesa=(fxMesaContext)calloc(1,sizeof(struct tfxMesaContext));
- if(!fxMesa) {
+ fxMesa = (fxMesaContext) calloc(1, sizeof(struct tfxMesaContext));
+ if (!fxMesa) {
errorstr = "malloc";
goto errorhandler;
}
- if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO)
- fxMesa->haveTwoTMUs=(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx > 1);
- else if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96)
- fxMesa->haveTwoTMUs=(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.nTexelfx > 1);
+ if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO)
+ fxMesa->haveTwoTMUs =
+ (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx >
+ 1);
+ else if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_SST96)
+ fxMesa->haveTwoTMUs =
+ (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.nTexelfx >
+ 1);
else
- fxMesa->haveTwoTMUs=GL_FALSE;
+ fxMesa->haveTwoTMUs = GL_FALSE;
- fxMesa->haveDoubleBuffer=doubleBuffer;
- fxMesa->haveAlphaBuffer=alphaBuffer;
- fxMesa->haveGlobalPaletteTexture=GL_FALSE;
- fxMesa->haveZBuffer=depthSize ? 1 : 0;
- fxMesa->verbose=verbose;
- fxMesa->board=glbCurrentBoard;
+ fxMesa->haveDoubleBuffer = doubleBuffer;
+ fxMesa->haveAlphaBuffer = alphaBuffer;
+ fxMesa->haveGlobalPaletteTexture = GL_FALSE;
+ fxMesa->haveZBuffer = depthSize ? 1 : 0;
+ fxMesa->verbose = verbose;
+ fxMesa->board = glbCurrentBoard;
- fxMesa->glideContext = FX_grSstWinOpen((FxU32)win,res,ref,
+ fxMesa->glideContext = FX_grSstWinOpen((FxU32) win, res, ref,
#if FXMESA_USE_ARGB
GR_COLORFORMAT_ARGB,
#else
GR_COLORFORMAT_ABGR,
#endif
- GR_ORIGIN_LOWER_LEFT,
- 2,aux);
- if (!fxMesa->glideContext){
- errorstr = "grSstWinOpen";
+ GR_ORIGIN_LOWER_LEFT, 2, aux);
+ if (!fxMesa->glideContext) {
+ errorstr = "grSstWinOpen";
goto errorhandler;
}
@@ -387,8 +403,8 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
* Pixel tables are use during pixel read-back
* Either initialize them for RGB or BGR order.
*/
-#if FXMESA_USE_ARGB
- useBGR = GL_FALSE; /* Force RGB pixel order */
+#if FXMESA_USE_ARGB
+ useBGR = GL_FALSE; /* Force RGB pixel order */
system = "FXMESA_USE_ARGB";
#else
if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) {
@@ -404,65 +420,64 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
if (voodoo->nTexelfx == 1) {
- /* Voodoo1 or Banshee */
- useBGR = GL_TRUE;
- system = "Voodoo1";
+ /* Voodoo1 or Banshee */
+ useBGR = GL_TRUE;
+ system = "Voodoo1";
}
else if (voodoo->nTexelfx == 2 &&
- voodoo->fbiRev == 260 &&
- voodoo->tmuConfig[0].tmuRev == 4 &&
- (voodoo->tmuConfig[0].tmuRam == 2 ||
- voodoo->tmuConfig[0].tmuRam == 4)) {
- /* Voodoo 2 */
- useBGR = GL_TRUE;
- system = "Voodoo2";
+ voodoo->fbiRev == 260 &&
+ voodoo->tmuConfig[0].tmuRev == 4 &&
+ (voodoo->tmuConfig[0].tmuRam == 2 ||
+ voodoo->tmuConfig[0].tmuRam == 4)) {
+ /* Voodoo 2 */
+ useBGR = GL_TRUE;
+ system = "Voodoo2";
}
else if (voodoo->nTexelfx == 2 &&
- voodoo->fbiRev == 2 &&
- voodoo->tmuConfig[0].tmuRev == 1 &&
- voodoo->tmuConfig[0].tmuRam == 4) {
- /* Quantum3D Obsidian 50/100 */
- useBGR = GL_TRUE;
- system = "Quantum3D Obsidian";
+ voodoo->fbiRev == 2 &&
+ voodoo->tmuConfig[0].tmuRev == 1 &&
+ voodoo->tmuConfig[0].tmuRam == 4) {
+ /* Quantum3D Obsidian 50/100 */
+ useBGR = GL_TRUE;
+ system = "Quantum3D Obsidian";
}
- else
- /* Brian
- * (voodoo->nTexelfx == 2 &&
- * voodoo->fbiRev == 0 &&
- * voodoo->tmuConfig[0].tmuRev == 148441048 &&
- * voodoo->tmuConfig[0].tmuRam == 3)
- * Bernd
- * (voodoo->nTexelfx == 2 &&
- * voodoo->fbiRev == 69634 &&
- * voodoo->tmuConfig[0].tmuRev == 69634 &&
- * voodoo->tmuConfig[0].tmuRam == 2 )
- */
+ else
+ /* Brian
+ * (voodoo->nTexelfx == 2 &&
+ * voodoo->fbiRev == 0 &&
+ * voodoo->tmuConfig[0].tmuRev == 148441048 &&
+ * voodoo->tmuConfig[0].tmuRam == 3)
+ * Bernd
+ * (voodoo->nTexelfx == 2 &&
+ * voodoo->fbiRev == 69634 &&
+ * voodoo->tmuConfig[0].tmuRev == 69634 &&
+ * voodoo->tmuConfig[0].tmuRam == 2 )
+ */
{
- /* Presumed Voodoo3 */
- useBGR = GL_FALSE;
- system = "Voodoo3";
+ /* Presumed Voodoo3 */
+ useBGR = GL_FALSE;
+ system = "Voodoo3";
}
- if (getenv("MESA_FX_INFO")) {
- printf("Voodoo: Texelfx: %d / FBI Rev.: %d / TMU Rev.: %d / TMU RAM: %d\n",
- voodoo->nTexelfx,
- voodoo->fbiRev,
- voodoo->tmuConfig[0].tmuRev,
- voodoo->tmuConfig[0].tmuRam );
+ if (getenv("MESA_FX_INFO")) {
+ printf
+ ("Voodoo: Texelfx: %d / FBI Rev.: %d / TMU Rev.: %d / TMU RAM: %d\n",
+ voodoo->nTexelfx, voodoo->fbiRev, voodoo->tmuConfig[0].tmuRev,
+ voodoo->tmuConfig[0].tmuRam);
}
}
else {
- useBGR = GL_FALSE; /* use RGB pixel order otherwise */
+ useBGR = GL_FALSE; /* use RGB pixel order otherwise */
system = "non-voodoo";
}
-#endif /*FXMESA_USE_ARGB*/
+#endif /*FXMESA_USE_ARGB */
- if (getenv("MESA_FX_INFO"))
+ if (getenv("MESA_FX_INFO"))
printf("Voodoo pixel order: %s (%s)\n", useBGR ? "BGR" : "RGB", system);
fxInitPixelTables(fxMesa, useBGR);
- fxMesa->width=FX_grSstScreenWidth();
- fxMesa->height=FX_grSstScreenHeight();
+ fxMesa->width = FX_grSstScreenWidth();
+ fxMesa->height = FX_grSstScreenHeight();
fxMesa->clipMinX = 0;
fxMesa->clipMaxX = fxMesa->width;
@@ -471,71 +486,69 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
fxMesa->screen_width = fxMesa->width;
fxMesa->screen_height = fxMesa->height;
-
+
fxMesa->new_state = ~0;
- if(verbose)
- fprintf(stderr,"Voodoo Glide screen size: %dx%d\n",
- (int)FX_grSstScreenWidth(),(int)FX_grSstScreenHeight());
-
- fxMesa->glVis=_mesa_create_visual(GL_TRUE, /* RGB mode */
- doubleBuffer,
- GL_FALSE, /* stereo */
- 5,6,5,0, /* RGBA bits */
- 0, /* index bits */
- depthSize, /* depth_size */
- stencilSize, /* stencil_size */
- accumSize, accumSize, accumSize, accumSize,
- 1 );
+ if (verbose)
+ fprintf(stderr, "Voodoo Glide screen size: %dx%d\n",
+ (int) FX_grSstScreenWidth(), (int) FX_grSstScreenHeight());
+
+ fxMesa->glVis = _mesa_create_visual(GL_TRUE, /* RGB mode */
+ doubleBuffer, GL_FALSE, /* stereo */
+ 5, 6, 5, 0, /* RGBA bits */
+ 0, /* index bits */
+ depthSize, /* depth_size */
+ stencilSize, /* stencil_size */
+ accumSize, accumSize, accumSize,
+ accumSize, 1);
if (!fxMesa->glVis) {
errorstr = "_mesa_create_visual";
goto errorhandler;
}
- ctx = fxMesa->glCtx=_mesa_create_context(fxMesa->glVis,
- shareCtx, /* share list context */
- (void *) fxMesa, GL_TRUE);
+ ctx = fxMesa->glCtx = _mesa_create_context(fxMesa->glVis, shareCtx, /* share list context */
+ (void *) fxMesa, GL_TRUE);
if (!ctx) {
errorstr = "_mesa_create_context";
goto errorhandler;
}
- if (!fxDDInitFxMesaContext( fxMesa )) {
- errorstr = "fxDDInitFxMesaContext failed";
+ if (!fxDDInitFxMesaContext(fxMesa)) {
+ errorstr = "fxDDInitFxMesaContext failed";
goto errorhandler;
}
- fxMesa->glBuffer=_mesa_create_framebuffer(fxMesa->glVis,
- GL_FALSE, /* no software depth */
- fxMesa->glVis->stencilBits > 0,
- fxMesa->glVis->accumRedBits > 0,
- fxMesa->glVis->alphaBits > 0 );
+ fxMesa->glBuffer = _mesa_create_framebuffer(fxMesa->glVis, GL_FALSE, /* no software depth */
+ fxMesa->glVis->stencilBits > 0,
+ fxMesa->glVis->accumRedBits >
+ 0,
+ fxMesa->glVis->alphaBits > 0);
if (!fxMesa->glBuffer) {
errorstr = "_mesa_create_framebuffer";
goto errorhandler;
}
-
+
glbTotNumCtx++;
/* install signal handlers */
#if defined(__linux__)
/* Only install if environment var. is not set. */
if (fxMesa->glCtx->CatchSignals && !getenv("MESA_FX_NO_SIGNALS")) {
- signal(SIGINT,cleangraphics_handler);
- signal(SIGHUP,cleangraphics_handler);
- signal(SIGPIPE,cleangraphics_handler);
- signal(SIGFPE,cleangraphics_handler);
- signal(SIGBUS,cleangraphics_handler);
- signal(SIGILL,cleangraphics_handler);
- signal(SIGSEGV,cleangraphics_handler);
- signal(SIGTERM,cleangraphics_handler);
+ signal(SIGINT, cleangraphics_handler);
+ signal(SIGHUP, cleangraphics_handler);
+ signal(SIGPIPE, cleangraphics_handler);
+ signal(SIGFPE, cleangraphics_handler);
+ signal(SIGBUS, cleangraphics_handler);
+ signal(SIGILL, cleangraphics_handler);
+ signal(SIGSEGV, cleangraphics_handler);
+ signal(SIGTERM, cleangraphics_handler);
}
#endif
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaCreateContext() End\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxMesaCreateContext() End\n");
}
return fxMesa;
@@ -545,8 +558,8 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
if (fxMesa->glideContext)
FX_grSstWinClose(fxMesa->glideContext);
fxMesa->glideContext = 0;
-
- if (fxMesa->state)
+
+ if (fxMesa->state)
free(fxMesa->state);
if (fxMesa->fogTable)
free(fxMesa->fogTable);
@@ -558,9 +571,9 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
_mesa_destroy_context(fxMesa->glCtx);
free(fxMesa);
}
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaCreateContext() End (%s)\n",errorstr);
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxMesaCreateContext() End (%s)\n", errorstr);
}
return NULL;
}
@@ -569,52 +582,59 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
/*
* Function to set the new window size in the context (mainly for the Voodoo Rush)
*/
-void GLAPIENTRY fxMesaUpdateScreenSize(fxMesaContext fxMesa)
+void GLAPIENTRY
+fxMesaUpdateScreenSize(fxMesaContext fxMesa)
{
- fxMesa->width=FX_grSstScreenWidth();
- fxMesa->height=FX_grSstScreenHeight();
+ fxMesa->width = FX_grSstScreenWidth();
+ fxMesa->height = FX_grSstScreenHeight();
}
/*
* Destroy the given FX/Mesa context.
*/
-void GLAPIENTRY fxMesaDestroyContext(fxMesaContext fxMesa)
+void GLAPIENTRY
+fxMesaDestroyContext(fxMesaContext fxMesa)
{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaDestroyContext()\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxMesaDestroyContext()\n");
}
- if(!fxMesa)
+ if (!fxMesa)
return;
- if(fxMesa->verbose) {
- fprintf(stderr,"Misc Stats:\n");
- fprintf(stderr," # swap buffer: %u\n",fxMesa->stats.swapBuffer);
+ if (fxMesa->verbose) {
+ fprintf(stderr, "Misc Stats:\n");
+ fprintf(stderr, " # swap buffer: %u\n", fxMesa->stats.swapBuffer);
- if(!fxMesa->stats.swapBuffer)
- fxMesa->stats.swapBuffer=1;
+ if (!fxMesa->stats.swapBuffer)
+ fxMesa->stats.swapBuffer = 1;
- fprintf(stderr,"Textures Stats:\n");
- fprintf(stderr," Free texture memory on TMU0: %d:\n",fxMesa->freeTexMem[FX_TMU0]);
- if(fxMesa->haveTwoTMUs)
- fprintf(stderr," Free texture memory on TMU1: %d:\n",fxMesa->freeTexMem[FX_TMU1]);
- fprintf(stderr," # request to TMM to upload a texture objects: %u\n",
+ fprintf(stderr, "Textures Stats:\n");
+ fprintf(stderr, " Free texture memory on TMU0: %d:\n",
+ fxMesa->freeTexMem[FX_TMU0]);
+ if (fxMesa->haveTwoTMUs)
+ fprintf(stderr, " Free texture memory on TMU1: %d:\n",
+ fxMesa->freeTexMem[FX_TMU1]);
+ fprintf(stderr, " # request to TMM to upload a texture objects: %u\n",
fxMesa->stats.reqTexUpload);
- fprintf(stderr," # request to TMM to upload a texture objects per swapbuffer: %.2f\n",
- fxMesa->stats.reqTexUpload/(float)fxMesa->stats.swapBuffer);
- fprintf(stderr," # texture objects uploaded: %u\n",
+ fprintf(stderr,
+ " # request to TMM to upload a texture objects per swapbuffer: %.2f\n",
+ fxMesa->stats.reqTexUpload / (float) fxMesa->stats.swapBuffer);
+ fprintf(stderr, " # texture objects uploaded: %u\n",
fxMesa->stats.texUpload);
- fprintf(stderr," # texture objects uploaded per swapbuffer: %.2f\n",
- fxMesa->stats.texUpload/(float)fxMesa->stats.swapBuffer);
- fprintf(stderr," # MBs uploaded to texture memory: %.2f\n",
- fxMesa->stats.memTexUpload/(float)(1<<20));
- fprintf(stderr," # MBs uploaded to texture memory per swapbuffer: %.2f\n",
- (fxMesa->stats.memTexUpload/(float)fxMesa->stats.swapBuffer)/(float)(1<<20));
+ fprintf(stderr, " # texture objects uploaded per swapbuffer: %.2f\n",
+ fxMesa->stats.texUpload / (float) fxMesa->stats.swapBuffer);
+ fprintf(stderr, " # MBs uploaded to texture memory: %.2f\n",
+ fxMesa->stats.memTexUpload / (float) (1 << 20));
+ fprintf(stderr,
+ " # MBs uploaded to texture memory per swapbuffer: %.2f\n",
+ (fxMesa->stats.memTexUpload /
+ (float) fxMesa->stats.swapBuffer) / (float) (1 << 20));
}
glbTotNumCtx--;
-
+
fxDDDestroyFxMesaContext(fxMesa);
_mesa_destroy_visual(fxMesa->glVis);
_mesa_destroy_context(fxMesa->glCtx);
@@ -625,65 +645,68 @@ void GLAPIENTRY fxMesaDestroyContext(fxMesaContext fxMesa)
free(fxMesa);
- if(fxMesa==fxMesaCurrentCtx)
- fxMesaCurrentCtx=NULL;
+ if (fxMesa == fxMesaCurrentCtx)
+ fxMesaCurrentCtx = NULL;
}
/*
* Make the specified FX/Mesa context the current one.
*/
-void GLAPIENTRY fxMesaMakeCurrent(fxMesaContext fxMesa)
+void GLAPIENTRY
+fxMesaMakeCurrent(fxMesaContext fxMesa)
{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaMakeCurrent(...) Start\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxMesaMakeCurrent(...) Start\n");
+ }
- if(!fxMesa) {
- _mesa_make_current(NULL,NULL);
- fxMesaCurrentCtx=NULL;
+ if (!fxMesa) {
+ _mesa_make_current(NULL, NULL);
+ fxMesaCurrentCtx = NULL;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaMakeCurrent(NULL) End\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxMesaMakeCurrent(NULL) End\n");
+ }
- return;
- }
+ return;
+ }
- /* if this context is already the current one, we can return early */
- if (fxMesaCurrentCtx == fxMesa
- && fxMesaCurrentCtx->glCtx == _mesa_get_current_context()) {
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaMakeCurrent(fxMesaCurrentCtx==fxMesa) End\n");
- }
+ /* if this context is already the current one, we can return early */
+ if (fxMesaCurrentCtx == fxMesa
+ && fxMesaCurrentCtx->glCtx == _mesa_get_current_context()) {
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr,
+ "fxmesa: fxMesaMakeCurrent(fxMesaCurrentCtx==fxMesa) End\n");
+ }
- return;
- }
+ return;
+ }
- if(fxMesaCurrentCtx)
- grGlideGetState((GrState*)fxMesaCurrentCtx->state);
+ if (fxMesaCurrentCtx)
+ grGlideGetState((GrState *) fxMesaCurrentCtx->state);
- fxMesaCurrentCtx=fxMesa;
+ fxMesaCurrentCtx = fxMesa;
- grSstSelect(fxMesa->board);
- grGlideSetState((GrState*)fxMesa->state);
+ grSstSelect(fxMesa->board);
+ grGlideSetState((GrState *) fxMesa->state);
- _mesa_make_current(fxMesa->glCtx,fxMesa->glBuffer);
+ _mesa_make_current(fxMesa->glCtx, fxMesa->glBuffer);
- fxSetupDDPointers(fxMesa->glCtx);
+ fxSetupDDPointers(fxMesa->glCtx);
- /* The first time we call MakeCurrent we set the initial viewport size */
- if(fxMesa->glCtx->Viewport.Width==0)
- _mesa_set_viewport(fxMesa->glCtx,0,0,fxMesa->width,fxMesa->height);
+ /* The first time we call MakeCurrent we set the initial viewport size */
+ if (fxMesa->glCtx->Viewport.Width == 0)
+ _mesa_set_viewport(fxMesa->glCtx, 0, 0, fxMesa->width, fxMesa->height);
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaMakeCurrent(...) End\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxMesaMakeCurrent(...) End\n");
+ }
}
#if 0
-static void QueryCounters(void)
+static void
+QueryCounters(void)
{
static GLuint prevPassed = 0;
static GLuint prevFailed = 0;
@@ -693,7 +716,8 @@ static void QueryCounters(void)
FX_grSstPerfStats(&st);
failed = st.zFuncFail - st.aFuncFail - st.chromaFail;
passed = st.pixelsIn - failed;
- printf("failed: %d passed: %d\n", failed - prevFailed, passed - prevPassed);
+ printf("failed: %d passed: %d\n", failed - prevFailed,
+ passed - prevPassed);
prevPassed = passed;
prevFailed = failed;
@@ -704,126 +728,148 @@ static void QueryCounters(void)
/*
* Swap front/back buffers for current context if double buffered.
*/
-void GLAPIENTRY fxMesaSwapBuffers(void)
+void GLAPIENTRY
+fxMesaSwapBuffers(void)
{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: ------------------------------- fxMesaSwapBuffers() -------------------------------\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr,
+ "fxmesa: ------------------------------- fxMesaSwapBuffers() -------------------------------\n");
+ }
- if(fxMesaCurrentCtx) {
- _mesa_swapbuffers( fxMesaCurrentCtx->glCtx );
+ if (fxMesaCurrentCtx) {
+ _mesa_swapbuffers(fxMesaCurrentCtx->glCtx);
- if(fxMesaCurrentCtx->haveDoubleBuffer) {
+ if (fxMesaCurrentCtx->haveDoubleBuffer) {
- grBufferSwap(fxMesaCurrentCtx->swapInterval);
+ grBufferSwap(fxMesaCurrentCtx->swapInterval);
- /*
- * Don't allow swap buffer commands to build up!
- */
- while(FX_grGetInteger(FX_PENDING_BUFFERSWAPS)>fxMesaCurrentCtx->maxPendingSwapBuffers)
- /* The driver is able to sleep when waiting for the completation
- of multiple swapbuffer operations instead of wasting
- CPU time (NOTE: you must uncomment the following line in the
- in order to enable this option) */
- /* usleep(10000); */
- ;
-
- fxMesaCurrentCtx->stats.swapBuffer++;
- }
- }
+ /*
+ * Don't allow swap buffer commands to build up!
+ */
+ while (FX_grGetInteger(FX_PENDING_BUFFERSWAPS) >
+ fxMesaCurrentCtx->maxPendingSwapBuffers)
+ /* The driver is able to sleep when waiting for the completation
+ of multiple swapbuffer operations instead of wasting
+ CPU time (NOTE: you must uncomment the following line in the
+ in order to enable this option) */
+ /* usleep(10000); */
+ ;
+
+ fxMesaCurrentCtx->stats.swapBuffer++;
+ }
+ }
}
/*
* Query 3Dfx hardware presence/kind
*/
-int GLAPIENTRY fxQueryHardware(void)
+int GLAPIENTRY
+fxQueryHardware(void)
{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxQueryHardware() Start\n");
- }
-
- if (!glbGlideInitialized) {
- grGlideInit();
- if (FX_grSstQueryHardware(&glbHWConfig)) {
- grSstSelect(glbCurrentBoard);
- glb3DfxPresent = 1;
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxQueryHardware() Start\n");
+ }
- if (getenv("MESA_FX_INFO")) {
- char buf[80];
-
- FX_grGlideGetVersion(buf);
- fprintf(stderr, "Voodoo Using Glide V%s\n", buf);
- fprintf(stderr, "Voodoo Number of boards: %d\n", glbHWConfig.num_sst);
-
- if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) {
- GrVoodooConfig_t *voodoo;
- voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
-
- fprintf(stderr, "Voodoo Framebuffer RAM: %d\n",
- voodoo->sliDetect ? (voodoo->fbRam*2) : voodoo->fbRam);
- fprintf(stderr, "Voodoo Number of TMUs: %d\n", voodoo->nTexelfx);
- fprintf(stderr, "Voodoo fbRam: %d\n", voodoo->fbRam);
- fprintf(stderr, "Voodoo fbiRev: %d\n", voodoo->fbiRev);
-
- fprintf(stderr,"Voodoo SLI detected: %d\n", voodoo->sliDetect);
- }
- else if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_SST96) {
- GrSst96Config_t *sst96;
- sst96 = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config;
- fprintf(stderr, "Voodoo Framebuffer RAM: %d\n", sst96->fbRam);
- fprintf(stderr, "Voodoo Number of TMUs: %d\n", sst96->nTexelfx);
- }
+ if (!glbGlideInitialized) {
+ grGlideInit();
+ if (FX_grSstQueryHardware(&glbHWConfig)) {
+ grSstSelect(glbCurrentBoard);
+ glb3DfxPresent = 1;
+
+ if (getenv("MESA_FX_INFO")) {
+ char buf[80];
+
+ FX_grGlideGetVersion(buf);
+ fprintf(stderr, "Voodoo Using Glide V%s\n", buf);
+ fprintf(stderr, "Voodoo Number of boards: %d\n",
+ glbHWConfig.num_sst);
+
+ if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) {
+ GrVoodooConfig_t *voodoo;
+ voodoo =
+ &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
+
+ fprintf(stderr, "Voodoo Framebuffer RAM: %d\n",
+ voodoo->sliDetect ? (voodoo->fbRam *
+ 2) : voodoo->fbRam);
+ fprintf(stderr, "Voodoo Number of TMUs: %d\n",
+ voodoo->nTexelfx);
+ fprintf(stderr, "Voodoo fbRam: %d\n", voodoo->fbRam);
+ fprintf(stderr, "Voodoo fbiRev: %d\n", voodoo->fbiRev);
+
+ fprintf(stderr, "Voodoo SLI detected: %d\n",
+ voodoo->sliDetect);
+ }
+ else if (glbHWConfig.SSTs[glbCurrentBoard].type ==
+ GR_SSTTYPE_SST96) {
+ GrSst96Config_t *sst96;
+ sst96 =
+ &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config;
+ fprintf(stderr, "Voodoo Framebuffer RAM: %d\n", sst96->fbRam);
+ fprintf(stderr, "Voodoo Number of TMUs: %d\n",
+ sst96->nTexelfx);
+ }
+ }
+ }
+ else {
+ glb3DfxPresent = 0;
}
- }
- else {
- glb3DfxPresent = 0;
- }
- glbGlideInitialized = 1;
+ glbGlideInitialized = 1;
#if defined(__WIN32__)
- onexit((_onexit_t)cleangraphics);
+ onexit((_onexit_t) cleangraphics);
#elif defined(__linux__)
- /* Only register handler if environment variable is not defined. */
- if (!getenv("MESA_FX_NO_SIGNALS")) {
- atexit(cleangraphics);
- }
+ /* Only register handler if environment variable is not defined. */
+ if (!getenv("MESA_FX_NO_SIGNALS")) {
+ atexit(cleangraphics);
+ }
#endif
- }
+ }
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxQueryHardware() End (voodooo)\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxQueryHardware() End (voodooo)\n");
+ }
- return glbHWConfig.SSTs[glbCurrentBoard].type;
+ return glbHWConfig.SSTs[glbCurrentBoard].type;
}
/*
* Shutdown Glide library
*/
-void GLAPIENTRY fxCloseHardware(void)
+void GLAPIENTRY
+fxCloseHardware(void)
{
- if (glbGlideInitialized) {
- if (getenv("MESA_FX_INFO")) {
- GrSstPerfStats_t st;
-
- FX_grSstPerfStats(&st);
- fprintf(stderr,"Pixels Stats:\n");
- fprintf(stderr," # pixels processed (minus buffer clears): %u\n",(unsigned)st.pixelsIn);
- fprintf(stderr," # pixels not drawn due to chroma key test failure: %u\n",(unsigned)st.chromaFail);
- fprintf(stderr," # pixels not drawn due to depth test failure: %u\n",(unsigned)st.zFuncFail);
- fprintf(stderr," # pixels not drawn due to alpha test failure: %u\n",(unsigned)st.aFuncFail);
- fprintf(stderr," # pixels drawn (including buffer clears and LFB writes): %u\n",(unsigned)st.pixelsOut);
- }
-
- if (glbTotNumCtx == 0) {
- grGlideShutdown();
- glbGlideInitialized = 0;
- }
- }
+ if (glbGlideInitialized) {
+ if (getenv("MESA_FX_INFO")) {
+ GrSstPerfStats_t st;
+
+ FX_grSstPerfStats(&st);
+ fprintf(stderr, "Pixels Stats:\n");
+ fprintf(stderr, " # pixels processed (minus buffer clears): %u\n",
+ (unsigned) st.pixelsIn);
+ fprintf(stderr,
+ " # pixels not drawn due to chroma key test failure: %u\n",
+ (unsigned) st.chromaFail);
+ fprintf(stderr,
+ " # pixels not drawn due to depth test failure: %u\n",
+ (unsigned) st.zFuncFail);
+ fprintf(stderr,
+ " # pixels not drawn due to alpha test failure: %u\n",
+ (unsigned) st.aFuncFail);
+ fprintf(stderr,
+ " # pixels drawn (including buffer clears and LFB writes): %u\n",
+ (unsigned) st.pixelsOut);
+ }
+
+ if (glbTotNumCtx == 0) {
+ grGlideShutdown();
+ glbGlideInitialized = 0;
+ }
+ }
}
@@ -834,9 +880,10 @@ void GLAPIENTRY fxCloseHardware(void)
* Need this to provide at least one external definition.
*/
extern int gl_fx_dummy_function_api(void);
-int gl_fx_dummy_function_api(void)
+int
+gl_fx_dummy_function_api(void)
{
- return 0;
+ return 0;
}
-#endif /* FX */
+#endif /* FX */
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index dc7137a933..83a5196683 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -79,30 +79,31 @@ GLubyte FX_PixelToB[0x10000];
* Initialize the FX_PixelTo{RGB} arrays.
* Input: bgrOrder - if TRUE, pixels are in BGR order, else RGB order.
*/
-void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder)
+void
+fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder)
{
- GLuint pixel;
-
- fxMesa->bgrOrder=bgrOrder;
- for (pixel = 0; pixel <= 0xffff; pixel++) {
- GLuint r, g, b;
- if (bgrOrder) {
- r = (pixel & 0x001F) << 3;
- g = (pixel & 0x07E0) >> 3;
- b = (pixel & 0xF800) >> 8;
- }
- else {
- r = (pixel & 0xF800) >> 8;
- g = (pixel & 0x07E0) >> 3;
- b = (pixel & 0x001F) << 3;
- }
- r = r * 255 / 0xF8; /* fill in low-order bits */
- g = g * 255 / 0xFC;
- b = b * 255 / 0xF8;
- FX_PixelToR[pixel] = r;
- FX_PixelToG[pixel] = g;
- FX_PixelToB[pixel] = b;
- }
+ GLuint pixel;
+
+ fxMesa->bgrOrder = bgrOrder;
+ for (pixel = 0; pixel <= 0xffff; pixel++) {
+ GLuint r, g, b;
+ if (bgrOrder) {
+ r = (pixel & 0x001F) << 3;
+ g = (pixel & 0x07E0) >> 3;
+ b = (pixel & 0xF800) >> 8;
+ }
+ else {
+ r = (pixel & 0xF800) >> 8;
+ g = (pixel & 0x07E0) >> 3;
+ b = (pixel & 0x001F) << 3;
+ }
+ r = r * 255 / 0xF8; /* fill in low-order bits */
+ g = g * 255 / 0xFC;
+ b = b * 255 / 0xF8;
+ FX_PixelToR[pixel] = r;
+ FX_PixelToG[pixel] = g;
+ FX_PixelToB[pixel] = b;
+ }
}
@@ -111,78 +112,81 @@ void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder)
/**********************************************************************/
/* Return buffer size information */
-static void fxDDBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
+static void
+fxDDBufferSize(GLcontext * ctx, GLuint * width, GLuint * height)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDBufferSize(...) Start\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDBufferSize(...) Start\n");
+ }
- *width=fxMesa->width;
- *height=fxMesa->height;
+ *width = fxMesa->width;
+ *height = fxMesa->height;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDBufferSize(...) End\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDBufferSize(...) End\n");
+ }
}
/* Implements glClearColor() */
-static void fxDDClearColor(GLcontext *ctx, const GLchan color[4])
+static void
+fxDDClearColor(GLcontext * ctx, const GLchan color[4])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLubyte col[4];
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLubyte col[4];
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDClearColor(%d,%d,%d,%d)\n",
- color[0], color[1], color[2], color[3]);
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDClearColor(%d,%d,%d,%d)\n",
+ color[0], color[1], color[2], color[3]);
+ }
- ASSIGN_4V( col, color[0], color[1], color[2], 255 );
- fxMesa->clearC = FXCOLOR4( col );
- fxMesa->clearA = color[3];
+ ASSIGN_4V(col, color[0], color[1], color[2], 255);
+ fxMesa->clearC = FXCOLOR4(col);
+ fxMesa->clearA = color[3];
}
/* Clear the color and/or depth buffers */
-static void fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+static void
+fxDDClear(GLcontext * ctx, GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
- const FxU16 clearD = (FxU16) (ctx->Depth.Clear * 0xffff);
- GLbitfield softwareMask = mask & (DD_STENCIL_BIT | DD_ACCUM_BIT);
-
- /* we can't clear stencil or accum buffers */
- mask &= ~(DD_STENCIL_BIT | DD_ACCUM_BIT);
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDClear(%d,%d,%d,%d)\n", (int) x, (int) y,
- (int) width, (int) height);
- }
-
- if (colorMask != 0xffffffff) {
- /* do masked color buffer clears in software */
- softwareMask |= (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
- mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
- }
-
- /*
- * This could probably be done fancier but doing each possible case
- * explicitly is less error prone.
- */
- switch (mask) {
- case DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask);
+ const FxU16 clearD = (FxU16) (ctx->Depth.Clear * 0xffff);
+ GLbitfield softwareMask = mask & (DD_STENCIL_BIT | DD_ACCUM_BIT);
+
+ /* we can't clear stencil or accum buffers */
+ mask &= ~(DD_STENCIL_BIT | DD_ACCUM_BIT);
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDClear(%d,%d,%d,%d)\n", (int) x, (int) y,
+ (int) width, (int) height);
+ }
+
+ if (colorMask != 0xffffffff) {
+ /* do masked color buffer clears in software */
+ softwareMask |= (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
+ mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
+ }
+
+ /*
+ * This could probably be done fancier but doing each possible case
+ * explicitly is less error prone.
+ */
+ switch (mask) {
+ case DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
/* back buffer & depth */
FX_grDepthMask(FXTRUE);
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
if (!ctx->Depth.Mask) {
- FX_grDepthMask(FXFALSE);
+ FX_grDepthMask(FXFALSE);
}
break;
- case DD_FRONT_LEFT_BIT | DD_DEPTH_BIT:
+ case DD_FRONT_LEFT_BIT | DD_DEPTH_BIT:
/* XXX it appears that the depth buffer isn't cleared when
* glRenderBuffer(GR_BUFFER_FRONTBUFFER) is set.
* This is a work-around/
@@ -190,32 +194,33 @@ static void fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
/* clear depth */
FX_grDepthMask(FXTRUE);
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- FX_grColorMask(FXFALSE,FXFALSE);
+ FX_grColorMask(FXFALSE, FXFALSE);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
/* clear front */
- FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
+ FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP]
+ && fxMesa->haveAlphaBuffer);
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
break;
- case DD_BACK_LEFT_BIT:
+ case DD_BACK_LEFT_BIT:
/* back buffer only */
FX_grDepthMask(FXFALSE);
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
if (ctx->Depth.Mask) {
- FX_grDepthMask(FXTRUE);
+ FX_grDepthMask(FXTRUE);
}
break;
- case DD_FRONT_LEFT_BIT:
+ case DD_FRONT_LEFT_BIT:
/* front buffer only */
FX_grDepthMask(FXFALSE);
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
if (ctx->Depth.Mask) {
- FX_grDepthMask(FXTRUE);
+ FX_grDepthMask(FXTRUE);
}
break;
- case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT:
+ case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT:
/* front and back */
FX_grDepthMask(FXFALSE);
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
@@ -223,10 +228,10 @@ static void fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
if (ctx->Depth.Mask) {
- FX_grDepthMask(FXTRUE);
+ FX_grDepthMask(FXTRUE);
}
break;
- case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
+ case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
/* clear front */
FX_grDepthMask(FXFALSE);
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
@@ -236,282 +241,281 @@ static void fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
if (!ctx->Depth.Mask) {
- FX_grDepthMask(FXFALSE);
+ FX_grDepthMask(FXFALSE);
}
break;
- case DD_DEPTH_BIT:
+ case DD_DEPTH_BIT:
/* just the depth buffer */
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- FX_grColorMask(FXFALSE,FXFALSE);
+ FX_grColorMask(FXFALSE, FXFALSE);
FX_grDepthMask(FXTRUE);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
- FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
+ FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP]
+ && fxMesa->haveAlphaBuffer);
if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT)
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+ FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
if (!ctx->Depth.Test || !ctx->Depth.Mask)
- FX_grDepthMask(FXFALSE);
+ FX_grDepthMask(FXFALSE);
break;
- default:
+ default:
/* error */
;
- }
+ }
- /* Clear any remaining buffers:
- */
- if (softwareMask)
- _swrast_Clear( ctx, softwareMask, all, x, y, width, height );
+ /* Clear any remaining buffers:
+ */
+ if (softwareMask)
+ _swrast_Clear(ctx, softwareMask, all, x, y, width, height);
}
/* Set the buffer used for drawing */
/* XXX support for separate read/draw buffers hasn't been tested */
-static GLboolean fxDDSetDrawBuffer(GLcontext *ctx, GLenum mode)
+static GLboolean
+fxDDSetDrawBuffer(GLcontext * ctx, GLenum mode)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDSetBuffer(%x)\n", (int) mode);
- }
-
- if (mode == GL_FRONT_LEFT) {
- fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
- FX_grRenderBuffer(fxMesa->currentFB);
- return GL_TRUE;
- }
- else if (mode == GL_BACK_LEFT) {
- fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
- FX_grRenderBuffer(fxMesa->currentFB);
- return GL_TRUE;
- }
- else if (mode == GL_NONE) {
- FX_grColorMask(FXFALSE,FXFALSE);
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDSetBuffer(%x)\n", (int) mode);
+ }
+
+ if (mode == GL_FRONT_LEFT) {
+ fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
+ FX_grRenderBuffer(fxMesa->currentFB);
+ return GL_TRUE;
+ }
+ else if (mode == GL_BACK_LEFT) {
+ fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
+ FX_grRenderBuffer(fxMesa->currentFB);
+ return GL_TRUE;
+ }
+ else if (mode == GL_NONE) {
+ FX_grColorMask(FXFALSE, FXFALSE);
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
+ }
}
/* Set the buffer used for reading */
/* XXX support for separate read/draw buffers hasn't been tested */
-static void fxDDSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer,
- GLenum mode )
+static void
+fxDDSetReadBuffer(GLcontext * ctx, GLframebuffer * buffer, GLenum mode)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- (void) buffer;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDSetBuffer(%x)\n", (int) mode);
- }
-
- if (mode == GL_FRONT_LEFT) {
- fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
- FX_grRenderBuffer(fxMesa->currentFB);
- }
- else if (mode == GL_BACK_LEFT) {
- fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
- FX_grRenderBuffer(fxMesa->currentFB);
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ (void) buffer;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDSetBuffer(%x)\n", (int) mode);
+ }
+
+ if (mode == GL_FRONT_LEFT) {
+ fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
+ FX_grRenderBuffer(fxMesa->currentFB);
+ }
+ else if (mode == GL_BACK_LEFT) {
+ fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
+ FX_grRenderBuffer(fxMesa->currentFB);
+ }
}
-static void fxDDDrawBitmap(GLcontext *ctx, GLint px, GLint py,
- GLsizei width, GLsizei height,
- const struct gl_pixelstore_attrib *unpack,
- const GLubyte *bitmap)
+static void
+fxDDDrawBitmap(GLcontext * ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte * bitmap)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GrLfbInfo_t info;
- FxU16 color;
- const struct gl_pixelstore_attrib *finalUnpack;
- struct gl_pixelstore_attrib scissoredUnpack;
-
- /* check if there's any raster operations enabled which we can't handle */
- if (ctx->Color.AlphaEnabled ||
- ctx->Color.BlendEnabled ||
- ctx->Depth.Test ||
- ctx->Fog.Enabled ||
- ctx->Color.ColorLogicOpEnabled ||
- ctx->Stencil.Enabled ||
- ctx->Scissor.Enabled ||
- ( ctx->DrawBuffer->UseSoftwareAlphaBuffers &&
- ctx->Color.ColorMask[ACOMP]) ||
- ctx->Color.MultiDrawBuffer)
- {
- _swrast_Bitmap( ctx, px, py, width, height, unpack, bitmap );
- return;
- }
-
-
- if (ctx->Scissor.Enabled) {
- /* This is a bit tricky, but by carefully adjusting the px, py,
- * width, height, skipPixels and skipRows values we can do
- * scissoring without special code in the rendering loop.
- *
- * KW: This code is never reached, see the test above.
- */
-
- /* we'll construct a new pixelstore struct */
- finalUnpack = &scissoredUnpack;
- scissoredUnpack = *unpack;
- if (scissoredUnpack.RowLength == 0)
- scissoredUnpack.RowLength = width;
-
- /* clip left */
- if (px < ctx->Scissor.X) {
- scissoredUnpack.SkipPixels += (ctx->Scissor.X - px);
- width -= (ctx->Scissor.X - px);
- px = ctx->Scissor.X;
- }
- /* clip right */
- if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) {
- width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width));
- }
- /* clip bottom */
- if (py < ctx->Scissor.Y) {
- scissoredUnpack.SkipRows += (ctx->Scissor.Y - py);
- height -= (ctx->Scissor.Y - py);
- py = ctx->Scissor.Y;
- }
- /* clip top */
- if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
- height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height));
- }
-
- if (width <= 0 || height <= 0)
- return;
- }
- else {
- finalUnpack = unpack;
- }
-
- /* compute pixel value */
- {
- GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f);
- GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f);
- GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f);
- /*GLint a = (GLint)(ctx->Current.RasterColor[3]*255.0f);*/
- if (fxMesa->bgrOrder)
- color = (FxU16)
- ( ((FxU16)0xf8 & b) << (11-3)) |
- ( ((FxU16)0xfc & g) << (5-3+1)) |
- ( ((FxU16)0xf8 & r) >> 3);
- else
- color = (FxU16)
- ( ((FxU16)0xf8 & r) << (11-3)) |
- ( ((FxU16)0xfc & g) << (5-3+1)) |
- ( ((FxU16)0xf8 & b) >> 3);
- }
-
- info.size = sizeof(info);
- if (!FX_grLfbLock(GR_LFB_WRITE_ONLY,
- fxMesa->currentFB,
- GR_LFBWRITEMODE_565,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GrLfbInfo_t info;
+ FxU16 color;
+ const struct gl_pixelstore_attrib *finalUnpack;
+ struct gl_pixelstore_attrib scissoredUnpack;
+
+ /* check if there's any raster operations enabled which we can't handle */
+ if (ctx->Color.AlphaEnabled ||
+ ctx->Color.BlendEnabled ||
+ ctx->Depth.Test ||
+ ctx->Fog.Enabled ||
+ ctx->Color.ColorLogicOpEnabled ||
+ ctx->Stencil.Enabled ||
+ ctx->Scissor.Enabled ||
+ (ctx->DrawBuffer->UseSoftwareAlphaBuffers &&
+ ctx->Color.ColorMask[ACOMP]) || ctx->Color.MultiDrawBuffer) {
+ _swrast_Bitmap(ctx, px, py, width, height, unpack, bitmap);
+ return;
+ }
+
+
+ if (ctx->Scissor.Enabled) {
+ /* This is a bit tricky, but by carefully adjusting the px, py,
+ * width, height, skipPixels and skipRows values we can do
+ * scissoring without special code in the rendering loop.
+ *
+ * KW: This code is never reached, see the test above.
+ */
+
+ /* we'll construct a new pixelstore struct */
+ finalUnpack = &scissoredUnpack;
+ scissoredUnpack = *unpack;
+ if (scissoredUnpack.RowLength == 0)
+ scissoredUnpack.RowLength = width;
+
+ /* clip left */
+ if (px < ctx->Scissor.X) {
+ scissoredUnpack.SkipPixels += (ctx->Scissor.X - px);
+ width -= (ctx->Scissor.X - px);
+ px = ctx->Scissor.X;
+ }
+ /* clip right */
+ if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) {
+ width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width));
+ }
+ /* clip bottom */
+ if (py < ctx->Scissor.Y) {
+ scissoredUnpack.SkipRows += (ctx->Scissor.Y - py);
+ height -= (ctx->Scissor.Y - py);
+ py = ctx->Scissor.Y;
+ }
+ /* clip top */
+ if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
+ height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height));
+ }
+
+ if (width <= 0 || height <= 0)
+ return;
+ }
+ else {
+ finalUnpack = unpack;
+ }
+
+ /* compute pixel value */
+ {
+ GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f);
+ GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f);
+ GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f);
+ /*GLint a = (GLint)(ctx->Current.RasterColor[3]*255.0f); */
+ if (fxMesa->bgrOrder)
+ color = (FxU16)
+ (((FxU16) 0xf8 & b) << (11 - 3)) |
+ (((FxU16) 0xfc & g) << (5 - 3 + 1)) | (((FxU16) 0xf8 & r) >> 3);
+ else
+ color = (FxU16)
+ (((FxU16) 0xf8 & r) << (11 - 3)) |
+ (((FxU16) 0xfc & g) << (5 - 3 + 1)) | (((FxU16) 0xf8 & b) >> 3);
+ }
+
+ info.size = sizeof(info);
+ if (!FX_grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_565,
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
#ifndef FX_SILENT
- fprintf(stderr,"fx Driver: error locking the linear frame buffer\n");
+ fprintf(stderr, "fx Driver: error locking the linear frame buffer\n");
#endif
- return;
- }
-
- {
- const GLint winX = 0;
- const GLint winY = fxMesa->height - 1;
- /* The dest stride depends on the hardware and whether we're drawing
- * to the front or back buffer. This compile-time test seems to do
- * the job for now.
- */
- const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */
-
- GLint row;
- /* compute dest address of bottom-left pixel in bitmap */
- GLushort *dst = (GLushort *) info.lfbPtr
- + (winY - py) * dstStride
- + (winX + px);
-
- for (row = 0; row < height; row++) {
- const GLubyte *src = (const GLubyte *) _mesa_image_address( finalUnpack,
- bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
- if (finalUnpack->LsbFirst) {
- /* least significan bit first */
- GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
- GLint col;
- for (col=0; col<width; col++) {
- if (*src & mask) {
- dst[col] = color;
- }
- if (mask == 128U) {
- src++;
- mask = 1U;
- }
- else {
- mask = mask << 1;
- }
- }
- if (mask != 1)
- src++;
- }
- else {
- /* most significan bit first */
- GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7);
- GLint col;
- for (col=0; col<width; col++) {
- if (*src & mask) {
- dst[col] = color;
- }
- if (mask == 1U) {
- src++;
- mask = 128U;
- }
- else {
- mask = mask >> 1;
- }
- }
- if (mask != 128)
- src++;
+ return;
+ }
+
+ {
+ const GLint winX = 0;
+ const GLint winY = fxMesa->height - 1;
+ /* The dest stride depends on the hardware and whether we're drawing
+ * to the front or back buffer. This compile-time test seems to do
+ * the job for now.
+ */
+ const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */
+
+ GLint row;
+ /* compute dest address of bottom-left pixel in bitmap */
+ GLushort *dst = (GLushort *) info.lfbPtr
+ + (winY - py) * dstStride + (winX + px);
+
+ for (row = 0; row < height; row++) {
+ const GLubyte *src =
+ (const GLubyte *) _mesa_image_address(finalUnpack,
+ bitmap, width, height,
+ GL_COLOR_INDEX, GL_BITMAP,
+ 0, row, 0);
+ if (finalUnpack->LsbFirst) {
+ /* least significan bit first */
+ GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
+ GLint col;
+ for (col = 0; col < width; col++) {
+ if (*src & mask) {
+ dst[col] = color;
+ }
+ if (mask == 128U) {
+ src++;
+ mask = 1U;
+ }
+ else {
+ mask = mask << 1;
+ }
+ }
+ if (mask != 1)
+ src++;
+ }
+ else {
+ /* most significan bit first */
+ GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7);
+ GLint col;
+ for (col = 0; col < width; col++) {
+ if (*src & mask) {
+ dst[col] = color;
+ }
+ if (mask == 1U) {
+ src++;
+ mask = 128U;
+ }
+ else {
+ mask = mask >> 1;
+ }
+ }
+ if (mask != 128)
+ src++;
+ }
+ dst -= dstStride;
}
- dst -= dstStride;
- }
- }
+ }
- FX_grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB);
+ FX_grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
}
-static void fxDDReadPixels( GLcontext *ctx, GLint x, GLint y,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const struct gl_pixelstore_attrib *packing,
- GLvoid *dstImage )
+static void
+fxDDReadPixels(GLcontext * ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing, GLvoid * dstImage)
{
if (ctx->_ImageTransferState) {
- _swrast_ReadPixels( ctx, x, y, width, height, format, type,
- packing, dstImage );
- return;
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
+ return;
}
else {
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
GrLfbInfo_t info;
BEGIN_BOARD_LOCK();
if (grLfbLock(GR_LFB_READ_ONLY,
fxMesa->currentFB,
GR_LFBWRITEMODE_ANY,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
const GLint winX = 0;
const GLint winY = fxMesa->height - 1;
- const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
+ const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
const GLushort *src = (const GLushort *) info.lfbPtr
+ (winY - y) * srcStride + (winX + x);
GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage,
- width, height, format, type, 0, 0, 0);
- GLint dstStride = _mesa_image_row_stride(packing, width, format, type);
+ width, height, format,
+ type, 0, 0, 0);
+ GLint dstStride =
+ _mesa_image_row_stride(packing, width, format, type);
if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
/* convert 5R6G5B into 8R8G8B */
@@ -532,7 +536,7 @@ static void fxDDReadPixels( GLcontext *ctx, GLint x, GLint y,
*d++ = FX_PixelToB[pixel1];
}
if (extraPixel) {
- GLushort pixel = src[width-1];
+ GLushort pixel = src[width - 1];
*d++ = FX_PixelToR[pixel];
*d++ = FX_PixelToG[pixel];
*d++ = FX_PixelToB[pixel];
@@ -562,7 +566,7 @@ static void fxDDReadPixels( GLcontext *ctx, GLint x, GLint y,
*d++ = 255;
}
if (extraPixel) {
- const GLushort pixel = src[width-1];
+ const GLushort pixel = src[width - 1];
*d++ = FX_PixelToR[pixel];
*d++ = FX_PixelToG[pixel];
*d++ = FX_PixelToB[pixel];
@@ -585,8 +589,8 @@ static void fxDDReadPixels( GLcontext *ctx, GLint x, GLint y,
else {
grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
END_BOARD_LOCK();
- _swrast_ReadPixels( ctx, x, y, width, height, format, type,
- packing, dstImage );
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
return;
}
@@ -598,9 +602,10 @@ static void fxDDReadPixels( GLcontext *ctx, GLint x, GLint y,
-static void fxDDFinish(GLcontext *ctx)
+static void
+fxDDFinish(GLcontext * ctx)
{
- FX_grFlush();
+ FX_grFlush();
}
@@ -611,70 +616,70 @@ static void fxDDFinish(GLcontext *ctx)
* checks for this rather than doing a glGet(GL_MAX_TEXTURE_SIZE).
* Why?
*/
-static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name)
+static const GLubyte *
+fxDDGetString(GLcontext * ctx, GLenum name)
{
- switch (name) {
- case GL_RENDERER:
+ switch (name) {
+ case GL_RENDERER:
{
- static char buf[80];
-
- if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) {
- GrVoodooConfig_t *vc =
- &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
-
- sprintf(buf,
- "Mesa Glide v0.30 Voodoo_Graphics %d "
- "CARD/%d FB/%d TM/%d TMU/%s",
- glbCurrentBoard,
- (vc->sliDetect ? (vc->fbRam*2) : vc->fbRam),
- (vc->tmuConfig[GR_TMU0].tmuRam +
- ((vc->nTexelfx>1) ? vc->tmuConfig[GR_TMU1].tmuRam : 0)),
- vc->nTexelfx,
- (vc->sliDetect ? "SLI" : "NOSLI"));
- }
- else if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96) {
- GrSst96Config_t *sc =
- &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config;
-
- sprintf(buf,
- "Glide v0.30 Voodoo_Rush %d "
- "CARD/%d FB/%d TM/%d TMU/NOSLI",
- glbCurrentBoard,
- sc->fbRam,
- sc->tmuConfig.tmuRam,
- sc->nTexelfx);
- }
- else {
- strcpy(buf, "Glide v0.30 UNKNOWN");
- }
- return (GLubyte *) buf;
+ static char buf[80];
+
+ if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) {
+ GrVoodooConfig_t *vc =
+ &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
+
+ sprintf(buf,
+ "Mesa Glide v0.30 Voodoo_Graphics %d "
+ "CARD/%d FB/%d TM/%d TMU/%s",
+ glbCurrentBoard,
+ (vc->sliDetect ? (vc->fbRam * 2) : vc->fbRam),
+ (vc->tmuConfig[GR_TMU0].tmuRam +
+ ((vc->nTexelfx > 1) ? vc->tmuConfig[GR_TMU1].
+ tmuRam : 0)), vc->nTexelfx,
+ (vc->sliDetect ? "SLI" : "NOSLI"));
+ }
+ else if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_SST96) {
+ GrSst96Config_t *sc =
+ &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config;
+
+ sprintf(buf,
+ "Glide v0.30 Voodoo_Rush %d "
+ "CARD/%d FB/%d TM/%d TMU/NOSLI",
+ glbCurrentBoard,
+ sc->fbRam, sc->tmuConfig.tmuRam, sc->nTexelfx);
+ }
+ else {
+ strcpy(buf, "Glide v0.30 UNKNOWN");
+ }
+ return (GLubyte *) buf;
}
- default:
+ default:
return NULL;
- }
+ }
}
static const struct gl_pipeline_stage *fx_pipeline[] = {
- &_tnl_vertex_transform_stage, /* TODO: Add the fastpath here */
- &_tnl_normal_transform_stage,
- &_tnl_lighting_stage,
+ &_tnl_vertex_transform_stage, /* TODO: Add the fastpath here */
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
&_tnl_fog_coordinate_stage, /* TODO: Omit fog stage */
- &_tnl_texgen_stage,
- &_tnl_texture_transform_stage,
- &_tnl_point_attenuation_stage,
- &_tnl_render_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_point_attenuation_stage,
+ &_tnl_render_stage,
0,
};
-int fxDDInitFxMesaContext( fxMesaContext fxMesa )
+int
+fxDDInitFxMesaContext(fxMesaContext fxMesa)
{
int i;
static int firsttime = 1;
- for (i = 0 ; i < 256 ; i++) {
+ for (i = 0; i < 256; i++) {
gl_ubyte_to_float_255_color_tab[i] = (float) i;
}
@@ -694,130 +699,134 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa )
if (!getenv("FX_DONT_FAKE_MULTITEX"))
fxMesa->emulateTwoTMUs = GL_TRUE;
- if(getenv("FX_GLIDE_SWAPINTERVAL"))
- fxMesa->swapInterval=atoi(getenv("FX_GLIDE_SWAPINTERVAL"));
+ if (getenv("FX_GLIDE_SWAPINTERVAL"))
+ fxMesa->swapInterval = atoi(getenv("FX_GLIDE_SWAPINTERVAL"));
else
- fxMesa->swapInterval=1;
+ fxMesa->swapInterval = 1;
- if(getenv("MESA_FX_SWAP_PENDING"))
- fxMesa->maxPendingSwapBuffers=atoi(getenv("MESA_FX_SWAP_PENDING"));
+ if (getenv("MESA_FX_SWAP_PENDING"))
+ fxMesa->maxPendingSwapBuffers = atoi(getenv("MESA_FX_SWAP_PENDING"));
else
- fxMesa->maxPendingSwapBuffers=2;
+ fxMesa->maxPendingSwapBuffers = 2;
- if(getenv("MESA_FX_INFO"))
- fxMesa->verbose=GL_TRUE;
+ if (getenv("MESA_FX_INFO"))
+ fxMesa->verbose = GL_TRUE;
else
- fxMesa->verbose=GL_FALSE;
+ fxMesa->verbose = GL_FALSE;
- fxMesa->color=0xffffffff;
- fxMesa->clearC=0;
- fxMesa->clearA=0;
+ fxMesa->color = 0xffffffff;
+ fxMesa->clearC = 0;
+ fxMesa->clearA = 0;
- fxMesa->stats.swapBuffer=0;
- fxMesa->stats.reqTexUpload=0;
- fxMesa->stats.texUpload=0;
- fxMesa->stats.memTexUpload=0;
+ fxMesa->stats.swapBuffer = 0;
+ fxMesa->stats.reqTexUpload = 0;
+ fxMesa->stats.texUpload = 0;
+ fxMesa->stats.memTexUpload = 0;
- fxMesa->tmuSrc=FX_TMU_NONE;
- fxMesa->lastUnitsMode=FX_UM_NONE;
+ fxMesa->tmuSrc = FX_TMU_NONE;
+ fxMesa->lastUnitsMode = FX_UM_NONE;
fxTMInit(fxMesa);
/* FX units setup */
- fxMesa->unitsState.alphaTestEnabled=GL_FALSE;
- fxMesa->unitsState.alphaTestFunc=GR_CMP_ALWAYS;
- fxMesa->unitsState.alphaTestRefValue=0;
+ fxMesa->unitsState.alphaTestEnabled = GL_FALSE;
+ fxMesa->unitsState.alphaTestFunc = GR_CMP_ALWAYS;
+ fxMesa->unitsState.alphaTestRefValue = 0;
- fxMesa->unitsState.blendEnabled=GL_FALSE;
- fxMesa->unitsState.blendSrcFuncRGB=GR_BLEND_ONE;
- fxMesa->unitsState.blendDstFuncRGB=GR_BLEND_ZERO;
- fxMesa->unitsState.blendSrcFuncAlpha=GR_BLEND_ONE;
- fxMesa->unitsState.blendDstFuncAlpha=GR_BLEND_ZERO;
+ fxMesa->unitsState.blendEnabled = GL_FALSE;
+ fxMesa->unitsState.blendSrcFuncRGB = GR_BLEND_ONE;
+ fxMesa->unitsState.blendDstFuncRGB = GR_BLEND_ZERO;
+ fxMesa->unitsState.blendSrcFuncAlpha = GR_BLEND_ONE;
+ fxMesa->unitsState.blendDstFuncAlpha = GR_BLEND_ZERO;
- fxMesa->unitsState.depthTestEnabled =GL_FALSE;
- fxMesa->unitsState.depthMask =GL_TRUE;
- fxMesa->unitsState.depthTestFunc =GR_CMP_LESS;
+ fxMesa->unitsState.depthTestEnabled = GL_FALSE;
+ fxMesa->unitsState.depthMask = GL_TRUE;
+ fxMesa->unitsState.depthTestFunc = GR_CMP_LESS;
FX_grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE);
- if(fxMesa->haveDoubleBuffer) {
- fxMesa->currentFB=GR_BUFFER_BACKBUFFER;
+ if (fxMesa->haveDoubleBuffer) {
+ fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- } else {
- fxMesa->currentFB=GR_BUFFER_FRONTBUFFER;
+ }
+ else {
+ fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
}
-
+
fxMesa->state = malloc(FX_grGetInteger(FX_GLIDE_STATE_SIZE));
- fxMesa->fogTable = malloc(FX_grGetInteger(FX_FOG_TABLE_ENTRIES) *
+ fxMesa->fogTable = malloc(FX_grGetInteger(FX_FOG_TABLE_ENTRIES) *
sizeof(GrFog_t));
-
+
if (!fxMesa->state || !fxMesa->fogTable) {
- if (fxMesa->state) free(fxMesa->state);
- if (fxMesa->fogTable) free(fxMesa->fogTable);
+ if (fxMesa->state)
+ free(fxMesa->state);
+ if (fxMesa->fogTable)
+ free(fxMesa->fogTable);
return 0;
}
- if(fxMesa->haveZBuffer)
+ if (fxMesa->haveZBuffer)
FX_grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
#if (!FXMESA_USE_ARGB)
- FX_grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); /* Not every Glide has this */
+ FX_grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); /* Not every Glide has this */
#endif
- fxMesa->textureAlign=FX_grGetInteger(FX_TEXTURE_ALIGN);
- fxMesa->glCtx->Const.MaxTextureLevels=9;
- fxMesa->glCtx->Const.MaxTextureSize=256;
- fxMesa->glCtx->Const.MaxTextureUnits=fxMesa->emulateTwoTMUs ? 2 : 1;
+ fxMesa->textureAlign = FX_grGetInteger(FX_TEXTURE_ALIGN);
+ fxMesa->glCtx->Const.MaxTextureLevels = 9;
+ fxMesa->glCtx->Const.MaxTextureSize = 256;
+ fxMesa->glCtx->Const.MaxTextureUnits = fxMesa->emulateTwoTMUs ? 2 : 1;
fxMesa->new_state = _NEW_ALL;
/* Initialize the software rasterizer and helper modules.
*/
- _swrast_CreateContext( fxMesa->glCtx );
- _ac_CreateContext( fxMesa->glCtx );
- _tnl_CreateContext( fxMesa->glCtx );
- _swsetup_CreateContext( fxMesa->glCtx );
+ _swrast_CreateContext(fxMesa->glCtx);
+ _ac_CreateContext(fxMesa->glCtx);
+ _tnl_CreateContext(fxMesa->glCtx);
+ _swsetup_CreateContext(fxMesa->glCtx);
+
+ _tnl_destroy_pipeline(fxMesa->glCtx);
+ _tnl_install_pipeline(fxMesa->glCtx, fx_pipeline);
- _tnl_destroy_pipeline( fxMesa->glCtx );
- _tnl_install_pipeline( fxMesa->glCtx, fx_pipeline );
-
- fxAllocVB( fxMesa->glCtx );
+ fxAllocVB(fxMesa->glCtx);
fxSetupDDPointers(fxMesa->glCtx);
/* Tell the software rasterizer to use pixel fog always.
*/
- _swrast_allow_vertex_fog( fxMesa->glCtx, GL_FALSE );
- _swrast_allow_pixel_fog( fxMesa->glCtx, GL_TRUE );
+ _swrast_allow_vertex_fog(fxMesa->glCtx, GL_FALSE);
+ _swrast_allow_pixel_fog(fxMesa->glCtx, GL_TRUE);
/* Tell tnl not to calculate or use vertex fog factors. (Needed to
* tell render stage not to clip fog coords).
*/
/* _tnl_calculate_vertex_fog( fxMesa->glCtx, GL_FALSE ); */
- fxDDInitExtensions(fxMesa->glCtx);
+ fxDDInitExtensions(fxMesa->glCtx);
#ifdef FXVTXFMT
fxDDInitVtxfmt(fxMesa->glCtx);
#endif
- FX_grGlideGetState((GrState*)fxMesa->state);
+ FX_grGlideGetState((GrState *) fxMesa->state);
/* Run the config file */
- _mesa_context_initialize( fxMesa->glCtx );
+ _mesa_context_initialize(fxMesa->glCtx);
return 1;
}
/* Undo the above.
*/
-void fxDDDestroyFxMesaContext( fxMesaContext fxMesa )
+void
+fxDDDestroyFxMesaContext(fxMesaContext fxMesa)
{
- _swsetup_DestroyContext( fxMesa->glCtx );
- _tnl_DestroyContext( fxMesa->glCtx );
- _ac_DestroyContext( fxMesa->glCtx );
- _swrast_DestroyContext( fxMesa->glCtx );
+ _swsetup_DestroyContext(fxMesa->glCtx);
+ _tnl_DestroyContext(fxMesa->glCtx);
+ _ac_DestroyContext(fxMesa->glCtx);
+ _swrast_DestroyContext(fxMesa->glCtx);
- if (fxMesa->state)
+ if (fxMesa->state)
free(fxMesa->state);
if (fxMesa->fogTable)
free(fxMesa->fogTable);
@@ -828,12 +837,13 @@ void fxDDDestroyFxMesaContext( fxMesaContext fxMesa )
-void fxDDInitExtensions( GLcontext *ctx )
+void
+fxDDInitExtensions(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
_mesa_add_extension(ctx, GL_TRUE, "3DFX_set_global_palette", 0);
- _mesa_enable_extension(ctx, "GL_EXT_point_parameters");
+ _mesa_enable_extension(ctx, "GL_EXT_point_parameters");
_mesa_enable_extension(ctx, "GL_EXT_paletted_texture");
_mesa_enable_extension(ctx, "GL_EXT_texture_lod_bias");
_mesa_enable_extension(ctx, "GL_EXT_shared_texture_palette");
@@ -854,112 +864,115 @@ void fxDDInitExtensions( GLcontext *ctx )
*
* Performs similar work to fxDDChooseRenderState() - should be merged.
*/
-static GLboolean fxIsInHardware(GLcontext *ctx)
+static GLboolean
+fxIsInHardware(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
if (ctx->RenderMode != GL_RENDER)
- return GL_FALSE;
-
- if (ctx->Stencil.Enabled ||
- ctx->Color.MultiDrawBuffer ||
- ((ctx->Color.BlendEnabled) && (ctx->Color.BlendEquation!=GL_FUNC_ADD_EXT)) ||
- ((ctx->Color.ColorLogicOpEnabled) && (ctx->Color.LogicOp!=GL_COPY)) ||
- (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) ||
- (!((ctx->Color.ColorMask[RCOMP]==ctx->Color.ColorMask[GCOMP]) &&
- (ctx->Color.ColorMask[GCOMP]==ctx->Color.ColorMask[BCOMP]) &&
- (ctx->Color.ColorMask[ACOMP]==ctx->Color.ColorMask[ACOMP])))
- )
- {
- return GL_FALSE;
- }
- /* Unsupported texture/multitexture cases */
-
- if (fxMesa->emulateTwoTMUs) {
- if (ctx->Texture._ReallyEnabled & (TEXTURE0_3D | TEXTURE1_3D))
- return GL_FALSE; /* can't do 3D textures */
- if (ctx->Texture._ReallyEnabled & (TEXTURE0_1D | TEXTURE1_1D))
- return GL_FALSE; /* can't do 1D textures */
-
- if (ctx->Texture._ReallyEnabled & TEXTURE0_2D) {
- if (ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
- (ctx->Texture._ReallyEnabled & TEXTURE1_2D ||
- ctx->Texture.Unit[0].EnvColor[0] != 0 ||
- ctx->Texture.Unit[0].EnvColor[1] != 0 ||
- ctx->Texture.Unit[0].EnvColor[2] != 0 ||
- ctx->Texture.Unit[0].EnvColor[3] != 1)) {
- return GL_FALSE;
+ return GL_FALSE;
+
+ if (ctx->Stencil.Enabled ||
+ ctx->Color.MultiDrawBuffer ||
+ ((ctx->Color.BlendEnabled)
+ && (ctx->Color.BlendEquation != GL_FUNC_ADD_EXT))
+ || ((ctx->Color.ColorLogicOpEnabled)
+ && (ctx->Color.LogicOp != GL_COPY))
+ || (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+ ||
+ (!((ctx->
+ Color.ColorMask[RCOMP] == ctx->Color.ColorMask[GCOMP])
+ && (ctx->Color.ColorMask[GCOMP] == ctx->Color.ColorMask[BCOMP])
+ && (ctx->Color.ColorMask[ACOMP] == ctx->Color.ColorMask[ACOMP])))
+ ) {
+ return GL_FALSE;
+ }
+ /* Unsupported texture/multitexture cases */
+
+ if (fxMesa->emulateTwoTMUs) {
+ if (ctx->Texture._ReallyEnabled & (TEXTURE0_3D | TEXTURE1_3D))
+ return GL_FALSE; /* can't do 3D textures */
+ if (ctx->Texture._ReallyEnabled & (TEXTURE0_1D | TEXTURE1_1D))
+ return GL_FALSE; /* can't do 1D textures */
+
+ if (ctx->Texture._ReallyEnabled & TEXTURE0_2D) {
+ if (ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
+ (ctx->Texture._ReallyEnabled & TEXTURE1_2D ||
+ ctx->Texture.Unit[0].EnvColor[0] != 0 ||
+ ctx->Texture.Unit[0].EnvColor[1] != 0 ||
+ ctx->Texture.Unit[0].EnvColor[2] != 0 ||
+ ctx->Texture.Unit[0].EnvColor[3] != 1)) {
+ return GL_FALSE;
+ }
+ if (ctx->Texture.Unit[0]._Current->Image[0]->Border > 0)
+ return GL_FALSE;
}
- if (ctx->Texture.Unit[0]._Current->Image[0]->Border > 0)
- return GL_FALSE;
- }
-
- if (ctx->Texture._ReallyEnabled & TEXTURE1_2D) {
- if (ctx->Texture.Unit[1].EnvMode == GL_BLEND)
- return GL_FALSE;
- if (ctx->Texture.Unit[0]._Current->Image[0]->Border > 0)
- return GL_FALSE;
- }
-
- if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE))
- fprintf(stderr, "fxMesa: fxIsInHardware, envmode is %s/%s\n",
- _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
- _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
-
- /* KW: This was wrong (I think) and I changed it... which doesn't mean
- * it is now correct...
- */
- if((ctx->_Enabled & (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D)) &&
- (ctx->_Enabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D)))
- {
- /* Can't use multipass to blend a multitextured triangle - fall
- * back to software.
- */
- if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled) {
- return GL_FALSE;
+
+ if (ctx->Texture._ReallyEnabled & TEXTURE1_2D) {
+ if (ctx->Texture.Unit[1].EnvMode == GL_BLEND)
+ return GL_FALSE;
+ if (ctx->Texture.Unit[0]._Current->Image[0]->Border > 0)
+ return GL_FALSE;
}
-
- if ((ctx->Texture.Unit[0].EnvMode!=ctx->Texture.Unit[1].EnvMode) &&
- (ctx->Texture.Unit[0].EnvMode!=GL_MODULATE) &&
- (ctx->Texture.Unit[0].EnvMode!=GL_REPLACE)) /* q2, seems ok... */
- {
- if (MESA_VERBOSE&VERBOSE_DRIVER)
- fprintf(stderr, "fxMesa: unsupported multitex env mode\n");
- return GL_FALSE;
- }
- }
- } else {
- if((ctx->_Enabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D)) ||
- /* Not very well written ... */
- ((ctx->_Enabled & TEXTURE0_1D) &&
- (!(ctx->_Enabled & TEXTURE0_2D)))
- ) {
- return GL_FALSE;
- }
+ if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+ fprintf(stderr, "fxMesa: fxIsInHardware, envmode is %s/%s\n",
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
+
+ /* KW: This was wrong (I think) and I changed it... which doesn't mean
+ * it is now correct...
+ */
+ if ((ctx->_Enabled & (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D)) &&
+ (ctx->_Enabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D))) {
+ /* Can't use multipass to blend a multitextured triangle - fall
+ * back to software.
+ */
+ if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled) {
+ return GL_FALSE;
+ }
+
+ if ((ctx->Texture.Unit[0].EnvMode != ctx->Texture.Unit[1].EnvMode) &&
+ (ctx->Texture.Unit[0].EnvMode != GL_MODULATE) &&
+ (ctx->Texture.Unit[0].EnvMode != GL_REPLACE)) { /* q2, seems ok... */
+ if (MESA_VERBOSE & VERBOSE_DRIVER)
+ fprintf(stderr, "fxMesa: unsupported multitex env mode\n");
+ return GL_FALSE;
+ }
+ }
+ }
+ else {
+ if ((ctx->_Enabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D)) ||
+ /* Not very well written ... */
+ ((ctx->_Enabled & TEXTURE0_1D) && (!(ctx->_Enabled & TEXTURE0_2D)))
+ ) {
+ return GL_FALSE;
+ }
- if((ctx->Texture._ReallyEnabled & TEXTURE0_2D) &&
- (ctx->Texture.Unit[0].EnvMode==GL_BLEND)) {
- return GL_FALSE;
- }
- }
- return GL_TRUE;
+ if ((ctx->Texture._ReallyEnabled & TEXTURE0_2D) &&
+ (ctx->Texture.Unit[0].EnvMode == GL_BLEND)) {
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
}
-static void update_texture_scales( GLcontext *ctx )
+static void
+update_texture_scales(GLcontext * ctx)
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
struct gl_texture_unit *t0 = &ctx->Texture.Unit[fxMesa->tmu_source[0]];
struct gl_texture_unit *t1 = &ctx->Texture.Unit[fxMesa->tmu_source[1]];
-
+
if (t0 && t0->_Current && FX_TEXTURE_DATA(t0)) {
fxMesa->s0scale = FX_TEXTURE_DATA(t0)->sScale;
fxMesa->t0scale = FX_TEXTURE_DATA(t0)->tScale;
fxMesa->inv_s0scale = 1.0 / fxMesa->s0scale;
fxMesa->inv_t0scale = 1.0 / fxMesa->t0scale;
}
-
+
if (t1 && t1->_Current && FX_TEXTURE_DATA(t1)) {
fxMesa->s1scale = FX_TEXTURE_DATA(t1)->sScale;
fxMesa->t1scale = FX_TEXTURE_DATA(t1)->tScale;
@@ -968,113 +981,116 @@ static void update_texture_scales( GLcontext *ctx )
}
}
-static void fxDDUpdateDDPointers(GLcontext *ctx, GLuint new_state)
+static void
+fxDDUpdateDDPointers(GLcontext * ctx, GLuint new_state)
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
- _swrast_InvalidateState( ctx, new_state );
- _ac_InvalidateState( ctx, new_state );
- _tnl_InvalidateState( ctx, new_state );
- _swsetup_InvalidateState( ctx, new_state );
+ _swrast_InvalidateState(ctx, new_state);
+ _ac_InvalidateState(ctx, new_state);
+ _tnl_InvalidateState(ctx, new_state);
+ _swsetup_InvalidateState(ctx, new_state);
/* Recalculate fog table on projection matrix changes. This used to
* be triggered by the NearFar callback.
*/
- if (new_state & _NEW_PROJECTION)
+ if (new_state & _NEW_PROJECTION)
fxMesa->new_state |= FX_NEW_FOG;
if (new_state & (_FX_NEW_IS_IN_HARDWARE |
_FX_NEW_RENDERSTATE |
- _FX_NEW_SETUP_FUNCTION |
- _NEW_TEXTURE))
- {
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ _FX_NEW_SETUP_FUNCTION | _NEW_TEXTURE)) {
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
if (new_state & _FX_NEW_IS_IN_HARDWARE)
fxMesa->is_in_hardware = fxIsInHardware(ctx);
-
+
if (fxMesa->new_state)
fxSetupFXUnits(ctx);
- if (new_state & _FX_NEW_RENDERSTATE)
- fxDDChooseRenderState( ctx );
-
+ if (new_state & _FX_NEW_RENDERSTATE)
+ fxDDChooseRenderState(ctx);
+
if (new_state & _FX_NEW_SETUP_FUNCTION)
- ctx->Driver.BuildProjectedVertices = fx_validate_BuildProjVerts;
+ ctx->Driver.BuildProjectedVertices = fx_validate_BuildProjVerts;
- if (new_state & _NEW_TEXTURE)
- update_texture_scales( ctx );
+ if (new_state & _NEW_TEXTURE)
+ update_texture_scales(ctx);
}
#ifdef FXVTXFMT
if (fxMesa->allow_vfmt) {
if (new_state & _NEW_LIGHT)
- fx_update_lighting( ctx );
+ fx_update_lighting(ctx);
if (new_state & _FX_NEW_VTXFMT)
- fxDDCheckVtxfmt( ctx );
+ fxDDCheckVtxfmt(ctx);
}
#endif
}
-static void fxDDRenderPrimitive( GLcontext *ctx, GLenum mode )
+static void
+fxDDRenderPrimitive(GLcontext * ctx, GLenum mode)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
if (!fxMesa->is_in_hardware) {
- _swsetup_RenderPrimitive( ctx, mode );
- }
+ _swsetup_RenderPrimitive(ctx, mode);
+ }
else {
fxMesa->render_prim = mode;
- }
+ }
}
-static void fxDDRenderStart( GLcontext *ctx )
+static void
+fxDDRenderStart(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
- _swsetup_RenderStart( ctx );
+ _swsetup_RenderStart(ctx);
if (fxMesa->new_state) {
- fxSetupFXUnits( ctx );
+ fxSetupFXUnits(ctx);
}
}
-static void fxDDRenderFinish( GLcontext *ctx )
+static void
+fxDDRenderFinish(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
if (!fxMesa->is_in_hardware) {
- _swsetup_RenderFinish( ctx );
- }
+ _swsetup_RenderFinish(ctx);
+ }
}
-void fxSetupDDPointers(GLcontext *ctx)
+void
+fxSetupDDPointers(GLcontext * ctx)
{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxSetupDDPointers()\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxSetupDDPointers()\n");
}
- ctx->Driver.UpdateState=fxDDUpdateDDPointers;
+ ctx->Driver.UpdateState = fxDDUpdateDDPointers;
- ctx->Driver.WriteDepthSpan=fxDDWriteDepthSpan;
- ctx->Driver.WriteDepthPixels=fxDDWriteDepthPixels;
- ctx->Driver.ReadDepthSpan=fxDDReadDepthSpan;
- ctx->Driver.ReadDepthPixels=fxDDReadDepthPixels;
+ ctx->Driver.WriteDepthSpan = fxDDWriteDepthSpan;
+ ctx->Driver.WriteDepthPixels = fxDDWriteDepthPixels;
+ ctx->Driver.ReadDepthSpan = fxDDReadDepthSpan;
+ ctx->Driver.ReadDepthPixels = fxDDReadDepthPixels;
- ctx->Driver.GetString=fxDDGetString;
+ ctx->Driver.GetString = fxDDGetString;
- ctx->Driver.ClearIndex=NULL;
- ctx->Driver.ClearColor=fxDDClearColor;
- ctx->Driver.Clear=fxDDClear;
+ ctx->Driver.ClearIndex = NULL;
+ ctx->Driver.ClearColor = fxDDClearColor;
+ ctx->Driver.Clear = fxDDClear;
- ctx->Driver.SetDrawBuffer=fxDDSetDrawBuffer;
- ctx->Driver.SetReadBuffer=fxDDSetReadBuffer;
- ctx->Driver.GetBufferSize=fxDDBufferSize;
+ ctx->Driver.SetDrawBuffer = fxDDSetDrawBuffer;
+ ctx->Driver.SetReadBuffer = fxDDSetReadBuffer;
+ ctx->Driver.GetBufferSize = fxDDBufferSize;
ctx->Driver.Accum = _swrast_Accum;
ctx->Driver.Bitmap = fxDDDrawBitmap;
@@ -1083,13 +1099,13 @@ void fxSetupDDPointers(GLcontext *ctx)
ctx->Driver.ReadPixels = fxDDReadPixels;
ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
- ctx->Driver.Finish=fxDDFinish;
- ctx->Driver.Flush=NULL;
+ ctx->Driver.Finish = fxDDFinish;
+ ctx->Driver.Flush = NULL;
- ctx->Driver.RenderStart=fxDDRenderStart;
- ctx->Driver.RenderFinish=fxDDRenderFinish;
- ctx->Driver.ResetLineStipple=_swrast_ResetLineStipple;
- ctx->Driver.RenderPrimitive=fxDDRenderPrimitive;
+ ctx->Driver.RenderStart = fxDDRenderStart;
+ ctx->Driver.RenderFinish = fxDDRenderFinish;
+ ctx->Driver.ResetLineStipple = _swrast_ResetLineStipple;
+ ctx->Driver.RenderPrimitive = fxDDRenderPrimitive;
/* Install the oldstyle interp functions:
*/
@@ -1117,22 +1133,22 @@ void fxSetupDDPointers(GLcontext *ctx)
ctx->Driver.DeleteTexture = fxDDTexDel;
ctx->Driver.UpdateTexturePalette = fxDDTexPalette;
- ctx->Driver.AlphaFunc=fxDDAlphaFunc;
- ctx->Driver.BlendFunc=fxDDBlendFunc;
- ctx->Driver.DepthFunc=fxDDDepthFunc;
- ctx->Driver.DepthMask=fxDDDepthMask;
- ctx->Driver.ColorMask=fxDDColorMask;
- ctx->Driver.Fogfv=fxDDFogfv;
- ctx->Driver.Scissor=fxDDScissor;
- ctx->Driver.FrontFace=fxDDFrontFace;
- ctx->Driver.CullFace=fxDDCullFace;
- ctx->Driver.ShadeModel=fxDDShadeModel;
- ctx->Driver.Enable=fxDDEnable;
+ ctx->Driver.AlphaFunc = fxDDAlphaFunc;
+ ctx->Driver.BlendFunc = fxDDBlendFunc;
+ ctx->Driver.DepthFunc = fxDDDepthFunc;
+ ctx->Driver.DepthMask = fxDDDepthMask;
+ ctx->Driver.ColorMask = fxDDColorMask;
+ ctx->Driver.Fogfv = fxDDFogfv;
+ ctx->Driver.Scissor = fxDDScissor;
+ ctx->Driver.FrontFace = fxDDFrontFace;
+ ctx->Driver.CullFace = fxDDCullFace;
+ ctx->Driver.ShadeModel = fxDDShadeModel;
+ ctx->Driver.Enable = fxDDEnable;
+
-
fxSetupDDSpanPointers(ctx);
- fxDDUpdateDDPointers(ctx,~0);
+ fxDDUpdateDDPointers(ctx, ~0);
}
@@ -1144,10 +1160,10 @@ void fxSetupDDPointers(GLcontext *ctx)
*/
extern int gl_fx_dummy_function_dd(void);
-int gl_fx_dummy_function_dd(void)
+int
+gl_fx_dummy_function_dd(void)
{
- return 0;
+ return 0;
}
-#endif /* FX */
-
+#endif /* FX */
diff --git a/src/mesa/drivers/glide/fxddspan.c b/src/mesa/drivers/glide/fxddspan.c
index fceeb0e60a..e02e792dea 100644
--- a/src/mesa/drivers/glide/fxddspan.c
+++ b/src/mesa/drivers/glide/fxddspan.c
@@ -63,7 +63,7 @@
#endif
-#if !defined(FXMESA_USE_ARGB)
+#if !defined(FXMESA_USE_ARGB)
@@ -101,33 +101,28 @@
( ((unsigned int)(c[RCOMP]))<<16 ) | \
( ((unsigned int)(c[GCOMP]))<<8 ) | \
( (unsigned int)(c[BCOMP])) )
-
-inline void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer,
- FxU32 dst_x,
- FxU32 dst_y,
- FxU32 src_width,
- FxI32 src_stride,
- void *src_data )
+
+inline void
+LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer,
+ FxU32 dst_x,
+ FxU32 dst_y,
+ FxU32 src_width, FxI32 src_stride, void *src_data)
{
/* Covert to ARGB */
- GLubyte (*rgba)[4] = src_data;
+ GLubyte(*rgba)[4] = src_data;
GLuint argb[MAX_WIDTH];
int i;
-
- for (i = 0; i < src_width; i++)
- {
+
+ for (i = 0; i < src_width; i++) {
argb[i] = MESACOLOR_TO_ARGB(rgba[i]);
}
- writeRegionClipped( /*fxMesa,*/ NULL, dst_buffer,
- dst_x,
- dst_y,
- GR_LFB_SRC_FMT_8888,
- src_width,
- 1,
- src_stride,
- (void*)argb);
+ writeRegionClipped( /*fxMesa, */ NULL, dst_buffer,
+ dst_x,
+ dst_y,
+ GR_LFB_SRC_FMT_8888,
+ src_width, 1, src_stride, (void *) argb);
}
-
+
#endif /* !defined(FXMESA_USE_RGBA) */
@@ -136,162 +131,178 @@ inline void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer,
/************************************************************************/
-static void fxDDWriteRGBASpan(const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte rgba[][4], const GLubyte mask[])
+static void
+fxDDWriteRGBASpan(const GLcontext * ctx,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgba[][4], const GLubyte mask[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLint bottom=fxMesa->height-1;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteRGBASpan(...)\n");
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLuint i;
+ GLint bottom = fxMesa->height - 1;
- if (mask) {
- int span=0;
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteRGBASpan(...)\n");
+ }
- for (i=0;i<n;i++) {
- if (mask[i]) {
- ++span;
- } else {
- if (span > 0) {
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y,
- /* GR_LFB_SRC_FMT_8888,*/ span, /*1,*/ 0, (void *) rgba[i-span] );
- span = 0;
- }
+ if (mask) {
+ int span = 0;
+
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ ++span;
+ }
+ else {
+ if (span > 0) {
+ LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x + i - span,
+ bottom - y,
+ /* GR_LFB_SRC_FMT_8888, */ span, /*1, */ 0,
+ (void *) rgba[i - span]);
+ span = 0;
+ }
+ }
}
- }
-
- if (span > 0)
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y,
- /* GR_LFB_SRC_FMT_8888, */ span, /*1,*/ 0, (void *) rgba[n-span] );
- } else
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/
- n,/* 1,*/ 0, (void *) rgba );
+
+ if (span > 0)
+ LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x + n - span, bottom - y,
+ /* GR_LFB_SRC_FMT_8888, */ span, /*1, */ 0,
+ (void *) rgba[n - span]);
+ }
+ else
+ LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x, bottom - y, /* GR_LFB_SRC_FMT_8888, */
+ n, /* 1, */ 0, (void *) rgba);
}
-static void fxDDWriteRGBSpan(const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte rgb[][3], const GLubyte mask[])
+static void
+fxDDWriteRGBSpan(const GLcontext * ctx,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgb[][3], const GLubyte mask[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLint bottom=fxMesa->height-1;
- GLubyte rgba[MAX_WIDTH][4];
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLuint i;
+ GLint bottom = fxMesa->height - 1;
+ GLubyte rgba[MAX_WIDTH][4];
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteRGBSpan()\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteRGBSpan()\n");
+ }
- if (mask) {
- int span=0;
+ if (mask) {
+ int span = 0;
+
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ rgba[span][RCOMP] = rgb[i][0];
+ rgba[span][GCOMP] = rgb[i][1];
+ rgba[span][BCOMP] = rgb[i][2];
+ rgba[span][ACOMP] = 255;
+ ++span;
+ }
+ else {
+ if (span > 0) {
+ LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x + i - span,
+ bottom - y,
+ /*GR_LFB_SRC_FMT_8888, */ span, /* 1, */ 0,
+ (void *) rgba);
+ span = 0;
+ }
+ }
+ }
- for (i=0;i<n;i++) {
- if (mask[i]) {
- rgba[span][RCOMP] = rgb[i][0];
- rgba[span][GCOMP] = rgb[i][1];
- rgba[span][BCOMP] = rgb[i][2];
- rgba[span][ACOMP] = 255;
- ++span;
- } else {
- if (span > 0) {
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y,
- /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
- span = 0;
- }
+ if (span > 0)
+ LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x + n - span, bottom - y,
+ /*GR_LFB_SRC_FMT_8888, */ span, /* 1, */ 0,
+ (void *) rgba);
+ }
+ else {
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = rgb[i][0];
+ rgba[i][GCOMP] = rgb[i][1];
+ rgba[i][BCOMP] = rgb[i][2];
+ rgba[i][ACOMP] = 255;
}
- }
-
- if (span > 0)
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y,
- /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
- } else {
- for (i=0;i<n;i++) {
- rgba[i][RCOMP]=rgb[i][0];
- rgba[i][GCOMP]=rgb[i][1];
- rgba[i][BCOMP]=rgb[i][2];
- rgba[i][ACOMP]=255;
- }
-
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/
- n,/* 1,*/ 0, (void *) rgba );
- }
+
+ LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x, bottom - y, /* GR_LFB_SRC_FMT_8888, */
+ n, /* 1, */ 0, (void *) rgba);
+ }
}
-static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLchan color[4], const GLubyte mask[])
+static void
+fxDDWriteMonoRGBASpan(const GLcontext * ctx,
+ GLuint n, GLint x, GLint y,
+ const GLchan color[4], const GLubyte mask[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLint bottom=fxMesa->height-1;
- GLuint data[MAX_WIDTH];
- GrColor_t gColor = FXCOLOR4(color);
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteMonoRGBASpan(...)\n");
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLuint i;
+ GLint bottom = fxMesa->height - 1;
+ GLuint data[MAX_WIDTH];
+ GrColor_t gColor = FXCOLOR4(color);
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteMonoRGBASpan(...)\n");
+ }
- if (mask) {
- int span=0;
+ if (mask) {
+ int span = 0;
+
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ data[span] = (GLuint) gColor;
+ ++span;
+ }
+ else {
+ if (span > 0) {
+ writeRegionClipped(fxMesa, fxMesa->currentFB, x + i - span,
+ bottom - y, GR_LFB_SRC_FMT_8888, span, 1, 0,
+ (void *) data);
+ span = 0;
+ }
+ }
+ }
- for (i=0;i<n;i++) {
- if (mask[i]) {
- data[span] = (GLuint) gColor;
- ++span;
- } else {
- if (span > 0) {
- writeRegionClipped(fxMesa, fxMesa->currentFB, x+i-span, bottom-y,
- GR_LFB_SRC_FMT_8888, span, 1, 0,
- (void *) data );
- span = 0;
- }
+ if (span > 0)
+ writeRegionClipped(fxMesa, fxMesa->currentFB, x + n - span,
+ bottom - y, GR_LFB_SRC_FMT_8888, span, 1, 0,
+ (void *) data);
+ }
+ else {
+ for (i = 0; i < n; i++) {
+ data[i] = (GLuint) gColor;
}
- }
-
- if (span > 0)
- writeRegionClipped(fxMesa, fxMesa->currentFB, x+n-span, bottom-y,
- GR_LFB_SRC_FMT_8888, span, 1, 0,
- (void *) data );
- } else {
- for (i=0;i<n;i++) {
- data[i]=(GLuint) gColor;
- }
-
- writeRegionClipped(fxMesa, fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888,
- n, 1, 0, (void *) data );
- }
+
+ writeRegionClipped(fxMesa, fxMesa->currentFB, x, bottom - y,
+ GR_LFB_SRC_FMT_8888, n, 1, 0, (void *) data);
+ }
}
#if 0
-static void fxDDReadRGBASpan(const GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLubyte rgba[][4])
+static void
+fxDDReadRGBASpan(const GLcontext * ctx,
+ GLuint n, GLint x, GLint y, GLubyte rgba[][4])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLushort data[MAX_WIDTH];
- GLuint i;
- GLint bottom=fxMesa->height-1;
-
- printf("read span %d, %d, %d\n", x,y,n);
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDReadRGBASpan(...)\n");
- }
-
- assert(n < MAX_WIDTH);
-
- FX_grLfbReadRegion( fxMesa->currentFB, x, bottom-y, n, 1, 0, data);
-
- for (i=0;i<n;i++) {
- GLushort pixel = data[i];
- rgba[i][RCOMP] = FX_PixelToR[pixel];
- rgba[i][GCOMP] = FX_PixelToG[pixel];
- rgba[i][BCOMP] = FX_PixelToB[pixel];
- rgba[i][ACOMP] = 255;
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLushort data[MAX_WIDTH];
+ GLuint i;
+ GLint bottom = fxMesa->height - 1;
+
+ printf("read span %d, %d, %d\n", x, y, n);
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDReadRGBASpan(...)\n");
+ }
+
+ assert(n < MAX_WIDTH);
+
+ FX_grLfbReadRegion(fxMesa->currentFB, x, bottom - y, n, 1, 0, data);
+
+ for (i = 0; i < n; i++) {
+ GLushort pixel = data[i];
+ rgba[i][RCOMP] = FX_PixelToR[pixel];
+ rgba[i][GCOMP] = FX_PixelToG[pixel];
+ rgba[i][BCOMP] = FX_PixelToB[pixel];
+ rgba[i][ACOMP] = 255;
+ }
}
#endif
@@ -300,52 +311,49 @@ static void fxDDReadRGBASpan(const GLcontext *ctx,
* Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects
* since OpenGL says obscured pixels have undefined values.
*/
-static void read_R5G6B5_span(const GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLubyte rgba[][4])
+static void
+read_R5G6B5_span(const GLcontext * ctx,
+ GLuint n, GLint x, GLint y, GLubyte rgba[][4])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GrLfbInfo_t info;
- BEGIN_BOARD_LOCK();
- if (grLfbLock(GR_LFB_READ_ONLY,
- fxMesa->currentFB,
- GR_LFBWRITEMODE_ANY,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winX = 0;
- const GLint winY = fxMesa->height - 1;
- const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
- const GLushort *data16 = (const GLushort *) info.lfbPtr
- + (winY - y) * srcStride
- + (winX + x);
- const GLuint *data32 = (const GLuint *) data16;
- GLuint i, j;
- GLuint extraPixel = (n & 1);
- n -= extraPixel;
- for (i = j = 0; i < n; i += 2, j++) {
- GLuint pixel = data32[j];
- GLuint pixel0 = pixel & 0xffff;
- GLuint pixel1 = pixel >> 16;
- rgba[i][RCOMP] = FX_PixelToR[pixel0];
- rgba[i][GCOMP] = FX_PixelToG[pixel0];
- rgba[i][BCOMP] = FX_PixelToB[pixel0];
- rgba[i][ACOMP] = 255;
- rgba[i+1][RCOMP] = FX_PixelToR[pixel1];
- rgba[i+1][GCOMP] = FX_PixelToG[pixel1];
- rgba[i+1][BCOMP] = FX_PixelToB[pixel1];
- rgba[i+1][ACOMP] = 255;
- }
- if (extraPixel) {
- GLushort pixel = data16[n];
- rgba[n][RCOMP] = FX_PixelToR[pixel];
- rgba[n][GCOMP] = FX_PixelToG[pixel];
- rgba[n][BCOMP] = FX_PixelToB[pixel];
- rgba[n][ACOMP] = 255;
- }
-
- grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GrLfbInfo_t info;
+ BEGIN_BOARD_LOCK();
+ if (grLfbLock(GR_LFB_READ_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+ const GLint winX = 0;
+ const GLint winY = fxMesa->height - 1;
+ const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
+ const GLushort *data16 = (const GLushort *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x);
+ const GLuint *data32 = (const GLuint *) data16;
+ GLuint i, j;
+ GLuint extraPixel = (n & 1);
+ n -= extraPixel;
+ for (i = j = 0; i < n; i += 2, j++) {
+ GLuint pixel = data32[j];
+ GLuint pixel0 = pixel & 0xffff;
+ GLuint pixel1 = pixel >> 16;
+ rgba[i][RCOMP] = FX_PixelToR[pixel0];
+ rgba[i][GCOMP] = FX_PixelToG[pixel0];
+ rgba[i][BCOMP] = FX_PixelToB[pixel0];
+ rgba[i][ACOMP] = 255;
+ rgba[i + 1][RCOMP] = FX_PixelToR[pixel1];
+ rgba[i + 1][GCOMP] = FX_PixelToG[pixel1];
+ rgba[i + 1][BCOMP] = FX_PixelToB[pixel1];
+ rgba[i + 1][ACOMP] = 255;
+ }
+ if (extraPixel) {
+ GLushort pixel = data16[n];
+ rgba[n][RCOMP] = FX_PixelToR[pixel];
+ rgba[n][GCOMP] = FX_PixelToG[pixel];
+ rgba[n][BCOMP] = FX_PixelToB[pixel];
+ rgba[n][ACOMP] = 255;
+ }
+
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
}
@@ -353,76 +361,75 @@ static void read_R5G6B5_span(const GLcontext *ctx,
/***** Pixel functions *****/
/************************************************************************/
-static void fxDDWriteRGBAPixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- CONST GLubyte rgba[][4], const GLubyte mask[])
+static void
+fxDDWriteRGBAPixels(const GLcontext * ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ CONST GLubyte rgba[][4], const GLubyte mask[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLint bottom=fxMesa->height-1;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n");
- }
-
- for(i=0;i<n;i++)
- if(mask[i])
- LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i], bottom-y[i],
- 1, 1, (void *)rgba[i]);
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLuint i;
+ GLint bottom = fxMesa->height - 1;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteRGBAPixels(...)\n");
+ }
+
+ for (i = 0; i < n; i++)
+ if (mask[i])
+ LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i], bottom - y[i],
+ 1, 1, (void *) rgba[i]);
}
-static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLchan color[4], const GLubyte mask[])
+static void
+fxDDWriteMonoRGBAPixels(const GLcontext * ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLchan color[4], const GLubyte mask[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLint bottom=fxMesa->height-1;
- GrColor_t gColor = FXCOLOR4(color);
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n");
- }
-
- for(i=0;i<n;i++)
- if(mask[i])
- writeRegionClipped(fxMesa, fxMesa->currentFB,x[i],bottom-y[i],
- GR_LFB_SRC_FMT_8888,1,1,0,(void *) &gColor);
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLuint i;
+ GLint bottom = fxMesa->height - 1;
+ GrColor_t gColor = FXCOLOR4(color);
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteMonoRGBAPixels(...)\n");
+ }
+
+ for (i = 0; i < n; i++)
+ if (mask[i])
+ writeRegionClipped(fxMesa, fxMesa->currentFB, x[i], bottom - y[i],
+ GR_LFB_SRC_FMT_8888, 1, 1, 0, (void *) &gColor);
}
-static void read_R5G6B5_pixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[])
+static void
+read_R5G6B5_pixels(const GLcontext * ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4], const GLubyte mask[])
{
- fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
- GrLfbInfo_t info;
- BEGIN_BOARD_LOCK();
- if (grLfbLock(GR_LFB_READ_ONLY,
- fxMesa->currentFB,
- GR_LFBWRITEMODE_ANY,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
- const GLint winX = 0;
- const GLint winY = fxMesa->height - 1;
- GLuint i;
- for(i=0;i<n;i++) {
- if(mask[i]) {
- const GLushort *data16 = (const GLushort *) info.lfbPtr
- + (winY - y[i]) * srcStride
- + (winX + x[i]);
- const GLushort pixel = *data16;
- rgba[i][RCOMP] = FX_PixelToR[pixel];
- rgba[i][GCOMP] = FX_PixelToG[pixel];
- rgba[i][BCOMP] = FX_PixelToB[pixel];
- rgba[i][ACOMP] = 255;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GrLfbInfo_t info;
+ BEGIN_BOARD_LOCK();
+ if (grLfbLock(GR_LFB_READ_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+ const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
+ const GLint winX = 0;
+ const GLint winY = fxMesa->height - 1;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ const GLushort *data16 = (const GLushort *) info.lfbPtr
+ + (winY - y[i]) * srcStride + (winX + x[i]);
+ const GLushort pixel = *data16;
+ rgba[i][RCOMP] = FX_PixelToR[pixel];
+ rgba[i][GCOMP] = FX_PixelToG[pixel];
+ rgba[i][BCOMP] = FX_PixelToB[pixel];
+ rgba[i][ACOMP] = 255;
+ }
}
- }
- grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
}
@@ -431,102 +438,106 @@ static void read_R5G6B5_pixels(const GLcontext *ctx,
/***** Depth functions *****/
/************************************************************************/
-void fxDDWriteDepthSpan(GLcontext *ctx,
- GLuint n, GLint x, GLint y, const GLdepth depth[],
- const GLubyte mask[])
+void
+fxDDWriteDepthSpan(GLcontext * ctx,
+ GLuint n, GLint x, GLint y, const GLdepth depth[],
+ const GLubyte mask[])
{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height - 1;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLint bottom = fxMesa->height - 1;
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDWriteDepthSpan(...)\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteDepthSpan(...)\n");
+ }
- if (mask) {
- GLint i;
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- GLshort d = depth[i];
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom - y,
- GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
+ if (mask) {
+ GLint i;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ GLshort d = depth[i];
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom - y,
+ GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
+ }
}
- }
- }
- else {
- GLushort depth16[MAX_WIDTH];
- GLint i;
- for (i = 0; i < n; i++) {
- depth16[i] = depth[i];
- }
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom - y,
- GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth16);
- }
+ }
+ else {
+ GLushort depth16[MAX_WIDTH];
+ GLint i;
+ for (i = 0; i < n; i++) {
+ depth16[i] = depth[i];
+ }
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom - y,
+ GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth16);
+ }
}
-void fxDDReadDepthSpan(GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLdepth depth[])
+void
+fxDDReadDepthSpan(GLcontext * ctx,
+ GLuint n, GLint x, GLint y, GLdepth depth[])
{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height - 1;
- GLushort depth16[MAX_WIDTH];
- GLuint i;
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDReadDepthSpan(...)\n");
- }
-
- FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
- for (i = 0; i < n; i++) {
- depth[i] = depth16[i];
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLint bottom = fxMesa->height - 1;
+ GLushort depth16[MAX_WIDTH];
+ GLuint i;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDReadDepthSpan(...)\n");
+ }
+
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
+ for (i = 0; i < n; i++) {
+ depth[i] = depth16[i];
+ }
}
-void fxDDWriteDepthPixels(GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLdepth depth[], const GLubyte mask[])
+void
+fxDDWriteDepthPixels(GLcontext * ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLdepth depth[], const GLubyte mask[])
{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height - 1;
- GLuint i;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLint bottom = fxMesa->height - 1;
+ GLuint i;
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDWriteDepthPixels(...)\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteDepthPixels(...)\n");
+ }
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- int xpos = x[i];
- int ypos = bottom - y[i];
- GLushort d = depth[i];
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos,
- GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
- }
- }
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ int xpos = x[i];
+ int ypos = bottom - y[i];
+ GLushort d = depth[i];
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos,
+ GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
+ }
+ }
}
-void fxDDReadDepthPixels(GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[], GLdepth depth[])
+void
+fxDDReadDepthPixels(GLcontext * ctx, GLuint n,
+ const GLint x[], const GLint y[], GLdepth depth[])
{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height - 1;
- GLuint i;
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDReadDepthPixels(...)\n");
- }
-
- for (i = 0; i < n; i++) {
- int xpos = x[i];
- int ypos = bottom - y[i];
- GLushort d;
- FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, xpos, ypos, 1, 1, 0, &d);
- depth[i] = d;
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLint bottom = fxMesa->height - 1;
+ GLuint i;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDReadDepthPixels(...)\n");
+ }
+
+ for (i = 0; i < n; i++) {
+ int xpos = x[i];
+ int ypos = bottom - y[i];
+ GLushort d;
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, xpos, ypos, 1, 1, 0, &d);
+ depth[i] = d;
+ }
}
@@ -535,26 +546,27 @@ void fxDDReadDepthPixels(GLcontext *ctx, GLuint n,
/************************************************************************/
-void fxSetupDDSpanPointers(GLcontext *ctx)
+void
+fxSetupDDSpanPointers(GLcontext * ctx)
{
- ctx->Driver.WriteRGBASpan =fxDDWriteRGBASpan;
- ctx->Driver.WriteRGBSpan =fxDDWriteRGBSpan;
- ctx->Driver.WriteMonoRGBASpan =fxDDWriteMonoRGBASpan;
- ctx->Driver.WriteRGBAPixels =fxDDWriteRGBAPixels;
- ctx->Driver.WriteMonoRGBAPixels =fxDDWriteMonoRGBAPixels;
-
- ctx->Driver.WriteCI8Span =NULL;
- ctx->Driver.WriteCI32Span =NULL;
- ctx->Driver.WriteMonoCISpan =NULL;
- ctx->Driver.WriteCI32Pixels =NULL;
- ctx->Driver.WriteMonoCIPixels =NULL;
-
- /* ctx->Driver.ReadRGBASpan =fxDDReadRGBASpan;*/
- ctx->Driver.ReadRGBASpan = read_R5G6B5_span;
- ctx->Driver.ReadRGBAPixels = read_R5G6B5_pixels;
-
- ctx->Driver.ReadCI32Span =NULL;
- ctx->Driver.ReadCI32Pixels =NULL;
+ ctx->Driver.WriteRGBASpan = fxDDWriteRGBASpan;
+ ctx->Driver.WriteRGBSpan = fxDDWriteRGBSpan;
+ ctx->Driver.WriteMonoRGBASpan = fxDDWriteMonoRGBASpan;
+ ctx->Driver.WriteRGBAPixels = fxDDWriteRGBAPixels;
+ ctx->Driver.WriteMonoRGBAPixels = fxDDWriteMonoRGBAPixels;
+
+ ctx->Driver.WriteCI8Span = NULL;
+ ctx->Driver.WriteCI32Span = NULL;
+ ctx->Driver.WriteMonoCISpan = NULL;
+ ctx->Driver.WriteCI32Pixels = NULL;
+ ctx->Driver.WriteMonoCIPixels = NULL;
+
+ /* ctx->Driver.ReadRGBASpan =fxDDReadRGBASpan; */
+ ctx->Driver.ReadRGBASpan = read_R5G6B5_span;
+ ctx->Driver.ReadRGBAPixels = read_R5G6B5_pixels;
+
+ ctx->Driver.ReadCI32Span = NULL;
+ ctx->Driver.ReadCI32Pixels = NULL;
}
@@ -566,9 +578,10 @@ void fxSetupDDSpanPointers(GLcontext *ctx)
*/
extern int gl_fx_dummy_function_span(void);
-int gl_fx_dummy_function_span(void)
+int
+gl_fx_dummy_function_span(void)
{
- return 0;
+ return 0;
}
-#endif /* FX */
+#endif /* FX */
diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c
index 4c4fb01825..a88ac0b2d0 100644
--- a/src/mesa/drivers/glide/fxddtex.c
+++ b/src/mesa/drivers/glide/fxddtex.c
@@ -55,35 +55,39 @@
#include "texutil.h"
-void fxPrintTextureData(tfxTexInfo *ti)
+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: %ld\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", (unsigned) ti->tm[0]->startAddr,
- (unsigned) ti->tm[0]->endAddr);
- if (ti->tm[1])
- fprintf(stderr, "\tMem1: %x-%x\n", (unsigned) ti->tm[1]->startAddr,
- (unsigned) ti->tm[1]->endAddr);
- fprintf(stderr, "\tMipmaps: %d-%d\n", ti->minLevel, ti->maxLevel);
- fprintf(stderr, "\tFilters: min %d min %d\n",
- (int) ti->minFilt, (int) ti->maxFilt);
- fprintf(stderr, "\tClamps: s %d t %d\n", (int) ti->sClamp, (int) 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");
+ 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: %ld\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", (unsigned) ti->tm[0]->startAddr,
+ (unsigned) ti->tm[0]->endAddr);
+ if (ti->tm[1])
+ fprintf(stderr, "\tMem1: %x-%x\n", (unsigned) ti->tm[1]->startAddr,
+ (unsigned) ti->tm[1]->endAddr);
+ fprintf(stderr, "\tMipmaps: %d-%d\n", ti->minLevel, ti->maxLevel);
+ fprintf(stderr, "\tFilters: min %d min %d\n",
+ (int) ti->minFilt, (int) ti->maxFilt);
+ fprintf(stderr, "\tClamps: s %d t %d\n", (int) ti->sClamp,
+ (int) 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");
}
@@ -91,245 +95,257 @@ void fxPrintTextureData(tfxTexInfo *ti)
/*************************** Texture Mapping ****************************/
/************************************************************************/
-static void fxTexInvalidate(GLcontext *ctx, struct gl_texture_object *tObj)
+static void
+fxTexInvalidate(GLcontext * ctx, struct gl_texture_object *tObj)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxTexInfo *ti;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ tfxTexInfo *ti;
- ti=fxTMGetTexInfo(tObj);
- if (ti->isInTM) fxTMMoveOutTM(fxMesa,tObj); /* TO DO: SLOW but easy to write */
+ ti = fxTMGetTexInfo(tObj);
+ if (ti->isInTM)
+ fxTMMoveOutTM(fxMesa, tObj); /* TO DO: SLOW but easy to write */
- ti->validated=GL_FALSE;
- fxMesa->new_state|=FX_NEW_TEXTURING;
+ ti->validated = GL_FALSE;
+ fxMesa->new_state |= FX_NEW_TEXTURING;
}
-static tfxTexInfo *fxAllocTexObjData(fxMesaContext fxMesa)
+static tfxTexInfo *
+fxAllocTexObjData(fxMesaContext fxMesa)
{
- tfxTexInfo *ti;
+ tfxTexInfo *ti;
- if(!(ti=CALLOC(sizeof(tfxTexInfo)))) {
- fprintf(stderr,"fx Driver: out of memory !\n");
- fxCloseHardware();
- exit(-1);
- }
+ if (!(ti = CALLOC(sizeof(tfxTexInfo)))) {
+ fprintf(stderr, "fx Driver: out of memory !\n");
+ fxCloseHardware();
+ exit(-1);
+ }
- ti->validated=GL_FALSE;
- ti->isInTM=GL_FALSE;
+ ti->validated = GL_FALSE;
+ ti->isInTM = GL_FALSE;
- ti->whichTMU=FX_TMU_NONE;
+ ti->whichTMU = FX_TMU_NONE;
- ti->tm[FX_TMU0]=NULL;
- ti->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;
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->maxFilt = GR_TEXTUREFILTER_BILINEAR;
- ti->sClamp=GR_TEXTURECLAMP_WRAP;
- ti->tClamp=GR_TEXTURECLAMP_WRAP;
+ ti->sClamp = GR_TEXTURECLAMP_WRAP;
+ ti->tClamp = GR_TEXTURECLAMP_WRAP;
- ti->mmMode=GR_MIPMAP_NEAREST;
- ti->LODblend=FXFALSE;
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXFALSE;
- return ti;
+ return ti;
}
-void fxDDTexBind(GLcontext *ctx, GLenum target, struct gl_texture_object *tObj)
+void
+fxDDTexBind(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxTexInfo *ti;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ tfxTexInfo *ti;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDTexBind(%d,%x)\n",tObj->Name,(GLuint)tObj->DriverData);
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDTexBind(%d,%x)\n", tObj->Name,
+ (GLuint) tObj->DriverData);
+ }
- if(target!=GL_TEXTURE_2D)
- return;
+ if (target != GL_TEXTURE_2D)
+ return;
- if (!tObj->DriverData) {
- tObj->DriverData=fxAllocTexObjData(fxMesa);
- }
+ if (!tObj->DriverData) {
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ }
- ti=fxTMGetTexInfo(tObj);
+ ti = fxTMGetTexInfo(tObj);
- fxMesa->texBindNumber++;
- ti->lastTimeUsed=fxMesa->texBindNumber;
+ fxMesa->texBindNumber++;
+ ti->lastTimeUsed = fxMesa->texBindNumber;
- fxMesa->new_state|=FX_NEW_TEXTURING;
+ fxMesa->new_state |= FX_NEW_TEXTURING;
}
-void fxDDTexEnv(GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param)
+void
+fxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
+ const GLfloat * param)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- if(param)
- fprintf(stderr,"fxmesa: texenv(%x,%x)\n",pname,(GLint)(*param));
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ if (param)
+ fprintf(stderr, "fxmesa: texenv(%x,%x)\n", pname, (GLint) (*param));
else
- fprintf(stderr,"fxmesa: texenv(%x)\n",pname);
+ fprintf(stderr, "fxmesa: texenv(%x)\n", pname);
}
/* apply any lod biasing right now */
- if (pname==GL_TEXTURE_LOD_BIAS_EXT) {
- FX_grTexLodBiasValue(GR_TMU0,*param);
+ if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
+ FX_grTexLodBiasValue(GR_TMU0, *param);
- if(fxMesa->haveTwoTMUs) {
- FX_grTexLodBiasValue(GR_TMU1,*param);
- }
+ if (fxMesa->haveTwoTMUs) {
+ FX_grTexLodBiasValue(GR_TMU1, *param);
+ }
}
- fxMesa->new_state|=FX_NEW_TEXTURING;
+ fxMesa->new_state |= FX_NEW_TEXTURING;
}
-void fxDDTexParam(GLcontext *ctx, GLenum target, struct gl_texture_object *tObj,
- GLenum pname, const GLfloat *params)
+void
+fxDDTexParam(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat * params)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLenum param=(GLenum)(GLint)params[0];
- tfxTexInfo *ti;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDTexParam(%d,%x,%x,%x)\n",tObj->Name,(GLuint)tObj->DriverData,pname,param);
- }
-
- if(target!=GL_TEXTURE_2D)
- return;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLenum param = (GLenum) (GLint) params[0];
+ tfxTexInfo *ti;
- if (!tObj->DriverData)
- tObj->DriverData=fxAllocTexObjData(fxMesa);
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDTexParam(%d,%x,%x,%x)\n", tObj->Name,
+ (GLuint) tObj->DriverData, pname, param);
+ }
- ti=fxTMGetTexInfo(tObj);
+ if (target != GL_TEXTURE_2D)
+ return;
- switch(pname) {
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
- case GL_TEXTURE_MIN_FILTER:
- switch(param) {
- case GL_NEAREST:
- ti->mmMode=GR_MIPMAP_DISABLE;
- ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
- ti->LODblend=FXFALSE;
- break;
- case GL_LINEAR:
- ti->mmMode=GR_MIPMAP_DISABLE;
- ti->minFilt=GR_TEXTUREFILTER_BILINEAR;
- ti->LODblend=FXFALSE;
- break;
- case GL_NEAREST_MIPMAP_NEAREST:
- ti->mmMode=GR_MIPMAP_NEAREST;
- ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
- ti->LODblend=FXFALSE;
- break;
- case GL_LINEAR_MIPMAP_NEAREST:
- ti->mmMode=GR_MIPMAP_NEAREST;
- ti->minFilt=GR_TEXTUREFILTER_BILINEAR;
- ti->LODblend=FXFALSE;
- break;
- case GL_NEAREST_MIPMAP_LINEAR:
- if(fxMesa->haveTwoTMUs) {
- ti->mmMode=GR_MIPMAP_NEAREST;
- ti->LODblend=FXTRUE;
- } else {
- ti->mmMode=GR_MIPMAP_NEAREST_DITHER;
- ti->LODblend=FXFALSE;
+ ti = fxTMGetTexInfo(tObj);
+
+ switch (pname) {
+
+ case GL_TEXTURE_MIN_FILTER:
+ switch (param) {
+ case GL_NEAREST:
+ ti->mmMode = GR_MIPMAP_DISABLE;
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_LINEAR:
+ ti->mmMode = GR_MIPMAP_DISABLE;
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ if (fxMesa->haveTwoTMUs) {
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXTRUE;
+ }
+ else {
+ ti->mmMode = GR_MIPMAP_NEAREST_DITHER;
+ ti->LODblend = FXFALSE;
+ }
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ if (fxMesa->haveTwoTMUs) {
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXTRUE;
+ }
+ else {
+ ti->mmMode = GR_MIPMAP_NEAREST_DITHER;
+ ti->LODblend = FXFALSE;
+ }
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ break;
+ default:
+ break;
}
- ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
+ fxTexInvalidate(ctx, tObj);
break;
- case GL_LINEAR_MIPMAP_LINEAR:
- if(fxMesa->haveTwoTMUs) {
- ti->mmMode=GR_MIPMAP_NEAREST;
- ti->LODblend=FXTRUE;
- } else {
- ti->mmMode=GR_MIPMAP_NEAREST_DITHER;
- ti->LODblend=FXFALSE;
+
+ case GL_TEXTURE_MAG_FILTER:
+ switch (param) {
+ case GL_NEAREST:
+ ti->maxFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ break;
+ case GL_LINEAR:
+ ti->maxFilt = GR_TEXTUREFILTER_BILINEAR;
+ break;
+ default:
+ break;
}
- ti->minFilt=GR_TEXTUREFILTER_BILINEAR;
- break;
- default:
- break;
- }
- fxTexInvalidate(ctx,tObj);
- break;
-
- case GL_TEXTURE_MAG_FILTER:
- switch(param) {
- case GL_NEAREST:
- ti->maxFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
+ fxTexInvalidate(ctx, tObj);
break;
- case GL_LINEAR:
- ti->maxFilt=GR_TEXTUREFILTER_BILINEAR;
+
+ case GL_TEXTURE_WRAP_S:
+ switch (param) {
+ case GL_CLAMP:
+ ti->sClamp = GR_TEXTURECLAMP_CLAMP;
+ break;
+ case GL_REPEAT:
+ ti->sClamp = GR_TEXTURECLAMP_WRAP;
+ break;
+ default:
+ break;
+ }
+ fxMesa->new_state |= FX_NEW_TEXTURING;
break;
- default:
+
+ case GL_TEXTURE_WRAP_T:
+ switch (param) {
+ case GL_CLAMP:
+ ti->tClamp = GR_TEXTURECLAMP_CLAMP;
+ break;
+ case GL_REPEAT:
+ ti->tClamp = GR_TEXTURECLAMP_WRAP;
+ break;
+ default:
+ break;
+ }
+ fxMesa->new_state |= FX_NEW_TEXTURING;
break;
- }
- fxTexInvalidate(ctx,tObj);
- break;
-
- case GL_TEXTURE_WRAP_S:
- switch(param) {
- case GL_CLAMP:
- ti->sClamp=GR_TEXTURECLAMP_CLAMP;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ /* TO DO */
break;
- case GL_REPEAT:
- ti->sClamp=GR_TEXTURECLAMP_WRAP;
+
+ case GL_TEXTURE_MIN_LOD:
+ /* TO DO */
break;
- default:
+ case GL_TEXTURE_MAX_LOD:
+ /* TO DO */
break;
- }
- fxMesa->new_state|=FX_NEW_TEXTURING;
- break;
-
- case GL_TEXTURE_WRAP_T:
- switch(param) {
- case GL_CLAMP:
- ti->tClamp=GR_TEXTURECLAMP_CLAMP;
+ case GL_TEXTURE_BASE_LEVEL:
+ fxTexInvalidate(ctx, tObj);
break;
- case GL_REPEAT:
- ti->tClamp=GR_TEXTURECLAMP_WRAP;
+ case GL_TEXTURE_MAX_LEVEL:
+ fxTexInvalidate(ctx, tObj);
break;
- default:
+
+ default:
break;
- }
- fxMesa->new_state|=FX_NEW_TEXTURING;
- break;
-
- case GL_TEXTURE_BORDER_COLOR:
- /* TO DO */
- break;
-
- case GL_TEXTURE_MIN_LOD:
- /* TO DO */
- break;
- case GL_TEXTURE_MAX_LOD:
- /* TO DO */
- break;
- case GL_TEXTURE_BASE_LEVEL:
- fxTexInvalidate(ctx,tObj);
- break;
- case GL_TEXTURE_MAX_LEVEL:
- fxTexInvalidate(ctx,tObj);
- break;
-
- default:
- break;
- }
+ }
}
-void fxDDTexDel(GLcontext *ctx, struct gl_texture_object *tObj)
+void
+fxDDTexDel(GLcontext * ctx, struct gl_texture_object *tObj)
{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDTexDel(%d,%p)\n", tObj->Name, ti);
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDTexDel(%d,%p)\n", tObj->Name, ti);
+ }
- if (!ti)
- return;
+ if (!ti)
+ return;
- fxTMFreeTexture(fxMesa, tObj);
+ fxTMFreeTexture(fxMesa, tObj);
- FREE(ti);
- tObj->DriverData = NULL;
+ FREE(ti);
+ tObj->DriverData = NULL;
}
@@ -340,146 +356,151 @@ void fxDDTexDel(GLcontext *ctx, struct gl_texture_object *tObj)
static void
convertPalette(FxU32 data[256], const struct gl_color_table *table)
{
- const GLubyte *tableUB = (const GLubyte *) table->Table;
- GLint width = table->Size;
- FxU32 r, g, b, a;
- GLint i;
+ const GLubyte *tableUB = (const GLubyte *) table->Table;
+ GLint width = table->Size;
+ FxU32 r, g, b, a;
+ GLint i;
- ASSERT(!table->FloatTable);
+ ASSERT(!table->FloatTable);
- switch (table->Format) {
- case GL_INTENSITY:
+ switch (table->Format) {
+ case GL_INTENSITY:
for (i = 0; i < width; i++) {
- r = tableUB[i];
- g = tableUB[i];
- b = tableUB[i];
- a = tableUB[i];
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ r = tableUB[i];
+ g = tableUB[i];
+ b = tableUB[i];
+ a = tableUB[i];
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
}
break;
- case GL_LUMINANCE:
+ case GL_LUMINANCE:
for (i = 0; i < width; i++) {
- r = tableUB[i];
- g = tableUB[i];
- b = tableUB[i];
- a = 255;
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ r = tableUB[i];
+ g = tableUB[i];
+ b = tableUB[i];
+ a = 255;
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
}
break;
- case GL_ALPHA:
+ case GL_ALPHA:
for (i = 0; i < width; i++) {
- r = g = b = 255;
- a = tableUB[i];
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ r = g = b = 255;
+ a = tableUB[i];
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
}
break;
- case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE_ALPHA:
for (i = 0; i < width; i++) {
- r = g = b = tableUB[i*2+0];
- a = tableUB[i*2+1];
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ r = g = b = tableUB[i * 2 + 0];
+ a = tableUB[i * 2 + 1];
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
}
break;
- case GL_RGB:
+ case GL_RGB:
for (i = 0; i < width; i++) {
- r = tableUB[i*3+0];
- g = tableUB[i*3+1];
- b = tableUB[i*3+2];
- a = 255;
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ r = tableUB[i * 3 + 0];
+ g = tableUB[i * 3 + 1];
+ b = tableUB[i * 3 + 2];
+ a = 255;
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
}
break;
- case GL_RGBA:
+ case GL_RGBA:
for (i = 0; i < width; i++) {
- r = tableUB[i*4+0];
- g = tableUB[i*4+1];
- b = tableUB[i*4+2];
- a = tableUB[i*4+3];
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ r = tableUB[i * 4 + 0];
+ g = tableUB[i * 4 + 1];
+ b = tableUB[i * 4 + 2];
+ a = tableUB[i * 4 + 3];
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
}
break;
- }
+ }
}
-void fxDDTexPalette(GLcontext *ctx, struct gl_texture_object *tObj)
+void
+fxDDTexPalette(GLcontext * ctx, struct gl_texture_object *tObj)
{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- if (tObj) {
- /* per-texture palette */
- tfxTexInfo *ti;
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDTexPalette(%d,%x)\n",
- tObj->Name, (GLuint) tObj->DriverData);
- }
- if (!tObj->DriverData)
- tObj->DriverData = fxAllocTexObjData(fxMesa);
- ti = fxTMGetTexInfo(tObj);
- convertPalette(ti->palette.data, &tObj->Palette);
- fxTexInvalidate(ctx, tObj);
- }
- else {
- /* global texture palette */
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDTexPalette(global)\n");
- }
- convertPalette(fxMesa->glbPalette.data, &ctx->Texture.Palette);
- fxMesa->new_state |= FX_NEW_TEXTURING;
- }
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (tObj) {
+ /* per-texture palette */
+ tfxTexInfo *ti;
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDTexPalette(%d,%x)\n",
+ tObj->Name, (GLuint) tObj->DriverData);
+ }
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ ti = fxTMGetTexInfo(tObj);
+ convertPalette(ti->palette.data, &tObj->Palette);
+ fxTexInvalidate(ctx, tObj);
+ }
+ else {
+ /* global texture palette */
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDTexPalette(global)\n");
+ }
+ convertPalette(fxMesa->glbPalette.data, &ctx->Texture.Palette);
+ fxMesa->new_state |= FX_NEW_TEXTURING;
+ }
}
-void fxDDTexUseGlbPalette(GLcontext *ctx, GLboolean state)
+void
+fxDDTexUseGlbPalette(GLcontext * ctx, GLboolean state)
{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDTexUseGlbPalette(%d)\n", state);
+ }
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDTexUseGlbPalette(%d)\n",state);
- }
+ if (state) {
+ fxMesa->haveGlobalPaletteTexture = 1;
- if (state) {
- fxMesa->haveGlobalPaletteTexture = 1;
+ FX_grTexDownloadTable(GR_TMU0, GR_TEXTABLE_PALETTE,
+ &(fxMesa->glbPalette));
+ if (fxMesa->haveTwoTMUs)
+ FX_grTexDownloadTable(GR_TMU1, GR_TEXTABLE_PALETTE,
+ &(fxMesa->glbPalette));
+ }
+ else {
+ fxMesa->haveGlobalPaletteTexture = 0;
- FX_grTexDownloadTable(GR_TMU0,GR_TEXTABLE_PALETTE, &(fxMesa->glbPalette));
- if (fxMesa->haveTwoTMUs)
- FX_grTexDownloadTable(GR_TMU1, GR_TEXTABLE_PALETTE, &(fxMesa->glbPalette));
- }
- else {
- fxMesa->haveGlobalPaletteTexture = 0;
+ if ((ctx->Texture.Unit[0]._Current == ctx->Texture.Unit[0].Current2D) &&
+ (ctx->Texture.Unit[0]._Current != NULL)) {
+ struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current;
- if ((ctx->Texture.Unit[0]._Current == ctx->Texture.Unit[0].Current2D) &&
- (ctx->Texture.Unit[0]._Current != NULL)) {
- struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current;
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
- if (!tObj->DriverData)
- tObj->DriverData = fxAllocTexObjData(fxMesa);
-
- fxTexInvalidate(ctx, tObj);
- }
- }
+ fxTexInvalidate(ctx, tObj);
+ }
+ }
}
-static int logbase2(int n)
+static int
+logbase2(int n)
{
- GLint i = 1;
- GLint log2 = 0;
-
- if (n<0) {
- return -1;
- }
-
- while (n > i) {
- i *= 2;
- log2++;
- }
- if (i != n) {
- return -1;
- }
- else {
- return log2;
- }
+ GLint i = 1;
+ GLint log2 = 0;
+
+ if (n < 0) {
+ return -1;
+ }
+
+ while (n > i) {
+ i *= 2;
+ log2++;
+ }
+ if (i != n) {
+ return -1;
+ }
+ else {
+ return log2;
+ }
}
/* Need different versions for different cpus.
@@ -487,329 +508,348 @@ static int logbase2(int n)
#define INT_TRICK(l2) (0x800000 * l2)
-int fxTexGetInfo(int w, int h, GrLOD_t *lodlevel, GrAspectRatio_t *ar,
- float *sscale, float *tscale,
- int *i_sscale, int *i_tscale,
- int *wscale, int *hscale)
+int
+fxTexGetInfo(int w, int h, GrLOD_t * lodlevel, GrAspectRatio_t * ar,
+ float *sscale, float *tscale,
+ int *i_sscale, int *i_tscale, int *wscale, int *hscale)
{
- static GrLOD_t lod[9]={GR_LOD_256,GR_LOD_128,GR_LOD_64,GR_LOD_32,
- GR_LOD_16,GR_LOD_8,GR_LOD_4,GR_LOD_2,GR_LOD_1};
-
- int logw,logh,ws,hs;
- GrLOD_t l;
- GrAspectRatio_t aspectratio;
- float s,t;
- int is,it;
-
- logw=logbase2(w);
- logh=logbase2(h);
-
- switch(logw-logh) {
- case 0:
- aspectratio=GR_ASPECT_1x1;
- l=lod[8-logw];
- s=t=256.0f;
- is=it=INT_TRICK(8);
- ws=hs=1;
- break;
- case 1:
- aspectratio=GR_ASPECT_2x1;
- l=lod[8-logw];
- s=256.0f;
- t=128.0f;
- is=INT_TRICK(8);it=INT_TRICK(7);
- ws=1;
- hs=1;
- break;
- case 2:
- aspectratio=GR_ASPECT_4x1;
- l=lod[8-logw];
- s=256.0f;
- t=64.0f;
- is=INT_TRICK(8);it=INT_TRICK(6);
- ws=1;
- hs=1;
- break;
- case 3:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=1;
- break;
- case 4:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=2;
- break;
- case 5:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=4;
- break;
- case 6:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=8;
- break;
- case 7:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=16;
- break;
- case 8:
- aspectratio=GR_ASPECT_8x1;
- l=lod[8-logw];
- s=256.0f;
- t=32.0f;
- is=INT_TRICK(8);it=INT_TRICK(5);
- ws=1;
- hs=32;
- break;
- case -1:
- aspectratio=GR_ASPECT_1x2;
- l=lod[8-logh];
- s=128.0f;
- t=256.0f;
- is=INT_TRICK(7);it=INT_TRICK(8);
- ws=1;
- hs=1;
- break;
- case -2:
- aspectratio=GR_ASPECT_1x4;
- l=lod[8-logh];
- s=64.0f;
- t=256.0f;
- is=INT_TRICK(6);it=INT_TRICK(8);
- ws=1;
- hs=1;
- break;
- case -3:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=1;
- hs=1;
- break;
- case -4:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=2;
- hs=1;
- break;
- case -5:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=4;
- hs=1;
- break;
- case -6:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=8;
- hs=1;
- break;
- case -7:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=16;
- hs=1;
- break;
- case -8:
- aspectratio=GR_ASPECT_1x8;
- l=lod[8-logh];
- s=32.0f;
- t=256.0f;
- is=INT_TRICK(5);it=INT_TRICK(8);
- ws=32;
- hs=1;
- break;
- default:
- return 0;
- break;
- }
-
- if(lodlevel)
- (*lodlevel)=l;
-
- if(ar)
- (*ar)=aspectratio;
-
- if(sscale)
- (*sscale)=s;
-
- if(tscale)
- (*tscale)=t;
-
- if(wscale)
- (*wscale)=ws;
-
- if(hscale)
- (*hscale)=hs;
-
- if (i_sscale)
- *i_sscale = is;
-
- if (i_tscale)
- *i_tscale = it;
-
-
- return 1;
+ static GrLOD_t lod[9] = { GR_LOD_256, GR_LOD_128, GR_LOD_64, GR_LOD_32,
+ GR_LOD_16, GR_LOD_8, GR_LOD_4, GR_LOD_2, GR_LOD_1
+ };
+
+ int logw, logh, ws, hs;
+ GrLOD_t l;
+ GrAspectRatio_t aspectratio;
+ float s, t;
+ int is, it;
+
+ logw = logbase2(w);
+ logh = logbase2(h);
+
+ switch (logw - logh) {
+ case 0:
+ aspectratio = GR_ASPECT_1x1;
+ l = lod[8 - logw];
+ s = t = 256.0f;
+ is = it = INT_TRICK(8);
+ ws = hs = 1;
+ break;
+ case 1:
+ aspectratio = GR_ASPECT_2x1;
+ l = lod[8 - logw];
+ s = 256.0f;
+ t = 128.0f;
+ is = INT_TRICK(8);
+ it = INT_TRICK(7);
+ ws = 1;
+ hs = 1;
+ break;
+ case 2:
+ aspectratio = GR_ASPECT_4x1;
+ l = lod[8 - logw];
+ s = 256.0f;
+ t = 64.0f;
+ is = INT_TRICK(8);
+ it = INT_TRICK(6);
+ ws = 1;
+ hs = 1;
+ break;
+ case 3:
+ aspectratio = GR_ASPECT_8x1;
+ l = lod[8 - logw];
+ s = 256.0f;
+ t = 32.0f;
+ is = INT_TRICK(8);
+ it = INT_TRICK(5);
+ ws = 1;
+ hs = 1;
+ break;
+ case 4:
+ aspectratio = GR_ASPECT_8x1;
+ l = lod[8 - logw];
+ s = 256.0f;
+ t = 32.0f;
+ is = INT_TRICK(8);
+ it = INT_TRICK(5);
+ ws = 1;
+ hs = 2;
+ break;
+ case 5:
+ aspectratio = GR_ASPECT_8x1;
+ l = lod[8 - logw];
+ s = 256.0f;
+ t = 32.0f;
+ is = INT_TRICK(8);
+ it = INT_TRICK(5);
+ ws = 1;
+ hs = 4;
+ break;
+ case 6:
+ aspectratio = GR_ASPECT_8x1;
+ l = lod[8 - logw];
+ s = 256.0f;
+ t = 32.0f;
+ is = INT_TRICK(8);
+ it = INT_TRICK(5);
+ ws = 1;
+ hs = 8;
+ break;
+ case 7:
+ aspectratio = GR_ASPECT_8x1;
+ l = lod[8 - logw];
+ s = 256.0f;
+ t = 32.0f;
+ is = INT_TRICK(8);
+ it = INT_TRICK(5);
+ ws = 1;
+ hs = 16;
+ break;
+ case 8:
+ aspectratio = GR_ASPECT_8x1;
+ l = lod[8 - logw];
+ s = 256.0f;
+ t = 32.0f;
+ is = INT_TRICK(8);
+ it = INT_TRICK(5);
+ ws = 1;
+ hs = 32;
+ break;
+ case -1:
+ aspectratio = GR_ASPECT_1x2;
+ l = lod[8 - logh];
+ s = 128.0f;
+ t = 256.0f;
+ is = INT_TRICK(7);
+ it = INT_TRICK(8);
+ ws = 1;
+ hs = 1;
+ break;
+ case -2:
+ aspectratio = GR_ASPECT_1x4;
+ l = lod[8 - logh];
+ s = 64.0f;
+ t = 256.0f;
+ is = INT_TRICK(6);
+ it = INT_TRICK(8);
+ ws = 1;
+ hs = 1;
+ break;
+ case -3:
+ aspectratio = GR_ASPECT_1x8;
+ l = lod[8 - logh];
+ s = 32.0f;
+ t = 256.0f;
+ is = INT_TRICK(5);
+ it = INT_TRICK(8);
+ ws = 1;
+ hs = 1;
+ break;
+ case -4:
+ aspectratio = GR_ASPECT_1x8;
+ l = lod[8 - logh];
+ s = 32.0f;
+ t = 256.0f;
+ is = INT_TRICK(5);
+ it = INT_TRICK(8);
+ ws = 2;
+ hs = 1;
+ break;
+ case -5:
+ aspectratio = GR_ASPECT_1x8;
+ l = lod[8 - logh];
+ s = 32.0f;
+ t = 256.0f;
+ is = INT_TRICK(5);
+ it = INT_TRICK(8);
+ ws = 4;
+ hs = 1;
+ break;
+ case -6:
+ aspectratio = GR_ASPECT_1x8;
+ l = lod[8 - logh];
+ s = 32.0f;
+ t = 256.0f;
+ is = INT_TRICK(5);
+ it = INT_TRICK(8);
+ ws = 8;
+ hs = 1;
+ break;
+ case -7:
+ aspectratio = GR_ASPECT_1x8;
+ l = lod[8 - logh];
+ s = 32.0f;
+ t = 256.0f;
+ is = INT_TRICK(5);
+ it = INT_TRICK(8);
+ ws = 16;
+ hs = 1;
+ break;
+ case -8:
+ aspectratio = GR_ASPECT_1x8;
+ l = lod[8 - logh];
+ s = 32.0f;
+ t = 256.0f;
+ is = INT_TRICK(5);
+ it = INT_TRICK(8);
+ ws = 32;
+ hs = 1;
+ break;
+ default:
+ return 0;
+ break;
+ }
+
+ if (lodlevel)
+ (*lodlevel) = l;
+
+ if (ar)
+ (*ar) = aspectratio;
+
+ if (sscale)
+ (*sscale) = s;
+
+ if (tscale)
+ (*tscale) = t;
+
+ if (wscale)
+ (*wscale) = ws;
+
+ if (hscale)
+ (*hscale) = hs;
+
+ if (i_sscale)
+ *i_sscale = is;
+
+ if (i_tscale)
+ *i_tscale = it;
+
+
+ return 1;
}
/*
* Given an OpenGL internal texture format, return the corresponding
* Glide internal texture format and base texture format.
*/
-void fxTexGetFormat(GLenum glformat, GrTextureFormat_t *tfmt, GLint *ifmt)
+void
+fxTexGetFormat(GLenum glformat, GrTextureFormat_t * tfmt, GLint * ifmt)
{
- switch(glformat) {
- case 1:
- case GL_LUMINANCE:
- case GL_LUMINANCE4:
- case GL_LUMINANCE8:
- case GL_LUMINANCE12:
- case GL_LUMINANCE16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_INTENSITY_8;
- if(ifmt)
- (*ifmt)=GL_LUMINANCE;
+ switch (glformat) {
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ if (tfmt)
+ (*tfmt) = GR_TEXFMT_INTENSITY_8;
+ if (ifmt)
+ (*ifmt) = GL_LUMINANCE;
break;
- case 2:
- case GL_LUMINANCE_ALPHA:
- case GL_LUMINANCE4_ALPHA4:
- case GL_LUMINANCE6_ALPHA2:
- case GL_LUMINANCE8_ALPHA8:
- case GL_LUMINANCE12_ALPHA4:
- case GL_LUMINANCE12_ALPHA12:
- case GL_LUMINANCE16_ALPHA16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ALPHA_INTENSITY_88;
- if(ifmt)
- (*ifmt)=GL_LUMINANCE_ALPHA;
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE4_ALPHA4:
+ case GL_LUMINANCE6_ALPHA2:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+ if (tfmt)
+ (*tfmt) = GR_TEXFMT_ALPHA_INTENSITY_88;
+ if (ifmt)
+ (*ifmt) = GL_LUMINANCE_ALPHA;
+ break;
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ if (tfmt)
+ (*tfmt) = GR_TEXFMT_ALPHA_8;
+ if (ifmt)
+ (*ifmt) = GL_INTENSITY;
break;
- case GL_INTENSITY:
- case GL_INTENSITY4:
- case GL_INTENSITY8:
- case GL_INTENSITY12:
- case GL_INTENSITY16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ALPHA_8;
- if(ifmt)
- (*ifmt)=GL_INTENSITY;
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ if (tfmt)
+ (*tfmt) = GR_TEXFMT_ALPHA_8;
+ if (ifmt)
+ (*ifmt) = GL_ALPHA;
break;
- case GL_ALPHA:
- case GL_ALPHA4:
- case GL_ALPHA8:
- case GL_ALPHA12:
- case GL_ALPHA16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ALPHA_8;
- if(ifmt)
- (*ifmt)=GL_ALPHA;
+ case 3:
+ case GL_RGB:
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ if (tfmt)
+ (*tfmt) = GR_TEXFMT_RGB_565;
+ if (ifmt)
+ (*ifmt) = GL_RGB;
break;
- case 3:
- case GL_RGB:
- case GL_R3_G3_B2:
- case GL_RGB4:
- case GL_RGB5:
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_RGB_565;
- if(ifmt)
- (*ifmt)=GL_RGB;
+ case 4:
+ case GL_RGBA:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ if (tfmt)
+ (*tfmt) = GR_TEXFMT_ARGB_4444;
+ if (ifmt)
+ (*ifmt) = GL_RGBA;
break;
- case 4:
- case GL_RGBA:
- case GL_RGBA2:
- case GL_RGBA4:
- case GL_RGBA8:
- case GL_RGB10_A2:
- case GL_RGBA12:
- case GL_RGBA16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ARGB_4444;
- if(ifmt)
- (*ifmt)=GL_RGBA;
+ case GL_RGB5_A1:
+ if (tfmt)
+ (*tfmt) = GR_TEXFMT_ARGB_1555;
+ if (ifmt)
+ (*ifmt) = GL_RGBA;
break;
- case GL_RGB5_A1:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ARGB_1555;
- if(ifmt)
- (*ifmt)=GL_RGBA;
- break;
- case GL_COLOR_INDEX:
- case GL_COLOR_INDEX1_EXT:
- case GL_COLOR_INDEX2_EXT:
- case GL_COLOR_INDEX4_EXT:
- case GL_COLOR_INDEX8_EXT:
- case GL_COLOR_INDEX12_EXT:
- case GL_COLOR_INDEX16_EXT:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_P_8;
- if(ifmt)
- (*ifmt)=GL_RGBA; /* XXX why is this RGBA? */
+ case GL_COLOR_INDEX:
+ case GL_COLOR_INDEX1_EXT:
+ case GL_COLOR_INDEX2_EXT:
+ case GL_COLOR_INDEX4_EXT:
+ case GL_COLOR_INDEX8_EXT:
+ case GL_COLOR_INDEX12_EXT:
+ case GL_COLOR_INDEX16_EXT:
+ if (tfmt)
+ (*tfmt) = GR_TEXFMT_P_8;
+ if (ifmt)
+ (*ifmt) = GL_RGBA; /* XXX why is this RGBA? */
break;
- default:
+ default:
fprintf(stderr,
- "fx Driver: unsupported internalFormat (0x%x) in fxTexGetFormat()\n",
- glformat);
+ "fx Driver: unsupported internalFormat (0x%x) in fxTexGetFormat()\n",
+ glformat);
fxCloseHardware();
exit(-1);
break;
- }
+ }
}
-static GLboolean fxIsTexSupported(GLenum target, GLint internalFormat,
- const struct gl_texture_image *image)
+static GLboolean
+fxIsTexSupported(GLenum target, GLint internalFormat,
+ const struct gl_texture_image *image)
{
- if(target != GL_TEXTURE_2D)
- return GL_FALSE;
+ if (target != GL_TEXTURE_2D)
+ return GL_FALSE;
- if(!fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL,
- NULL,NULL))
- return GL_FALSE;
+ if (!fxTexGetInfo
+ (image->Width, image->Height, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL)) return GL_FALSE;
- if (image->Border > 0)
- return GL_FALSE;
+ if (image->Border > 0)
+ return GL_FALSE;
- return GL_TRUE;
+ return GL_TRUE;
}
@@ -826,12 +866,12 @@ static GLboolean fxIsTexSupported(GLenum target, GLint internalFormat,
static void
fetch_intensity8(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texelOut)
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
{
GLchan *rgba = (GLchan *) texelOut;
const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
const GLubyte *texel;
-
+
i = i * mml->wScale;
j = j * mml->hScale;
@@ -845,12 +885,12 @@ fetch_intensity8(const struct gl_texture_image *texImage,
static void
fetch_luminance8(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texelOut)
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
{
GLchan *rgba = (GLchan *) texelOut;
const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
const GLubyte *texel;
-
+
i = i * mml->wScale;
j = j * mml->hScale;
@@ -864,12 +904,12 @@ fetch_luminance8(const struct gl_texture_image *texImage,
static void
fetch_alpha8(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texelOut)
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
{
GLchan *rgba = (GLchan *) texelOut;
const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
const GLubyte *texel;
-
+
i = i * mml->wScale;
j = j * mml->hScale;
i = i * mml->width / texImage->Width;
@@ -885,7 +925,7 @@ fetch_alpha8(const struct gl_texture_image *texImage,
static void
fetch_index8(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texelOut)
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
{
/* XXX todo */
}
@@ -893,12 +933,12 @@ fetch_index8(const struct gl_texture_image *texImage,
static void
fetch_luminance8_alpha8(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texelOut)
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
{
GLchan *rgba = (GLchan *) texelOut;
const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
const GLubyte *texel;
-
+
i = i * mml->wScale;
j = j * mml->hScale;
@@ -912,86 +952,87 @@ fetch_luminance8_alpha8(const struct gl_texture_image *texImage,
static void
fetch_r5g6b5(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texelOut)
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
{
GLchan *rgba = (GLchan *) texelOut;
const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
const GLushort *texel;
-
+
i = i * mml->wScale;
j = j * mml->hScale;
texel = ((GLushort *) texImage->Data) + j * mml->width + i;
rgba[RCOMP] = (((*texel) >> 11) & 0x1f) * 255 / 31;
- rgba[GCOMP] = (((*texel) >> 5) & 0x3f) * 255 / 63;
- rgba[BCOMP] = (((*texel) >> 0) & 0x1f) * 255 / 31;
+ rgba[GCOMP] = (((*texel) >> 5) & 0x3f) * 255 / 63;
+ rgba[BCOMP] = (((*texel) >> 0) & 0x1f) * 255 / 31;
rgba[ACOMP] = 255;
}
static void
fetch_r4g4b4a4(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texelOut)
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
{
GLchan *rgba = (GLchan *) texelOut;
const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
const GLushort *texel;
-
+
i = i * mml->wScale;
j = j * mml->hScale;
texel = ((GLushort *) texImage->Data) + j * mml->width + i;
rgba[RCOMP] = (((*texel) >> 12) & 0xf) * 255 / 15;
- rgba[GCOMP] = (((*texel) >> 8) & 0xf) * 255 / 15;
- rgba[BCOMP] = (((*texel) >> 4) & 0xf) * 255 / 15;
- rgba[ACOMP] = (((*texel) >> 0) & 0xf) * 255 / 15;
+ rgba[GCOMP] = (((*texel) >> 8) & 0xf) * 255 / 15;
+ rgba[BCOMP] = (((*texel) >> 4) & 0xf) * 255 / 15;
+ rgba[ACOMP] = (((*texel) >> 0) & 0xf) * 255 / 15;
}
static void
fetch_r5g5b5a1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texelOut)
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
{
GLchan *rgba = (GLchan *) texelOut;
const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
const GLushort *texel;
-
+
i = i * mml->wScale;
j = j * mml->hScale;
texel = ((GLushort *) texImage->Data) + j * mml->width + i;
rgba[RCOMP] = (((*texel) >> 11) & 0x1f) * 255 / 31;
- rgba[GCOMP] = (((*texel) >> 6) & 0x1f) * 255 / 31;
- rgba[BCOMP] = (((*texel) >> 1) & 0x1f) * 255 / 31;
- rgba[ACOMP] = (((*texel) >> 0) & 0x01) * 255;
+ rgba[GCOMP] = (((*texel) >> 6) & 0x1f) * 255 / 31;
+ rgba[BCOMP] = (((*texel) >> 1) & 0x1f) * 255 / 31;
+ rgba[ACOMP] = (((*texel) >> 0) & 0x01) * 255;
}
-static void PrintTexture(int w, int h, int c, const GLubyte *data)
+static void
+PrintTexture(int w, int h, int c, const GLubyte * data)
{
- int i, j;
- for (i = 0; i < h; i++) {
- for (j = 0; j < w; j++) {
- if (c==2)
- printf("%02x %02x ", data[0], data[1]);
- else if (c==3)
- printf("%02x %02x %02x ", data[0], data[1], data[2]);
- data += c;
- }
- printf("\n");
- }
+ int i, j;
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ if (c == 2)
+ printf("%02x %02x ", data[0], data[1]);
+ else if (c == 3)
+ printf("%02x %02x %02x ", data[0], data[1], data[2]);
+ data += c;
+ }
+ printf("\n");
+ }
}
void
-fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
- GLint internalFormat, GLint width, GLint height, GLint border,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+ GLint internalFormat, GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
GrTextureFormat_t gldformat;
tfxTexInfo *ti;
tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
@@ -1016,8 +1057,8 @@ fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
fxTexGetFormat(internalFormat, &gldformat, NULL);
fxTexGetInfo(width, height, NULL, NULL, NULL, NULL,
- NULL, NULL, &mml->wScale, &mml->hScale);
-
+ NULL, NULL, &mml->wScale, &mml->hScale);
+
mml->width = width * mml->wScale;
mml->height = height * mml->hScale;
@@ -1117,13 +1158,13 @@ fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
}
_mesa_set_teximage_component_sizes(mesaFormat, texImage);
- texImage->Type = 0; /* indicates a driver-specific format */
+ texImage->Type = 0; /* indicates a driver-specific format */
/* allocate storage for texture image */
texImage->Data = MALLOC(mml->width * mml->height * texelSize);
if (!texImage->Data)
return;
-
+
mml->glideFormat = gldformat;
fxTexInvalidate(ctx, texObj);
@@ -1133,9 +1174,9 @@ fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
}
else {
success = _mesa_convert_teximage(mesaFormat, mml->width, mml->height,
- texImage->Data, mml->width * texelSize,
- width, height,
- format, type, pixels, packing);
+ texImage->Data, mml->width * texelSize,
+ width, height,
+ format, type, pixels, packing);
}
if (!success) {
@@ -1152,44 +1193,44 @@ fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
/* Apply pixel transfer ops and convert image format to something
* simple (format = simpleFormat, type = CHAN_TYPE).
*/
- _mesa_transfer_teximage(ctx, 2, /* dimensions */
- simpleFormat, /* dest format */
- tempImage, /* dest addr */
- width, height, 1, /* src size */
- 0, 0, 0, /* dst offsets */
- width * comps, /* dstRowStride */
- 0, /* dstImageStride */
- format, type, pixels, packing /* src info */);
+ _mesa_transfer_teximage(ctx, 2, /* dimensions */
+ simpleFormat, /* dest format */
+ tempImage, /* dest addr */
+ width, height, 1, /* src size */
+ 0, 0, 0, /* dst offsets */
+ width * comps, /* dstRowStride */
+ 0, /* dstImageStride */
+ format, type, pixels, packing /* src info */ );
/* this conversion better work! */
success = _mesa_convert_teximage(mesaFormat, mml->width, mml->height,
- texImage->Data, mml->width * texelSize,
- width, height,
- simpleFormat, CHAN_TYPE, tempImage,
- &_mesa_native_packing);
+ texImage->Data, mml->width * texelSize,
+ width, height,
+ simpleFormat, CHAN_TYPE, tempImage,
+ &_mesa_native_packing);
assert(success);
FREE(tempImage);
}
if (ti->validated && ti->isInTM) {
- /*printf("reloadmipmaplevels\n");*/
+ /*printf("reloadmipmaplevels\n"); */
fxTMReloadMipMapLevel(fxMesa, texObj, level);
}
else {
- /*printf("invalidate2\n");*/
- fxTexInvalidate(ctx,texObj);
+ /*printf("invalidate2\n"); */
+ fxTexInvalidate(ctx, texObj);
}
}
void
-fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type, const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
{
fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
tfxTexInfo *ti;
@@ -1208,7 +1249,7 @@ fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
mml = FX_MIPMAP_DATA(texImage);
assert(mml);
- assert(texImage->Data); /* must have an existing texture image! */
+ assert(texImage->Data); /* must have an existing texture image! */
switch (mml->glideFormat) {
case GR_TEXFMT_INTENSITY_8:
@@ -1249,12 +1290,12 @@ fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
}
else {
success = _mesa_convert_texsubimage(mesaFormat, xoffset, yoffset,
- mml->width, mml->height,
- texImage->Data,
- mml->width * texelSize,
- width, height,
- texImage->Width, texImage->Height,
- format, type, pixels, packing);
+ mml->width, mml->height,
+ texImage->Data,
+ mml->width * texelSize,
+ width, height,
+ texImage->Width, texImage->Height,
+ format, type, pixels, packing);
}
if (!success) {
@@ -1273,25 +1314,24 @@ fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
/* Apply pixel transfer ops and convert image format to something
* simple (format = simpleFormat, type = CHAN_TYPE).
*/
- _mesa_transfer_teximage(ctx, 2, /* dimensions */
- simpleFormat, /* dest format */
- tempImage, /* dest addr */
- width, height, 1, /* src size */
- 0, 0, 0, /* dst offsets */
- width * comps, /* dstRowStride */
- 0, /* dstImageStride */
- format, type, pixels, packing /* src info */);
+ _mesa_transfer_teximage(ctx, 2, /* dimensions */
+ simpleFormat, /* dest format */
+ tempImage, /* dest addr */
+ width, height, 1, /* src size */
+ 0, 0, 0, /* dst offsets */
+ width * comps, /* dstRowStride */
+ 0, /* dstImageStride */
+ format, type, pixels, packing /* src info */ );
/* this conversion better work! */
success = _mesa_convert_texsubimage(mesaFormat, xoffset, yoffset,
- mml->width, mml->height,
- texImage->Data,
- mml->width * texelSize, /* dstRowStride */
- width * mml->wScale,
- height * mml->hScale,
- width, height,
- simpleFormat, CHAN_TYPE, tempImage,
- &_mesa_native_packing);
+ mml->width, mml->height,
+ texImage->Data, mml->width * texelSize, /* dstRowStride */
+ width * mml->wScale,
+ height * mml->hScale,
+ width, height,
+ simpleFormat, CHAN_TYPE, tempImage,
+ &_mesa_native_packing);
assert(success);
FREE(tempImage);
}
@@ -1311,9 +1351,10 @@ fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
*/
extern int gl_fx_dummy_function_ddtex(void);
-int gl_fx_dummy_function_ddtex(void)
+int
+gl_fx_dummy_function_ddtex(void)
{
- return 0;
+ return 0;
}
-#endif /* FX */
+#endif /* FX */
diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h
index 2e2a71c88e..7a92f12a75 100644
--- a/src/mesa/drivers/glide/fxdrv.h
+++ b/src/mesa/drivers/glide/fxdrv.h
@@ -96,29 +96,33 @@ extern float gl_ubyte_to_float_255_color_tab[256];
/* Should have size == 16 * sizeof(float).
*/
-typedef union {
- GrVertex v;
- GLfloat f[16];
- GLuint ui[16];
-} fxVertex;
+typedef union
+{
+ GrVertex v;
+ GLfloat f[16];
+ GLuint ui[16];
+}
+fxVertex;
/* Used in the fxvtxfmt t&l engine.
*/
-typedef struct {
+typedef struct
+{
GrVertex v;
GLfloat clip[4];
GLfloat texcoord[2][2];
GLubyte mask;
GLfloat normal[3]; /* for replay & fallback */
-} fxClipVertex;
+}
+fxClipVertex;
-typedef void (*vfmt_project_func)( GLcontext *ctx, fxClipVertex *v );
-typedef void (*vfmt_interpolate_func)( GLfloat t,
- fxClipVertex *O,
- const fxClipVertex *I,
- const fxClipVertex *J );
+typedef void (*vfmt_project_func) (GLcontext * ctx, fxClipVertex * v);
+typedef void (*vfmt_interpolate_func) (GLfloat t,
+ fxClipVertex * O,
+ const fxClipVertex * I,
+ const fxClipVertex * J);
@@ -204,87 +208,97 @@ typedef void (*vfmt_interpolate_func)( GLfloat t,
/*
Memory range from startAddr to endAddr-1
*/
-typedef struct MemRange_t {
- struct MemRange_t *next;
- FxU32 startAddr, endAddr;
-} MemRange;
-
-typedef struct {
- GLsizei width, height; /* image size */
- GLint wScale, hScale; /* image scale factor */
- GrTextureFormat_t glideFormat; /* Glide image format */
-} tfxMipMapLevel;
+typedef struct MemRange_t
+{
+ struct MemRange_t *next;
+ FxU32 startAddr, endAddr;
+}
+MemRange;
+
+typedef struct
+{
+ GLsizei width, height; /* image size */
+ GLint wScale, hScale; /* image scale factor */
+ GrTextureFormat_t glideFormat; /* Glide image format */
+}
+tfxMipMapLevel;
/*
* TDFX-specific texture object data. This hangs off of the
* struct gl_texture_object DriverData pointer.
*/
-typedef struct tfxTexInfo_t {
- struct tfxTexInfo *next;
- struct gl_texture_object *tObj;
+typedef struct tfxTexInfo_t
+{
+ struct tfxTexInfo *next;
+ struct gl_texture_object *tObj;
- GLuint lastTimeUsed;
- FxU32 whichTMU;
- GLboolean isInTM;
+ GLuint lastTimeUsed;
+ FxU32 whichTMU;
+ GLboolean isInTM;
- MemRange *tm[FX_NUM_TMU];
+ MemRange *tm[FX_NUM_TMU];
- GLint minLevel, maxLevel;
- GLint baseLevelInternalFormat;
+ GLint minLevel, maxLevel;
+ GLint baseLevelInternalFormat;
- GrTexInfo info;
+ GrTexInfo info;
- GrTextureFilterMode_t minFilt;
- GrTextureFilterMode_t maxFilt;
- FxBool LODblend;
+ GrTextureFilterMode_t minFilt;
+ GrTextureFilterMode_t maxFilt;
+ FxBool LODblend;
- GrTextureClampMode_t sClamp;
- GrTextureClampMode_t tClamp;
+ GrTextureClampMode_t sClamp;
+ GrTextureClampMode_t tClamp;
- GrMipMapMode_t mmMode;
+ GrMipMapMode_t mmMode;
- GLfloat sScale, tScale;
- GLint int_sScale, int_tScale; /* x86 floating point trick for
- * multiplication by powers of 2.
- * Used in fxfasttmp.h
- */
+ GLfloat sScale, tScale;
+ GLint int_sScale, int_tScale; /* x86 floating point trick for
+ * multiplication by powers of 2.
+ * Used in fxfasttmp.h
+ */
- GuTexPalette palette;
+ GuTexPalette palette;
- GLboolean fixedPalette;
- GLboolean validated;
-} tfxTexInfo;
+ GLboolean fixedPalette;
+ GLboolean validated;
+}
+tfxTexInfo;
-typedef struct {
- GLuint swapBuffer;
- GLuint reqTexUpload;
- GLuint texUpload;
- GLuint memTexUpload;
-} tfxStats;
+typedef struct
+{
+ GLuint swapBuffer;
+ GLuint reqTexUpload;
+ GLuint texUpload;
+ GLuint memTexUpload;
+}
+tfxStats;
-typedef struct {
- /* Alpha test */
+typedef struct
+{
+ /* Alpha test */
- GLboolean alphaTestEnabled;
- GrCmpFnc_t alphaTestFunc;
- GrAlpha_t alphaTestRefValue;
+ GLboolean alphaTestEnabled;
+ GrCmpFnc_t alphaTestFunc;
+ GrAlpha_t alphaTestRefValue;
- /* Blend function */
+ /* Blend function */
- GLboolean blendEnabled;
- GrAlphaBlendFnc_t blendSrcFuncRGB;
- GrAlphaBlendFnc_t blendDstFuncRGB;
- GrAlphaBlendFnc_t blendSrcFuncAlpha;
- GrAlphaBlendFnc_t blendDstFuncAlpha;
+ GLboolean blendEnabled;
+ GrAlphaBlendFnc_t blendSrcFuncRGB;
+ GrAlphaBlendFnc_t blendDstFuncRGB;
+ GrAlphaBlendFnc_t blendSrcFuncAlpha;
+ GrAlphaBlendFnc_t blendDstFuncAlpha;
- /* Depth test */
+ /* Depth test */
- GLboolean depthTestEnabled;
- GLboolean depthMask;
- GrCmpFnc_t depthTestFunc;
-} tfxUnitsState;
+ GLboolean depthTestEnabled;
+ GLboolean depthMask;
+ GrCmpFnc_t depthTestFunc;
+}
+tfxUnitsState;
@@ -360,7 +374,7 @@ typedef struct {
_NEW_MODELVIEW | \
_TNL_NEW_NEED_EYE_COORDS | \
_FX_NEW_RENDERSTATE)
-
+
/* These lookup table are used to extract RGB values in [0,255] from
* 16-bit pixel values.
@@ -370,20 +384,22 @@ extern GLubyte FX_PixelToG[0x10000];
extern GLubyte FX_PixelToB[0x10000];
-typedef void (*fx_tri_func)( GLcontext *, const fxVertex *,
- const fxVertex *, const fxVertex * );
-typedef void (*fx_line_func)( GLcontext *, const fxVertex *, const fxVertex * );
-typedef void (*fx_point_func)( GLcontext *, const fxVertex * );
+typedef void (*fx_tri_func) (GLcontext *, const fxVertex *,
+ const fxVertex *, const fxVertex *);
+typedef void (*fx_line_func) (GLcontext *, const fxVertex *,
+ const fxVertex *);
+typedef void (*fx_point_func) (GLcontext *, const fxVertex *);
-struct tfxMesaContext {
+struct tfxMesaContext
+{
GuTexPalette glbPalette;
- GLcontext *glCtx; /* the core Mesa context */
- GLvisual *glVis; /* describes the color buffer */
- GLframebuffer *glBuffer; /* the ancillary buffers */
+ GLcontext *glCtx; /* the core Mesa context */
+ GLvisual *glVis; /* describes the color buffer */
+ GLframebuffer *glBuffer; /* the ancillary buffers */
- GLint board; /* the board used for this context */
- GLint width, height; /* size of color buffer */
+ GLint board; /* the board used for this context */
+ GLint width, height; /* size of color buffer */
GrBuffer_t currentFB;
@@ -395,10 +411,10 @@ struct tfxMesaContext {
GrCullMode_t cullMode;
tfxUnitsState unitsState;
- tfxUnitsState restoreUnitsState; /* saved during multipass */
+ tfxUnitsState restoreUnitsState; /* saved during multipass */
- GLuint new_state;
+ GLuint new_state;
/* Texture Memory Manager Data
*/
@@ -476,7 +492,7 @@ struct tfxMesaContext {
GLboolean haveGlobalPaletteTexture;
GLint swapInterval;
GLint maxPendingSwapBuffers;
-
+
FX_GrContext_t glideContext;
int screen_width;
@@ -493,18 +509,18 @@ struct tfxMesaContext {
GLvertexformat vtxfmt;
fxClipVertex current;
fxClipVertex *vert; /* points into verts[] */
- void (*fire_on_vertex)( GLcontext * );
- void (*fire_on_end)( GLcontext * );
- void (*fire_on_fallback)( GLcontext * );
-
+ void (*fire_on_vertex) (GLcontext *);
+ void (*fire_on_end) (GLcontext *);
+ void (*fire_on_fallback) (GLcontext *);
+
vfmt_project_func project_vertex;
vfmt_interpolate_func interpolate_vertices;
int vtxfmt_fallback_count;
int vtxfmt_installed;
- void (*old_begin)( GLenum );
+ void (*old_begin) (GLenum);
GLenum prim;
-
+
GLuint accel_light;
GLfloat basecolor[4];
@@ -516,7 +532,7 @@ struct tfxMesaContext {
GLuint size;
};
-typedef void (*tfxSetupFunc)(GLcontext *ctx, GLuint, GLuint );
+typedef void (*tfxSetupFunc) (GLcontext * ctx, GLuint, GLuint);
extern GrHwConfiguration glbHWConfig;
extern int glbCurrentBoard;
@@ -527,40 +543,41 @@ extern void fxSetupDDPointers(GLcontext *);
/* fxvsetup:
*/
extern void fxDDSetupInit(void);
-extern void fxAllocVB( GLcontext *ctx );
-extern void fxFreeVB( GLcontext *ctx );
-extern void fxPrintSetupFlags( const char *msg, GLuint flags );
-extern void fx_BuildProjVerts( GLcontext *ctx,
- GLuint start, GLuint count,
- GLuint newinputs );
-extern void fx_validate_BuildProjVerts(GLcontext *ctx,
+extern void fxAllocVB(GLcontext * ctx);
+extern void fxFreeVB(GLcontext * ctx);
+extern void fxPrintSetupFlags(const char *msg, GLuint flags);
+extern void fx_BuildProjVerts(GLcontext * ctx,
+ GLuint start, GLuint count, GLuint newinputs);
+extern void fx_validate_BuildProjVerts(GLcontext * ctx,
GLuint start, GLuint count,
- GLuint newinputs );
+ GLuint newinputs);
/* fxtrifuncs:
*/
extern void fxDDTrifuncInit(void);
-extern void fxDDChooseRenderState( GLcontext *ctx );
+extern void fxDDChooseRenderState(GLcontext * ctx);
extern void fxUpdateDDSpanPointers(GLcontext *);
extern void fxSetupDDSpanPointers(GLcontext *);
-extern void fxPrintTextureData(tfxTexInfo *ti);
-extern void fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
- GLint internalFormat, GLint width, GLint height, GLint border,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-
-extern void fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+extern void fxPrintTextureData(tfxTexInfo * ti);
+extern void fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+ GLint internalFormat, GLint width, GLint height,
+ GLint border, GLenum format, GLenum type,
+ const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+extern void fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *);
extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *,
GLenum, const GLfloat *);
@@ -575,7 +592,7 @@ extern void fxDDBlendFunc(GLcontext *, GLenum, GLenum);
extern void fxDDDepthMask(GLcontext *, GLboolean);
extern void fxDDDepthFunc(GLcontext *, GLenum);
-extern void fxDDInitExtensions( GLcontext *ctx );
+extern void fxDDInitExtensions(GLcontext * ctx);
extern void fxTMInit(fxMesaContext ctx);
extern void fxTMClose(fxMesaContext ctx);
@@ -584,64 +601,64 @@ extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint);
extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *);
#define fxTMMoveOutTM_NoLock fxTMMoveOutTM
extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *);
-extern void fxTMReloadMipMapLevel(fxMesaContext, struct gl_texture_object *, GLint);
-extern void fxTMReloadSubMipMapLevel(fxMesaContext, struct gl_texture_object *,
- GLint, GLint, GLint);
+extern void fxTMReloadMipMapLevel(fxMesaContext, struct gl_texture_object *,
+ GLint);
+extern void fxTMReloadSubMipMapLevel(fxMesaContext,
+ struct gl_texture_object *, GLint, GLint,
+ GLint);
extern void fxTexGetFormat(GLenum, GrTextureFormat_t *, GLint *);
extern int fxTexGetInfo(int, int, GrLOD_t *, GrAspectRatio_t *,
float *, float *, int *, int *, int *, int *);
-extern void fxDDScissor( GLcontext *ctx,
- GLint x, GLint y, GLsizei w, GLsizei h );
-extern void fxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params );
-extern void fxDDColorMask(GLcontext *ctx,
- GLboolean r, GLboolean g,
- GLboolean b, GLboolean a );
+extern void fxDDScissor(GLcontext * ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h);
+extern void fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params);
+extern void fxDDColorMask(GLcontext * ctx,
+ GLboolean r, GLboolean g, GLboolean b, GLboolean a);
-extern void fxDDWriteDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLdepth depth[], const GLubyte mask[]);
+extern void fxDDWriteDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
+ const GLdepth depth[], const GLubyte mask[]);
-extern void fxDDReadDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLdepth depth[]);
+extern void fxDDReadDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
+ GLdepth depth[]);
-extern void fxDDWriteDepthPixels(GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- const GLdepth depth[], const GLubyte mask[]);
+extern void fxDDWriteDepthPixels(GLcontext * ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLdepth depth[], const GLubyte mask[]);
-extern void fxDDReadDepthPixels(GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- GLdepth depth[]);
+extern void fxDDReadDepthPixels(GLcontext * ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ GLdepth depth[]);
-extern void fxDDShadeModel(GLcontext *ctx, GLenum mode);
+extern void fxDDShadeModel(GLcontext * ctx, GLenum mode);
-extern void fxDDCullFace(GLcontext *ctx, GLenum mode);
-extern void fxDDFrontFace(GLcontext *ctx, GLenum mode);
+extern void fxDDCullFace(GLcontext * ctx, GLenum mode);
+extern void fxDDFrontFace(GLcontext * ctx, GLenum mode);
-extern void fxPrintRenderState( const char *msg, GLuint state );
-extern void fxPrintHintState( const char *msg, GLuint state );
+extern void fxPrintRenderState(const char *msg, GLuint state);
+extern void fxPrintHintState(const char *msg, GLuint state);
-extern int fxDDInitFxMesaContext( fxMesaContext fxMesa );
-extern void fxDDDestroyFxMesaContext( fxMesaContext fxMesa );
+extern int fxDDInitFxMesaContext(fxMesaContext fxMesa);
+extern void fxDDDestroyFxMesaContext(fxMesaContext fxMesa);
-extern void fxSetScissorValues(GLcontext *ctx);
+extern void fxSetScissorValues(GLcontext * ctx);
extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
- struct gl_texture_object *tObj,
- GLint where);
+ struct gl_texture_object *tObj, GLint where);
extern void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder);
/* fxvtxfmt:
*/
-extern void fxDDCheckVtxfmt( GLcontext *ctx );
-extern void fx_update_lighting( GLcontext *ctx );
-extern void fxDDInitVtxfmt( GLcontext *ctx );
+extern void fxDDCheckVtxfmt(GLcontext * ctx);
+extern void fx_update_lighting(GLcontext * ctx);
+extern void fxDDInitVtxfmt(GLcontext * ctx);
/* fxsimplerender
*/
-extern const struct gl_pipeline_stage fx_render_stage;
+extern const struct gl_pipeline_stage fx_render_stage;
#endif
diff --git a/src/mesa/drivers/glide/fxglidew.c b/src/mesa/drivers/glide/fxglidew.c
index 400f1fbafc..89f6e5f8e6 100644
--- a/src/mesa/drivers/glide/fxglidew.c
+++ b/src/mesa/drivers/glide/fxglidew.c
@@ -41,7 +41,7 @@
* See fxapi.h for more revision/author details.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
@@ -54,280 +54,319 @@
#include <stdlib.h>
#include <string.h>
-FxI32 FX_grGetInteger_NoLock(FxU32 pname)
+FxI32
+FX_grGetInteger_NoLock(FxU32 pname)
{
#if !defined(FX_GLIDE3)
- switch (pname)
- {
- case FX_FOG_TABLE_ENTRIES:
- return GR_FOG_TABLE_SIZE;
- case FX_GLIDE_STATE_SIZE:
- return sizeof(GrState);
- case FX_LFB_PIXEL_PIPE:
- return FXFALSE;
- case FX_PENDING_BUFFERSWAPS:
- return grBufferNumPending();
- case FX_TEXTURE_ALIGN:
- /* This is a guess from reading the glide3 docs */
- return 8;
- default:
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n");
- }
- return -1;
- }
+ switch (pname) {
+ case FX_FOG_TABLE_ENTRIES:
+ return GR_FOG_TABLE_SIZE;
+ case FX_GLIDE_STATE_SIZE:
+ return sizeof(GrState);
+ case FX_LFB_PIXEL_PIPE:
+ return FXFALSE;
+ case FX_PENDING_BUFFERSWAPS:
+ return grBufferNumPending();
+ case FX_TEXTURE_ALIGN:
+ /* This is a guess from reading the glide3 docs */
+ return 8;
+ default:
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "Wrong parameter in FX_grGetInteger!\n");
+ }
+ return -1;
+ }
#else
- FxU32 grname;
- FxI32 result;
-
- switch (pname)
- {
- case FX_FOG_TABLE_ENTRIES:
- case FX_GLIDE_STATE_SIZE:
- case FX_LFB_PIXEL_PIPE:
- case FX_PENDING_BUFFERSWAPS:
- case FX_TEXTURE_ALIGN:
- grname = pname;
- break;
- default:
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n");
- }
- return -1;
- }
-
- grGet(grname,4,&result);
- return result;
+ FxU32 grname;
+ FxI32 result;
+
+ switch (pname) {
+ case FX_FOG_TABLE_ENTRIES:
+ case FX_GLIDE_STATE_SIZE:
+ case FX_LFB_PIXEL_PIPE:
+ case FX_PENDING_BUFFERSWAPS:
+ case FX_TEXTURE_ALIGN:
+ grname = pname;
+ break;
+ default:
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "Wrong parameter in FX_grGetInteger!\n");
+ }
+ return -1;
+ }
+
+ grGet(grname, 4, &result);
+ return result;
#endif
}
-FxI32 FX_grGetInteger(FxU32 pname)
+FxI32
+FX_grGetInteger(FxU32 pname)
{
- int result;
+ int result;
- BEGIN_BOARD_LOCK();
- result=FX_grGetInteger_NoLock(pname);
- END_BOARD_LOCK();
- return result;
+ BEGIN_BOARD_LOCK();
+ result = FX_grGetInteger_NoLock(pname);
+ END_BOARD_LOCK();
+ return result;
}
-FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
- GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
- FxBool pixelPipeline, GrLfbInfo_t *info ) {
- FxBool result;
+FxBool
+FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
+ GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
+ FxBool pixelPipeline, GrLfbInfo_t * info)
+{
+ FxBool result;
- BEGIN_BOARD_LOCK();
- result=grLfbLock(type, buffer, writeMode, origin, pixelPipeline, info);
- END_BOARD_LOCK();
- return result;
+ BEGIN_BOARD_LOCK();
+ result = grLfbLock(type, buffer, writeMode, origin, pixelPipeline, info);
+ END_BOARD_LOCK();
+ return result;
}
-FxU32 FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info) {
- FxU32 result;
+FxU32
+FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo * info)
+{
+ FxU32 result;
- BEGIN_BOARD_LOCK();
- result=grTexTextureMemRequired(evenOdd, info);
- END_BOARD_LOCK();
- return result;
+ BEGIN_BOARD_LOCK();
+ result = grTexTextureMemRequired(evenOdd, info);
+ END_BOARD_LOCK();
+ return result;
}
-FxU32 FX_grTexMinAddress(GrChipID_t tmu) {
- FxU32 result;
+FxU32
+FX_grTexMinAddress(GrChipID_t tmu)
+{
+ FxU32 result;
- BEGIN_BOARD_LOCK();
- result=grTexMinAddress(tmu);
- END_BOARD_LOCK();
- return result;
+ BEGIN_BOARD_LOCK();
+ result = grTexMinAddress(tmu);
+ END_BOARD_LOCK();
+ return result;
}
-extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu) {
- FxU32 result;
+extern FxU32
+FX_grTexMaxAddress(GrChipID_t tmu)
+{
+ FxU32 result;
- BEGIN_BOARD_LOCK();
- result=grTexMaxAddress(tmu);
- END_BOARD_LOCK();
- return result;
+ BEGIN_BOARD_LOCK();
+ result = grTexMaxAddress(tmu);
+ END_BOARD_LOCK();
+ return result;
}
-FxBool FX_grSstControl(FxU32 code)
+FxBool
+FX_grSstControl(FxU32 code)
{
#if defined(FX_GLIDE3)
- /* The glide 3 sources call for grEnable/grDisable to be called in exchange
- * for grSstControl. */
- switch(code) {
- case GR_CONTROL_ACTIVATE:
+ /* 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:
+ case GR_CONTROL_DEACTIVATE:
grDisable(GR_PASSTHRU);
break;
- }
- /* Appearently GR_CONTROL_RESIZE can be ignored. */
- return 1; /* OK? */
+ }
+ /* Appearently GR_CONTROL_RESIZE can be ignored. */
+ return 1; /* OK? */
#else
- FxU32 result;
- BEGIN_BOARD_LOCK();
- result = grSstControl(code);
- END_BOARD_LOCK();
- return result;
+ FxU32 result;
+ BEGIN_BOARD_LOCK();
+ result = grSstControl(code);
+ END_BOARD_LOCK();
+ return result;
#endif
}
#if defined(FX_GLIDE3)
-void FX_grGammaCorrectionValue(float val)
+void
+FX_grGammaCorrectionValue(float val)
{
- (void)val;
+ (void) val;
/* ToDo */
}
-int FX_getFogTableSize(void)
+int
+FX_getFogTableSize(void)
{
int result;
BEGIN_BOARD_LOCK();
- grGet(GR_FOG_TABLE_ENTRIES,sizeof(int),(void*)&result);
+ grGet(GR_FOG_TABLE_ENTRIES, sizeof(int), (void *) &result);
END_BOARD_LOCK();
- return result;
+ return result;
}
-int FX_getGrStateSize(void)
+int
+FX_getGrStateSize(void)
{
int result;
BEGIN_BOARD_LOCK();
- grGet(GR_GLIDE_STATE_SIZE,sizeof(int),(void*)&result);
+ grGet(GR_GLIDE_STATE_SIZE, sizeof(int), (void *) &result);
END_BOARD_LOCK();
return result;
-
+
}
-int FX_grSstScreenWidth()
+int
+FX_grSstScreenWidth()
{
FxI32 result[4];
BEGIN_BOARD_LOCK();
- grGet(GR_VIEWPORT,sizeof(FxI32)*4,result);
+ grGet(GR_VIEWPORT, sizeof(FxI32) * 4, result);
END_BOARD_LOCK();
-
+
return result[2];
}
-int FX_grSstScreenHeight()
+int
+FX_grSstScreenHeight()
{
FxI32 result[4];
BEGIN_BOARD_LOCK();
- grGet(GR_VIEWPORT,sizeof(FxI32)*4,result);
+ grGet(GR_VIEWPORT, sizeof(FxI32) * 4, result);
END_BOARD_LOCK();
-
+
return result[3];
}
-void FX_grGlideGetVersion(char *buf)
+void
+FX_grGlideGetVersion(char *buf)
{
- BEGIN_BOARD_LOCK();
- strcpy(buf,grGetString(GR_VERSION));
- END_BOARD_LOCK();
+ BEGIN_BOARD_LOCK();
+ strcpy(buf, grGetString(GR_VERSION));
+ END_BOARD_LOCK();
}
-void FX_grSstPerfStats(GrSstPerfStats_t *st)
+void
+FX_grSstPerfStats(GrSstPerfStats_t * st)
{
- 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;
+ 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)
+void
+FX_grAADrawLine(GrVertex * a, GrVertex * b)
{
/* ToDo */
BEGIN_CLIP_LOOP();
- grDrawLine(a,b);
+ grDrawLine(a, b);
END_CLIP_LOOP();
}
-void FX_grAADrawPoint(GrVertex *a)
+void
+FX_grAADrawPoint(GrVertex * a)
{
- BEGIN_CLIP_LOOP();
- grDrawPoint(a);
- END_CLIP_LOOP();
+ BEGIN_CLIP_LOOP();
+ grDrawPoint(a);
+ END_CLIP_LOOP();
}
-void FX_grDrawPolygonVertexList(int n, GrVertex *verts)
+void
+FX_grDrawPolygonVertexList(int n, GrVertex * verts)
{
- BEGIN_CLIP_LOOP();
- grDrawVertexArrayContiguous(GR_POLYGON, n, verts, sizeof(GrVertex));
- END_CLIP_LOOP();
+ BEGIN_CLIP_LOOP();
+ grDrawVertexArrayContiguous(GR_POLYGON, n, verts, sizeof(GrVertex));
+ END_CLIP_LOOP();
}
-void FX_setupGrVertexLayout(void)
+void
+FX_setupGrVertexLayout(void)
{
- 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_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();
+ 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_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();
}
-void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask)
+void
+FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask)
{
- switch(hintType) {
- case GR_HINT_STWHINT:
- {
- if (hintMask & GR_STWHINT_W_DIFF_TMU0)
- grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
- else
- grVertexLayout(GR_PARAM_Q0,GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
-
- if (hintMask & GR_STWHINT_ST_DIFF_TMU1)
- grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
- else
- grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
-
- if (hintMask & GR_STWHINT_W_DIFF_TMU1)
- grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
- else
- grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
-
- }
- }
+ switch (hintType) {
+ case GR_HINT_STWHINT:
+ {
+ if (hintMask & GR_STWHINT_W_DIFF_TMU0)
+ grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,
+ GR_PARAM_ENABLE);
+ else
+ grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,
+ GR_PARAM_DISABLE);
+
+ if (hintMask & GR_STWHINT_ST_DIFF_TMU1)
+ grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2,
+ GR_PARAM_ENABLE);
+ else
+ grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2,
+ GR_PARAM_DISABLE);
+
+ if (hintMask & GR_STWHINT_W_DIFF_TMU1)
+ grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2,
+ GR_PARAM_ENABLE);
+ else
+ grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2,
+ GR_PARAM_DISABLE);
+
+ }
+ }
}
-void FX_grHints(GrHint_t hintType, FxU32 hintMask) {
- BEGIN_BOARD_LOCK();
- FX_grHints_NoLock(hintType, hintMask);
- END_BOARD_LOCK();
+void
+FX_grHints(GrHint_t hintType, FxU32 hintMask)
+{
+ BEGIN_BOARD_LOCK();
+ FX_grHints_NoLock(hintType, hintMask);
+ END_BOARD_LOCK();
}
/*
* Glide3 doesn't have the grSstQueryHardware function anymore.
* Instead, we call grGet() and fill in the data structures ourselves.
*/
-int FX_grSstQueryHardware(GrHwConfiguration *config)
+int
+FX_grSstQueryHardware(GrHwConfiguration * config)
{
int i, j;
int numFB;
BEGIN_BOARD_LOCK();
- grGet(GR_NUM_BOARDS, 4, (void*)&(config->num_sst));
+ grGet(GR_NUM_BOARDS, 4, (void *) &(config->num_sst));
if (config->num_sst == 0)
return 0;
- for (i = 0; i< config->num_sst; i++) {
+ for (i = 0; i < config->num_sst; i++) {
FxI32 result;
config->SSTs[i].type = GR_SSTTYPE_VOODOO;
@@ -335,24 +374,25 @@ int FX_grSstQueryHardware(GrHwConfiguration *config)
grGet(GR_MEMORY_FB, 4, &result);
config->SSTs[i].sstBoard.VoodooConfig.fbRam = result / (1024 * 1024);
-
+
grGet(GR_NUM_TMU, 4, &result);
config->SSTs[i].sstBoard.VoodooConfig.nTexelfx = result;
grGet(GR_REVISION_FB, 4, &result);
config->SSTs[i].sstBoard.VoodooConfig.fbiRev = result;
-
- grGet(GR_NUM_FB,4,(void*)&numFB);
+
+ grGet(GR_NUM_FB, 4, (void *) &numFB);
if (numFB > 1)
- config->SSTs[i].sstBoard.VoodooConfig.sliDetect = FXTRUE;
+ config->SSTs[i].sstBoard.VoodooConfig.sliDetect = FXTRUE;
else
- config->SSTs[i].sstBoard.VoodooConfig.sliDetect = FXFALSE;
+ config->SSTs[i].sstBoard.VoodooConfig.sliDetect = FXFALSE;
for (j = 0; j < config->SSTs[i].sstBoard.VoodooConfig.nTexelfx; j++) {
- grGet(GR_MEMORY_TMU, 4, &result);
- config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRam = result / (1024*1024);
- grGet(GR_REVISION_TMU, 4, &result);
- config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRev = result;
+ grGet(GR_MEMORY_TMU, 4, &result);
+ config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRam =
+ result / (1024 * 1024);
+ grGet(GR_REVISION_TMU, 4, &result);
+ config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRev = result;
}
}
END_BOARD_LOCK();
@@ -361,7 +401,8 @@ int FX_grSstQueryHardware(GrHwConfiguration *config)
#else
-int FX_grSstScreenWidth()
+int
+FX_grSstScreenWidth()
{
int i;
BEGIN_BOARD_LOCK();
@@ -370,7 +411,8 @@ int FX_grSstScreenWidth()
return i;
}
-int FX_grSstScreenHeight()
+int
+FX_grSstScreenHeight()
{
int i;
BEGIN_BOARD_LOCK();
@@ -379,51 +421,49 @@ int FX_grSstScreenHeight()
return i;
}
-int FX_grSstQueryHardware(GrHwConfiguration *c)
+int
+FX_grSstQueryHardware(GrHwConfiguration * c)
{
int i;
BEGIN_BOARD_LOCK();
i = grSstQueryHardware(c);
END_BOARD_LOCK();
return i;
-}
+}
-#endif /* FX_GLIDE3 */
+#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,
- GrColorFormat_t color_format,
- GrOriginLocation_t origin_location,
- int nColBuffers,
- int nAuxBuffers)
+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)
{
FX_GrContext_t i;
BEGIN_BOARD_LOCK();
- i = grSstWinOpen( hWnd,
- screen_resolution,
- refresh_rate,
- color_format,
- origin_location,
- nColBuffers,
- nAuxBuffers );
-
+ i = grSstWinOpen(hWnd,
+ screen_resolution,
+ refresh_rate,
+ color_format, origin_location, nColBuffers, nAuxBuffers);
+
/*
- fprintf(stderr,
- "grSstWinOpen( win %d res %d ref %d fmt %d\n"
- " org %d ncol %d naux %d )\n"
- " ==> %d\n",
- hWnd,
- screen_resolution,
- refresh_rate,
- color_format,
- origin_location,
- nColBuffers,
- nAuxBuffers,
- i);
- */
+ fprintf(stderr,
+ "grSstWinOpen( win %d res %d ref %d fmt %d\n"
+ " org %d ncol %d naux %d )\n"
+ " ==> %d\n",
+ hWnd,
+ screen_resolution,
+ refresh_rate,
+ color_format,
+ origin_location,
+ nColBuffers,
+ nAuxBuffers,
+ i);
+ */
END_BOARD_LOCK();
return i;
}
@@ -437,9 +477,10 @@ FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd,
*/
extern int gl_fx_dummy_function_glidew(void);
-int gl_fx_dummy_function_glidew(void)
+int
+gl_fx_dummy_function_glidew(void)
{
- return 0;
+ return 0;
}
#endif /* FX */
diff --git a/src/mesa/drivers/glide/fxglidew.h b/src/mesa/drivers/glide/fxglidew.h
index 9d549368d4..eecf01a3ba 100644
--- a/src/mesa/drivers/glide/fxglidew.h
+++ b/src/mesa/drivers/glide/fxglidew.h
@@ -51,9 +51,9 @@
* General context:
*/
#if !defined(FX_GLIDE3)
- typedef FxU32 FX_GrContext_t; /* Not used in Glide2 */
+typedef FxU32 FX_GrContext_t; /* Not used in Glide2 */
#else
- typedef GrContext_t FX_GrContext_t;
+typedef GrContext_t FX_GrContext_t;
#endif
/*
@@ -61,22 +61,22 @@
*/
#if !defined(FX_GLIDE3)
/* Constanst for FX_grGetInteger( ) */
- #define FX_FOG_TABLE_ENTRIES 0x0004 /* The number of entries in the hardware fog table. */
- #define FX_GLIDE_STATE_SIZE 0x0006 /* Size of buffer, in bytes, needed to save Glide state. */
- #define FX_LFB_PIXEL_PIPE 0x0009 /* 1 if LFB writes can go through the 3D pixel pipe. */
- #define FX_PENDING_BUFFERSWAPS 0x0014 /* The number of buffer swaps pending. */
- #define FX_TEXTURE_ALIGN 0x0024 /* The required alignment for textures */
+#define FX_FOG_TABLE_ENTRIES 0x0004 /* The number of entries in the hardware fog table. */
+#define FX_GLIDE_STATE_SIZE 0x0006 /* Size of buffer, in bytes, needed to save Glide state. */
+#define FX_LFB_PIXEL_PIPE 0x0009 /* 1 if LFB writes can go through the 3D pixel pipe. */
+#define FX_PENDING_BUFFERSWAPS 0x0014 /* The number of buffer swaps pending. */
+#define FX_TEXTURE_ALIGN 0x0024 /* The required alignment for textures */
#else
- #define FX_FOG_TABLE_ENTRIES GR_FOG_TABLE_ENTRIES
- #define FX_GLIDE_STATE_SIZE GR_GLIDE_STATE_SIZE
- #define FX_LFB_PIXEL_PIPE GR_LFB_PIXEL_PIPE
- #define FX_PENDING_BUFFERSWAPS GR_PENDING_BUFFERSWAPS
- #define FX_TEXTURE_ALIGN GR_TEXTURE_ALIGN
+#define FX_FOG_TABLE_ENTRIES GR_FOG_TABLE_ENTRIES
+#define FX_GLIDE_STATE_SIZE GR_GLIDE_STATE_SIZE
+#define FX_LFB_PIXEL_PIPE GR_LFB_PIXEL_PIPE
+#define FX_PENDING_BUFFERSWAPS GR_PENDING_BUFFERSWAPS
+#define FX_TEXTURE_ALIGN GR_TEXTURE_ALIGN
#endif
/*
* Genral warper functions for Glide2/Glide3:
- */
+ */
extern FxI32 FX_grGetInteger(FxU32 pname);
extern FxI32 FX_grGetInteger_NoLock(FxU32 pname);
@@ -96,7 +96,7 @@ extern FxI32 FX_grGetInteger_NoLock(FxU32 pname);
#define GR_LOD_256 GR_LOD_LOG2_256
#define GR_LOD_128 GR_LOD_LOG2_128
#define GR_LOD_64 GR_LOD_LOG2_64
-#define GR_LOD_32 GR_LOD_LOG2_32
+#define GR_LOD_32 GR_LOD_LOG2_32
#define GR_LOD_16 GR_LOD_LOG2_16
#define GR_LOD_8 GR_LOD_LOG2_8
#define GR_LOD_4 GR_LOD_LOG2_4
@@ -114,43 +114,57 @@ typedef int GrSstType;
#define GR_SSTTYPE_AT3D 2
#define GR_SSTTYPE_Voodoo2 3
-typedef struct GrTMUConfig_St {
- int tmuRev; /* Rev of Texelfx chip */
- int tmuRam; /* 1, 2, or 4 MB */
-} GrTMUConfig_t;
-
-typedef struct GrVoodooConfig_St {
- int fbRam; /* 1, 2, or 4 MB */
- int fbiRev; /* Rev of Pixelfx chip */
- int nTexelfx; /* How many texelFX chips are there? */
- FxBool sliDetect; /* Is it a scan-line interleaved board? */
- GrTMUConfig_t tmuConfig[GLIDE_NUM_TMU]; /* Configuration of the Texelfx chips */
-} GrVoodooConfig_t;
-
-typedef struct GrSst96Config_St {
- int fbRam; /* How much? */
- int nTexelfx;
- GrTMUConfig_t tmuConfig;
-} GrSst96Config_t;
+typedef struct GrTMUConfig_St
+{
+ int tmuRev; /* Rev of Texelfx chip */
+ int tmuRam; /* 1, 2, or 4 MB */
+}
+GrTMUConfig_t;
+
+typedef struct GrVoodooConfig_St
+{
+ int fbRam; /* 1, 2, or 4 MB */
+ int fbiRev; /* Rev of Pixelfx chip */
+ int nTexelfx; /* How many texelFX chips are there? */
+ FxBool sliDetect; /* Is it a scan-line interleaved board? */
+ GrTMUConfig_t tmuConfig[GLIDE_NUM_TMU]; /* Configuration of the Texelfx chips */
+}
+GrVoodooConfig_t;
+
+typedef struct GrSst96Config_St
+{
+ int fbRam; /* How much? */
+ int nTexelfx;
+ GrTMUConfig_t tmuConfig;
+}
+GrSst96Config_t;
typedef GrVoodooConfig_t GrVoodoo2Config_t;
-typedef struct GrAT3DConfig_St {
- int rev;
-} GrAT3DConfig_t;
-
-typedef struct {
- int num_sst; /* # of HW units in the system */
- struct {
- GrSstType type; /* Which hardware is it? */
- union SstBoard_u {
- GrVoodooConfig_t VoodooConfig;
- GrSst96Config_t SST96Config;
- GrAT3DConfig_t AT3DConfig;
- GrVoodoo2Config_t Voodoo2Config;
- } sstBoard;
- } SSTs[MAX_NUM_SST]; /* configuration for each board */
-} GrHwConfiguration;
+typedef struct GrAT3DConfig_St
+{
+ int rev;
+}
+GrAT3DConfig_t;
+
+typedef struct
+{
+ int num_sst; /* # of HW units in the system */
+ struct
+ {
+ GrSstType type; /* Which hardware is it? */
+ union SstBoard_u
+ {
+ GrVoodooConfig_t VoodooConfig;
+ GrSst96Config_t SST96Config;
+ GrAT3DConfig_t AT3DConfig;
+ GrVoodoo2Config_t Voodoo2Config;
+ }
+ sstBoard;
+ }
+ SSTs[MAX_NUM_SST]; /* configuration for each board */
+}
+GrHwConfiguration;
typedef FxU32 GrHint_t;
#define GR_HINTTYPE_MIN 0
@@ -173,22 +187,25 @@ typedef FxU32 GrSTWHint_t;
/*
** move the vertex layout defintion to application
*/
-typedef struct {
- float sow; /* s texture ordinate (s over w) */
- float tow; /* t texture ordinate (t over w) */
- float oow; /* 1/w (used mipmapping - really 0xfff/w) */
-} GrTmuVertex;
+typedef struct
+{
+ float sow; /* s texture ordinate (s over w) */
+ float tow; /* t texture ordinate (t over w) */
+ float oow; /* 1/w (used mipmapping - really 0xfff/w) */
+}
+GrTmuVertex;
typedef struct
{
- float x, y, z; /* X, Y, and Z of scrn space -- Z is ignored */
- float r, g, b; /* R, G, B, ([0..255.0]) */
- float ooz; /* 65535/Z (used for Z-buffering) */
- float a; /* Alpha [0..255.0] */
- float oow; /* 1/W (used for W-buffering, texturing) */
- GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
-} GrVertex;
+ float x, y, z; /* X, Y, and Z of scrn space -- Z is ignored */
+ float r, g, b; /* R, G, B, ([0..255.0]) */
+ float ooz; /* 65535/Z (used for Z-buffering) */
+ float a; /* Alpha [0..255.0] */
+ float oow; /* 1/W (used for W-buffering, texturing) */
+ GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
+}
+GrVertex;
#define GR_VERTEX_X_OFFSET 0
#define GR_VERTEX_Y_OFFSET 1
@@ -248,7 +265,7 @@ typedef struct
grSstIdle(); \
END_BOARD_LOCK(); \
} while (0)
-#endif
+#endif
#define FX_grFinish() \
do { \
@@ -300,54 +317,54 @@ typedef struct
* For Lod/LodLog2 conversion.
*/
#if defined(FX_GLIDE3)
- #define FX_largeLodLog2(info) (info).largeLodLog2
+#define FX_largeLodLog2(info) (info).largeLodLog2
#else
- #define FX_largeLodLog2(info) (info).largeLod
+#define FX_largeLodLog2(info) (info).largeLod
#endif
#if defined(FX_GLIDE3)
- #define FX_aspectRatioLog2(info) (info).aspectRatioLog2
+#define FX_aspectRatioLog2(info) (info).aspectRatioLog2
#else
- #define FX_aspectRatioLog2(info) (info).aspectRatio
+#define FX_aspectRatioLog2(info) (info).aspectRatio
#endif
#if defined(FX_GLIDE3)
- #define FX_smallLodLog2(info) (info).smallLodLog2
+#define FX_smallLodLog2(info) (info).smallLodLog2
#else
- #define FX_smallLodLog2(info) (info).smallLod
+#define FX_smallLodLog2(info) (info).smallLod
#endif
#if defined(FX_GLIDE3)
- #define FX_lodToValue(val) ((int)(GR_LOD_256-val))
+#define FX_lodToValue(val) ((int)(GR_LOD_256-val))
#else
- #define FX_lodToValue(val) ((int)(val))
+#define FX_lodToValue(val) ((int)(val))
#endif
#if defined(FX_GLIDE3)
- #define FX_largeLodValue(info) ((int)(GR_LOD_256-(info).largeLodLog2))
+#define FX_largeLodValue(info) ((int)(GR_LOD_256-(info).largeLodLog2))
#else
- #define FX_largeLodValue(info) ((int)(info).largeLod)
+#define FX_largeLodValue(info) ((int)(info).largeLod)
#endif
#define FX_largeLodValue_NoLock FX_largeLodValue
#if defined(FX_GLIDE3)
- #define FX_smallLodValue(info) ((int)(GR_LOD_256-(info).smallLodLog2))
+#define FX_smallLodValue(info) ((int)(GR_LOD_256-(info).smallLodLog2))
#else
- #define FX_smallLodValue(info) ((int)(info).smallLod)
+#define FX_smallLodValue(info) ((int)(info).smallLod)
#endif
#define FX_smallLodValue_NoLock FX_smallLodValue
#if defined(FX_GLIDE3)
- #define FX_valueToLod(val) ((GrLOD_t)(GR_LOD_256-val))
+#define FX_valueToLod(val) ((GrLOD_t)(GR_LOD_256-val))
#else
- #define FX_valueToLod(val) ((GrLOD_t)(val))
+#define FX_valueToLod(val) ((GrLOD_t)(val))
#endif
/*
* ScreenWidth/Height stuff.
*/
- extern int FX_grSstScreenWidth(void);
- extern int FX_grSstScreenHeight(void);
+extern int FX_grSstScreenWidth(void);
+extern int FX_grSstScreenHeight(void);
@@ -355,9 +372,9 @@ typedef struct
* Version string.
*/
#if defined(FX_GLIDE3)
- extern void FX_grGlideGetVersion(char *buf);
+extern void FX_grGlideGetVersion(char *buf);
#else
- #define FX_grGlideGetVersion(b) \
+#define FX_grGlideGetVersion(b) \
do { \
BEGIN_BOARD_LOCK(); \
grGlideGetVersion(b); \
@@ -368,9 +385,9 @@ typedef struct
* Performance statistics
*/
#if defined(FX_GLIDE3)
- extern void FX_grSstPerfStats(GrSstPerfStats_t *st);
+extern void FX_grSstPerfStats(GrSstPerfStats_t * st);
#else
- #define FX_grSstPerfStats(s) \
+#define FX_grSstPerfStats(s) \
do { \
BEGIN_BOARD_LOCK(); \
grSstPerfStats(s); \
@@ -381,30 +398,30 @@ typedef struct
/*
* Hardware Query
*/
- extern int FX_grSstQueryHardware(GrHwConfiguration *config);
+extern int FX_grSstQueryHardware(GrHwConfiguration * config);
/*
* GrHints
*/
#if defined(FX_GLIDE3)
- extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask);
- extern void FX_grHints(GrHint_t hintType, FxU32 hintMask);
+extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask);
+extern void FX_grHints(GrHint_t hintType, FxU32 hintMask);
#else
- #define FX_grHints(t,m) \
+#define FX_grHints(t,m) \
do { \
BEGIN_BOARD_LOCK(); \
grHints(t, m); \
END_BOARD_LOCK(); \
} while(0)
- #define FX_grHints_NoLock grHints
+#define FX_grHints_NoLock grHints
#endif
/*
* Antialiashed line+point drawing.
*/
#if defined(FX_GLIDE3)
- extern void FX_grAADrawLine(GrVertex *a,GrVertex *b);
+extern void FX_grAADrawLine(GrVertex * a, GrVertex * b);
#else
- #define FX_grAADrawLine(a,b) \
+#define FX_grAADrawLine(a,b) \
do { \
BEGIN_CLIP_LOOP(); \
grAADrawLine(a,b); \
@@ -413,9 +430,9 @@ typedef struct
#endif
#if defined(FX_GLIDE3)
- extern void FX_grAADrawPoint(GrVertex *a);
+extern void FX_grAADrawPoint(GrVertex * a);
#else
- #define FX_grAADrawPoint(a) \
+#define FX_grAADrawPoint(a) \
do { \
BEGIN_CLIP_LOOP(); \
grAADrawPoint(a); \
@@ -427,9 +444,9 @@ typedef struct
* Needed for Glide3 only, to set up Glide2 compatible vertex layout.
*/
#if defined(FX_GLIDE3)
- extern void FX_setupGrVertexLayout(void);
+extern void FX_setupGrVertexLayout(void);
#else
- #define FX_setupGrVertexLayout() do {} while (0)
+#define FX_setupGrVertexLayout() do {} while (0)
#endif
/*
* grSstControl stuff
@@ -440,9 +457,9 @@ extern FxBool FX_grSstControl(FxU32 code);
* grGammaCorrectionValue
*/
#if defined(FX_GLIDE3)
- extern void FX_grGammaCorrectionValue(float val);
+extern void FX_grGammaCorrectionValue(float val);
#else
- #define FX_grGammaCorrectionValue(v) \
+#define FX_grGammaCorrectionValue(v) \
do { \
BEGIN_BOARD_LOCK(); \
grGammaCorrectionValue(v) \
@@ -467,13 +484,12 @@ extern FxBool FX_grSstControl(FxU32 code);
#endif
-extern 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);
+extern 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);
#define FX_grDrawLine(v1, v2) \
@@ -491,7 +507,7 @@ extern FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd,
} while (0)
#if defined(FX_GLIDE3)
-extern void FX_grDrawPolygonVertexList(int n, GrVertex *v);
+extern void FX_grDrawPolygonVertexList(int n, GrVertex * v);
#else
#define FX_grDrawPolygonVertexList(n, v) \
do { \
@@ -536,10 +552,10 @@ extern void FX_grDrawPolygonVertexList(int n, GrVertex *v);
END_BOARD_LOCK(); \
} while (0)
-extern FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
- GrLfbWriteMode_t writeMode,
- GrOriginLocation_t origin, FxBool pixelPipeline,
- GrLfbInfo_t *info );
+extern FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
+ GrLfbWriteMode_t writeMode,
+ GrOriginLocation_t origin, FxBool pixelPipeline,
+ GrLfbInfo_t * info);
#define FX_grLfbUnlock(t, b) \
do { \
@@ -718,7 +734,7 @@ extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu);
#define FX_grTexSource_NoLock grTexSource
-extern FxU32 FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info);
+extern FxU32 FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo * info);
#define FX_grTexTextureMemRequired_NoLock grTexTextureMemRequired
#define FX_grGlideGetState(s) \
@@ -797,4 +813,3 @@ extern int FX_getFogTableSize(void);
extern int FX_getGrStateSize(void);
#endif /* __FX_GLIDE_WARPER__ */
-
diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c
index 5d844473d8..dc2db8e319 100644
--- a/src/mesa/drivers/glide/fxsetup.c
+++ b/src/mesa/drivers/glide/fxsetup.c
@@ -56,562 +56,561 @@
#include "tnl/t_context.h"
-static GLuint fxGetTexSetConfiguration(GLcontext *ctx,
- struct gl_texture_object *tObj0,
- struct gl_texture_object *tObj1);
-static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset);
-static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
- struct gl_texture_object *tObj0,
- struct gl_texture_object *tObj1);
-static void fxSetupTexture_NoLock(GLcontext *ctx);
-static void fxSetupTexture(GLcontext *ctx);
-static void fxSetupBlend(GLcontext *ctx);
-static void fxSetupDepthTest(GLcontext *ctx);
-static void fxSetupScissor(GLcontext *ctx);
-static void fxSetupCull(GLcontext *ctx);
-static void fx_print_state_flags( const char *msg, GLuint flags);
+static GLuint fxGetTexSetConfiguration(GLcontext * ctx,
+ struct gl_texture_object *tObj0,
+ struct gl_texture_object *tObj1);
+static void fxSetupTextureSingleTMU_NoLock(GLcontext * ctx,
+ GLuint textureset);
+static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
+ struct gl_texture_object *tObj0,
+ struct gl_texture_object *tObj1);
+static void fxSetupTexture_NoLock(GLcontext * ctx);
+static void fxSetupTexture(GLcontext * ctx);
+static void fxSetupBlend(GLcontext * ctx);
+static void fxSetupDepthTest(GLcontext * ctx);
+static void fxSetupScissor(GLcontext * ctx);
+static void fxSetupCull(GLcontext * ctx);
+static void fx_print_state_flags(const char *msg, GLuint flags);
/*static GLboolean fxMultipassBlend(struct vertex_buffer *, GLuint);*/
-static GLboolean fxMultipassTexture( GLcontext *, GLuint );
+static GLboolean fxMultipassTexture(GLcontext *, GLuint);
-static void fxTexValidate(GLcontext *ctx, struct gl_texture_object *tObj)
+static void
+fxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj)
{
- tfxTexInfo *ti=fxTMGetTexInfo(tObj);
- GLint minl, maxl;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxTexValidate(...) Start\n");
- }
-
- if(ti->validated) {
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxTexValidate(...) End (validated=GL_TRUE)\n");
- }
- return;
- }
-
- ti->tObj=tObj;
- minl=ti->minLevel=tObj->BaseLevel;
- maxl=ti->maxLevel=MIN2(tObj->MaxLevel,tObj->Image[0]->MaxLog2);
-
- fxTexGetInfo(tObj->Image[minl]->Width, tObj->Image[minl]->Height,
- &(FX_largeLodLog2(ti->info)), &(FX_aspectRatioLog2(ti->info)),
- &(ti->sScale), &(ti->tScale),
- &(ti->int_sScale), &(ti->int_tScale),
- NULL, NULL);
-
- if((tObj->MinFilter!=GL_NEAREST) && (tObj->MinFilter!=GL_LINEAR))
- fxTexGetInfo(tObj->Image[maxl]->Width,tObj->Image[maxl]->Height,
- &(FX_smallLodLog2(ti->info)),NULL,
- NULL,NULL,
- NULL,NULL,
- NULL,NULL);
- else
- FX_smallLodLog2(ti->info)=FX_largeLodLog2(ti->info);
-
- fxTexGetFormat(tObj->Image[minl]->IntFormat,&(ti->info.format),&(ti->baseLevelInternalFormat));
-
- switch (tObj->WrapS) {
- case GL_CLAMP_TO_EDGE:
- /* What's this really mean compared to GL_CLAMP? */
- case GL_CLAMP:
- ti->sClamp=1;
- break;
- case GL_REPEAT:
- ti->sClamp=0;
- break;
- default:
- ; /* silence compiler warning */
- }
- switch (tObj->WrapT) {
- case GL_CLAMP_TO_EDGE:
- /* What's this really mean compared to GL_CLAMP? */
- case GL_CLAMP:
- ti->tClamp=1;
- break;
- case GL_REPEAT:
- ti->tClamp=0;
- break;
- default:
- ; /* silence compiler warning */
- }
-
- ti->validated=GL_TRUE;
-
- ti->info.data=NULL;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxTexValidate(...) End\n");
- }
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ GLint minl, maxl;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxTexValidate(...) Start\n");
+ }
+
+ if (ti->validated) {
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr,
+ "fxmesa: fxTexValidate(...) End (validated=GL_TRUE)\n");
+ }
+ return;
+ }
+
+ ti->tObj = tObj;
+ minl = ti->minLevel = tObj->BaseLevel;
+ maxl = ti->maxLevel = MIN2(tObj->MaxLevel, tObj->Image[0]->MaxLog2);
+
+ fxTexGetInfo(tObj->Image[minl]->Width, tObj->Image[minl]->Height,
+ &(FX_largeLodLog2(ti->info)), &(FX_aspectRatioLog2(ti->info)),
+ &(ti->sScale), &(ti->tScale),
+ &(ti->int_sScale), &(ti->int_tScale), NULL, NULL);
+
+ if ((tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR))
+ fxTexGetInfo(tObj->Image[maxl]->Width, tObj->Image[maxl]->Height,
+ &(FX_smallLodLog2(ti->info)), NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ else
+ FX_smallLodLog2(ti->info) = FX_largeLodLog2(ti->info);
+
+ fxTexGetFormat(tObj->Image[minl]->IntFormat, &(ti->info.format),
+ &(ti->baseLevelInternalFormat));
+
+ switch (tObj->WrapS) {
+ case GL_CLAMP_TO_EDGE:
+ /* What's this really mean compared to GL_CLAMP? */
+ case GL_CLAMP:
+ ti->sClamp = 1;
+ break;
+ case GL_REPEAT:
+ ti->sClamp = 0;
+ break;
+ default:
+ ; /* silence compiler warning */
+ }
+ switch (tObj->WrapT) {
+ case GL_CLAMP_TO_EDGE:
+ /* What's this really mean compared to GL_CLAMP? */
+ case GL_CLAMP:
+ ti->tClamp = 1;
+ break;
+ case GL_REPEAT:
+ ti->tClamp = 0;
+ break;
+ default:
+ ; /* silence compiler warning */
+ }
+
+ ti->validated = GL_TRUE;
+
+ ti->info.data = NULL;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxTexValidate(...) End\n");
+ }
}
-static void fxPrintUnitsMode( const char *msg, GLuint mode )
+static void
+fxPrintUnitsMode(const char *msg, GLuint mode)
{
- fprintf(stderr,
+ fprintf(stderr,
"%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
msg,
mode,
- (mode & FX_UM_E0_REPLACE) ? "E0_REPLACE, " : "",
- (mode & FX_UM_E0_MODULATE) ? "E0_MODULATE, " : "",
- (mode & FX_UM_E0_DECAL) ? "E0_DECAL, " : "",
- (mode & FX_UM_E0_BLEND) ? "E0_BLEND, " : "",
- (mode & FX_UM_E1_REPLACE) ? "E1_REPLACE, " : "",
- (mode & FX_UM_E1_MODULATE) ? "E1_MODULATE, " : "",
- (mode & FX_UM_E1_DECAL) ? "E1_DECAL, " : "",
- (mode & FX_UM_E1_BLEND) ? "E1_BLEND, " : "",
- (mode & FX_UM_E0_ALPHA) ? "E0_ALPHA, " : "",
- (mode & FX_UM_E0_LUMINANCE) ? "E0_LUMINANCE, " : "",
+ (mode & FX_UM_E0_REPLACE) ? "E0_REPLACE, " : "",
+ (mode & FX_UM_E0_MODULATE) ? "E0_MODULATE, " : "",
+ (mode & FX_UM_E0_DECAL) ? "E0_DECAL, " : "",
+ (mode & FX_UM_E0_BLEND) ? "E0_BLEND, " : "",
+ (mode & FX_UM_E1_REPLACE) ? "E1_REPLACE, " : "",
+ (mode & FX_UM_E1_MODULATE) ? "E1_MODULATE, " : "",
+ (mode & FX_UM_E1_DECAL) ? "E1_DECAL, " : "",
+ (mode & FX_UM_E1_BLEND) ? "E1_BLEND, " : "",
+ (mode & FX_UM_E0_ALPHA) ? "E0_ALPHA, " : "",
+ (mode & FX_UM_E0_LUMINANCE) ? "E0_LUMINANCE, " : "",
(mode & FX_UM_E0_LUMINANCE_ALPHA) ? "E0_LUMINANCE_ALPHA, " : "",
- (mode & FX_UM_E0_INTENSITY) ? "E0_INTENSITY, " : "",
- (mode & FX_UM_E0_RGB) ? "E0_RGB, " : "",
- (mode & FX_UM_E0_RGBA) ? "E0_RGBA, " : "",
- (mode & FX_UM_E1_ALPHA) ? "E1_ALPHA, " : "",
- (mode & FX_UM_E1_LUMINANCE) ? "E1_LUMINANCE, " : "",
+ (mode & FX_UM_E0_INTENSITY) ? "E0_INTENSITY, " : "",
+ (mode & FX_UM_E0_RGB) ? "E0_RGB, " : "",
+ (mode & FX_UM_E0_RGBA) ? "E0_RGBA, " : "",
+ (mode & FX_UM_E1_ALPHA) ? "E1_ALPHA, " : "",
+ (mode & FX_UM_E1_LUMINANCE) ? "E1_LUMINANCE, " : "",
(mode & FX_UM_E1_LUMINANCE_ALPHA) ? "E1_LUMINANCE_ALPHA, " : "",
- (mode & FX_UM_E1_INTENSITY) ? "E1_INTENSITY, " : "",
- (mode & FX_UM_E1_RGB) ? "E1_RGB, " : "",
- (mode & FX_UM_E1_RGBA) ? "E1_RGBA, " : "",
- (mode & FX_UM_COLOR_ITERATED) ? "COLOR_ITERATED, " : "",
- (mode & FX_UM_COLOR_CONSTANT) ? "COLOR_CONSTANT, " : "",
- (mode & FX_UM_ALPHA_ITERATED) ? "ALPHA_ITERATED, " : "",
- (mode & FX_UM_ALPHA_CONSTANT) ? "ALPHA_CONSTANT, " : "");
+ (mode & FX_UM_E1_INTENSITY) ? "E1_INTENSITY, " : "",
+ (mode & FX_UM_E1_RGB) ? "E1_RGB, " : "",
+ (mode & FX_UM_E1_RGBA) ? "E1_RGBA, " : "",
+ (mode & FX_UM_COLOR_ITERATED) ? "COLOR_ITERATED, " : "",
+ (mode & FX_UM_COLOR_CONSTANT) ? "COLOR_CONSTANT, " : "",
+ (mode & FX_UM_ALPHA_ITERATED) ? "ALPHA_ITERATED, " : "",
+ (mode & FX_UM_ALPHA_CONSTANT) ? "ALPHA_CONSTANT, " : "");
}
-static GLuint fxGetTexSetConfiguration(GLcontext *ctx,
- struct gl_texture_object *tObj0,
- struct gl_texture_object *tObj1)
+static GLuint
+fxGetTexSetConfiguration(GLcontext * ctx,
+ struct gl_texture_object *tObj0,
+ struct gl_texture_object *tObj1)
{
- GLuint unitsmode=0;
- GLuint envmode=0;
- GLuint ifmt=0;
+ GLuint unitsmode = 0;
+ GLuint envmode = 0;
+ GLuint ifmt = 0;
+
+ if ((ctx->Light.ShadeModel == GL_SMOOTH) || 1 ||
+ (ctx->Point.SmoothFlag) ||
+ (ctx->Line.SmoothFlag) ||
+ (ctx->Polygon.SmoothFlag)) unitsmode |= FX_UM_ALPHA_ITERATED;
+ else
+ unitsmode |= FX_UM_ALPHA_CONSTANT;
+
+ if (ctx->Light.ShadeModel == GL_SMOOTH || 1)
+ unitsmode |= FX_UM_COLOR_ITERATED;
+ else
+ unitsmode |= FX_UM_COLOR_CONSTANT;
+
+
+
+ /*
+ OpenGL Feeds Texture 0 into Texture 1
+ Glide Feeds Texture 1 into Texture 0
+ */
+ if (tObj0) {
+ tfxTexInfo *ti0 = fxTMGetTexInfo(tObj0);
+
+ switch (ti0->baseLevelInternalFormat) {
+ case GL_ALPHA:
+ ifmt |= FX_UM_E0_ALPHA;
+ break;
+ case GL_LUMINANCE:
+ ifmt |= FX_UM_E0_LUMINANCE;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ ifmt |= FX_UM_E0_LUMINANCE_ALPHA;
+ break;
+ case GL_INTENSITY:
+ ifmt |= FX_UM_E0_INTENSITY;
+ break;
+ case GL_RGB:
+ ifmt |= FX_UM_E0_RGB;
+ break;
+ case GL_RGBA:
+ ifmt |= FX_UM_E0_RGBA;
+ break;
+ }
- if((ctx->Light.ShadeModel==GL_SMOOTH) || 1 ||
- (ctx->Point.SmoothFlag) ||
- (ctx->Line.SmoothFlag) ||
- (ctx->Polygon.SmoothFlag))
- unitsmode|=FX_UM_ALPHA_ITERATED;
- else
- unitsmode|=FX_UM_ALPHA_CONSTANT;
+ switch (ctx->Texture.Unit[0].EnvMode) {
+ case GL_DECAL:
+ envmode |= FX_UM_E0_DECAL;
+ break;
+ case GL_MODULATE:
+ envmode |= FX_UM_E0_MODULATE;
+ break;
+ case GL_REPLACE:
+ envmode |= FX_UM_E0_REPLACE;
+ break;
+ case GL_BLEND:
+ envmode |= FX_UM_E0_BLEND;
+ break;
+ case GL_ADD:
+ envmode |= FX_UM_E0_ADD;
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ }
- if(ctx->Light.ShadeModel==GL_SMOOTH || 1)
- unitsmode|=FX_UM_COLOR_ITERATED;
- else
- unitsmode|=FX_UM_COLOR_CONSTANT;
+ if (tObj1) {
+ tfxTexInfo *ti1 = fxTMGetTexInfo(tObj1);
+
+ switch (ti1->baseLevelInternalFormat) {
+ case GL_ALPHA:
+ ifmt |= FX_UM_E1_ALPHA;
+ break;
+ case GL_LUMINANCE:
+ ifmt |= FX_UM_E1_LUMINANCE;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ ifmt |= FX_UM_E1_LUMINANCE_ALPHA;
+ break;
+ case GL_INTENSITY:
+ ifmt |= FX_UM_E1_INTENSITY;
+ break;
+ case GL_RGB:
+ ifmt |= FX_UM_E1_RGB;
+ break;
+ case GL_RGBA:
+ ifmt |= FX_UM_E1_RGBA;
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ switch (ctx->Texture.Unit[1].EnvMode) {
+ case GL_DECAL:
+ envmode |= FX_UM_E1_DECAL;
+ break;
+ case GL_MODULATE:
+ envmode |= FX_UM_E1_MODULATE;
+ break;
+ case GL_REPLACE:
+ envmode |= FX_UM_E1_REPLACE;
+ break;
+ case GL_BLEND:
+ envmode |= FX_UM_E1_BLEND;
+ break;
+ case GL_ADD:
+ envmode |= FX_UM_E1_ADD;
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ }
+ unitsmode |= (ifmt | envmode);
- /*
- OpenGL Feeds Texture 0 into Texture 1
- Glide Feeds Texture 1 into Texture 0
- */
- if(tObj0) {
- tfxTexInfo *ti0=fxTMGetTexInfo(tObj0);
+ if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+ fxPrintUnitsMode("unitsmode", unitsmode);
- switch(ti0->baseLevelInternalFormat) {
- case GL_ALPHA:
- ifmt|=FX_UM_E0_ALPHA;
- break;
- case GL_LUMINANCE:
- ifmt|=FX_UM_E0_LUMINANCE;
- break;
- case GL_LUMINANCE_ALPHA:
- ifmt|=FX_UM_E0_LUMINANCE_ALPHA;
- break;
- case GL_INTENSITY:
- ifmt|=FX_UM_E0_INTENSITY;
- break;
- case GL_RGB:
- ifmt|=FX_UM_E0_RGB;
- break;
- case GL_RGBA:
- ifmt|=FX_UM_E0_RGBA;
- break;
- }
+ return unitsmode;
+}
- switch(ctx->Texture.Unit[0].EnvMode) {
- case GL_DECAL:
- envmode|=FX_UM_E0_DECAL;
- break;
- case GL_MODULATE:
- envmode|=FX_UM_E0_MODULATE;
- break;
- case GL_REPLACE:
- envmode|=FX_UM_E0_REPLACE;
- break;
- case GL_BLEND:
- envmode|=FX_UM_E0_BLEND;
- break;
- case GL_ADD:
- envmode|=FX_UM_E0_ADD;
- break;
- default:
- /* do nothing */
- break;
- }
- }
+/************************************************************************/
+/************************* Rendering Mode SetUp *************************/
+/************************************************************************/
- if(tObj1) {
- tfxTexInfo *ti1=fxTMGetTexInfo(tObj1);
+/************************* Single Texture Set ***************************/
- switch(ti1->baseLevelInternalFormat) {
- case GL_ALPHA:
- ifmt|=FX_UM_E1_ALPHA;
- break;
- case GL_LUMINANCE:
- ifmt|=FX_UM_E1_LUMINANCE;
- break;
- case GL_LUMINANCE_ALPHA:
- ifmt|=FX_UM_E1_LUMINANCE_ALPHA;
- break;
- case GL_INTENSITY:
- ifmt|=FX_UM_E1_INTENSITY;
- break;
- case GL_RGB:
- ifmt|=FX_UM_E1_RGB;
- break;
- case GL_RGBA:
- ifmt|=FX_UM_E1_RGBA;
- break;
- default:
- /* do nothing */
- break;
- }
+static void
+fxSetupSingleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj)
+{
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ int tmu;
+
+ /* Make sure we're not loaded incorrectly */
+ if (ti->isInTM) {
+ if (ti->LODblend) {
+ if (ti->whichTMU != FX_TMU_SPLIT)
+ fxTMMoveOutTM(fxMesa, tObj);
+ }
+ else {
+ if (ti->whichTMU == FX_TMU_SPLIT)
+ fxTMMoveOutTM(fxMesa, tObj);
+ }
+ }
- switch(ctx->Texture.Unit[1].EnvMode) {
- case GL_DECAL:
- envmode|=FX_UM_E1_DECAL;
- break;
- case GL_MODULATE:
- envmode|=FX_UM_E1_MODULATE;
- break;
- case GL_REPLACE:
- envmode|=FX_UM_E1_REPLACE;
- break;
- case GL_BLEND:
- envmode|=FX_UM_E1_BLEND;
- break;
- case GL_ADD:
- envmode|=FX_UM_E1_ADD;
- break;
- default:
- /* do nothing */
- break;
- }
- }
+ /* Make sure we're loaded correctly */
+ if (!ti->isInTM) {
+ if (ti->LODblend)
+ fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU_SPLIT);
+ else {
+ if (fxMesa->haveTwoTMUs) {
+ if (fxMesa->freeTexMem[FX_TMU0] >
+ FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info))) {
+ fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0);
+ }
+ else {
+ fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU1);
+ }
+ }
+ else
+ fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0);
+ }
+ }
- unitsmode|=(ifmt | envmode);
+ if (ti->LODblend && ti->whichTMU == FX_TMU_SPLIT) {
+ if ((ti->info.format == GR_TEXFMT_P_8)
+ && (!fxMesa->haveGlobalPaletteTexture)) {
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: uploading texture palette\n");
+ }
+ FX_grTexDownloadTable_NoLock(GR_TMU0, GR_TEXTABLE_PALETTE,
+ &(ti->palette));
+ FX_grTexDownloadTable_NoLock(GR_TMU1, GR_TEXTABLE_PALETTE,
+ &(ti->palette));
+ }
- if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE))
- fxPrintUnitsMode("unitsmode", unitsmode);
+ FX_grTexClampMode_NoLock(GR_TMU0, ti->sClamp, ti->tClamp);
+ FX_grTexClampMode_NoLock(GR_TMU1, ti->sClamp, ti->tClamp);
+ FX_grTexFilterMode_NoLock(GR_TMU0, ti->minFilt, ti->maxFilt);
+ FX_grTexFilterMode_NoLock(GR_TMU1, ti->minFilt, ti->maxFilt);
+ FX_grTexMipMapMode_NoLock(GR_TMU0, ti->mmMode, ti->LODblend);
+ FX_grTexMipMapMode_NoLock(GR_TMU1, ti->mmMode, ti->LODblend);
+
+ FX_grTexSource_NoLock(GR_TMU0, ti->tm[FX_TMU0]->startAddr,
+ GR_MIPMAPLEVELMASK_ODD, &(ti->info));
+ FX_grTexSource_NoLock(GR_TMU1, ti->tm[FX_TMU1]->startAddr,
+ GR_MIPMAPLEVELMASK_EVEN, &(ti->info));
+ }
+ else {
+ if (ti->whichTMU == FX_TMU_BOTH)
+ tmu = FX_TMU0;
+ else
+ tmu = ti->whichTMU;
- return unitsmode;
-}
+ if ((ti->info.format == GR_TEXFMT_P_8)
+ && (!fxMesa->haveGlobalPaletteTexture)) {
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: uploading texture palette\n");
+ }
+ FX_grTexDownloadTable_NoLock(tmu, GR_TEXTABLE_PALETTE,
+ &(ti->palette));
+ }
-/************************************************************************/
-/************************* Rendering Mode SetUp *************************/
-/************************************************************************/
+ /* KW: The alternative is to do the download to the other tmu. If
+ * we get to this point, I think it means we are thrashing the
+ * texture memory, so perhaps it's not a good idea.
+ */
+ if (ti->LODblend && (MESA_VERBOSE & VERBOSE_DRIVER))
+ fprintf(stderr, "fxmesa: not blending texture - only on one tmu\n");
-/************************* Single Texture Set ***************************/
+ FX_grTexClampMode_NoLock(tmu, ti->sClamp, ti->tClamp);
+ FX_grTexFilterMode_NoLock(tmu, ti->minFilt, ti->maxFilt);
+ FX_grTexMipMapMode_NoLock(tmu, ti->mmMode, FXFALSE);
-static void fxSetupSingleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj)
-{
- tfxTexInfo *ti=fxTMGetTexInfo(tObj);
- int tmu;
-
- /* Make sure we're not loaded incorrectly */
- if (ti->isInTM) {
- if (ti->LODblend) {
- if (ti->whichTMU!=FX_TMU_SPLIT)
- fxTMMoveOutTM(fxMesa, tObj);
- } else {
- if (ti->whichTMU==FX_TMU_SPLIT)
- fxTMMoveOutTM(fxMesa, tObj);
- }
- }
-
- /* Make sure we're loaded correctly */
- if (!ti->isInTM) {
- if (ti->LODblend)
- fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU_SPLIT);
- else {
- if (fxMesa->haveTwoTMUs) {
- if (fxMesa->freeTexMem[FX_TMU0] >
- FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
- &(ti->info))) {
- fxTMMoveInTM_NoLock(fxMesa,tObj, FX_TMU0);
- } else {
- fxTMMoveInTM_NoLock(fxMesa,tObj, FX_TMU1);
- }
- } else
- fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU0);
- }
- }
-
- if (ti->LODblend && ti->whichTMU == FX_TMU_SPLIT) {
- if ((ti->info.format==GR_TEXFMT_P_8) && (!fxMesa->haveGlobalPaletteTexture)) {
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: uploading texture palette\n");
- }
- FX_grTexDownloadTable_NoLock(GR_TMU0,GR_TEXTABLE_PALETTE,&(ti->palette));
- FX_grTexDownloadTable_NoLock(GR_TMU1,GR_TEXTABLE_PALETTE,&(ti->palette));
- }
-
- FX_grTexClampMode_NoLock(GR_TMU0,ti->sClamp,ti->tClamp);
- FX_grTexClampMode_NoLock(GR_TMU1,ti->sClamp,ti->tClamp);
- FX_grTexFilterMode_NoLock(GR_TMU0,ti->minFilt,ti->maxFilt);
- FX_grTexFilterMode_NoLock(GR_TMU1,ti->minFilt,ti->maxFilt);
- FX_grTexMipMapMode_NoLock(GR_TMU0,ti->mmMode,ti->LODblend);
- FX_grTexMipMapMode_NoLock(GR_TMU1,ti->mmMode,ti->LODblend);
-
- FX_grTexSource_NoLock(GR_TMU0,ti->tm[FX_TMU0]->startAddr,
- GR_MIPMAPLEVELMASK_ODD,&(ti->info));
- FX_grTexSource_NoLock(GR_TMU1,ti->tm[FX_TMU1]->startAddr,
- GR_MIPMAPLEVELMASK_EVEN,&(ti->info));
- } else {
- if (ti->whichTMU==FX_TMU_BOTH) tmu=FX_TMU0;
- else tmu=ti->whichTMU;
-
- if((ti->info.format==GR_TEXFMT_P_8) && (!fxMesa->haveGlobalPaletteTexture)) {
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: uploading texture palette\n");
- }
- FX_grTexDownloadTable_NoLock(tmu, GR_TEXTABLE_PALETTE, &(ti->palette));
- }
-
- /* KW: The alternative is to do the download to the other tmu. If
- * we get to this point, I think it means we are thrashing the
- * texture memory, so perhaps it's not a good idea.
- */
- if (ti->LODblend && (MESA_VERBOSE&VERBOSE_DRIVER))
- fprintf(stderr, "fxmesa: not blending texture - only on one tmu\n");
-
- FX_grTexClampMode_NoLock(tmu, ti->sClamp, ti->tClamp);
- FX_grTexFilterMode_NoLock(tmu, ti->minFilt, ti->maxFilt);
- FX_grTexMipMapMode_NoLock(tmu, ti->mmMode, FXFALSE);
-
- FX_grTexSource_NoLock(tmu, ti->tm[tmu]->startAddr,
- GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
- }
+ FX_grTexSource_NoLock(tmu, ti->tm[tmu]->startAddr,
+ GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+ }
}
-static void fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu,
- FxBool LODblend)
+static void
+fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, FxBool LODblend)
{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxSelectSingleTMUSrc(%d,%d)\n",tmu,LODblend);
- }
-
- if (LODblend) {
- FX_grTexCombine_NoLock(GR_TMU0,
- GR_COMBINE_FUNCTION_BLEND,
- GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION,
- GR_COMBINE_FUNCTION_BLEND,
- GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION,
- FXFALSE,FXFALSE);
-
- if (fxMesa->haveTwoTMUs)
- FX_grTexCombine_NoLock(GR_TMU1,
- GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
- FXFALSE,FXFALSE);
- fxMesa->tmuSrc=FX_TMU_SPLIT;
- }
- else {
- if (tmu!=FX_TMU1) {
- FX_grTexCombine_NoLock(GR_TMU0,
- GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
- FXFALSE,FXFALSE);
- if (fxMesa->haveTwoTMUs) {
- FX_grTexCombine_NoLock(GR_TMU1,
- GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE,
- FXFALSE,FXFALSE);
- }
- fxMesa->tmuSrc=FX_TMU0;
- }
- else {
- FX_grTexCombine_NoLock(GR_TMU1,
- GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
- FXFALSE,FXFALSE);
-
- /* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxSelectSingleTMUSrc(%d,%d)\n", tmu, LODblend);
+ }
+ if (LODblend) {
FX_grTexCombine_NoLock(GR_TMU0,
GR_COMBINE_FUNCTION_BLEND,
- GR_COMBINE_FACTOR_ONE,
+ GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION,
GR_COMBINE_FUNCTION_BLEND,
- GR_COMBINE_FACTOR_ONE,
- FXFALSE,FXFALSE);
-
- fxMesa->tmuSrc=FX_TMU1;
- }
- }
+ GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION,
+ FXFALSE, FXFALSE);
+
+ if (fxMesa->haveTwoTMUs)
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+ fxMesa->tmuSrc = FX_TMU_SPLIT;
+ }
+ else {
+ if (tmu != FX_TMU1) {
+ FX_grTexCombine_NoLock(GR_TMU0,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+ if (fxMesa->haveTwoTMUs) {
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_ZERO,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_ZERO,
+ GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+ }
+ fxMesa->tmuSrc = FX_TMU0;
+ }
+ else {
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+
+ /* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */
+
+ FX_grTexCombine_NoLock(GR_TMU0,
+ GR_COMBINE_FUNCTION_BLEND,
+ GR_COMBINE_FACTOR_ONE,
+ GR_COMBINE_FUNCTION_BLEND,
+ GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE);
+
+ fxMesa->tmuSrc = FX_TMU1;
+ }
+ }
}
-static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset)
+static void
+fxSetupTextureSingleTMU_NoLock(GLcontext * ctx, GLuint textureset)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GrCombineLocal_t localc,locala;
- GLuint unitsmode;
- GLint ifmt;
- tfxTexInfo *ti;
- struct gl_texture_object *tObj=ctx->Texture.Unit[textureset].Current2D;
- int tmu;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxSetupTextureSingleTMU(...) Start\n");
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GrCombineLocal_t localc, locala;
+ GLuint unitsmode;
+ GLint ifmt;
+ tfxTexInfo *ti;
+ struct gl_texture_object *tObj = ctx->Texture.Unit[textureset].Current2D;
+ int tmu;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxSetupTextureSingleTMU(...) Start\n");
+ }
- ti=fxTMGetTexInfo(tObj);
+ ti = fxTMGetTexInfo(tObj);
- fxTexValidate(ctx,tObj);
+ fxTexValidate(ctx, tObj);
- fxSetupSingleTMU_NoLock(fxMesa,tObj);
+ fxSetupSingleTMU_NoLock(fxMesa, tObj);
- if (ti->whichTMU==FX_TMU_BOTH) tmu=FX_TMU0;
- else tmu=ti->whichTMU;
- if (fxMesa->tmuSrc!=tmu)
- fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend);
+ if (ti->whichTMU == FX_TMU_BOTH)
+ tmu = FX_TMU0;
+ else
+ tmu = ti->whichTMU;
+ if (fxMesa->tmuSrc != tmu)
+ fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend);
- if(textureset==0 || !fxMesa->haveTwoTMUs)
- unitsmode=fxGetTexSetConfiguration(ctx,tObj,NULL);
- else
- unitsmode=fxGetTexSetConfiguration(ctx,NULL,tObj);
+ if (textureset == 0 || !fxMesa->haveTwoTMUs)
+ unitsmode = fxGetTexSetConfiguration(ctx, tObj, NULL);
+ else
+ unitsmode = fxGetTexSetConfiguration(ctx, NULL, tObj);
/* if(fxMesa->lastUnitsMode==unitsmode) */
/* return; */
- fxMesa->lastUnitsMode=unitsmode;
-
- fxMesa->stw_hint_state = 0;
- FX_grHints_NoLock(GR_HINT_STWHINT,0);
-
- ifmt=ti->baseLevelInternalFormat;
-
- if(unitsmode & FX_UM_ALPHA_ITERATED)
- locala=GR_COMBINE_LOCAL_ITERATED;
- else
- locala=GR_COMBINE_LOCAL_CONSTANT;
-
- if(unitsmode & FX_UM_COLOR_ITERATED)
- localc=GR_COMBINE_LOCAL_ITERATED;
- else
- localc=GR_COMBINE_LOCAL_CONSTANT;
-
- if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE))
- fprintf(stderr, "fxMesa: fxSetupTextureSingleTMU, envmode is %s\n",
- _mesa_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode));
-
- switch(ctx->Texture.Unit[textureset].EnvMode) {
- case GL_DECAL:
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- locala,
- GR_COMBINE_OTHER_NONE,
- FXFALSE);
-
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_BLEND,
- GR_COMBINE_FACTOR_TEXTURE_ALPHA,
- localc,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
- break;
- case GL_MODULATE:
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- locala,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
-
- if(ifmt==GL_ALPHA)
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+ fxMesa->lastUnitsMode = unitsmode;
+
+ fxMesa->stw_hint_state = 0;
+ FX_grHints_NoLock(GR_HINT_STWHINT, 0);
+
+ ifmt = ti->baseLevelInternalFormat;
+
+ if (unitsmode & FX_UM_ALPHA_ITERATED)
+ locala = GR_COMBINE_LOCAL_ITERATED;
+ else
+ locala = GR_COMBINE_LOCAL_CONSTANT;
+
+ if (unitsmode & FX_UM_COLOR_ITERATED)
+ localc = GR_COMBINE_LOCAL_ITERATED;
+ else
+ localc = GR_COMBINE_LOCAL_CONSTANT;
+
+ if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+ fprintf(stderr, "fxMesa: fxSetupTextureSingleTMU, envmode is %s\n",
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode));
+
+ switch (ctx->Texture.Unit[textureset].EnvMode) {
+ case GL_DECAL:
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
GR_COMBINE_FACTOR_NONE,
- localc,
- GR_COMBINE_OTHER_NONE,
- FXFALSE);
- else
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+ locala, GR_COMBINE_OTHER_NONE, FXFALSE);
+
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_BLEND,
+ GR_COMBINE_FACTOR_TEXTURE_ALPHA,
+ localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+ break;
+ case GL_MODULATE:
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
GR_COMBINE_FACTOR_LOCAL,
- localc,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
- break;
- case GL_BLEND:
+ locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+
+ if (ifmt == GL_ALPHA)
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ localc, GR_COMBINE_OTHER_NONE, FXFALSE);
+ else
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+ GR_COMBINE_FACTOR_LOCAL,
+ localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+ break;
+ case GL_BLEND:
#if 0
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- locala,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
- if (ifmt==GL_ALPHA)
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- localc,
- GR_COMBINE_OTHER_NONE,
- FXFALSE);
- else
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
GR_COMBINE_FACTOR_LOCAL,
- localc,
- GR_COMBINE_OTHER_TEXTURE,
- FXTRUE);
- ctx->Driver.MultipassFunc = fxMultipassBlend;
+ locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+ if (ifmt == GL_ALPHA)
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ localc, GR_COMBINE_OTHER_NONE, FXFALSE);
+ else
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+ GR_COMBINE_FACTOR_LOCAL,
+ localc, GR_COMBINE_OTHER_TEXTURE, FXTRUE);
+ ctx->Driver.MultipassFunc = fxMultipassBlend;
#else
- if (MESA_VERBOSE&VERBOSE_DRIVER)
- fprintf(stderr,"fx Driver: GL_BLEND not yet supported\n");
-#endif
- break;
- case GL_REPLACE:
- if((ifmt==GL_RGB) || (ifmt==GL_LUMINANCE))
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- locala,
- GR_COMBINE_OTHER_NONE,
- FXFALSE);
- else
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_ONE,
- locala,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
-
- if(ifmt==GL_ALPHA)
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- localc,
- GR_COMBINE_OTHER_NONE,
- FXFALSE);
- else
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_ONE,
- localc,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
- break;
- default:
- if (MESA_VERBOSE&VERBOSE_DRIVER)
- fprintf(stderr, "fx Driver: %x Texture.EnvMode not yet supported\n",
- ctx->Texture.Unit[textureset].EnvMode);
- break;
- }
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxSetupTextureSingleTMU(...) End\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER)
+ fprintf(stderr, "fx Driver: GL_BLEND not yet supported\n");
+#endif
+ break;
+ case GL_REPLACE:
+ if ((ifmt == GL_RGB) || (ifmt == GL_LUMINANCE))
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ locala, GR_COMBINE_OTHER_NONE, FXFALSE);
+ else
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+ GR_COMBINE_FACTOR_ONE,
+ locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+
+ if (ifmt == GL_ALPHA)
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ localc, GR_COMBINE_OTHER_NONE, FXFALSE);
+ else
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+ GR_COMBINE_FACTOR_ONE,
+ localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+ break;
+ default:
+ if (MESA_VERBOSE & VERBOSE_DRIVER)
+ fprintf(stderr, "fx Driver: %x Texture.EnvMode not yet supported\n",
+ ctx->Texture.Unit[textureset].EnvMode);
+ break;
+ }
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxSetupTextureSingleTMU(...) End\n");
+ }
}
-static void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) {
- BEGIN_BOARD_LOCK();
- fxSetupTextureSingleTMU_NoLock(ctx, textureset);
- END_BOARD_LOCK();
+static void
+fxSetupTextureSingleTMU(GLcontext * ctx, GLuint textureset)
+{
+ BEGIN_BOARD_LOCK();
+ fxSetupTextureSingleTMU_NoLock(ctx, textureset);
+ END_BOARD_LOCK();
}
/************************* Double Texture Set ***************************/
-static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
- struct gl_texture_object *tObj0,
- struct gl_texture_object *tObj1)
+static void
+fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
+ struct gl_texture_object *tObj0,
+ struct gl_texture_object *tObj1)
{
#define T0_NOT_IN_TMU 0x01
#define T1_NOT_IN_TMU 0x02
@@ -620,119 +619,130 @@ static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
#define T0_IN_TMU1 0x10
#define T1_IN_TMU1 0x20
- tfxTexInfo *ti0=fxTMGetTexInfo(tObj0);
- tfxTexInfo *ti1=fxTMGetTexInfo(tObj1);
- GLuint tstate=0;
- int tmu0=0, tmu1=1;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxSetupDoubleTMU(...)\n");
- }
-
- /* We shouldn't need to do this. There is something wrong with
- mutlitexturing when the TMUs are swapped. So, we're forcing
- them to always be loaded correctly. !!! */
- if (ti0->whichTMU==FX_TMU1)
- fxTMMoveOutTM_NoLock(fxMesa, tObj0);
- if (ti1->whichTMU==FX_TMU0)
- fxTMMoveOutTM_NoLock(fxMesa, tObj1);
-
- if (ti0->isInTM) {
- switch (ti0->whichTMU) {
- case FX_TMU0:
- tstate|=T0_IN_TMU0;
- break;
- case FX_TMU1:
- tstate|=T0_IN_TMU1;
- break;
- case FX_TMU_BOTH:
- tstate|=T0_IN_TMU0|T0_IN_TMU1;
- break;
- case FX_TMU_SPLIT:
- tstate|=T0_NOT_IN_TMU;
- break;
- }
- } else tstate|=T0_NOT_IN_TMU;
-
- if (ti1->isInTM) {
- switch (ti1->whichTMU) {
- case FX_TMU0:
- tstate|=T1_IN_TMU0;
- break;
- case FX_TMU1:
- tstate|=T1_IN_TMU1;
- break;
- case FX_TMU_BOTH:
- tstate|=T1_IN_TMU0|T1_IN_TMU1;
- break;
- case FX_TMU_SPLIT:
- tstate|=T1_NOT_IN_TMU;
- break;
- }
- } else tstate|=T1_NOT_IN_TMU;
-
- ti0->lastTimeUsed=fxMesa->texBindNumber;
- ti1->lastTimeUsed=fxMesa->texBindNumber;
-
- /* Move texture maps into TMUs */
-
- if (!(((tstate&T0_IN_TMU0) && (tstate&T1_IN_TMU1)) ||
- ((tstate&T0_IN_TMU1) && (tstate&T1_IN_TMU0)))) {
- if (tObj0==tObj1) fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU_BOTH);
- else {
- /* Find the minimal way to correct the situation */
- if ((tstate&T0_IN_TMU0) || (tstate&T1_IN_TMU1)) {
- /* We have one in the standard order, setup the other */
- if (tstate&T0_IN_TMU0) { /* T0 is in TMU0, put T1 in TMU1 */
- fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1);
- } else {
- fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);
- }
- /* tmu0 and tmu1 are setup */
- } else if ((tstate&T0_IN_TMU1) || (tstate&T1_IN_TMU0)) {
- /* we have one in the reverse order, setup the other */
- if (tstate&T1_IN_TMU0) { /* T1 is in TMU0, put T0 in TMU1 */
- fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU1);
- } else {
- fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0);
- }
- tmu0=1;
- tmu1=0;
- } else { /* Nothing is loaded */
- fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);
- fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1);
- /* tmu0 and tmu1 are setup */
+ tfxTexInfo *ti0 = fxTMGetTexInfo(tObj0);
+ tfxTexInfo *ti1 = fxTMGetTexInfo(tObj1);
+ GLuint tstate = 0;
+ int tmu0 = 0, tmu1 = 1;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxSetupDoubleTMU(...)\n");
+ }
+
+ /* We shouldn't need to do this. There is something wrong with
+ mutlitexturing when the TMUs are swapped. So, we're forcing
+ them to always be loaded correctly. !!! */
+ if (ti0->whichTMU == FX_TMU1)
+ fxTMMoveOutTM_NoLock(fxMesa, tObj0);
+ if (ti1->whichTMU == FX_TMU0)
+ fxTMMoveOutTM_NoLock(fxMesa, tObj1);
+
+ if (ti0->isInTM) {
+ switch (ti0->whichTMU) {
+ case FX_TMU0:
+ tstate |= T0_IN_TMU0;
+ break;
+ case FX_TMU1:
+ tstate |= T0_IN_TMU1;
+ break;
+ case FX_TMU_BOTH:
+ tstate |= T0_IN_TMU0 | T0_IN_TMU1;
+ break;
+ case FX_TMU_SPLIT:
+ tstate |= T0_NOT_IN_TMU;
+ break;
}
- }
- }
-
- if (!fxMesa->haveGlobalPaletteTexture) {
- if (ti0->info.format==GR_TEXFMT_P_8) {
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: uploading texture palette TMU0\n");
- }
- FX_grTexDownloadTable_NoLock(tmu0, GR_TEXTABLE_PALETTE, &(ti0->palette));
- }
-
- if (ti1->info.format==GR_TEXFMT_P_8) {
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: uploading texture palette TMU1\n");
- }
- FX_grTexDownloadTable_NoLock(tmu1, GR_TEXTABLE_PALETTE, &(ti1->palette));
- }
- }
-
- FX_grTexSource_NoLock(tmu0, ti0->tm[tmu0]->startAddr,
- GR_MIPMAPLEVELMASK_BOTH, &(ti0->info));
- FX_grTexClampMode_NoLock(tmu0, ti0->sClamp, ti0->tClamp);
- FX_grTexFilterMode_NoLock(tmu0, ti0->minFilt, ti0->maxFilt);
- FX_grTexMipMapMode_NoLock(tmu0, ti0->mmMode, FXFALSE);
-
- FX_grTexSource_NoLock(tmu1, ti1->tm[tmu1]->startAddr,
- GR_MIPMAPLEVELMASK_BOTH, &(ti1->info));
- FX_grTexClampMode_NoLock(tmu1, ti1->sClamp, ti1->tClamp);
- FX_grTexFilterMode_NoLock(tmu1, ti1->minFilt, ti1->maxFilt);
- FX_grTexMipMapMode_NoLock(tmu1, ti1->mmMode, FXFALSE);
+ }
+ else
+ tstate |= T0_NOT_IN_TMU;
+
+ if (ti1->isInTM) {
+ switch (ti1->whichTMU) {
+ case FX_TMU0:
+ tstate |= T1_IN_TMU0;
+ break;
+ case FX_TMU1:
+ tstate |= T1_IN_TMU1;
+ break;
+ case FX_TMU_BOTH:
+ tstate |= T1_IN_TMU0 | T1_IN_TMU1;
+ break;
+ case FX_TMU_SPLIT:
+ tstate |= T1_NOT_IN_TMU;
+ break;
+ }
+ }
+ else
+ tstate |= T1_NOT_IN_TMU;
+
+ ti0->lastTimeUsed = fxMesa->texBindNumber;
+ ti1->lastTimeUsed = fxMesa->texBindNumber;
+
+ /* Move texture maps into TMUs */
+
+ if (!(((tstate & T0_IN_TMU0) && (tstate & T1_IN_TMU1)) ||
+ ((tstate & T0_IN_TMU1) && (tstate & T1_IN_TMU0)))) {
+ if (tObj0 == tObj1)
+ fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU_BOTH);
+ else {
+ /* Find the minimal way to correct the situation */
+ if ((tstate & T0_IN_TMU0) || (tstate & T1_IN_TMU1)) {
+ /* We have one in the standard order, setup the other */
+ if (tstate & T0_IN_TMU0) { /* T0 is in TMU0, put T1 in TMU1 */
+ fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1);
+ }
+ else {
+ fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);
+ }
+ /* tmu0 and tmu1 are setup */
+ }
+ else if ((tstate & T0_IN_TMU1) || (tstate & T1_IN_TMU0)) {
+ /* we have one in the reverse order, setup the other */
+ if (tstate & T1_IN_TMU0) { /* T1 is in TMU0, put T0 in TMU1 */
+ fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU1);
+ }
+ else {
+ fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0);
+ }
+ tmu0 = 1;
+ tmu1 = 0;
+ }
+ else { /* Nothing is loaded */
+ fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);
+ fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1);
+ /* tmu0 and tmu1 are setup */
+ }
+ }
+ }
+
+ if (!fxMesa->haveGlobalPaletteTexture) {
+ if (ti0->info.format == GR_TEXFMT_P_8) {
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: uploading texture palette TMU0\n");
+ }
+ FX_grTexDownloadTable_NoLock(tmu0, GR_TEXTABLE_PALETTE,
+ &(ti0->palette));
+ }
+
+ if (ti1->info.format == GR_TEXFMT_P_8) {
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: uploading texture palette TMU1\n");
+ }
+ FX_grTexDownloadTable_NoLock(tmu1, GR_TEXTABLE_PALETTE,
+ &(ti1->palette));
+ }
+ }
+
+ FX_grTexSource_NoLock(tmu0, ti0->tm[tmu0]->startAddr,
+ GR_MIPMAPLEVELMASK_BOTH, &(ti0->info));
+ FX_grTexClampMode_NoLock(tmu0, ti0->sClamp, ti0->tClamp);
+ FX_grTexFilterMode_NoLock(tmu0, ti0->minFilt, ti0->maxFilt);
+ FX_grTexMipMapMode_NoLock(tmu0, ti0->mmMode, FXFALSE);
+
+ FX_grTexSource_NoLock(tmu1, ti1->tm[tmu1]->startAddr,
+ GR_MIPMAPLEVELMASK_BOTH, &(ti1->info));
+ FX_grTexClampMode_NoLock(tmu1, ti1->sClamp, ti1->tClamp);
+ FX_grTexFilterMode_NoLock(tmu1, ti1->minFilt, ti1->maxFilt);
+ FX_grTexMipMapMode_NoLock(tmu1, ti1->mmMode, FXFALSE);
#undef T0_NOT_IN_TMU
#undef T1_NOT_IN_TMU
@@ -742,376 +752,345 @@ static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
#undef T1_IN_TMU1
}
-static void fxSetupTextureDoubleTMU_NoLock(GLcontext *ctx)
+static void
+fxSetupTextureDoubleTMU_NoLock(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GrCombineLocal_t localc,locala;
- tfxTexInfo *ti0,*ti1;
- struct gl_texture_object *tObj0=ctx->Texture.Unit[0].Current2D;
- struct gl_texture_object *tObj1=ctx->Texture.Unit[1].Current2D;
- GLuint envmode,ifmt,unitsmode;
- int tmu0=0, tmu1=1;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxSetupTextureDoubleTMU(...) Start\n");
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GrCombineLocal_t localc, locala;
+ tfxTexInfo *ti0, *ti1;
+ struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].Current2D;
+ struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].Current2D;
+ GLuint envmode, ifmt, unitsmode;
+ int tmu0 = 0, tmu1 = 1;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxSetupTextureDoubleTMU(...) Start\n");
+ }
- ti0=fxTMGetTexInfo(tObj0);
- fxTexValidate(ctx,tObj0);
+ ti0 = fxTMGetTexInfo(tObj0);
+ fxTexValidate(ctx, tObj0);
- ti1=fxTMGetTexInfo(tObj1);
- fxTexValidate(ctx,tObj1);
+ ti1 = fxTMGetTexInfo(tObj1);
+ fxTexValidate(ctx, tObj1);
- fxSetupDoubleTMU_NoLock(fxMesa,tObj0,tObj1);
+ fxSetupDoubleTMU_NoLock(fxMesa, tObj0, tObj1);
- unitsmode=fxGetTexSetConfiguration(ctx,tObj0,tObj1);
+ unitsmode = fxGetTexSetConfiguration(ctx, tObj0, tObj1);
/* if(fxMesa->lastUnitsMode==unitsmode) */
/* return; */
- fxMesa->lastUnitsMode=unitsmode;
+ fxMesa->lastUnitsMode = unitsmode;
- fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1;
- FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state);
+ fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1;
+ FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state);
- envmode=unitsmode & FX_UM_E_ENVMODE;
- ifmt=unitsmode & FX_UM_E_IFMT;
+ envmode = unitsmode & FX_UM_E_ENVMODE;
+ ifmt = unitsmode & FX_UM_E_IFMT;
- if(unitsmode & FX_UM_ALPHA_ITERATED)
- locala=GR_COMBINE_LOCAL_ITERATED;
- else
- locala=GR_COMBINE_LOCAL_CONSTANT;
+ if (unitsmode & FX_UM_ALPHA_ITERATED)
+ locala = GR_COMBINE_LOCAL_ITERATED;
+ else
+ locala = GR_COMBINE_LOCAL_CONSTANT;
- if(unitsmode & FX_UM_COLOR_ITERATED)
- localc=GR_COMBINE_LOCAL_ITERATED;
- else
- localc=GR_COMBINE_LOCAL_CONSTANT;
+ if (unitsmode & FX_UM_COLOR_ITERATED)
+ localc = GR_COMBINE_LOCAL_ITERATED;
+ else
+ localc = GR_COMBINE_LOCAL_CONSTANT;
- if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE))
- fprintf(stderr, "fxMesa: fxSetupTextureDoubleTMU, envmode is %s/%s\n",
- _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
- _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
+ if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+ fprintf(stderr, "fxMesa: fxSetupTextureDoubleTMU, envmode is %s/%s\n",
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
- if ((ti0->whichTMU==FX_TMU1) || (ti1->whichTMU==FX_TMU0)) {
- tmu0=1;
- tmu1=0;
- }
- fxMesa->tmuSrc=FX_TMU_BOTH;
- switch(envmode) {
- case (FX_UM_E0_MODULATE | FX_UM_E1_MODULATE):
- {
- GLboolean isalpha[FX_NUM_TMU];
-
- if(ti0->baseLevelInternalFormat==GL_ALPHA)
- isalpha[tmu0]=GL_TRUE;
- else
- isalpha[tmu0]=GL_FALSE;
+ if ((ti0->whichTMU == FX_TMU1) || (ti1->whichTMU == FX_TMU0)) {
+ tmu0 = 1;
+ tmu1 = 0;
+ }
+ fxMesa->tmuSrc = FX_TMU_BOTH;
+ switch (envmode) {
+ case (FX_UM_E0_MODULATE | FX_UM_E1_MODULATE):
+ {
+ GLboolean isalpha[FX_NUM_TMU];
+
+ if (ti0->baseLevelInternalFormat == GL_ALPHA)
+ isalpha[tmu0] = GL_TRUE;
+ else
+ isalpha[tmu0] = GL_FALSE;
+
+ if (ti1->baseLevelInternalFormat == GL_ALPHA)
+ isalpha[tmu1] = GL_TRUE;
+ else
+ isalpha[tmu1] = GL_FALSE;
+
+ if (isalpha[FX_TMU1])
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_ZERO,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE, FXTRUE, FXFALSE);
+ else
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+
+ if (isalpha[FX_TMU0])
+ FX_grTexCombine_NoLock(GR_TMU0,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_ONE,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE);
+ else
+ FX_grTexCombine_NoLock(GR_TMU0,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_LOCAL,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE);
+
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+ GR_COMBINE_FACTOR_LOCAL,
+ localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+ GR_COMBINE_FACTOR_LOCAL,
+ locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+ break;
+ }
+ case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND): /* Only for GLQuake */
+ if (tmu1 == FX_TMU1) {
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE, FXTRUE, FXFALSE);
+
+ FX_grTexCombine_NoLock(GR_TMU0,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_LOCAL,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE);
+ }
+ else {
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+
+ FX_grTexCombine_NoLock(GR_TMU0,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_ONE_MINUS_LOCAL,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_ONE_MINUS_LOCAL,
+ FXFALSE, FXFALSE);
+ }
- if(ti1->baseLevelInternalFormat==GL_ALPHA)
- isalpha[tmu1]=GL_TRUE;
- else
- isalpha[tmu1]=GL_FALSE;
-
- if(isalpha[FX_TMU1])
- FX_grTexCombine_NoLock(GR_TMU1,
- GR_COMBINE_FUNCTION_ZERO,
- GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- FXTRUE,FXFALSE);
- else
- FX_grTexCombine_NoLock(GR_TMU1,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_LOCAL,
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
GR_COMBINE_FACTOR_NONE,
- FXFALSE,FXFALSE);
-
- if(isalpha[FX_TMU0])
- FX_grTexCombine_NoLock(GR_TMU0,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_ONE,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- FXFALSE,FXFALSE);
- else
- FX_grTexCombine_NoLock(GR_TMU0,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- FXFALSE,FXFALSE);
+ locala, GR_COMBINE_OTHER_NONE, FXFALSE);
FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- localc,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
-
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- locala,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
- break;
- }
- case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND): /* Only for GLQuake */
- if (tmu1==FX_TMU1) {
- FX_grTexCombine_NoLock(GR_TMU1,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- FXTRUE,FXFALSE);
-
- FX_grTexCombine_NoLock(GR_TMU0,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- FXFALSE,FXFALSE);
- } else {
- FX_grTexCombine_NoLock(GR_TMU1,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- FXFALSE,FXFALSE);
-
- FX_grTexCombine_NoLock(GR_TMU0,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_ONE_MINUS_LOCAL,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_ONE_MINUS_LOCAL,
- FXFALSE,FXFALSE);
- }
-
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- locala,
- GR_COMBINE_OTHER_NONE,
- FXFALSE);
-
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_ONE,
- localc,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
- break;
- case (FX_UM_E0_REPLACE | FX_UM_E1_MODULATE): /* Quake 2 and 3 */
- if (tmu1==FX_TMU1) {
- FX_grTexCombine_NoLock(GR_TMU1,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_ZERO,
- GR_COMBINE_FACTOR_NONE,
- FXFALSE,FXTRUE);
-
- FX_grTexCombine_NoLock(GR_TMU0,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- FXFALSE,FXFALSE);
-
- } else {
- FX_grTexCombine_NoLock(GR_TMU1,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- FXFALSE,FXFALSE);
-
- FX_grTexCombine_NoLock(GR_TMU0,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- GR_COMBINE_FUNCTION_BLEND_OTHER,
- GR_COMBINE_FACTOR_ONE,
- FXFALSE,FXFALSE);
- }
-
- if(ti0->baseLevelInternalFormat==GL_RGB)
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- locala,
- GR_COMBINE_OTHER_NONE,
- FXFALSE);
- else
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
GR_COMBINE_FACTOR_ONE,
- locala,
- GR_COMBINE_OTHER_NONE,
- FXFALSE);
-
-
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_ONE,
- localc,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
- break;
-
+ localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+ break;
+ case (FX_UM_E0_REPLACE | FX_UM_E1_MODULATE): /* Quake 2 and 3 */
+ if (tmu1 == FX_TMU1) {
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_ZERO,
+ GR_COMBINE_FACTOR_NONE, FXFALSE, FXTRUE);
+
+ FX_grTexCombine_NoLock(GR_TMU0,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_LOCAL,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE);
- case (FX_UM_E0_MODULATE | FX_UM_E1_ADD): /* Quake 3 Sky */
- {
- GLboolean isalpha[FX_NUM_TMU];
+ }
+ else {
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+
+ FX_grTexCombine_NoLock(GR_TMU0,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_LOCAL,
+ GR_COMBINE_FUNCTION_BLEND_OTHER,
+ GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE);
+ }
- if(ti0->baseLevelInternalFormat==GL_ALPHA)
- isalpha[tmu0]=GL_TRUE;
+ if (ti0->baseLevelInternalFormat == GL_RGB)
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ locala, GR_COMBINE_OTHER_NONE, FXFALSE);
else
- isalpha[tmu0]=GL_FALSE;
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+ GR_COMBINE_FACTOR_ONE,
+ locala, GR_COMBINE_OTHER_NONE, FXFALSE);
- if(ti1->baseLevelInternalFormat==GL_ALPHA)
- isalpha[tmu1]=GL_TRUE;
- else
- isalpha[tmu1]=GL_FALSE;
-
- if(isalpha[FX_TMU1])
- FX_grTexCombine_NoLock(GR_TMU1,
- GR_COMBINE_FUNCTION_ZERO,
- GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- FXTRUE,FXFALSE);
- else
- FX_grTexCombine_NoLock(GR_TMU1,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- FXFALSE,FXFALSE);
- if(isalpha[FX_TMU0])
- FX_grTexCombine_NoLock(GR_TMU0,
- GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_ONE,
- GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
- GR_COMBINE_FACTOR_ONE,
- FXFALSE,FXFALSE);
- else
- FX_grTexCombine_NoLock(GR_TMU0,
- GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
- GR_COMBINE_FACTOR_ONE,
- GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
GR_COMBINE_FACTOR_ONE,
- FXFALSE,FXFALSE);
+ localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+ break;
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- localc,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- locala,
- GR_COMBINE_OTHER_TEXTURE,
- FXFALSE);
- break;
- }
- default:
- fprintf(stderr, "Unexpected dual texture mode encountered\n");
- break;
- }
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxSetupTextureDoubleTMU(...) End\n");
- }
+ case (FX_UM_E0_MODULATE | FX_UM_E1_ADD): /* Quake 3 Sky */
+ {
+ GLboolean isalpha[FX_NUM_TMU];
+
+ if (ti0->baseLevelInternalFormat == GL_ALPHA)
+ isalpha[tmu0] = GL_TRUE;
+ else
+ isalpha[tmu0] = GL_FALSE;
+
+ if (ti1->baseLevelInternalFormat == GL_ALPHA)
+ isalpha[tmu1] = GL_TRUE;
+ else
+ isalpha[tmu1] = GL_FALSE;
+
+ if (isalpha[FX_TMU1])
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_ZERO,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE, FXTRUE, FXFALSE);
+ else
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+
+ if (isalpha[FX_TMU0])
+ FX_grTexCombine_NoLock(GR_TMU0,
+ GR_COMBINE_FUNCTION_SCALE_OTHER,
+ GR_COMBINE_FACTOR_ONE,
+ GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+ GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE);
+ else
+ FX_grTexCombine_NoLock(GR_TMU0,
+ GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+ GR_COMBINE_FACTOR_ONE,
+ GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+ GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE);
+
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+ GR_COMBINE_FACTOR_LOCAL,
+ localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+ GR_COMBINE_FACTOR_LOCAL,
+ locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+ break;
+ }
+ default:
+ fprintf(stderr, "Unexpected dual texture mode encountered\n");
+ break;
+ }
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxSetupTextureDoubleTMU(...) End\n");
+ }
}
/************************* No Texture ***************************/
-static void fxSetupTextureNone_NoLock(GLcontext *ctx)
+static void
+fxSetupTextureNone_NoLock(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GrCombineLocal_t localc,locala;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxSetupTextureNone(...)\n");
- }
-
- if((ctx->Light.ShadeModel==GL_SMOOTH) || 1 ||
- (ctx->Point.SmoothFlag) ||
- (ctx->Line.SmoothFlag) ||
- (ctx->Polygon.SmoothFlag))
- locala=GR_COMBINE_LOCAL_ITERATED;
- else
- locala=GR_COMBINE_LOCAL_CONSTANT;
-
- if(ctx->Light.ShadeModel==GL_SMOOTH || 1)
- localc=GR_COMBINE_LOCAL_ITERATED;
- else
- localc=GR_COMBINE_LOCAL_CONSTANT;
-
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- locala,
- GR_COMBINE_OTHER_NONE,
- FXFALSE);
-
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- localc,
- GR_COMBINE_OTHER_NONE,
- FXFALSE);
-
- fxMesa->lastUnitsMode=FX_UM_NONE;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GrCombineLocal_t localc, locala;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxSetupTextureNone(...)\n");
+ }
+
+ if ((ctx->Light.ShadeModel == GL_SMOOTH) || 1 ||
+ (ctx->Point.SmoothFlag) ||
+ (ctx->Line.SmoothFlag) ||
+ (ctx->Polygon.SmoothFlag)) locala = GR_COMBINE_LOCAL_ITERATED;
+ else
+ locala = GR_COMBINE_LOCAL_CONSTANT;
+
+ if (ctx->Light.ShadeModel == GL_SMOOTH || 1)
+ localc = GR_COMBINE_LOCAL_ITERATED;
+ else
+ localc = GR_COMBINE_LOCAL_CONSTANT;
+
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ locala, GR_COMBINE_OTHER_NONE, FXFALSE);
+
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ localc, GR_COMBINE_OTHER_NONE, FXFALSE);
+
+ fxMesa->lastUnitsMode = FX_UM_NONE;
}
/************************************************************************/
/************************** Texture Mode SetUp **************************/
/************************************************************************/
-static void fxSetupTexture_NoLock(GLcontext *ctx)
+static void
+fxSetupTexture_NoLock(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint tex2Denabled;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxSetupTexture(...)\n");
- }
-
- /* Disable multipass texturing.
- */
- ctx->Driver.MultipassFunc = 0;
-
- /* Texture Combine, Color Combine and Alpha Combine.
- */
- tex2Denabled = (ctx->Texture._ReallyEnabled & TEXTURE0_2D);
-
- if (fxMesa->emulateTwoTMUs)
- tex2Denabled |= (ctx->Texture._ReallyEnabled & TEXTURE1_2D);
-
- switch(tex2Denabled) {
- case TEXTURE0_2D:
- fxSetupTextureSingleTMU_NoLock(ctx,0);
- break;
- case TEXTURE1_2D:
- fxSetupTextureSingleTMU_NoLock(ctx,1);
- break;
- case (TEXTURE0_2D|TEXTURE1_2D):
- if (fxMesa->haveTwoTMUs)
- fxSetupTextureDoubleTMU_NoLock(ctx);
- else {
- if (MESA_VERBOSE&VERBOSE_DRIVER)
- fprintf(stderr, "fxmesa: enabling fake multitexture\n");
-
- fxSetupTextureSingleTMU_NoLock(ctx,0);
- ctx->Driver.MultipassFunc = fxMultipassTexture;
- }
- break;
- default:
- fxSetupTextureNone_NoLock(ctx);
- break;
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLuint tex2Denabled;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxSetupTexture(...)\n");
+ }
+
+ /* Disable multipass texturing.
+ */
+ ctx->Driver.MultipassFunc = 0;
+
+ /* Texture Combine, Color Combine and Alpha Combine.
+ */
+ tex2Denabled = (ctx->Texture._ReallyEnabled & TEXTURE0_2D);
+
+ if (fxMesa->emulateTwoTMUs)
+ tex2Denabled |= (ctx->Texture._ReallyEnabled & TEXTURE1_2D);
+
+ switch (tex2Denabled) {
+ case TEXTURE0_2D:
+ fxSetupTextureSingleTMU_NoLock(ctx, 0);
+ break;
+ case TEXTURE1_2D:
+ fxSetupTextureSingleTMU_NoLock(ctx, 1);
+ break;
+ case (TEXTURE0_2D | TEXTURE1_2D):
+ if (fxMesa->haveTwoTMUs)
+ fxSetupTextureDoubleTMU_NoLock(ctx);
+ else {
+ if (MESA_VERBOSE & VERBOSE_DRIVER)
+ fprintf(stderr, "fxmesa: enabling fake multitexture\n");
+
+ fxSetupTextureSingleTMU_NoLock(ctx, 0);
+ ctx->Driver.MultipassFunc = fxMultipassTexture;
+ }
+ break;
+ default:
+ fxSetupTextureNone_NoLock(ctx);
+ break;
+ }
}
-static void fxSetupTexture(GLcontext *ctx) {
- BEGIN_BOARD_LOCK();
- fxSetupTexture_NoLock(ctx);
- END_BOARD_LOCK();
+static void
+fxSetupTexture(GLcontext * ctx)
+{
+ BEGIN_BOARD_LOCK();
+ fxSetupTexture_NoLock(ctx);
+ END_BOARD_LOCK();
}
/************************************************************************/
@@ -1119,302 +1098,313 @@ static void fxSetupTexture(GLcontext *ctx) {
/************************************************************************/
/* XXX consider supporting GL_INGR_blend_func_separate */
-void fxDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
+void
+fxDDBlendFunc(GLcontext * ctx, GLenum sfactor, GLenum dfactor)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
- GrAlphaBlendFnc_t sfact,dfact,asfact,adfact;
-
- /* From the Glide documentation:
- For alpha source and destination blend function factor
- parameters, Voodoo Graphics supports only
- GR_BLEND_ZERO and GR_BLEND_ONE.
- */
-
- switch(sfactor) {
- case GL_ZERO:
- asfact=sfact=GR_BLEND_ZERO;
- break;
- case GL_ONE:
- asfact=sfact=GR_BLEND_ONE;
- break;
- case GL_DST_COLOR:
- sfact=GR_BLEND_DST_COLOR;
- asfact=GR_BLEND_ONE;
- break;
- case GL_ONE_MINUS_DST_COLOR:
- sfact=GR_BLEND_ONE_MINUS_DST_COLOR;
- asfact=GR_BLEND_ONE;
- break;
- case GL_SRC_ALPHA:
- sfact=GR_BLEND_SRC_ALPHA;
- asfact=GR_BLEND_ONE;
- break;
- case GL_ONE_MINUS_SRC_ALPHA:
- sfact=GR_BLEND_ONE_MINUS_SRC_ALPHA;
- asfact=GR_BLEND_ONE;
- break;
- case GL_DST_ALPHA:
- sfact=GR_BLEND_DST_ALPHA;
- asfact=GR_BLEND_ONE;
- break;
- case GL_ONE_MINUS_DST_ALPHA:
- sfact=GR_BLEND_ONE_MINUS_DST_ALPHA;
- asfact=GR_BLEND_ONE;
- break;
- case GL_SRC_ALPHA_SATURATE:
- sfact=GR_BLEND_ALPHA_SATURATE;
- asfact=GR_BLEND_ONE;
- break;
- case GL_SRC_COLOR:
- case GL_ONE_MINUS_SRC_COLOR:
- /* USELESS */
- asfact=sfact=GR_BLEND_ONE;
- break;
- default:
- asfact=sfact=GR_BLEND_ONE;
- break;
- }
-
- if((sfact!=us->blendSrcFuncRGB) ||
- (asfact!=us->blendSrcFuncAlpha)) {
- us->blendSrcFuncRGB=sfact;
- us->blendSrcFuncAlpha=asfact;
- fxMesa->new_state |= FX_NEW_BLEND;
- }
-
- switch(dfactor) {
- case GL_ZERO:
- adfact=dfact=GR_BLEND_ZERO;
- break;
- case GL_ONE:
- adfact=dfact=GR_BLEND_ONE;
- break;
- case GL_SRC_COLOR:
- dfact=GR_BLEND_SRC_COLOR;
- adfact=GR_BLEND_ZERO;
- break;
- case GL_ONE_MINUS_SRC_COLOR:
- dfact=GR_BLEND_ONE_MINUS_SRC_COLOR;
- adfact=GR_BLEND_ZERO;
- break;
- case GL_SRC_ALPHA:
- dfact=GR_BLEND_SRC_ALPHA;
- adfact=GR_BLEND_ZERO;
- break;
- case GL_ONE_MINUS_SRC_ALPHA:
- dfact=GR_BLEND_ONE_MINUS_SRC_ALPHA;
- adfact=GR_BLEND_ZERO;
- break;
- case GL_DST_ALPHA:
- /* dfact=GR_BLEND_DST_ALPHA; */
- /* We can't do DST_ALPHA */
- dfact=GR_BLEND_ONE;
- adfact=GR_BLEND_ZERO;
- break;
- case GL_ONE_MINUS_DST_ALPHA:
- /* dfact=GR_BLEND_ONE_MINUS_DST_ALPHA; */
- /* We can't do DST_ALPHA */
- dfact=GR_BLEND_ZERO;
- adfact=GR_BLEND_ZERO;
- break;
- case GL_SRC_ALPHA_SATURATE:
- case GL_DST_COLOR:
- case GL_ONE_MINUS_DST_COLOR:
- /* USELESS */
- adfact=dfact=GR_BLEND_ZERO;
- break;
- default:
- adfact=dfact=GR_BLEND_ZERO;
- break;
- }
-
- if((dfact!=us->blendDstFuncRGB) ||
- (adfact!=us->blendDstFuncAlpha)) {
- us->blendDstFuncRGB=dfact;
- us->blendDstFuncAlpha=adfact;
- fxMesa->new_state |= FX_NEW_BLEND;
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ tfxUnitsState *us = &fxMesa->unitsState;
+ GrAlphaBlendFnc_t sfact, dfact, asfact, adfact;
+
+ /* From the Glide documentation:
+ For alpha source and destination blend function factor
+ parameters, Voodoo Graphics supports only
+ GR_BLEND_ZERO and GR_BLEND_ONE.
+ */
+
+ switch (sfactor) {
+ case GL_ZERO:
+ asfact = sfact = GR_BLEND_ZERO;
+ break;
+ case GL_ONE:
+ asfact = sfact = GR_BLEND_ONE;
+ break;
+ case GL_DST_COLOR:
+ sfact = GR_BLEND_DST_COLOR;
+ asfact = GR_BLEND_ONE;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ sfact = GR_BLEND_ONE_MINUS_DST_COLOR;
+ asfact = GR_BLEND_ONE;
+ break;
+ case GL_SRC_ALPHA:
+ sfact = GR_BLEND_SRC_ALPHA;
+ asfact = GR_BLEND_ONE;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ sfact = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+ asfact = GR_BLEND_ONE;
+ break;
+ case GL_DST_ALPHA:
+ sfact = GR_BLEND_DST_ALPHA;
+ asfact = GR_BLEND_ONE;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ sfact = GR_BLEND_ONE_MINUS_DST_ALPHA;
+ asfact = GR_BLEND_ONE;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ sfact = GR_BLEND_ALPHA_SATURATE;
+ asfact = GR_BLEND_ONE;
+ break;
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ /* USELESS */
+ asfact = sfact = GR_BLEND_ONE;
+ break;
+ default:
+ asfact = sfact = GR_BLEND_ONE;
+ break;
+ }
+
+ if ((sfact != us->blendSrcFuncRGB) || (asfact != us->blendSrcFuncAlpha)) {
+ us->blendSrcFuncRGB = sfact;
+ us->blendSrcFuncAlpha = asfact;
+ fxMesa->new_state |= FX_NEW_BLEND;
+ }
+
+ switch (dfactor) {
+ case GL_ZERO:
+ adfact = dfact = GR_BLEND_ZERO;
+ break;
+ case GL_ONE:
+ adfact = dfact = GR_BLEND_ONE;
+ break;
+ case GL_SRC_COLOR:
+ dfact = GR_BLEND_SRC_COLOR;
+ adfact = GR_BLEND_ZERO;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ dfact = GR_BLEND_ONE_MINUS_SRC_COLOR;
+ adfact = GR_BLEND_ZERO;
+ break;
+ case GL_SRC_ALPHA:
+ dfact = GR_BLEND_SRC_ALPHA;
+ adfact = GR_BLEND_ZERO;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ dfact = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+ adfact = GR_BLEND_ZERO;
+ break;
+ case GL_DST_ALPHA:
+ /* dfact=GR_BLEND_DST_ALPHA; */
+ /* We can't do DST_ALPHA */
+ dfact = GR_BLEND_ONE;
+ adfact = GR_BLEND_ZERO;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ /* dfact=GR_BLEND_ONE_MINUS_DST_ALPHA; */
+ /* We can't do DST_ALPHA */
+ dfact = GR_BLEND_ZERO;
+ adfact = GR_BLEND_ZERO;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ case GL_DST_COLOR:
+ case GL_ONE_MINUS_DST_COLOR:
+ /* USELESS */
+ adfact = dfact = GR_BLEND_ZERO;
+ break;
+ default:
+ adfact = dfact = GR_BLEND_ZERO;
+ break;
+ }
+
+ if ((dfact != us->blendDstFuncRGB) || (adfact != us->blendDstFuncAlpha)) {
+ us->blendDstFuncRGB = dfact;
+ us->blendDstFuncAlpha = adfact;
+ fxMesa->new_state |= FX_NEW_BLEND;
+ }
}
-static void fxSetupBlend(GLcontext *ctx)
+static void
+fxSetupBlend(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
-
- if(us->blendEnabled)
- FX_grAlphaBlendFunction(us->blendSrcFuncRGB,us->blendDstFuncRGB,
- us->blendSrcFuncAlpha,us->blendDstFuncAlpha);
- else
- FX_grAlphaBlendFunction(GR_BLEND_ONE,GR_BLEND_ZERO,GR_BLEND_ONE,GR_BLEND_ZERO);
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (us->blendEnabled)
+ FX_grAlphaBlendFunction(us->blendSrcFuncRGB, us->blendDstFuncRGB,
+ us->blendSrcFuncAlpha, us->blendDstFuncAlpha);
+ else
+ FX_grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE,
+ GR_BLEND_ZERO);
}
-
+
/************************************************************************/
/************************** Alpha Test SetUp ****************************/
/************************************************************************/
-void fxDDAlphaFunc(GLcontext *ctx, GLenum func, GLchan ref)
+void
+fxDDAlphaFunc(GLcontext * ctx, GLenum func, GLchan ref)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
- GrCmpFnc_t newfunc;
-
- switch(func) {
- case GL_NEVER:
- newfunc=GR_CMP_NEVER;
- break;
- case GL_LESS:
- newfunc=GR_CMP_LESS;
- break;
- case GL_EQUAL:
- newfunc=GR_CMP_EQUAL;
- break;
- case GL_LEQUAL:
- newfunc=GR_CMP_LEQUAL;
- break;
- case GL_GREATER:
- newfunc=GR_CMP_GREATER;
- break;
- case GL_NOTEQUAL:
- newfunc=GR_CMP_NOTEQUAL;
- break;
- case GL_GEQUAL:
- newfunc=GR_CMP_GEQUAL;
- break;
- case GL_ALWAYS:
- newfunc=GR_CMP_ALWAYS;
- break;
- default:
- fprintf(stderr,"fx Driver: internal error in fxDDAlphaFunc()\n");
- fxCloseHardware();
- exit(-1);
- break;
- }
-
- if(newfunc!=us->alphaTestFunc) {
- us->alphaTestFunc=newfunc;
- fxMesa->new_state |= FX_NEW_ALPHA;
- }
-
- if (ref != us->alphaTestRefValue) {
- us->alphaTestRefValue = ref;
- fxMesa->new_state |= FX_NEW_ALPHA;
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ tfxUnitsState *us = &fxMesa->unitsState;
+ GrCmpFnc_t newfunc;
+
+ switch (func) {
+ case GL_NEVER:
+ newfunc = GR_CMP_NEVER;
+ break;
+ case GL_LESS:
+ newfunc = GR_CMP_LESS;
+ break;
+ case GL_EQUAL:
+ newfunc = GR_CMP_EQUAL;
+ break;
+ case GL_LEQUAL:
+ newfunc = GR_CMP_LEQUAL;
+ break;
+ case GL_GREATER:
+ newfunc = GR_CMP_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ newfunc = GR_CMP_NOTEQUAL;
+ break;
+ case GL_GEQUAL:
+ newfunc = GR_CMP_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ newfunc = GR_CMP_ALWAYS;
+ break;
+ default:
+ fprintf(stderr, "fx Driver: internal error in fxDDAlphaFunc()\n");
+ fxCloseHardware();
+ exit(-1);
+ break;
+ }
+
+ if (newfunc != us->alphaTestFunc) {
+ us->alphaTestFunc = newfunc;
+ fxMesa->new_state |= FX_NEW_ALPHA;
+ }
+
+ if (ref != us->alphaTestRefValue) {
+ us->alphaTestRefValue = ref;
+ fxMesa->new_state |= FX_NEW_ALPHA;
+ }
}
-static void fxSetupAlphaTest(GLcontext *ctx)
+static void
+fxSetupAlphaTest(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
-
- if(us->alphaTestEnabled) {
- FX_grAlphaTestFunction(us->alphaTestFunc);
- FX_grAlphaTestReferenceValue(us->alphaTestRefValue);
- } else
- FX_grAlphaTestFunction(GR_CMP_ALWAYS);
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (us->alphaTestEnabled) {
+ FX_grAlphaTestFunction(us->alphaTestFunc);
+ FX_grAlphaTestReferenceValue(us->alphaTestRefValue);
+ }
+ else
+ FX_grAlphaTestFunction(GR_CMP_ALWAYS);
}
/************************************************************************/
/************************** Depth Test SetUp ****************************/
/************************************************************************/
-void fxDDDepthFunc(GLcontext *ctx, GLenum func)
+void
+fxDDDepthFunc(GLcontext * ctx, GLenum func)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
- GrCmpFnc_t dfunc;
-
- switch(func) {
- case GL_NEVER:
- dfunc=GR_CMP_NEVER;
- break;
- case GL_LESS:
- dfunc=GR_CMP_LESS;
- break;
- case GL_GEQUAL:
- dfunc=GR_CMP_GEQUAL;
- break;
- case GL_LEQUAL:
- dfunc=GR_CMP_LEQUAL;
- break;
- case GL_GREATER:
- dfunc=GR_CMP_GREATER;
- break;
- case GL_NOTEQUAL:
- dfunc=GR_CMP_NOTEQUAL;
- break;
- case GL_EQUAL:
- dfunc=GR_CMP_EQUAL;
- break;
- case GL_ALWAYS:
- dfunc=GR_CMP_ALWAYS;
- break;
- default:
- fprintf(stderr,"fx Driver: internal error in fxDDDepthFunc()\n");
- fxCloseHardware();
- exit(-1);
- break;
- }
-
- if(dfunc!=us->depthTestFunc) {
- us->depthTestFunc=dfunc;
- fxMesa->new_state |= FX_NEW_DEPTH;
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ tfxUnitsState *us = &fxMesa->unitsState;
+ GrCmpFnc_t dfunc;
+
+ switch (func) {
+ case GL_NEVER:
+ dfunc = GR_CMP_NEVER;
+ break;
+ case GL_LESS:
+ dfunc = GR_CMP_LESS;
+ break;
+ case GL_GEQUAL:
+ dfunc = GR_CMP_GEQUAL;
+ break;
+ case GL_LEQUAL:
+ dfunc = GR_CMP_LEQUAL;
+ break;
+ case GL_GREATER:
+ dfunc = GR_CMP_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ dfunc = GR_CMP_NOTEQUAL;
+ break;
+ case GL_EQUAL:
+ dfunc = GR_CMP_EQUAL;
+ break;
+ case GL_ALWAYS:
+ dfunc = GR_CMP_ALWAYS;
+ break;
+ default:
+ fprintf(stderr, "fx Driver: internal error in fxDDDepthFunc()\n");
+ fxCloseHardware();
+ exit(-1);
+ break;
+ }
+
+ if (dfunc != us->depthTestFunc) {
+ us->depthTestFunc = dfunc;
+ fxMesa->new_state |= FX_NEW_DEPTH;
+ }
}
-void fxDDDepthMask(GLcontext *ctx, GLboolean flag)
+void
+fxDDDepthMask(GLcontext * ctx, GLboolean flag)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ tfxUnitsState *us = &fxMesa->unitsState;
- if(flag!=us->depthMask) {
- us->depthMask=flag;
- fxMesa->new_state |= FX_NEW_DEPTH;
- }
+ if (flag != us->depthMask) {
+ us->depthMask = flag;
+ fxMesa->new_state |= FX_NEW_DEPTH;
+ }
}
-static void fxSetupDepthTest(GLcontext *ctx)
+static void
+fxSetupDepthTest(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
-
- if (us->depthTestEnabled) {
- FX_grDepthBufferFunction(us->depthTestFunc);
- FX_grDepthMask(us->depthMask);
- }
- else {
- FX_grDepthBufferFunction(GR_CMP_ALWAYS);
- FX_grDepthMask(FXFALSE);
- }
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (us->depthTestEnabled) {
+ FX_grDepthBufferFunction(us->depthTestFunc);
+ FX_grDepthMask(us->depthMask);
+ }
+ else {
+ FX_grDepthBufferFunction(GR_CMP_ALWAYS);
+ FX_grDepthMask(FXFALSE);
+ }
}
/************************************************************************/
/**************************** Color Mask SetUp **************************/
/************************************************************************/
-void fxDDColorMask(GLcontext *ctx,
- GLboolean r, GLboolean g,
- GLboolean b, GLboolean a )
+void
+fxDDColorMask(GLcontext * ctx,
+ GLboolean r, GLboolean g, GLboolean b, GLboolean a)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- fxMesa->new_state |= FX_NEW_COLOR_MASK;
- (void) r; (void) g; (void) b; (void) a;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ fxMesa->new_state |= FX_NEW_COLOR_MASK;
+ (void) r;
+ (void) g;
+ (void) b;
+ (void) a;
}
-static void fxSetupColorMask(GLcontext *ctx)
+static void
+fxSetupColorMask(GLcontext * ctx)
{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- if (ctx->Color.DrawBuffer == GL_NONE) {
- FX_grColorMask(FXFALSE, FXFALSE);
- }
- else {
- FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
- ctx->Color.ColorMask[GCOMP] ||
- ctx->Color.ColorMask[BCOMP],
- ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
- }
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (ctx->Color.DrawBuffer == GL_NONE) {
+ FX_grColorMask(FXFALSE, FXFALSE);
+ }
+ else {
+ FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
+ ctx->Color.ColorMask[GCOMP] ||
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
+ }
}
@@ -1427,52 +1417,55 @@ static void fxSetupColorMask(GLcontext *ctx)
/*
* This is called during state update in order to update the Glide fog state.
*/
-static void fxSetupFog(GLcontext *ctx)
+static void
+fxSetupFog(GLcontext * ctx)
{
- if (ctx->Fog.Enabled /*&& ctx->FogMode==FOG_FRAGMENT*/) {
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- /* update fog color */
- GLubyte col[4];
- col[0]=(unsigned int)(255*ctx->Fog.Color[0]);
- col[1]=(unsigned int)(255*ctx->Fog.Color[1]);
- col[2]=(unsigned int)(255*ctx->Fog.Color[2]);
- col[3]=(unsigned int)(255*ctx->Fog.Color[3]);
- FX_grFogColorValue(FXCOLOR4(col));
-
- if(fxMesa->fogTableMode != ctx->Fog.Mode ||
- fxMesa->fogDensity != ctx->Fog.Density ||
- fxMesa->fogStart != ctx->Fog.Start ||
- fxMesa->fogEnd != ctx->Fog.End) {
- /* reload the fog table */
- switch (ctx->Fog.Mode) {
- case GL_LINEAR:
- guFogGenerateLinear(fxMesa->fogTable, ctx->Fog.Start, ctx->Fog.End);
- break;
- case GL_EXP:
- guFogGenerateExp(fxMesa->fogTable, ctx->Fog.Density);
- break;
- case GL_EXP2:
- guFogGenerateExp2(fxMesa->fogTable, ctx->Fog.Density);
- break;
- default:
- ;
+ if (ctx->Fog.Enabled /*&& ctx->FogMode==FOG_FRAGMENT */ ) {
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ /* update fog color */
+ GLubyte col[4];
+ col[0] = (unsigned int) (255 * ctx->Fog.Color[0]);
+ col[1] = (unsigned int) (255 * ctx->Fog.Color[1]);
+ col[2] = (unsigned int) (255 * ctx->Fog.Color[2]);
+ col[3] = (unsigned int) (255 * ctx->Fog.Color[3]);
+ FX_grFogColorValue(FXCOLOR4(col));
+
+ if (fxMesa->fogTableMode != ctx->Fog.Mode ||
+ fxMesa->fogDensity != ctx->Fog.Density ||
+ fxMesa->fogStart != ctx->Fog.Start ||
+ fxMesa->fogEnd != ctx->Fog.End) {
+ /* reload the fog table */
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ guFogGenerateLinear(fxMesa->fogTable, ctx->Fog.Start,
+ ctx->Fog.End);
+ break;
+ case GL_EXP:
+ guFogGenerateExp(fxMesa->fogTable, ctx->Fog.Density);
+ break;
+ case GL_EXP2:
+ guFogGenerateExp2(fxMesa->fogTable, ctx->Fog.Density);
+ break;
+ default:
+ ;
+ }
+ fxMesa->fogTableMode = ctx->Fog.Mode;
+ fxMesa->fogDensity = ctx->Fog.Density;
+ fxMesa->fogStart = ctx->Fog.Start;
+ fxMesa->fogEnd = ctx->Fog.End;
}
- fxMesa->fogTableMode = ctx->Fog.Mode;
- fxMesa->fogDensity = ctx->Fog.Density;
- fxMesa->fogStart = ctx->Fog.Start;
- fxMesa->fogEnd = ctx->Fog.End;
- }
-
- FX_grFogTable(fxMesa->fogTable);
- FX_grFogMode(GR_FOG_WITH_TABLE);
- }
- else {
- FX_grFogMode(GR_FOG_DISABLE);
- }
+
+ FX_grFogTable(fxMesa->fogTable);
+ FX_grFogMode(GR_FOG_WITH_TABLE);
+ }
+ else {
+ FX_grFogMode(GR_FOG_DISABLE);
+ }
}
-void fxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
+void
+fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params)
{
FX_CONTEXT(ctx)->new_state |= FX_NEW_FOG;
}
@@ -1482,42 +1475,48 @@ void fxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
/************************************************************************/
/* This routine is used in managing the lock state, and therefore can't lock */
-void fxSetScissorValues(GLcontext *ctx)
+void
+fxSetScissorValues(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- int xmin, xmax;
- int ymin, ymax, check;
-
- if (ctx->Scissor.Enabled) {
- xmin=ctx->Scissor.X;
- xmax=ctx->Scissor.X+ctx->Scissor.Width;
- ymin=ctx->Scissor.Y;
- ymax=ctx->Scissor.Y+ctx->Scissor.Height;
- check=1;
- } else {
- xmin=0;
- ymin=0;
- xmax=fxMesa->width;
- ymax=fxMesa->height;
- check=0;
- }
- if (xmin<fxMesa->clipMinX) xmin=fxMesa->clipMinX;
- if (xmax>fxMesa->clipMaxX) xmax=fxMesa->clipMaxX;
- if (ymin<fxMesa->screen_height-fxMesa->clipMaxY)
- ymin=fxMesa->screen_height-fxMesa->clipMaxY;
- if (ymax>fxMesa->screen_height-fxMesa->clipMinY)
- ymax=fxMesa->screen_height-fxMesa->clipMinY;
- FX_grClipWindow_NoLock(xmin, ymin, xmax, ymax);
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ int xmin, xmax;
+ int ymin, ymax, check;
+
+ if (ctx->Scissor.Enabled) {
+ xmin = ctx->Scissor.X;
+ xmax = ctx->Scissor.X + ctx->Scissor.Width;
+ ymin = ctx->Scissor.Y;
+ ymax = ctx->Scissor.Y + ctx->Scissor.Height;
+ check = 1;
+ }
+ else {
+ xmin = 0;
+ ymin = 0;
+ xmax = fxMesa->width;
+ ymax = fxMesa->height;
+ check = 0;
+ }
+ if (xmin < fxMesa->clipMinX)
+ xmin = fxMesa->clipMinX;
+ if (xmax > fxMesa->clipMaxX)
+ xmax = fxMesa->clipMaxX;
+ if (ymin < fxMesa->screen_height - fxMesa->clipMaxY)
+ ymin = fxMesa->screen_height - fxMesa->clipMaxY;
+ if (ymax > fxMesa->screen_height - fxMesa->clipMinY)
+ ymax = fxMesa->screen_height - fxMesa->clipMinY;
+ FX_grClipWindow_NoLock(xmin, ymin, xmax, ymax);
}
-static void fxSetupScissor(GLcontext *ctx)
+static void
+fxSetupScissor(GLcontext * ctx)
{
- BEGIN_BOARD_LOCK();
- fxSetScissorValues(ctx);
- END_BOARD_LOCK();
+ BEGIN_BOARD_LOCK();
+ fxSetScissorValues(ctx);
+ END_BOARD_LOCK();
}
-void fxDDScissor( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h )
+void
+fxDDScissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
FX_CONTEXT(ctx)->new_state |= FX_NEW_SCISSOR;
}
@@ -1527,44 +1526,49 @@ void fxDDScissor( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h )
/************************************************************************/
-void fxDDCullFace(GLcontext *ctx, GLenum mode)
+void
+fxDDCullFace(GLcontext * ctx, GLenum mode)
{
(void) mode;
FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL;
}
-void fxDDFrontFace(GLcontext *ctx, GLenum mode)
+void
+fxDDFrontFace(GLcontext * ctx, GLenum mode)
{
(void) mode;
FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL;
}
-static void fxSetupCull(GLcontext *ctx)
+static void
+fxSetupCull(GLcontext * ctx)
{
- if (ctx->Polygon.CullFlag) {
- switch (ctx->Polygon.CullFaceMode) {
- case GL_BACK:
- if (ctx->Polygon.FrontFace==GL_CCW)
- FX_CONTEXT(ctx)->cullMode=GR_CULL_NEGATIVE;
- else
- FX_CONTEXT(ctx)->cullMode=GR_CULL_POSITIVE;
- break;
- case GL_FRONT:
- if(ctx->Polygon.FrontFace==GL_CCW)
- FX_CONTEXT(ctx)->cullMode=GR_CULL_POSITIVE;
- else
- FX_CONTEXT(ctx)->cullMode=GR_CULL_NEGATIVE;
- break;
- case GL_FRONT_AND_BACK:
- FX_CONTEXT(ctx)->cullMode=GR_CULL_DISABLE;
- break;
- default:
- break;
- }
- } else FX_CONTEXT(ctx)->cullMode=GR_CULL_DISABLE;
+ if (ctx->Polygon.CullFlag) {
+ switch (ctx->Polygon.CullFaceMode) {
+ case GL_BACK:
+ if (ctx->Polygon.FrontFace == GL_CCW)
+ FX_CONTEXT(ctx)->cullMode = GR_CULL_NEGATIVE;
+ else
+ FX_CONTEXT(ctx)->cullMode = GR_CULL_POSITIVE;
+ break;
+ case GL_FRONT:
+ if (ctx->Polygon.FrontFace == GL_CCW)
+ FX_CONTEXT(ctx)->cullMode = GR_CULL_POSITIVE;
+ else
+ FX_CONTEXT(ctx)->cullMode = GR_CULL_NEGATIVE;
+ break;
+ case GL_FRONT_AND_BACK:
+ FX_CONTEXT(ctx)->cullMode = GR_CULL_DISABLE;
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ FX_CONTEXT(ctx)->cullMode = GR_CULL_DISABLE;
- FX_grCullMode(FX_CONTEXT(ctx)->cullMode);
+ FX_grCullMode(FX_CONTEXT(ctx)->cullMode);
}
@@ -1572,63 +1576,65 @@ static void fxSetupCull(GLcontext *ctx)
/****************************** DD Enable ******************************/
/************************************************************************/
-void fxDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
+void
+fxDDEnable(GLcontext * ctx, GLenum cap, GLboolean state)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxUnitsState *us=&fxMesa->unitsState;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ tfxUnitsState *us = &fxMesa->unitsState;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDEnable(...)\n");
- }
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDEnable(...)\n");
+ }
- switch(cap) {
- case GL_ALPHA_TEST:
- if(state!=us->alphaTestEnabled) {
- us->alphaTestEnabled=state;
- fxMesa->new_state |= FX_NEW_ALPHA;
- }
- break;
- case GL_BLEND:
- if(state!=us->blendEnabled) {
- us->blendEnabled=state;
- fxMesa->new_state |= FX_NEW_BLEND;
- }
- break;
- case GL_DEPTH_TEST:
- if(state!=us->depthTestEnabled) {
- us->depthTestEnabled=state;
- fxMesa->new_state |= FX_NEW_DEPTH;
- }
- break;
- case GL_DITHER:
- if (state) {
- FX_grDitherMode(GR_DITHER_4x4);
- } else {
- FX_grDitherMode(GR_DITHER_DISABLE);
- }
- break;
- case GL_SCISSOR_TEST:
- fxMesa->new_state |= FX_NEW_SCISSOR;
- break;
- case GL_SHARED_TEXTURE_PALETTE_EXT:
- fxDDTexUseGlbPalette(ctx, state);
- break;
- case GL_FOG:
- fxMesa->new_state |= FX_NEW_FOG;
- break;
- case GL_CULL_FACE:
- fxMesa->new_state |= FX_NEW_CULL;
- break;
- case GL_LINE_SMOOTH:
- case GL_LINE_STIPPLE:
- case GL_POINT_SMOOTH:
- case GL_POLYGON_SMOOTH:
- case GL_TEXTURE_2D:
+ switch (cap) {
+ case GL_ALPHA_TEST:
+ if (state != us->alphaTestEnabled) {
+ us->alphaTestEnabled = state;
+ fxMesa->new_state |= FX_NEW_ALPHA;
+ }
+ break;
+ case GL_BLEND:
+ if (state != us->blendEnabled) {
+ us->blendEnabled = state;
+ fxMesa->new_state |= FX_NEW_BLEND;
+ }
+ break;
+ case GL_DEPTH_TEST:
+ if (state != us->depthTestEnabled) {
+ us->depthTestEnabled = state;
+ fxMesa->new_state |= FX_NEW_DEPTH;
+ }
+ break;
+ case GL_DITHER:
+ if (state) {
+ FX_grDitherMode(GR_DITHER_4x4);
+ }
+ else {
+ FX_grDitherMode(GR_DITHER_DISABLE);
+ }
+ break;
+ case GL_SCISSOR_TEST:
+ fxMesa->new_state |= FX_NEW_SCISSOR;
+ break;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ fxDDTexUseGlbPalette(ctx, state);
+ break;
+ case GL_FOG:
+ fxMesa->new_state |= FX_NEW_FOG;
+ break;
+ case GL_CULL_FACE:
+ fxMesa->new_state |= FX_NEW_CULL;
+ break;
+ case GL_LINE_SMOOTH:
+ case GL_LINE_STIPPLE:
+ case GL_POINT_SMOOTH:
+ case GL_POLYGON_SMOOTH:
+ case GL_TEXTURE_2D:
fxMesa->new_state |= FX_NEW_TEXTURING;
break;
- default:
- ; /* XXX no-op? */
- }
+ default:
+ ; /* XXX no-op? */
+ }
}
#if 0
@@ -1638,47 +1644,48 @@ void fxDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
Cc*Ct gets written during the second pass (in this function)
Everything gets reset in the third call (in this function)
*/
-static GLboolean fxMultipassBlend(struct vertex_buffer *VB, GLuint pass)
+static GLboolean
+fxMultipassBlend(struct vertex_buffer *VB, GLuint pass)
{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- switch (pass) {
- case 1:
- /* Add Cc*Ct */
- fxMesa->restoreUnitsState=fxMesa->unitsState;
- if (ctx->Depth.Mask) {
- /* We don't want to check or change the depth buffers */
- switch (ctx->Depth.Func) {
- case GL_NEVER:
- case GL_ALWAYS:
- break;
- default:
- fxDDDepthFunc(ctx, GL_EQUAL);
- break;
+ GLcontext *ctx = VB->ctx;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ switch (pass) {
+ case 1:
+ /* Add Cc*Ct */
+ fxMesa->restoreUnitsState = fxMesa->unitsState;
+ if (ctx->Depth.Mask) {
+ /* We don't want to check or change the depth buffers */
+ switch (ctx->Depth.Func) {
+ case GL_NEVER:
+ case GL_ALWAYS:
+ break;
+ default:
+ fxDDDepthFunc(ctx, GL_EQUAL);
+ break;
+ }
+ fxDDDepthMask(ctx, FALSE);
}
- fxDDDepthMask(ctx, FALSE);
- }
- /* Enable Cc*Ct mode */
- /* XXX Set the Constant Color ? */
- fxDDEnable(ctx, GL_BLEND, GL_TRUE);
- fxDDBlendFunc(ctx, XXX, XXX);
- fxSetupTextureSingleTMU(ctx, XXX);
- fxSetupBlend(ctx);
- fxSetupDepthTest(ctx);
- break;
-
- case 2:
- /* Reset everything back to normal */
- fxMesa->unitsState = fxMesa->restoreUnitsState;
- fxMesa->setup_gone |= XXX;
- fxSetupTextureSingleTMU(ctx, XXX);
- fxSetupBlend(ctx);
- fxSetupDepthTest(ctx);
- break;
- }
-
- return pass==1;
+ /* Enable Cc*Ct mode */
+ /* XXX Set the Constant Color ? */
+ fxDDEnable(ctx, GL_BLEND, GL_TRUE);
+ fxDDBlendFunc(ctx, XXX, XXX);
+ fxSetupTextureSingleTMU(ctx, XXX);
+ fxSetupBlend(ctx);
+ fxSetupDepthTest(ctx);
+ break;
+
+ case 2:
+ /* Reset everything back to normal */
+ fxMesa->unitsState = fxMesa->restoreUnitsState;
+ fxMesa->setup_gone |= XXX;
+ fxSetupTextureSingleTMU(ctx, XXX);
+ fxSetupBlend(ctx);
+ fxSetupDepthTest(ctx);
+ break;
+ }
+
+ return pass == 1;
}
#endif
@@ -1694,7 +1701,8 @@ static GLboolean fxMultipassBlend(struct vertex_buffer *VB, GLuint pass)
* voodoo 1. In all other cases for both voodoo 1 and 2, we fall back
* to software rendering, satisfying the spec if not the user.
*/
-static GLboolean fxMultipassTexture( GLcontext *ctx, GLuint pass )
+static GLboolean
+fxMultipassTexture(GLcontext * ctx, GLuint pass)
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -1703,15 +1711,16 @@ static GLboolean fxMultipassTexture( GLcontext *ctx, GLuint pass )
switch (pass) {
case 1:
- if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_PIPELINE|VERBOSE_TEXTURE))
- fprintf(stderr, "fxmesa: Second texture pass\n");
+ if (MESA_VERBOSE &
+ (VERBOSE_DRIVER | VERBOSE_PIPELINE | VERBOSE_TEXTURE))
+ fprintf(stderr, "fxmesa: Second texture pass\n");
- for ( ; v != last ; v++) {
+ for (; v != last; v++) {
v->f[S0COORD] = v->f[S1COORD];
v->f[T0COORD] = v->f[T1COORD];
}
- fxMesa->restoreUnitsState = fxMesa->unitsState;
+ fxMesa->restoreUnitsState = fxMesa->unitsState;
fxMesa->tmu_source[0] = 1;
if (ctx->Depth.Mask) {
@@ -1720,21 +1729,21 @@ static GLboolean fxMultipassTexture( GLcontext *ctx, GLuint pass )
case GL_ALWAYS:
break;
default:
- fxDDDepthFunc( ctx, GL_EQUAL );
+ fxDDDepthFunc(ctx, GL_EQUAL);
break;
}
- fxDDDepthMask( ctx, GL_FALSE );
+ fxDDDepthMask(ctx, GL_FALSE);
}
-
+
if (ctx->Texture.Unit[1].EnvMode == GL_MODULATE) {
- fxDDEnable( ctx, GL_BLEND, GL_TRUE );
- fxDDBlendFunc( ctx, GL_DST_COLOR, GL_ZERO );
+ fxDDEnable(ctx, GL_BLEND, GL_TRUE);
+ fxDDBlendFunc(ctx, GL_DST_COLOR, GL_ZERO);
}
- fxSetupTextureSingleTMU( ctx, 1 );
- fxSetupBlend( ctx );
- fxSetupDepthTest( ctx );
+ fxSetupTextureSingleTMU(ctx, 1);
+ fxSetupBlend(ctx);
+ fxSetupDepthTest(ctx);
break;
case 2:
@@ -1743,13 +1752,13 @@ static GLboolean fxMultipassTexture( GLcontext *ctx, GLuint pass )
fxMesa->tmu_source[0] = 0;
fxMesa->unitsState = fxMesa->restoreUnitsState;
fxMesa->setup_gone |= SETUP_TMU0;
- fxSetupTextureSingleTMU( ctx, 0 );
- fxSetupBlend( ctx );
- fxSetupDepthTest( ctx );
+ fxSetupTextureSingleTMU(ctx, 0);
+ fxSetupBlend(ctx);
+ fxSetupDepthTest(ctx);
break;
}
- return pass == 1;
+ return pass == 1;
}
@@ -1760,7 +1769,8 @@ static GLboolean fxMultipassTexture( GLcontext *ctx, GLuint pass )
/* All units setup is handled under texture setup.
*/
-void fxDDShadeModel(GLcontext *ctx, GLenum mode)
+void
+fxDDShadeModel(GLcontext * ctx, GLenum mode)
{
FX_CONTEXT(ctx)->new_state |= FX_NEW_TEXTURING;
}
@@ -1770,59 +1780,61 @@ void fxDDShadeModel(GLcontext *ctx, GLenum mode)
/************************************************************************/
/****************************** Units SetUp *****************************/
/************************************************************************/
-static void fx_print_state_flags( const char *msg, GLuint flags )
+static void
+fx_print_state_flags(const char *msg, GLuint flags)
{
- fprintf(stderr,
+ fprintf(stderr,
"%s: (0x%x) %s%s%s%s%s%s%s\n",
msg,
flags,
- (flags & FX_NEW_TEXTURING) ? "texture, " : "",
- (flags & FX_NEW_BLEND) ? "blend, " : "",
- (flags & FX_NEW_ALPHA) ? "alpha, " : "",
- (flags & FX_NEW_FOG) ? "fog, " : "",
- (flags & FX_NEW_SCISSOR) ? "scissor, " : "",
- (flags & FX_NEW_COLOR_MASK) ? "colormask, " : "",
- (flags & FX_NEW_CULL) ? "cull, " : "");
+ (flags & FX_NEW_TEXTURING) ? "texture, " : "",
+ (flags & FX_NEW_BLEND) ? "blend, " : "",
+ (flags & FX_NEW_ALPHA) ? "alpha, " : "",
+ (flags & FX_NEW_FOG) ? "fog, " : "",
+ (flags & FX_NEW_SCISSOR) ? "scissor, " : "",
+ (flags & FX_NEW_COLOR_MASK) ? "colormask, " : "",
+ (flags & FX_NEW_CULL) ? "cull, " : "");
}
-void fxSetupFXUnits( GLcontext *ctx )
+void
+fxSetupFXUnits(GLcontext * ctx)
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint newstate = fxMesa->new_state;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLuint newstate = fxMesa->new_state;
- if (MESA_VERBOSE&VERBOSE_DRIVER)
- fx_print_state_flags("fxmesa: fxSetupFXUnits", newstate);
+ if (MESA_VERBOSE & VERBOSE_DRIVER)
+ fx_print_state_flags("fxmesa: fxSetupFXUnits", newstate);
- if (newstate) {
- if (newstate & FX_NEW_TEXTURING)
- fxSetupTexture(ctx);
+ if (newstate) {
+ if (newstate & FX_NEW_TEXTURING)
+ fxSetupTexture(ctx);
- if (newstate & FX_NEW_BLEND)
- fxSetupBlend(ctx);
+ if (newstate & FX_NEW_BLEND)
+ fxSetupBlend(ctx);
- if (newstate & FX_NEW_ALPHA)
- fxSetupAlphaTest(ctx);
-
- if (newstate & FX_NEW_DEPTH)
- fxSetupDepthTest(ctx);
+ if (newstate & FX_NEW_ALPHA)
+ fxSetupAlphaTest(ctx);
- if (newstate & FX_NEW_FOG)
- fxSetupFog(ctx);
+ if (newstate & FX_NEW_DEPTH)
+ fxSetupDepthTest(ctx);
- if (newstate & FX_NEW_SCISSOR)
- fxSetupScissor(ctx);
+ if (newstate & FX_NEW_FOG)
+ fxSetupFog(ctx);
- if (newstate & FX_NEW_COLOR_MASK)
- fxSetupColorMask(ctx);
+ if (newstate & FX_NEW_SCISSOR)
+ fxSetupScissor(ctx);
- if (newstate & FX_NEW_CULL)
- fxSetupCull(ctx);
+ if (newstate & FX_NEW_COLOR_MASK)
+ fxSetupColorMask(ctx);
- fxMesa->draw_point = fxMesa->initial_point;
- fxMesa->draw_line = fxMesa->initial_line;
- fxMesa->draw_tri = fxMesa->initial_tri;
- fxMesa->new_state = 0;
- }
+ if (newstate & FX_NEW_CULL)
+ fxSetupCull(ctx);
+
+ fxMesa->draw_point = fxMesa->initial_point;
+ fxMesa->draw_line = fxMesa->initial_line;
+ fxMesa->draw_tri = fxMesa->initial_tri;
+ fxMesa->new_state = 0;
+ }
}
@@ -1835,9 +1847,10 @@ void fxSetupFXUnits( GLcontext *ctx )
*/
extern int gl_fx_dummy_function_setup(void);
-int gl_fx_dummy_function_setup(void)
+int
+gl_fx_dummy_function_setup(void)
{
- return 0;
+ return 0;
}
-#endif /* FX */
+#endif /* FX */
diff --git a/src/mesa/drivers/glide/fxtexman.c b/src/mesa/drivers/glide/fxtexman.c
index 9dc2d890ad..2e989a04b4 100644
--- a/src/mesa/drivers/glide/fxtexman.c
+++ b/src/mesa/drivers/glide/fxtexman.c
@@ -53,7 +53,7 @@
#include "fxdrv.h"
-int texSwaps=0;
+int texSwaps = 0;
#define FX_2MB_SPLIT 0x200000
@@ -62,697 +62,743 @@ static struct gl_texture_object *fxTMFindOldestObject(fxMesaContext fxMesa,
#ifdef TEXSANITY
-static void fubar()
+static void
+fubar()
{
}
/* Sanity Check */
-static void sanity(fxMesaContext fxMesa)
+static void
+sanity(fxMesaContext fxMesa)
{
- MemRange *tmp, *prev, *pos;
-
- prev=0;
- tmp = fxMesa->tmFree[0];
- while (tmp) {
- if (!tmp->startAddr && !tmp->endAddr) {
- fprintf(stderr, "Textures fubar\n");
- fubar();
- }
- if (tmp->startAddr>=tmp->endAddr) {
- fprintf(stderr, "Node fubar\n");
- fubar();
- }
- if (prev && (prev->startAddr>=tmp->startAddr ||
- prev->endAddr>tmp->startAddr)) {
- fprintf(stderr, "Sorting fubar\n");
- fubar();
- }
- prev=tmp;
- tmp=tmp->next;
- }
- prev=0;
- tmp = fxMesa->tmFree[1];
- while (tmp) {
- if (!tmp->startAddr && !tmp->endAddr) {
- fprintf(stderr, "Textures fubar\n");
- fubar();
- }
- if (tmp->startAddr>=tmp->endAddr) {
- fprintf(stderr, "Node fubar\n");
- fubar();
- }
- if (prev && (prev->startAddr>=tmp->startAddr ||
- prev->endAddr>tmp->startAddr)) {
- fprintf(stderr, "Sorting fubar\n");
- fubar();
- }
- prev=tmp;
- tmp=tmp->next;
- }
+ MemRange *tmp, *prev, *pos;
+
+ prev = 0;
+ tmp = fxMesa->tmFree[0];
+ while (tmp) {
+ if (!tmp->startAddr && !tmp->endAddr) {
+ fprintf(stderr, "Textures fubar\n");
+ fubar();
+ }
+ if (tmp->startAddr >= tmp->endAddr) {
+ fprintf(stderr, "Node fubar\n");
+ fubar();
+ }
+ if (prev && (prev->startAddr >= tmp->startAddr ||
+ prev->endAddr > tmp->startAddr)) {
+ fprintf(stderr, "Sorting fubar\n");
+ fubar();
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
+ prev = 0;
+ tmp = fxMesa->tmFree[1];
+ while (tmp) {
+ if (!tmp->startAddr && !tmp->endAddr) {
+ fprintf(stderr, "Textures fubar\n");
+ fubar();
+ }
+ if (tmp->startAddr >= tmp->endAddr) {
+ fprintf(stderr, "Node fubar\n");
+ fubar();
+ }
+ if (prev && (prev->startAddr >= tmp->startAddr ||
+ prev->endAddr > tmp->startAddr)) {
+ fprintf(stderr, "Sorting fubar\n");
+ fubar();
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
}
#endif
-static MemRange *fxTMNewRangeNode(fxMesaContext fxMesa, FxU32 start, FxU32 end) {
- MemRange *result=0;
-
- if (fxMesa->tmPool) {
- result=fxMesa->tmPool;
- fxMesa->tmPool=fxMesa->tmPool->next;
- } else {
- if (!(result=MALLOC(sizeof(MemRange)))) {
- fprintf(stderr, "fxDriver: out of memory!\n");
- fxCloseHardware();
- exit(-1);
- }
- }
- result->startAddr=start;
- result->endAddr=end;
- return result;
+static MemRange *
+fxTMNewRangeNode(fxMesaContext fxMesa, FxU32 start, FxU32 end)
+{
+ MemRange *result = 0;
+
+ if (fxMesa->tmPool) {
+ result = fxMesa->tmPool;
+ fxMesa->tmPool = fxMesa->tmPool->next;
+ }
+ else {
+ if (!(result = MALLOC(sizeof(MemRange)))) {
+ fprintf(stderr, "fxDriver: out of memory!\n");
+ fxCloseHardware();
+ exit(-1);
+ }
+ }
+ result->startAddr = start;
+ result->endAddr = end;
+ return result;
}
-static void fxTMDeleteRangeNode(fxMesaContext fxMesa, MemRange *range)
+static void
+fxTMDeleteRangeNode(fxMesaContext fxMesa, MemRange * range)
{
- range->next=fxMesa->tmPool;
- fxMesa->tmPool=range;
+ range->next = fxMesa->tmPool;
+ fxMesa->tmPool = range;
}
-static void fxTMUInit(fxMesaContext fxMesa, int tmu)
+static void
+fxTMUInit(fxMesaContext fxMesa, int tmu)
{
- MemRange *tmn, *last;
- FxU32 start,end,blockstart,blockend;
-
- start=FX_grTexMinAddress(tmu);
- end=FX_grTexMaxAddress(tmu);
+ MemRange *tmn, *last;
+ FxU32 start, end, blockstart, blockend;
+
+ start = FX_grTexMinAddress(tmu);
+ end = FX_grTexMaxAddress(tmu);
+
+ if (fxMesa->verbose) {
+ fprintf(stderr, "Voodoo %s configuration:",
+ (tmu == FX_TMU0) ? "TMU0" : "TMU1");
+ fprintf(stderr, "Voodoo Lower texture memory address (%u)\n",
+ (unsigned int) start);
+ fprintf(stderr, "Voodoo Higher texture memory address (%u)\n",
+ (unsigned int) end);
+ fprintf(stderr, "Voodoo Splitting Texture memory in 2b blocks:\n");
+ }
+
+ fxMesa->freeTexMem[tmu] = end - start;
+ fxMesa->tmFree[tmu] = NULL;
+
+ last = 0;
+ blockstart = start;
+ while (blockstart < end) {
+ if (blockstart + FX_2MB_SPLIT > end)
+ blockend = end;
+ else
+ blockend = blockstart + FX_2MB_SPLIT;
- if(fxMesa->verbose) {
- fprintf(stderr,"Voodoo %s configuration:",(tmu==FX_TMU0) ? "TMU0" : "TMU1");
- fprintf(stderr,"Voodoo Lower texture memory address (%u)\n",(unsigned int)start);
- fprintf(stderr,"Voodoo Higher texture memory address (%u)\n",(unsigned int)end);
- fprintf(stderr,"Voodoo Splitting Texture memory in 2b blocks:\n");
- }
+ if (fxMesa->verbose)
+ fprintf(stderr, "Voodoo %07u-%07u\n",
+ (unsigned int) blockstart, (unsigned int) blockend);
- fxMesa->freeTexMem[tmu]=end-start;
- fxMesa->tmFree[tmu]=NULL;
+ tmn = fxTMNewRangeNode(fxMesa, blockstart, blockend);
+ tmn->next = 0;
- last=0;
- blockstart=start;
- while (blockstart<end) {
- if (blockstart+FX_2MB_SPLIT>end) blockend=end;
- else blockend=blockstart+FX_2MB_SPLIT;
+ if (last)
+ last->next = tmn;
+ else
+ fxMesa->tmFree[tmu] = tmn;
+ last = tmn;
- if(fxMesa->verbose)
- fprintf(stderr,"Voodoo %07u-%07u\n",
- (unsigned int)blockstart,(unsigned int)blockend);
+ blockstart += FX_2MB_SPLIT;
+ }
+}
- tmn=fxTMNewRangeNode(fxMesa, blockstart, blockend);
- tmn->next=0;
+static int
+fxTMFindStartAddr(fxMesaContext fxMesa, GLint tmu, int size)
+{
+ MemRange *prev, *tmp;
+ int result;
+ struct gl_texture_object *obj;
+
+ while (1) {
+ prev = 0;
+ tmp = fxMesa->tmFree[tmu];
+ while (tmp) {
+ if (tmp->endAddr - tmp->startAddr >= size) { /* Fits here */
+ result = tmp->startAddr;
+ tmp->startAddr += size;
+ if (tmp->startAddr == tmp->endAddr) { /* Empty */
+ if (prev) {
+ prev->next = tmp->next;
+ }
+ else {
+ fxMesa->tmFree[tmu] = tmp->next;
+ }
+ fxTMDeleteRangeNode(fxMesa, tmp);
+ }
+ fxMesa->freeTexMem[tmu] -= size;
+ return result;
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
+ /* No free space. Discard oldest */
+ obj = fxTMFindOldestObject(fxMesa, tmu);
+ if (!obj) {
+ fprintf(stderr, "fx Driver: No space for texture\n");
+ return -1;
+ }
+ fxTMMoveOutTM(fxMesa, obj);
+ texSwaps++;
+ }
+}
- if (last) last->next=tmn;
- else fxMesa->tmFree[tmu]=tmn;
- last=tmn;
+static void
+fxTMRemoveRange(fxMesaContext fxMesa, GLint tmu, MemRange * range)
+{
+ MemRange *tmp, *prev;
- blockstart+=FX_2MB_SPLIT;
- }
+ if (range->startAddr == range->endAddr) {
+ fxTMDeleteRangeNode(fxMesa, range);
+ return;
+ }
+ fxMesa->freeTexMem[tmu] += range->endAddr - range->startAddr;
+ prev = 0;
+ tmp = fxMesa->tmFree[tmu];
+ while (tmp) {
+ if (range->startAddr > tmp->startAddr) {
+ prev = tmp;
+ tmp = tmp->next;
+ }
+ else
+ break;
+ }
+ /* When we create the regions, we make a split at the 2MB boundary.
+ Now we have to make sure we don't join those 2MB boundary regions
+ back together again. */
+ range->next = tmp;
+ if (tmp) {
+ if (range->endAddr == tmp->startAddr
+ && tmp->startAddr & (FX_2MB_SPLIT - 1)) {
+ /* Combine */
+ tmp->startAddr = range->startAddr;
+ fxTMDeleteRangeNode(fxMesa, range);
+ range = tmp;
+ }
+ }
+ if (prev) {
+ if (prev->endAddr == range->startAddr
+ && range->startAddr & (FX_2MB_SPLIT - 1)) {
+ /* Combine */
+ prev->endAddr = range->endAddr;
+ prev->next = range->next;
+ fxTMDeleteRangeNode(fxMesa, range);
+ }
+ else
+ prev->next = range;
+ }
+ else {
+ fxMesa->tmFree[tmu] = range;
+ }
}
-static int fxTMFindStartAddr(fxMesaContext fxMesa, GLint tmu, int size)
+static struct gl_texture_object *
+fxTMFindOldestObject(fxMesaContext fxMesa, int tmu)
{
- MemRange *prev, *tmp;
- int result;
- struct gl_texture_object *obj;
-
- while (1) {
- prev=0;
- tmp=fxMesa->tmFree[tmu];
- while (tmp) {
- if (tmp->endAddr-tmp->startAddr>=size) { /* Fits here */
- result=tmp->startAddr;
- tmp->startAddr+=size;
- if (tmp->startAddr==tmp->endAddr) { /* Empty */
- if (prev) {
- prev->next=tmp->next;
- } else {
- fxMesa->tmFree[tmu]=tmp->next;
- }
- fxTMDeleteRangeNode(fxMesa, tmp);
- }
- fxMesa->freeTexMem[tmu]-=size;
- return result;
+ GLuint age, old, lasttime, bindnumber;
+ tfxTexInfo *info;
+ struct gl_texture_object *obj, *tmp;
+
+ tmp = fxMesa->glCtx->Shared->TexObjectList;
+ if (!tmp)
+ return 0;
+ obj = 0;
+ old = 0;
+
+ bindnumber = fxMesa->texBindNumber;
+ while (tmp) {
+ info = fxTMGetTexInfo(tmp);
+
+ if (info && info->isInTM &&
+ ((info->whichTMU == tmu) || (info->whichTMU == FX_TMU_BOTH) ||
+ (info->whichTMU == FX_TMU_SPLIT))) {
+ lasttime = info->lastTimeUsed;
+
+ if (lasttime > bindnumber)
+ age = bindnumber + (UINT_MAX - lasttime + 1); /* TO DO: check wrap around */
+ else
+ age = bindnumber - lasttime;
+
+ if (age >= old) {
+ old = age;
+ obj = tmp;
+ }
}
- prev=tmp;
- tmp=tmp->next;
- }
- /* No free space. Discard oldest */
- obj=fxTMFindOldestObject(fxMesa, tmu);
- if (!obj) {
- fprintf(stderr, "fx Driver: No space for texture\n");
- return -1;
- }
- fxTMMoveOutTM(fxMesa, obj);
- texSwaps++;
- }
+ tmp = tmp->Next;
+ }
+ return obj;
}
-static void fxTMRemoveRange(fxMesaContext fxMesa, GLint tmu, MemRange *range)
+static MemRange *
+fxTMAddObj(fxMesaContext fxMesa,
+ struct gl_texture_object *tObj, GLint tmu, int texmemsize)
{
- MemRange *tmp, *prev;
-
- if (range->startAddr==range->endAddr) {
- fxTMDeleteRangeNode(fxMesa, range);
- return;
- }
- fxMesa->freeTexMem[tmu]+=range->endAddr-range->startAddr;
- prev=0;
- tmp=fxMesa->tmFree[tmu];
- while (tmp) {
- if (range->startAddr>tmp->startAddr) {
- prev=tmp;
- tmp=tmp->next;
- } else break;
- }
- /* When we create the regions, we make a split at the 2MB boundary.
- Now we have to make sure we don't join those 2MB boundary regions
- back together again. */
- range->next=tmp;
- if (tmp) {
- if (range->endAddr==tmp->startAddr && tmp->startAddr&(FX_2MB_SPLIT-1)) {
- /* Combine */
- tmp->startAddr=range->startAddr;
- fxTMDeleteRangeNode(fxMesa, range);
- range=tmp;
- }
- }
- if (prev) {
- if (prev->endAddr==range->startAddr && range->startAddr&(FX_2MB_SPLIT-1)) {
- /* Combine */
- prev->endAddr=range->endAddr;
- prev->next=range->next;
- fxTMDeleteRangeNode(fxMesa, range);
- } else prev->next=range;
- } else {
- fxMesa->tmFree[tmu]=range;
- }
+ FxU32 startAddr;
+ MemRange *range;
+
+ startAddr = fxTMFindStartAddr(fxMesa, tmu, texmemsize);
+ if (startAddr < 0)
+ return 0;
+ range = fxTMNewRangeNode(fxMesa, startAddr, startAddr + texmemsize);
+ return range;
}
-static struct gl_texture_object *fxTMFindOldestObject(fxMesaContext fxMesa,
- int tmu)
+/* External Functions */
+
+void
+fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj,
+ GLint where)
{
- GLuint age, old, lasttime, bindnumber;
- tfxTexInfo *info;
- struct gl_texture_object *obj, *tmp;
-
- tmp=fxMesa->glCtx->Shared->TexObjectList;
- if (!tmp) return 0;
- obj=0;
- old=0;
-
- bindnumber=fxMesa->texBindNumber;
- while (tmp) {
- info=fxTMGetTexInfo(tmp);
-
- if (info && info->isInTM &&
- ((info->whichTMU==tmu) || (info->whichTMU==FX_TMU_BOTH) ||
- (info->whichTMU==FX_TMU_SPLIT))) {
- lasttime=info->lastTimeUsed;
-
- if (lasttime>bindnumber)
- age=bindnumber+(UINT_MAX-lasttime+1); /* TO DO: check wrap around */
- else
- age=bindnumber-lasttime;
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ int i, l;
+ int texmemsize;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxTMMoveInTM(%d)\n", tObj->Name);
+ }
- if (age>=old) {
- old=age;
- obj=tmp;
+ fxMesa->stats.reqTexUpload++;
+
+ if (!ti->validated) {
+ fprintf(stderr,
+ "fx Driver: internal error in fxTMMoveInTM() -> not validated\n");
+ fxCloseHardware();
+ exit(-1);
+ }
+
+ if (ti->isInTM) {
+ if (ti->whichTMU == where)
+ return;
+ if (where == FX_TMU_SPLIT || ti->whichTMU == FX_TMU_SPLIT)
+ fxTMMoveOutTM_NoLock(fxMesa, tObj);
+ else {
+ if (ti->whichTMU == FX_TMU_BOTH)
+ return;
+ where = FX_TMU_BOTH;
}
- }
- tmp=tmp->Next;
- }
- return obj;
+ }
+
+ if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) {
+ fprintf(stderr, "fxmesa: downloading %x (%d) in texture memory in %d\n",
+ (GLuint) tObj, tObj->Name, where);
+ }
+
+ ti->whichTMU = (FxU32) where;
+
+ switch (where) {
+ case FX_TMU0:
+ case FX_TMU1:
+ texmemsize =
+ (int) FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info));
+ ti->tm[where] = fxTMAddObj(fxMesa, tObj, where, texmemsize);
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ for (i = FX_largeLodValue(ti->info), l = ti->minLevel;
+ i <= FX_smallLodValue(ti->info); i++, l++) {
+ struct gl_texture_image *texImage = tObj->Image[l];
+ FX_grTexDownloadMipMapLevel_NoLock(where,
+ ti->tm[where]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ texImage->Data);
+ }
+ break;
+ case FX_TMU_SPLIT:
+ texmemsize =
+ (int) FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_ODD,
+ &(ti->info));
+ ti->tm[FX_TMU0] = fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ texmemsize =
+ (int) FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_EVEN,
+ &(ti->info));
+ ti->tm[FX_TMU1] = fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize);
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ for (i = FX_largeLodValue(ti->info), l = ti->minLevel;
+ i <= FX_smallLodValue(ti->info); i++, l++) {
+ struct gl_texture_image *texImage = tObj->Image[l];
+
+ FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
+ ti->tm[FX_TMU0]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_ODD,
+ texImage->Data);
+
+ FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
+ ti->tm[FX_TMU1]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_EVEN,
+ texImage->Data);
+ }
+ break;
+ case FX_TMU_BOTH:
+ texmemsize =
+ (int) FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info));
+ ti->tm[FX_TMU0] = fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ texmemsize =
+ (int) FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info));
+ ti->tm[FX_TMU1] = fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize);
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ for (i = FX_largeLodValue(ti->info), l = ti->minLevel;
+ i <= FX_smallLodValue(ti->info); i++, l++) {
+ struct gl_texture_image *texImage = tObj->Image[l];
+ FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
+ ti->tm[FX_TMU0]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ texImage->Data);
+
+ FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
+ ti->tm[FX_TMU1]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ texImage->Data);
+ }
+ break;
+ default:
+ fprintf(stderr,
+ "fx Driver: internal error in fxTMMoveInTM() -> wrong tmu (%d)\n",
+ where);
+ fxCloseHardware();
+ exit(-1);
+ }
+
+ fxMesa->stats.texUpload++;
+
+ ti->isInTM = GL_TRUE;
}
-static MemRange *fxTMAddObj(fxMesaContext fxMesa,
- struct gl_texture_object *tObj,
- GLint tmu, int texmemsize)
-{
- FxU32 startAddr;
- MemRange *range;
- startAddr=fxTMFindStartAddr(fxMesa, tmu, texmemsize);
- if (startAddr<0) return 0;
- range=fxTMNewRangeNode(fxMesa, startAddr, startAddr+texmemsize);
- return range;
+void
+fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj,
+ GLint where)
+{
+ BEGIN_BOARD_LOCK();
+ fxTMMoveInTM_NoLock(fxMesa, tObj, where);
+ END_BOARD_LOCK();
}
-/* External Functions */
-void fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint where)
+void
+fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj,
+ GLint level)
+{
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ GrLOD_t lodlevel;
+ GLint tmu;
+ struct gl_texture_image *texImage = tObj->Image[level];
+ tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+
+ assert(mml);
+
+ if (!ti->validated) {
+ fprintf(stderr,
+ "fx Driver: internal error in fxTMReloadMipMapLevel() -> not validated\n");
+ fxCloseHardware();
+ exit(-1);
+ }
+
+ tmu = (int) ti->whichTMU;
+ fxTMMoveInTM(fxMesa, tObj, tmu);
+
+ fxTexGetInfo(mml->width, mml->height,
+ &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+
+#ifdef FX_GLIDE3
+ lodlevel -= level;
+#else
+ lodlevel += level;
+#endif
+ switch (tmu) {
+ case FX_TMU0:
+ case FX_TMU1:
+ FX_grTexDownloadMipMapLevel(tmu,
+ ti->tm[tmu]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH, texImage->Data);
+ break;
+ case FX_TMU_SPLIT:
+ FX_grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[GR_TMU0]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_ODD, texImage->Data);
+
+ FX_grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[GR_TMU1]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_EVEN, texImage->Data);
+ break;
+ case FX_TMU_BOTH:
+ FX_grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[GR_TMU0]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH, texImage->Data);
+
+ FX_grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[GR_TMU1]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH, texImage->Data);
+ break;
+
+ default:
+ fprintf(stderr,
+ "fx Driver: internal error in fxTMReloadMipMapLevel() -> wrong tmu (%d)\n",
+ tmu);
+ fxCloseHardware();
+ exit(-1);
+ }
+}
+
+void
+fxTMReloadSubMipMapLevel(fxMesaContext fxMesa,
+ struct gl_texture_object *tObj,
+ GLint level, GLint yoffset, GLint height)
{
- tfxTexInfo *ti=fxTMGetTexInfo(tObj);
- int i,l;
- int texmemsize;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxTMMoveInTM(%d)\n",tObj->Name);
- }
-
- fxMesa->stats.reqTexUpload++;
-
- if (!ti->validated) {
- fprintf(stderr,"fx Driver: internal error in fxTMMoveInTM() -> not validated\n");
- fxCloseHardware();
- exit(-1);
- }
-
- if (ti->isInTM) {
- if (ti->whichTMU==where) return;
- if (where==FX_TMU_SPLIT || ti->whichTMU==FX_TMU_SPLIT)
- fxTMMoveOutTM_NoLock(fxMesa, tObj);
- else {
- if (ti->whichTMU==FX_TMU_BOTH) return;
- where=FX_TMU_BOTH;
- }
- }
-
- if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_TEXTURE)) {
- fprintf(stderr,"fxmesa: downloading %x (%d) in texture memory in %d\n",(GLuint)tObj,tObj->Name,where);
- }
-
- ti->whichTMU=(FxU32)where;
-
- switch (where) {
- case FX_TMU0:
- case FX_TMU1:
- texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
- &(ti->info));
- ti->tm[where]=fxTMAddObj(fxMesa, tObj, where, texmemsize);
- fxMesa->stats.memTexUpload+=texmemsize;
-
- for (i=FX_largeLodValue(ti->info), l=ti->minLevel;
- i<=FX_smallLodValue(ti->info);
- i++,l++) {
- struct gl_texture_image *texImage = tObj->Image[l];
- FX_grTexDownloadMipMapLevel_NoLock(where,
- ti->tm[where]->startAddr,
- FX_valueToLod(i),
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ GrLOD_t lodlevel;
+ unsigned short *data;
+ GLint tmu;
+ struct gl_texture_image *texImage = tObj->Image[level];
+ tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+
+ assert(mml);
+
+ if (!ti->validated) {
+ fprintf(stderr,
+ "fx Driver: internal error in fxTMReloadSubMipMapLevel() -> not validated\n");
+ fxCloseHardware();
+ exit(-1);
+ }
+
+ tmu = (int) ti->whichTMU;
+ fxTMMoveInTM(fxMesa, tObj, tmu);
+
+ fxTexGetInfo(mml->width, mml->height,
+ &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+
+ if ((ti->info.format == GR_TEXFMT_INTENSITY_8) ||
+ (ti->info.format == GR_TEXFMT_P_8) ||
+ (ti->info.format == GR_TEXFMT_ALPHA_8))
+ data = (GLushort *) texImage->Data + ((yoffset * mml->width) >> 1);
+ else
+ data = (GLushort *) texImage->Data + yoffset * mml->width;
+
+ switch (tmu) {
+ case FX_TMU0:
+ case FX_TMU1:
+ FX_grTexDownloadMipMapLevelPartial(tmu,
+ ti->tm[tmu]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)
+ + level),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- texImage->Data);
- }
- break;
- case FX_TMU_SPLIT:
- texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_ODD,
- &(ti->info));
- ti->tm[FX_TMU0]=fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
- fxMesa->stats.memTexUpload+=texmemsize;
-
- texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_EVEN,
- &(ti->info));
- ti->tm[FX_TMU1]=fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize);
- fxMesa->stats.memTexUpload+=texmemsize;
-
- for (i=FX_largeLodValue(ti->info),l=ti->minLevel;
- i<=FX_smallLodValue(ti->info);
- i++,l++) {
- struct gl_texture_image *texImage = tObj->Image[l];
-
- FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
+ GR_MIPMAPLEVELMASK_BOTH, data,
+ yoffset, yoffset + height - 1);
+ break;
+ case FX_TMU_SPLIT:
+ FX_grTexDownloadMipMapLevelPartial(GR_TMU0,
ti->tm[FX_TMU0]->startAddr,
- FX_valueToLod(i),
+ FX_valueToLod(FX_lodToValue(lodlevel)
+ + level),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
- GR_MIPMAPLEVELMASK_ODD,
- texImage->Data);
+ GR_MIPMAPLEVELMASK_ODD, data,
+ yoffset, yoffset + height - 1);
- FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
+ FX_grTexDownloadMipMapLevelPartial(GR_TMU1,
ti->tm[FX_TMU1]->startAddr,
- FX_valueToLod(i),
+ FX_valueToLod(FX_lodToValue(lodlevel)
+ + level),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
- GR_MIPMAPLEVELMASK_EVEN,
- texImage->Data);
- }
- break;
- case FX_TMU_BOTH:
- texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
- &(ti->info));
- ti->tm[FX_TMU0]=fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
- fxMesa->stats.memTexUpload+=texmemsize;
-
- texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
- &(ti->info));
- ti->tm[FX_TMU1]=fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize);
- fxMesa->stats.memTexUpload+=texmemsize;
-
- for (i=FX_largeLodValue(ti->info),l=ti->minLevel;
- i<=FX_smallLodValue(ti->info);
- i++,l++) {
- struct gl_texture_image *texImage = tObj->Image[l];
- FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
+ GR_MIPMAPLEVELMASK_EVEN, data,
+ yoffset, yoffset + height - 1);
+ break;
+ case FX_TMU_BOTH:
+ FX_grTexDownloadMipMapLevelPartial(GR_TMU0,
ti->tm[FX_TMU0]->startAddr,
- FX_valueToLod(i),
+ FX_valueToLod(FX_lodToValue(lodlevel)
+ + level),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- texImage->Data);
+ GR_MIPMAPLEVELMASK_BOTH, data,
+ yoffset, yoffset + height - 1);
- FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
+ FX_grTexDownloadMipMapLevelPartial(GR_TMU1,
ti->tm[FX_TMU1]->startAddr,
- FX_valueToLod(i),
+ FX_valueToLod(FX_lodToValue(lodlevel)
+ + level),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- texImage->Data);
- }
- break;
- default:
- fprintf(stderr,"fx Driver: internal error in fxTMMoveInTM() -> wrong tmu (%d)\n",where);
- fxCloseHardware();
- exit(-1);
- }
-
- fxMesa->stats.texUpload++;
-
- ti->isInTM=GL_TRUE;
+ GR_MIPMAPLEVELMASK_BOTH, data,
+ yoffset, yoffset + height - 1);
+ break;
+ default:
+ fprintf(stderr,
+ "fx Driver: internal error in fxTMReloadSubMipMapLevel() -> wrong tmu (%d)\n",
+ tmu);
+ fxCloseHardware();
+ exit(-1);
+ }
}
-
void
-fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint where)
+fxTMMoveOutTM(fxMesaContext fxMesa, struct gl_texture_object *tObj)
{
- BEGIN_BOARD_LOCK();
- fxTMMoveInTM_NoLock(fxMesa, tObj, where);
- END_BOARD_LOCK();
-}
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxTMMoveOutTM(%x (%d))\n", (GLuint) tObj,
+ tObj->Name);
+ }
+
+ if (!ti->isInTM)
+ return;
+
+ switch (ti->whichTMU) {
+ case FX_TMU0:
+ case FX_TMU1:
+ fxTMRemoveRange(fxMesa, (int) ti->whichTMU, ti->tm[ti->whichTMU]);
+ break;
+ case FX_TMU_SPLIT:
+ case FX_TMU_BOTH:
+ fxTMRemoveRange(fxMesa, FX_TMU0, ti->tm[FX_TMU0]);
+ fxTMRemoveRange(fxMesa, FX_TMU1, ti->tm[FX_TMU1]);
+ break;
+ default:
+ fprintf(stderr, "fx Driver: internal error in fxTMMoveOutTM()\n");
+ fxCloseHardware();
+ exit(-1);
+ }
+ ti->isInTM = GL_FALSE;
+ ti->whichTMU = FX_TMU_NONE;
+}
void
-fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj,
- GLint level)
+fxTMFreeTexture(fxMesaContext fxMesa, struct gl_texture_object *tObj)
{
- tfxTexInfo *ti = fxTMGetTexInfo(tObj);
- GrLOD_t lodlevel;
- GLint tmu;
- struct gl_texture_image *texImage = tObj->Image[level];
- tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
-
- assert(mml);
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ int i;
- if (!ti->validated) {
- fprintf(stderr,"fx Driver: internal error in fxTMReloadMipMapLevel() -> not validated\n");
- fxCloseHardware();
- exit(-1);
- }
+ fxTMMoveOutTM(fxMesa, tObj);
- tmu = (int)ti->whichTMU;
- fxTMMoveInTM(fxMesa, tObj, tmu);
-
- fxTexGetInfo(mml->width, mml->height,
- &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-
-#ifdef FX_GLIDE3
- lodlevel-=level;
-#else
- lodlevel+=level;
-#endif
- switch(tmu) {
- case FX_TMU0:
- case FX_TMU1:
- FX_grTexDownloadMipMapLevel(tmu,
- ti->tm[tmu]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- texImage->Data);
- break;
- case FX_TMU_SPLIT:
- FX_grTexDownloadMipMapLevel(GR_TMU0,
- ti->tm[GR_TMU0]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_ODD,
- texImage->Data);
-
- FX_grTexDownloadMipMapLevel(GR_TMU1,
- ti->tm[GR_TMU1]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_EVEN,
- texImage->Data);
- break;
- case FX_TMU_BOTH:
- FX_grTexDownloadMipMapLevel(GR_TMU0,
- ti->tm[GR_TMU0]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- texImage->Data);
-
- FX_grTexDownloadMipMapLevel(GR_TMU1,
- ti->tm[GR_TMU1]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- texImage->Data);
- break;
-
- default:
- fprintf(stderr,"fx Driver: internal error in fxTMReloadMipMapLevel() -> wrong tmu (%d)\n",tmu);
- fxCloseHardware();
- exit(-1);
- }
+ for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+ struct gl_texture_image *texImage = tObj->Image[i];
+ if (texImage->Data) {
+ FREE(texImage->Data);
+ texImage->Data = NULL;
+ }
+ if (texImage->DriverData) {
+ FREE(texImage->DriverData);
+ texImage->DriverData = NULL;
+ }
+ }
+ switch (ti->whichTMU) {
+ case FX_TMU0:
+ case FX_TMU1:
+ fxTMDeleteRangeNode(fxMesa, ti->tm[ti->whichTMU]);
+ break;
+ case FX_TMU_SPLIT:
+ case FX_TMU_BOTH:
+ fxTMDeleteRangeNode(fxMesa, ti->tm[FX_TMU0]);
+ fxTMDeleteRangeNode(fxMesa, ti->tm[FX_TMU1]);
+ break;
+ }
}
-void fxTMReloadSubMipMapLevel(fxMesaContext fxMesa,
- struct gl_texture_object *tObj,
- GLint level, GLint yoffset, GLint height)
+void
+fxTMInit(fxMesaContext fxMesa)
{
- tfxTexInfo *ti=fxTMGetTexInfo(tObj);
- GrLOD_t lodlevel;
- unsigned short *data;
- GLint tmu;
- struct gl_texture_image *texImage = tObj->Image[level];
- tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
-
- assert(mml);
-
- if (!ti->validated) {
- fprintf(stderr,"fx Driver: internal error in fxTMReloadSubMipMapLevel() -> not validated\n");
- fxCloseHardware();
- exit(-1);
- }
-
- tmu=(int)ti->whichTMU;
- fxTMMoveInTM(fxMesa, tObj, tmu);
-
- fxTexGetInfo(mml->width, mml->height,
- &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-
- if((ti->info.format==GR_TEXFMT_INTENSITY_8) ||
- (ti->info.format==GR_TEXFMT_P_8) ||
- (ti->info.format==GR_TEXFMT_ALPHA_8))
- data = (GLushort *) texImage->Data + ((yoffset * mml->width) >> 1);
- else
- data = (GLushort *) texImage->Data + yoffset * mml->width;
-
- switch(tmu) {
- case FX_TMU0:
- case FX_TMU1:
- FX_grTexDownloadMipMapLevelPartial(tmu,
- ti->tm[tmu]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)+level),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- data,
- yoffset,yoffset+height-1);
- break;
- case FX_TMU_SPLIT:
- FX_grTexDownloadMipMapLevelPartial(GR_TMU0,
- ti->tm[FX_TMU0]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)+level),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_ODD,
- data,
- yoffset,yoffset+height-1);
-
- FX_grTexDownloadMipMapLevelPartial(GR_TMU1,
- ti->tm[FX_TMU1]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)+level),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_EVEN,
- data,
- yoffset,yoffset+height-1);
- break;
- case FX_TMU_BOTH:
- FX_grTexDownloadMipMapLevelPartial(GR_TMU0,
- ti->tm[FX_TMU0]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)+level),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- data,
- yoffset,yoffset+height-1);
-
- FX_grTexDownloadMipMapLevelPartial(GR_TMU1,
- ti->tm[FX_TMU1]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)+level),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- data,
- yoffset,yoffset+height-1);
- break;
- default:
- fprintf(stderr,"fx Driver: internal error in fxTMReloadSubMipMapLevel() -> wrong tmu (%d)\n",tmu);
- fxCloseHardware();
- exit(-1);
- }
-}
+ fxMesa->texBindNumber = 0;
+ fxMesa->tmPool = 0;
-void fxTMMoveOutTM(fxMesaContext fxMesa, struct gl_texture_object *tObj)
-{
- tfxTexInfo *ti=fxTMGetTexInfo(tObj);
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxTMMoveOutTM(%x (%d))\n",(GLuint)tObj,tObj->Name);
- }
-
- if (!ti->isInTM) return;
-
- switch(ti->whichTMU) {
- case FX_TMU0:
- case FX_TMU1:
- fxTMRemoveRange(fxMesa, (int)ti->whichTMU, ti->tm[ti->whichTMU]);
- break;
- case FX_TMU_SPLIT:
- case FX_TMU_BOTH:
- fxTMRemoveRange(fxMesa, FX_TMU0, ti->tm[FX_TMU0]);
- fxTMRemoveRange(fxMesa, FX_TMU1, ti->tm[FX_TMU1]);
- break;
- default:
- fprintf(stderr,"fx Driver: internal error in fxTMMoveOutTM()\n");
- fxCloseHardware();
- exit(-1);
- }
-
- ti->isInTM=GL_FALSE;
- ti->whichTMU=FX_TMU_NONE;
-}
+ fxTMUInit(fxMesa, FX_TMU0);
-void fxTMFreeTexture(fxMesaContext fxMesa, struct gl_texture_object *tObj)
-{
- tfxTexInfo *ti=fxTMGetTexInfo(tObj);
- int i;
-
- fxTMMoveOutTM(fxMesa, tObj);
-
- for (i=0; i<MAX_TEXTURE_LEVELS; i++) {
- struct gl_texture_image *texImage = tObj->Image[i];
- if (texImage->Data) {
- FREE(texImage->Data);
- texImage->Data = NULL;
- }
- if (texImage->DriverData) {
- FREE(texImage->DriverData);
- texImage->DriverData = NULL;
- }
- }
- switch (ti->whichTMU) {
- case FX_TMU0:
- case FX_TMU1:
- fxTMDeleteRangeNode(fxMesa, ti->tm[ti->whichTMU]);
- break;
- case FX_TMU_SPLIT:
- case FX_TMU_BOTH:
- fxTMDeleteRangeNode(fxMesa, ti->tm[FX_TMU0]);
- fxTMDeleteRangeNode(fxMesa, ti->tm[FX_TMU1]);
- break;
- }
+ if (fxMesa->haveTwoTMUs)
+ fxTMUInit(fxMesa, FX_TMU1);
}
-void fxTMInit(fxMesaContext fxMesa)
+void
+fxTMClose(fxMesaContext fxMesa)
{
- fxMesa->texBindNumber=0;
- fxMesa->tmPool=0;
-
- fxTMUInit(fxMesa,FX_TMU0);
-
- if(fxMesa->haveTwoTMUs)
- fxTMUInit(fxMesa,FX_TMU1);
-}
+ MemRange *tmp, *next;
-void fxTMClose(fxMesaContext fxMesa)
-{
- MemRange *tmp, *next;
-
- tmp=fxMesa->tmPool;
- while (tmp) {
- next=tmp->next;
- FREE(tmp);
- tmp=next;
- }
- tmp=fxMesa->tmFree[FX_TMU0];
- while (tmp) {
- next=tmp->next;
- FREE(tmp);
- tmp=next;
- }
- if (fxMesa->haveTwoTMUs) {
- tmp=fxMesa->tmFree[FX_TMU1];
- while (tmp) {
- next=tmp->next;
+ tmp = fxMesa->tmPool;
+ while (tmp) {
+ next = tmp->next;
+ FREE(tmp);
+ tmp = next;
+ }
+ tmp = fxMesa->tmFree[FX_TMU0];
+ while (tmp) {
+ next = tmp->next;
FREE(tmp);
- tmp=next;
- }
- }
+ tmp = next;
+ }
+ if (fxMesa->haveTwoTMUs) {
+ tmp = fxMesa->tmFree[FX_TMU1];
+ while (tmp) {
+ next = tmp->next;
+ FREE(tmp);
+ tmp = next;
+ }
+ }
}
void
-fxTMRestoreTextures_NoLock(fxMesaContext ctx) {
- tfxTexInfo *ti;
- struct gl_texture_object *tObj;
- int i, where;
-
- tObj=ctx->glCtx->Shared->TexObjectList;
- while (tObj) {
- ti=fxTMGetTexInfo(tObj);
- if (ti && ti->isInTM) {
- for (i=0; i<MAX_TEXTURE_UNITS; i++)
- if (ctx->glCtx->Texture.Unit[i]._Current==tObj) {
- /* Force the texture onto the board, as it could be in use */
- where=ti->whichTMU;
- fxTMMoveOutTM_NoLock(ctx, tObj);
- fxTMMoveInTM_NoLock(ctx, tObj, where);
- break;
- }
- if (i==MAX_TEXTURE_UNITS) /* Mark the texture as off the board */
- fxTMMoveOutTM_NoLock(ctx, tObj);
- }
- tObj=tObj->Next;
- }
+fxTMRestoreTextures_NoLock(fxMesaContext ctx)
+{
+ tfxTexInfo *ti;
+ struct gl_texture_object *tObj;
+ int i, where;
+
+ tObj = ctx->glCtx->Shared->TexObjectList;
+ while (tObj) {
+ ti = fxTMGetTexInfo(tObj);
+ if (ti && ti->isInTM) {
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++)
+ if (ctx->glCtx->Texture.Unit[i]._Current == tObj) {
+ /* Force the texture onto the board, as it could be in use */
+ where = ti->whichTMU;
+ fxTMMoveOutTM_NoLock(ctx, tObj);
+ fxTMMoveInTM_NoLock(ctx, tObj, where);
+ break;
+ }
+ if (i == MAX_TEXTURE_UNITS) /* Mark the texture as off the board */
+ fxTMMoveOutTM_NoLock(ctx, tObj);
+ }
+ tObj = tObj->Next;
+ }
}
#else
@@ -763,9 +809,10 @@ fxTMRestoreTextures_NoLock(fxMesaContext ctx) {
*/
extern int gl_fx_dummy_function_texman(void);
-int gl_fx_dummy_function_texman(void)
+int
+gl_fx_dummy_function_texman(void)
{
- return 0;
+ return 0;
}
-#endif /* FX */
+#endif /* FX */
diff --git a/src/mesa/drivers/glide/fxtris.c b/src/mesa/drivers/glide/fxtris.c
index d15ebf8bc1..a0c8383fdd 100644
--- a/src/mesa/drivers/glide/fxtris.c
+++ b/src/mesa/drivers/glide/fxtris.c
@@ -23,17 +23,15 @@
-static void
-fx_draw_point( GLcontext *ctx, const fxVertex *v )
+static void
+fx_draw_point(GLcontext * ctx, const fxVertex * v)
{
GLfloat sz = ctx->Point._Size;
- if ( sz <= 1.0 )
- {
- grDrawPoint( &(v->v) );
+ if (sz <= 1.0) {
+ grDrawPoint(&(v->v));
}
- else
- {
+ else {
GrVertex verts[4];
sz *= .5;
@@ -48,30 +46,28 @@ fx_draw_point( GLcontext *ctx, const fxVertex *v )
verts[1].x = v->v.x + sz;
verts[1].y = v->v.y - sz;
-
+
verts[2].x = v->v.x + sz;
verts[2].y = v->v.y + sz;
verts[3].x = v->v.x - sz;
verts[3].y = v->v.y + sz;
- grDrawTriangle( &verts[0], &verts[1], &verts[3] );
- grDrawTriangle( &verts[1], &verts[2], &verts[3] );
+ grDrawTriangle(&verts[0], &verts[1], &verts[3]);
+ grDrawTriangle(&verts[1], &verts[2], &verts[3]);
}
}
-static void
-fx_draw_line( GLcontext *ctx, const fxVertex *v0, const fxVertex *v1 )
+static void
+fx_draw_line(GLcontext * ctx, const fxVertex * v0, const fxVertex * v1)
{
float width = ctx->Line.Width;
- if ( width <= 1.0 )
- {
- grDrawLine( &(v0->v), &(v1->v) );
+ if (width <= 1.0) {
+ grDrawLine(&(v0->v), &(v1->v));
}
- else
- {
+ else {
GrVertex verts[4];
float dx, dy, ix, iy;
@@ -81,7 +77,8 @@ fx_draw_line( GLcontext *ctx, const fxVertex *v0, const fxVertex *v1 )
if (dx * dx > dy * dy) {
iy = width * .5;
ix = 0;
- } else {
+ }
+ else {
iy = 0;
ix = width * .5;
}
@@ -103,16 +100,16 @@ fx_draw_line( GLcontext *ctx, const fxVertex *v0, const fxVertex *v1 )
verts[3].x -= ix;
verts[3].y -= iy;
- grDrawTriangle( &verts[0], &verts[1], &verts[3] );
- grDrawTriangle( &verts[1], &verts[2], &verts[3] );
+ grDrawTriangle(&verts[0], &verts[1], &verts[3]);
+ grDrawTriangle(&verts[1], &verts[2], &verts[3]);
}
}
-static void
-fx_draw_tri( GLcontext *ctx, const fxVertex *v0, const fxVertex *v1,
- const fxVertex *v2 )
+static void
+fx_draw_tri(GLcontext * ctx, const fxVertex * v0, const fxVertex * v1,
+ const fxVertex * v2)
{
- grDrawTriangle( &(v0->v), &(v1->v), &(v2->v) );
+ grDrawTriangle(&(v0->v), &(v1->v), &(v2->v));
}
@@ -141,12 +138,14 @@ fx_draw_tri( GLcontext *ctx, const fxVertex *v0, const fxVertex *v1,
#define FX_FALLBACK_BIT 0x20
#define FX_MAX_TRIFUNC 0x40
-static struct {
- points_func points;
- line_func line;
- triangle_func triangle;
- quad_func quad;
-} rast_tab[FX_MAX_TRIFUNC];
+static struct
+{
+ points_func points;
+ line_func line;
+ triangle_func triangle;
+ quad_func quad;
+}
+rast_tab[FX_MAX_TRIFUNC];
#define IND (0)
@@ -282,7 +281,8 @@ static struct {
-void fxDDTrifuncInit( void )
+void
+fxDDTrifuncInit(void)
{
init();
init_flat();
@@ -330,13 +330,13 @@ void fxDDTrifuncInit( void )
* primitives are being drawn, and only for the unaccelerated
* primitives.
*/
-static void
-fx_translate_vertex(GLcontext *ctx, const fxVertex *src, SWvertex *dst)
+static void
+fx_translate_vertex(GLcontext * ctx, const fxVertex * src, SWvertex * dst)
{
- fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
GLuint ts0 = fxMesa->tmu_source[0];
GLuint ts1 = fxMesa->tmu_source[1];
- GLfloat w = 1.0 / src->v.oow;
+ GLfloat w = 1.0 / src->v.oow;
dst->win[0] = src->v.x;
dst->win[1] = src->v.y;
@@ -359,52 +359,53 @@ fx_translate_vertex(GLcontext *ctx, const fxVertex *src, SWvertex *dst)
dst->texcoord[ts1][0] = fxMesa->inv_s1scale * src->v.tmuvtx[1].sow * w;
dst->texcoord[ts1][1] = fxMesa->inv_t1scale * src->v.tmuvtx[1].tow * w;
- if (fxMesa->stw_hint_state & GR_STWHINT_W_DIFF_TMU1)
+ if (fxMesa->stw_hint_state & GR_STWHINT_W_DIFF_TMU1)
dst->texcoord[ts1][3] = src->v.tmuvtx[1].oow * w;
else
dst->texcoord[ts1][3] = 1.0;
}
-static void
-fx_fallback_tri( GLcontext *ctx,
- const fxVertex *v0, const fxVertex *v1, const fxVertex *v2 )
+static void
+fx_fallback_tri(GLcontext * ctx,
+ const fxVertex * v0, const fxVertex * v1, const fxVertex * v2)
{
SWvertex v[3];
- fx_translate_vertex( ctx, v0, &v[0] );
- fx_translate_vertex( ctx, v1, &v[1] );
- fx_translate_vertex( ctx, v2, &v[2] );
- _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+ fx_translate_vertex(ctx, v0, &v[0]);
+ fx_translate_vertex(ctx, v1, &v[1]);
+ fx_translate_vertex(ctx, v2, &v[2]);
+ _swrast_Triangle(ctx, &v[0], &v[1], &v[2]);
}
-static void
-fx_fallback_line( GLcontext *ctx, const fxVertex *v0, const fxVertex *v1 )
+static void
+fx_fallback_line(GLcontext * ctx, const fxVertex * v0, const fxVertex * v1)
{
SWvertex v[2];
- fx_translate_vertex( ctx, v0, &v[0] );
- fx_translate_vertex( ctx, v1, &v[1] );
- _swrast_Line( ctx, &v[0], &v[1] );
+ fx_translate_vertex(ctx, v0, &v[0]);
+ fx_translate_vertex(ctx, v1, &v[1]);
+ _swrast_Line(ctx, &v[0], &v[1]);
}
-static void
-fx_fallback_point( GLcontext *ctx, const fxVertex *v0 )
+static void
+fx_fallback_point(GLcontext * ctx, const fxVertex * v0)
{
SWvertex v[1];
- fx_translate_vertex( ctx, v0, &v[0] );
- _swrast_Point( ctx, &v[0] );
+ fx_translate_vertex(ctx, v0, &v[0]);
+ _swrast_Point(ctx, &v[0]);
}
/* System to turn culling off for rasterized lines and points, and
* back on for rasterized triangles.
*/
-static void
-fx_cull_draw_tri( GLcontext *ctx,
- const fxVertex *v0, const fxVertex *v1, const fxVertex *v2 )
+static void
+fx_cull_draw_tri(GLcontext * ctx,
+ const fxVertex * v0, const fxVertex * v1,
+ const fxVertex * v2)
{
- fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
FX_grCullMode(fxMesa->cullMode);
@@ -412,29 +413,29 @@ fx_cull_draw_tri( GLcontext *ctx,
fxMesa->draw_point = fxMesa->initial_point;
fxMesa->draw_tri = fxMesa->subsequent_tri;
- fxMesa->draw_tri( ctx, v0, v1, v2 );
+ fxMesa->draw_tri(ctx, v0, v1, v2);
}
-static void
-fx_cull_draw_line( GLcontext *ctx, const fxVertex *v0, const fxVertex *v1 )
+static void
+fx_cull_draw_line(GLcontext * ctx, const fxVertex * v0, const fxVertex * v1)
{
- fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
- FX_grCullMode( GR_CULL_DISABLE );
+ FX_grCullMode(GR_CULL_DISABLE);
fxMesa->draw_point = fxMesa->initial_point;
fxMesa->draw_tri = fxMesa->initial_tri;
fxMesa->draw_line = fxMesa->subsequent_line;
- fxMesa->draw_line( ctx, v0, v1 );
+ fxMesa->draw_line(ctx, v0, v1);
}
-static void
-fx_cull_draw_point( GLcontext *ctx, const fxVertex *v0 )
+static void
+fx_cull_draw_point(GLcontext * ctx, const fxVertex * v0)
{
- fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
FX_grCullMode(GR_CULL_DISABLE);
@@ -442,13 +443,13 @@ fx_cull_draw_point( GLcontext *ctx, const fxVertex *v0 )
fxMesa->draw_tri = fxMesa->initial_tri;
fxMesa->draw_point = fxMesa->subsequent_point;
- fxMesa->draw_point( ctx, v0 );
+ fxMesa->draw_point(ctx, v0);
}
-static void
-fx_null_tri( GLcontext *ctx,
- const fxVertex *v0, const fxVertex *v1, const fxVertex *v2 )
+static void
+fx_null_tri(GLcontext * ctx,
+ const fxVertex * v0, const fxVertex * v1, const fxVertex * v2)
{
(void) v0;
(void) v1;
@@ -488,8 +489,8 @@ fx_null_tri( GLcontext *ctx,
/* Verts, no clipping.
*/
#define ELT(x) x
-#define RESET_STIPPLE
-#define RESET_OCCLUSION
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
#define PRESERVE_VB_DEFS
#include "tnl/t_vb_rendertmp.h"
@@ -514,7 +515,7 @@ fx_null_tri( GLcontext *ctx,
#define LINE_FALLBACK (DD_LINE_STIPPLE)
#define TRI_FALLBACK (DD_TRI_SMOOTH | DD_TRI_STIPPLE )
#define ANY_FALLBACK (POINT_FALLBACK | LINE_FALLBACK | TRI_FALLBACK)
-
+
#define ANY_RENDER_FLAGS (DD_FLATSHADE | \
DD_TRI_LIGHT_TWOSIDE | \
@@ -527,13 +528,14 @@ fx_null_tri( GLcontext *ctx,
* current rendering state. Wherever possible, use the hardware to
* render the primitive. Otherwise, fallback to software rendering.
*/
-void fxDDChooseRenderState( GLcontext *ctx )
+void
+fxDDChooseRenderState(GLcontext * ctx)
{
- fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
GLuint flags = ctx->_TriangleCaps;
GLuint index = 0;
- if ( !fxMesa->is_in_hardware ) {
+ if (!fxMesa->is_in_hardware) {
/* Build software vertices directly. No acceleration is
* possible. GrVertices may be insufficient for this mode.
*/
@@ -548,20 +550,22 @@ void fxDDChooseRenderState( GLcontext *ctx )
return;
}
- if ( flags & ANY_RENDER_FLAGS ) {
- if ( flags & DD_FLATSHADE ) index |= FX_FLAT_BIT;
- if ( flags & DD_TRI_LIGHT_TWOSIDE ) index |= FX_TWOSIDE_BIT;
- if ( flags & DD_TRI_OFFSET ) index |= FX_OFFSET_BIT;
- if ( flags & DD_TRI_UNFILLED ) index |= FX_UNFILLED_BIT;
+ if (flags & ANY_RENDER_FLAGS) {
+ if (flags & DD_FLATSHADE)
+ index |= FX_FLAT_BIT;
+ if (flags & DD_TRI_LIGHT_TWOSIDE)
+ index |= FX_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET)
+ index |= FX_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED)
+ index |= FX_UNFILLED_BIT;
}
- if ( flags & (ANY_FALLBACK|
- DD_LINE_WIDTH|
- DD_POINT_SIZE|
- DD_TRI_CULL_FRONT_BACK) ) {
-
+ if (flags & (ANY_FALLBACK |
+ DD_LINE_WIDTH | DD_POINT_SIZE | DD_TRI_CULL_FRONT_BACK)) {
+
/* Hook in fallbacks for specific primitives.
- *
+
* Set up a system to turn culling on/off for wide points and
* lines. Alternately: figure out what tris to send so that
* culling isn't a problem.
@@ -577,19 +581,19 @@ void fxDDChooseRenderState( GLcontext *ctx )
fxMesa->subsequent_line = fx_draw_line;
fxMesa->subsequent_tri = fx_draw_tri;
- if ( flags & POINT_FALLBACK )
+ if (flags & POINT_FALLBACK)
fxMesa->initial_point = fx_fallback_point;
- if ( flags & LINE_FALLBACK )
+ if (flags & LINE_FALLBACK)
fxMesa->initial_line = fx_fallback_line;
- if ((flags & DD_LINE_SMOOTH) && ctx->Line.Width != 1.0)
+ if ((flags & DD_LINE_SMOOTH) && ctx->Line.Width != 1.0)
fxMesa->initial_line = fx_fallback_line;
- if ( flags & TRI_FALLBACK )
+ if (flags & TRI_FALLBACK)
fxMesa->initial_tri = fx_fallback_tri;
- if ( flags & DD_TRI_CULL_FRONT_BACK )
+ if (flags & DD_TRI_CULL_FRONT_BACK)
fxMesa->initial_tri = fx_null_tri;
fxMesa->draw_point = fxMesa->initial_point;
@@ -599,7 +603,7 @@ void fxDDChooseRenderState( GLcontext *ctx )
else if (fxMesa->render_index & FX_FALLBACK_BIT) {
FX_grCullMode(fxMesa->cullMode);
}
-
+
ctx->Driver.PointsFunc = rast_tab[index].points;
ctx->Driver.LineFunc = rast_tab[index].line;
ctx->Driver.TriangleFunc = rast_tab[index].triangle;
@@ -609,7 +613,8 @@ void fxDDChooseRenderState( GLcontext *ctx )
if (fxMesa->render_index == 0) {
ctx->Driver.RenderTabVerts = fx_render_tab_verts;
ctx->Driver.RenderTabElts = fx_render_tab_elts;
- } else {
+ }
+ else {
ctx->Driver.RenderTabVerts = _tnl_render_tab_verts;
ctx->Driver.RenderTabElts = _tnl_render_tab_elts;
}
@@ -626,9 +631,10 @@ void fxDDChooseRenderState( GLcontext *ctx )
*/
extern int gl_fx_dummy_function_trifuncs(void);
-int gl_fx_dummy_function_trifuncs(void)
+int
+gl_fx_dummy_function_trifuncs(void)
{
- return 0;
+ return 0;
}
-#endif /* FX */
+#endif /* FX */
diff --git a/src/mesa/drivers/glide/fxvb.c b/src/mesa/drivers/glide/fxvb.c
index d95cfca579..40acbb7e9e 100644
--- a/src/mesa/drivers/glide/fxvb.c
+++ b/src/mesa/drivers/glide/fxvb.c
@@ -48,23 +48,24 @@
#include "tnl/t_pipeline.h"
-void fxPrintSetupFlags( const char *msg, GLuint flags )
+void
+fxPrintSetupFlags(const char *msg, GLuint flags)
{
fprintf(stderr, "%s: %d %s%s%s%s%s\n",
- msg,
- flags,
- (flags & SETUP_XYZW) ? " xyzw," : "",
- (flags & SETUP_SNAP) ? " snap," : "",
- (flags & SETUP_RGBA) ? " rgba," : "",
- (flags & SETUP_TMU0) ? " tmu0," : "",
- (flags & SETUP_TMU1) ? " tmu1," : "");
+ msg,
+ flags,
+ (flags & SETUP_XYZW) ? " xyzw," : "",
+ (flags & SETUP_SNAP) ? " snap," : "",
+ (flags & SETUP_RGBA) ? " rgba," : "",
+ (flags & SETUP_TMU0) ? " tmu0," : "",
+ (flags & SETUP_TMU1) ? " tmu1," : "");
}
-static void project_texcoords( fxVertex *v,
- struct vertex_buffer *VB,
- GLuint tmu_nr, GLuint tc_nr,
- GLuint start, GLuint count )
-{
+static void
+project_texcoords(fxVertex * v,
+ struct vertex_buffer *VB,
+ GLuint tmu_nr, GLuint tc_nr, GLuint start, GLuint count)
+{
GrTmuVertex *tmu = &(v->v.tmuvtx[tmu_nr]);
GLvector4f *vec = VB->TexCoordPtr[tc_nr];
@@ -72,43 +73,42 @@ static void project_texcoords( fxVertex *v,
GLuint stride = vec->stride;
GLfloat *data = VEC_ELT(vec, GLfloat, start);
- for (i = start ; i < count ; i++, STRIDE_F(data, stride), v++) {
+ for (i = start; i < count; i++, STRIDE_F(data, stride), v++) {
tmu->oow = v->v.oow * data[3];
- tmu = (GrTmuVertex *)((char *)tmu + sizeof(fxVertex));
- }
+ tmu = (GrTmuVertex *) ((char *) tmu + sizeof(fxVertex));
+ }
}
-static void copy_w( fxVertex *v,
- struct vertex_buffer *VB,
- GLuint tmu_nr,
- GLuint start, GLuint count )
-{
+static void
+copy_w(fxVertex * v,
+ struct vertex_buffer *VB, GLuint tmu_nr, GLuint start, GLuint count)
+{
GrTmuVertex *tmu = &(v->v.tmuvtx[tmu_nr]);
GLuint i;
- for (i = start ; i < count ; i++, v++) {
+ for (i = start; i < count; i++, v++) {
tmu->oow = v->v.oow;
- tmu = (GrTmuVertex *)((char *)tmu + sizeof(fxVertex));
- }
+ tmu = (GrTmuVertex *) ((char *) tmu + sizeof(fxVertex));
+ }
}
/* need to compute W values for fogging purposes
*/
-static void fx_fake_fog_w( GLcontext *ctx,
- fxVertex *verts,
- struct vertex_buffer *VB,
- GLuint start, GLuint end )
+static void
+fx_fake_fog_w(GLcontext * ctx,
+ fxVertex * verts,
+ struct vertex_buffer *VB, GLuint start, GLuint end)
{
const GLfloat m10 = ctx->ProjectionMatrix.m[10];
const GLfloat m14 = ctx->ProjectionMatrix.m[14];
- GLfloat (*clip)[4] = VB->ClipPtr->data;
+ GLfloat(*clip)[4] = VB->ClipPtr->data;
GLubyte *clipmask = VB->ClipMask;
GLuint i;
- for ( i = start ; i < end ; i++) {
+ for (i = start; i < end; i++) {
if (clipmask[i] == 0) {
- verts[i].v.oow = - m10 / (clip[i][2] - m14); /* -1/zEye */
+ verts[i].v.oow = -m10 / (clip[i][2] - m14); /* -1/zEye */
}
}
}
@@ -238,59 +238,61 @@ static tfxSetupFunc setupfuncs[MAX_SETUP];
static void
-fxsetup_invalid( GLcontext *ctx, GLuint start, GLuint end )
+fxsetup_invalid(GLcontext * ctx, GLuint start, GLuint end)
{
fprintf(stderr, "fxMesa: invalid setup function\n");
(void) (ctx && start && end);
}
-void fxDDSetupInit( void )
+void
+fxDDSetupInit(void)
{
GLuint i;
- for (i = 0 ; i < Elements(setupfuncs) ; i++)
+ for (i = 0; i < Elements(setupfuncs); i++)
setupfuncs[i] = fxsetup_invalid;
setupfuncs[SETUP_XYZW] = fxsetupXYZW;
- setupfuncs[SETUP_XYZW|SETUP_RGBA] = fxsetupXYZWRGBA;
- setupfuncs[SETUP_XYZW|SETUP_TMU0] = fxsetupXYZWT0;
- setupfuncs[SETUP_XYZW|SETUP_TMU1] = fxsetupXYZWT1;
- setupfuncs[SETUP_XYZW|SETUP_TMU0|SETUP_RGBA] = fxsetupXYZWRGBAT0;
- setupfuncs[SETUP_XYZW|SETUP_TMU1|SETUP_RGBA] = fxsetupXYZWRGBAT1;
- setupfuncs[SETUP_XYZW|SETUP_TMU1|SETUP_TMU0] = fxsetupXYZWT0T1;
- setupfuncs[SETUP_XYZW|SETUP_TMU1|SETUP_TMU0|SETUP_RGBA] =
+ setupfuncs[SETUP_XYZW | SETUP_RGBA] = fxsetupXYZWRGBA;
+ setupfuncs[SETUP_XYZW | SETUP_TMU0] = fxsetupXYZWT0;
+ setupfuncs[SETUP_XYZW | SETUP_TMU1] = fxsetupXYZWT1;
+ setupfuncs[SETUP_XYZW | SETUP_TMU0 | SETUP_RGBA] = fxsetupXYZWRGBAT0;
+ setupfuncs[SETUP_XYZW | SETUP_TMU1 | SETUP_RGBA] = fxsetupXYZWRGBAT1;
+ setupfuncs[SETUP_XYZW | SETUP_TMU1 | SETUP_TMU0] = fxsetupXYZWT0T1;
+ setupfuncs[SETUP_XYZW | SETUP_TMU1 | SETUP_TMU0 | SETUP_RGBA] =
fxsetupXYZWRGBAT0T1;
- setupfuncs[SETUP_XYZW|SETUP_SNAP] = fxsetupXYZW_SNAP;
- setupfuncs[SETUP_XYZW|SETUP_SNAP|SETUP_RGBA] = fxsetupXYZW_SNAP_RGBA;
- setupfuncs[SETUP_XYZW|SETUP_SNAP|SETUP_TMU0] = fxsetupXYZW_SNAP_T0;
- setupfuncs[SETUP_XYZW|SETUP_SNAP|SETUP_TMU1] = fxsetupXYZW_SNAP_T1;
- setupfuncs[SETUP_XYZW|SETUP_SNAP|SETUP_TMU0|SETUP_RGBA] =
+ setupfuncs[SETUP_XYZW | SETUP_SNAP] = fxsetupXYZW_SNAP;
+ setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_RGBA] = fxsetupXYZW_SNAP_RGBA;
+ setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU0] = fxsetupXYZW_SNAP_T0;
+ setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU1] = fxsetupXYZW_SNAP_T1;
+ setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU0 | SETUP_RGBA] =
fxsetupXYZW_SNAP_RGBAT0;
- setupfuncs[SETUP_XYZW|SETUP_SNAP|SETUP_TMU1|SETUP_RGBA] =
+ setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU1 | SETUP_RGBA] =
fxsetupXYZW_SNAP_RGBAT1;
- setupfuncs[SETUP_XYZW|SETUP_SNAP|SETUP_TMU1|SETUP_TMU0] =
+ setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU1 | SETUP_TMU0] =
fxsetupXYZW_SNAP_T0T1;
- setupfuncs[SETUP_XYZW|SETUP_SNAP|SETUP_TMU1|SETUP_TMU0|SETUP_RGBA] =
- fxsetupXYZW_SNAP_RGBAT0T1;
+ setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU1 | SETUP_TMU0 | SETUP_RGBA]
+ = fxsetupXYZW_SNAP_RGBAT0T1;
setupfuncs[SETUP_RGBA] = fxsetupRGBA;
setupfuncs[SETUP_TMU0] = fxsetupT0;
setupfuncs[SETUP_TMU1] = fxsetupT1;
- setupfuncs[SETUP_TMU1|SETUP_TMU0] = fxsetupT0T1;
- setupfuncs[SETUP_TMU0|SETUP_RGBA] = fxsetupRGBAT0;
- setupfuncs[SETUP_TMU1|SETUP_RGBA] = fxsetupRGBAT1;
- setupfuncs[SETUP_TMU1|SETUP_TMU0|SETUP_RGBA] = fxsetupRGBAT0T1;
+ setupfuncs[SETUP_TMU1 | SETUP_TMU0] = fxsetupT0T1;
+ setupfuncs[SETUP_TMU0 | SETUP_RGBA] = fxsetupRGBAT0;
+ setupfuncs[SETUP_TMU1 | SETUP_RGBA] = fxsetupRGBAT1;
+ setupfuncs[SETUP_TMU1 | SETUP_TMU0 | SETUP_RGBA] = fxsetupRGBAT0T1;
}
-void fx_validate_BuildProjVerts(GLcontext *ctx, GLuint start, GLuint count,
- GLuint newinputs )
+void
+fx_validate_BuildProjVerts(GLcontext * ctx, GLuint start, GLuint count,
+ GLuint newinputs)
{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
- if (!fxMesa->is_in_hardware)
+ if (!fxMesa->is_in_hardware)
ctx->Driver.BuildProjectedVertices = _swsetup_BuildProjectedVertices;
else {
GLuint setupindex = SETUP_XYZW;
@@ -299,56 +301,61 @@ void fx_validate_BuildProjVerts(GLcontext *ctx, GLuint start, GLuint count,
fxMesa->tmu_source[1] = 1;
fxMesa->tex_dest[0] = SETUP_TMU0;
fxMesa->tex_dest[1] = SETUP_TMU1;
-
+
/* For flat and two-side-lit triangles, colors will always be added
* to vertices in the triangle functions. Vertices will *always*
* have rbga values, but only sometimes will they come from here.
*/
- if ((ctx->_TriangleCaps & (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE)) == 0)
+ if ((ctx->_TriangleCaps & (DD_FLATSHADE | DD_TRI_LIGHT_TWOSIDE)) == 0)
setupindex |= SETUP_RGBA;
- if (ctx->Texture._ReallyEnabled & TEXTURE0_2D)
+ if (ctx->Texture._ReallyEnabled & TEXTURE0_2D)
setupindex |= SETUP_TMU0;
if (ctx->Texture._ReallyEnabled & TEXTURE1_2D) {
if ((ctx->Texture._ReallyEnabled & TEXTURE0_2D) == 0) {
- fxMesa->tmu_source[0] = 1; fxMesa->tex_dest[0] = SETUP_TMU1;
- fxMesa->tmu_source[1] = 0; fxMesa->tex_dest[1] = SETUP_TMU0;
+ fxMesa->tmu_source[0] = 1;
+ fxMesa->tex_dest[0] = SETUP_TMU1;
+ fxMesa->tmu_source[1] = 0;
+ fxMesa->tex_dest[1] = SETUP_TMU0;
setupindex |= SETUP_TMU0;
- } else {
+ }
+ else {
setupindex |= SETUP_TMU1;
}
}
- if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_PIPELINE|VERBOSE_STATE))
- fxPrintSetupFlags("fxmesa: vertex setup function", setupindex);
-
+ if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_PIPELINE | VERBOSE_STATE))
+ fxPrintSetupFlags("fxmesa: vertex setup function", setupindex);
+
fxMesa->setupindex = setupindex;
ctx->Driver.BuildProjectedVertices = fx_BuildProjVerts;
}
- ctx->Driver.BuildProjectedVertices( ctx, start, count, newinputs );
+ ctx->Driver.BuildProjectedVertices(ctx, start, count, newinputs);
}
-void fx_BuildProjVerts( GLcontext *ctx, GLuint start, GLuint count,
- GLuint newinputs )
+void
+fx_BuildProjVerts(GLcontext * ctx, GLuint start, GLuint count,
+ GLuint newinputs)
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
if (newinputs == ~0) {
/* build interpolated vertices */
- setupfuncs[fxMesa->setupindex]( ctx, start, count );
- } else {
+ setupfuncs[fxMesa->setupindex] (ctx, start, count);
+ }
+ else {
GLuint ind = fxMesa->setup_gone;
fxMesa->setup_gone = 0;
-
- if (newinputs & VERT_CLIP)
+
+ if (newinputs & VERT_CLIP)
ind = fxMesa->setupindex; /* clipmask has potentially changed */
else {
if (newinputs & VERT_TEX0)
ind |= fxMesa->tex_dest[0];
-
+
if (newinputs & VERT_TEX1)
ind |= fxMesa->tex_dest[1];
@@ -359,30 +366,32 @@ void fx_BuildProjVerts( GLcontext *ctx, GLuint start, GLuint count,
}
if (ind) {
- if (fxMesa->new_state)
- fxSetupFXUnits( ctx ); /* why? */
-
+ if (fxMesa->new_state)
+ fxSetupFXUnits(ctx); /* why? */
+
if (VB->importable_data & newinputs)
- VB->import_data( ctx, VB->importable_data & newinputs,
- VEC_BAD_STRIDE );
-
- setupfuncs[ind]( ctx, start, count );
+ VB->import_data(ctx, VB->importable_data & newinputs,
+ VEC_BAD_STRIDE);
+
+ setupfuncs[ind] (ctx, start, count);
}
}
}
-void fxAllocVB( GLcontext *ctx )
+void
+fxAllocVB(GLcontext * ctx)
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
- fxMesa->verts = ALIGN_MALLOC( tnl->vb.Size * sizeof(fxMesa->verts[0]), 32 );
+ fxMesa->verts = ALIGN_MALLOC(tnl->vb.Size * sizeof(fxMesa->verts[0]), 32);
}
-void fxFreeVB( GLcontext *ctx )
+void
+fxFreeVB(GLcontext * ctx)
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
if (fxMesa->verts)
- ALIGN_FREE( fxMesa->verts );
+ ALIGN_FREE(fxMesa->verts);
fxMesa->verts = 0;
}
@@ -395,9 +404,10 @@ void fxFreeVB( GLcontext *ctx )
*/
extern int gl_fx_dummy_function_vsetup(void);
-int gl_fx_dummy_function_vsetup(void)
+int
+gl_fx_dummy_function_vsetup(void)
{
- return 0;
+ return 0;
}
-#endif /* FX */
+#endif /* FX */
diff --git a/src/mesa/drivers/glide/fxvbtmp.h b/src/mesa/drivers/glide/fxvbtmp.h
index 0133758295..8d7649c6bb 100644
--- a/src/mesa/drivers/glide/fxvbtmp.h
+++ b/src/mesa/drivers/glide/fxvbtmp.h
@@ -27,17 +27,18 @@
*/
-static void NAME(GLcontext *ctx, GLuint start, GLuint end )
+static void
+NAME(GLcontext * ctx, GLuint start, GLuint end)
{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
fxVertex *verts = fxMesa->verts;
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
GLuint tmu0_source = fxMesa->tmu_source[0];
GLuint tmu1_source = fxMesa->tmu_source[1];
- GLfloat (*tmu0_data)[4];
- GLfloat (*tmu1_data)[4];
- GLubyte (*color)[4];
- GLfloat (*proj)[4] = VB->ProjectedClipPtr->data;
+ GLfloat(*tmu0_data)[4];
+ GLfloat(*tmu1_data)[4];
+ GLubyte(*color)[4];
+ GLfloat(*proj)[4] = VB->ProjectedClipPtr->data;
fxVertex *v = &verts[start];
GLfloat sscale0 = fxMesa->s0scale;
GLfloat tscale0 = fxMesa->t0scale;
@@ -45,36 +46,36 @@ static void NAME(GLcontext *ctx, GLuint start, GLuint end )
GLfloat tscale1 = fxMesa->t1scale;
GLubyte *clipmask = VB->ClipMask;
GLuint i;
- const GLfloat * const s = ctx->Viewport._WindowMap.m;
+ const GLfloat *const s = ctx->Viewport._WindowMap.m;
if (IND & SETUP_TMU0)
tmu0_data = VB->TexCoordPtr[tmu0_source]->data;
if (IND & SETUP_TMU1)
tmu1_data = VB->TexCoordPtr[tmu1_source]->data;
-
+
if (IND & SETUP_RGBA)
color = VB->ColorPtr[0]->data;
if (VB->ClipOrMask) {
- for (i = start ; i < end ; i++, v++) {
+ for (i = start; i < end; i++, v++) {
if (!clipmask[i]) {
if (IND & SETUP_XYZW) {
- v->v.x = s[0] * proj[i][0] + s[12];
- v->v.y = s[5] * proj[i][1] + s[13];
- v->v.ooz = s[10] * proj[i][2] + s[14];
- v->v.oow = proj[i][3];
-
+ v->v.x = s[0] * proj[i][0] + s[12];
+ v->v.y = s[5] * proj[i][1] + s[13];
+ v->v.ooz = s[10] * proj[i][2] + s[14];
+ v->v.oow = proj[i][3];
+
if (IND & SETUP_SNAP) {
#if defined(USE_IEEE)
- const float snapper = (3L<<18);
- v->v.x += snapper;
- v->v.x -= snapper;
- v->v.y += snapper;
- v->v.y -= snapper;
+ const float snapper = (3L << 18);
+ v->v.x += snapper;
+ v->v.x -= snapper;
+ v->v.y += snapper;
+ v->v.y -= snapper;
#else
- v->v.x = ((int)(v->v.x*16.0f)) * (1.0f/16.0f);
- v->v.y = ((int)(v->v.y*16.0f)) * (1.0f/16.0f);
+ v->v.x = ((int) (v->v.x * 16.0f)) * (1.0f / 16.0f);
+ v->v.y = ((int) (v->v.y * 16.0f)) * (1.0f / 16.0f);
#endif
}
}
@@ -85,34 +86,34 @@ static void NAME(GLcontext *ctx, GLuint start, GLuint end )
UBYTE_COLOR_TO_FLOAT_255_COLOR2(v->v.a, color[i][3]);
}
if (IND & SETUP_TMU0) {
- v->v.tmuvtx[0].sow = sscale0*tmu0_data[i][0]*v->v.oow;
- v->v.tmuvtx[0].tow = tscale0*tmu0_data[i][1]*v->v.oow;
+ v->v.tmuvtx[0].sow = sscale0 * tmu0_data[i][0] * v->v.oow;
+ v->v.tmuvtx[0].tow = tscale0 * tmu0_data[i][1] * v->v.oow;
}
if (IND & SETUP_TMU1) {
- v->v.tmuvtx[1].sow = sscale1*tmu1_data[i][0]*v->v.oow;
- v->v.tmuvtx[1].tow = tscale1*tmu1_data[i][1]*v->v.oow;
+ v->v.tmuvtx[1].sow = sscale1 * tmu1_data[i][0] * v->v.oow;
+ v->v.tmuvtx[1].tow = tscale1 * tmu1_data[i][1] * v->v.oow;
}
}
}
}
else {
- for (i = start ; i < end ; i++, v++) {
+ for (i = start; i < end; i++, v++) {
if (IND & SETUP_XYZW) {
- v->v.x = s[0] * proj[i][0] + s[12];
- v->v.y = s[5] * proj[i][1] + s[13];
- v->v.ooz = s[10] * proj[i][2] + s[14];
- v->v.oow = proj[i][3];
-
+ v->v.x = s[0] * proj[i][0] + s[12];
+ v->v.y = s[5] * proj[i][1] + s[13];
+ v->v.ooz = s[10] * proj[i][2] + s[14];
+ v->v.oow = proj[i][3];
+
if (IND & SETUP_SNAP) {
#if defined(USE_IEEE)
- const float snapper = (3L<<18);
- v->v.x += snapper;
- v->v.x -= snapper;
- v->v.y += snapper;
- v->v.y -= snapper;
+ const float snapper = (3L << 18);
+ v->v.x += snapper;
+ v->v.x -= snapper;
+ v->v.y += snapper;
+ v->v.y -= snapper;
#else
- v->v.x = ((int)(v->v.x*16.0f)) * (1.0f/16.0f);
- v->v.y = ((int)(v->v.y*16.0f)) * (1.0f/16.0f);
+ v->v.x = ((int) (v->v.x * 16.0f)) * (1.0f / 16.0f);
+ v->v.y = ((int) (v->v.y * 16.0f)) * (1.0f / 16.0f);
#endif
}
}
@@ -123,29 +124,27 @@ static void NAME(GLcontext *ctx, GLuint start, GLuint end )
UBYTE_COLOR_TO_FLOAT_255_COLOR2(v->v.a, color[i][3]);
}
if (IND & SETUP_TMU0) {
- v->v.tmuvtx[0].sow = sscale0*tmu0_data[i][0]*v->v.oow;
- v->v.tmuvtx[0].tow = tscale0*tmu0_data[i][1]*v->v.oow;
+ v->v.tmuvtx[0].sow = sscale0 * tmu0_data[i][0] * v->v.oow;
+ v->v.tmuvtx[0].tow = tscale0 * tmu0_data[i][1] * v->v.oow;
}
if (IND & SETUP_TMU1) {
- v->v.tmuvtx[1].sow = sscale1*tmu1_data[i][0]*v->v.oow;
- v->v.tmuvtx[1].tow = tscale1*tmu1_data[i][1]*v->v.oow;
+ v->v.tmuvtx[1].sow = sscale1 * tmu1_data[i][0] * v->v.oow;
+ v->v.tmuvtx[1].tow = tscale1 * tmu1_data[i][1] * v->v.oow;
}
}
}
-
+
if ((IND & SETUP_XYZW) &&
- ctx->ProjectionMatrix.m[15] != 0.0F &&
- ctx->Fog.Enabled)
- {
- fx_fake_fog_w( ctx, v, VB, start, end );
+ ctx->ProjectionMatrix.m[15] != 0.0F && ctx->Fog.Enabled) {
+ fx_fake_fog_w(ctx, v, VB, start, end);
}
/* Check for and enable projective texturing in each texture unit.
*/
- if (IND & (SETUP_TMU0|SETUP_TMU1)) {
+ if (IND & (SETUP_TMU0 | SETUP_TMU1)) {
GLuint tmu0_sz = 2;
GLuint tmu1_sz = 2;
- GLuint hs = fxMesa->stw_hint_state & ~(GR_STWHINT_W_DIFF_TMU0 |
+ GLuint hs = fxMesa->stw_hint_state & ~(GR_STWHINT_W_DIFF_TMU0 |
GR_STWHINT_W_DIFF_TMU1);
if (VB->TexCoordPtr[tmu0_source])
@@ -155,15 +154,15 @@ static void NAME(GLcontext *ctx, GLuint start, GLuint end )
tmu1_sz = VB->TexCoordPtr[tmu1_source]->size;
if (tmu0_sz == 4) {
- project_texcoords( v, VB, 0, tmu0_source, start, end );
+ project_texcoords(v, VB, 0, tmu0_source, start, end);
if (tmu1_sz == 4)
- project_texcoords( v, VB, 1, tmu1_source, start, end );
- else
- copy_w( v, VB, 1, start, end );
- hs |= (GR_STWHINT_W_DIFF_TMU0|GR_STWHINT_W_DIFF_TMU1);
- }
+ project_texcoords(v, VB, 1, tmu1_source, start, end);
+ else
+ copy_w(v, VB, 1, start, end);
+ hs |= (GR_STWHINT_W_DIFF_TMU0 | GR_STWHINT_W_DIFF_TMU1);
+ }
else if (tmu1_sz == 4) {
- project_texcoords( v, VB, 1, tmu1_source, start, end );
+ project_texcoords(v, VB, 1, tmu1_source, start, end);
hs |= GR_STWHINT_W_DIFF_TMU1;
}
diff --git a/src/mesa/drivers/glide/fxwgl.c b/src/mesa/drivers/glide/fxwgl.c
index cff1e621a3..1bcde83e10 100644
--- a/src/mesa/drivers/glide/fxwgl.c
+++ b/src/mesa/drivers/glide/fxwgl.c
@@ -51,14 +51,15 @@
#ifdef __WIN32__
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
#include <windows.h>
#include "GL/gl.h"
#ifdef __cplusplus
- }
+}
#endif
#include <stdio.h>
@@ -69,171 +70,169 @@ extern "C" {
struct __extensions__
{
- PROC proc;
- char *name;
+ PROC proc;
+ char *name;
};
struct __pixelformat__
{
- PIXELFORMATDESCRIPTOR pfd;
- GLint mesaAttr[MAX_MESA_ATTRS];
+ PIXELFORMATDESCRIPTOR pfd;
+ GLint mesaAttr[MAX_MESA_ATTRS];
};
WINGDIAPI void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *);
-static struct __extensions__ ext[] = {
+static struct __extensions__ ext[] = {
#ifdef GL_EXT_polygon_offset
- { (PROC)glPolygonOffsetEXT, "glPolygonOffsetEXT" },
+ {(PROC) glPolygonOffsetEXT, "glPolygonOffsetEXT"},
#endif
- { (PROC)glBlendEquationEXT, "glBlendEquationEXT" },
- { (PROC)glBlendColorEXT, "glBlendColorExt" },
- { (PROC)glVertexPointerEXT, "glVertexPointerEXT" },
- { (PROC)glNormalPointerEXT, "glNormalPointerEXT" },
- { (PROC)glColorPointerEXT, "glColorPointerEXT" },
- { (PROC)glIndexPointerEXT, "glIndexPointerEXT" },
- { (PROC)glTexCoordPointerEXT, "glTexCoordPointer" },
- { (PROC)glEdgeFlagPointerEXT, "glEdgeFlagPointerEXT" },
- { (PROC)glGetPointervEXT, "glGetPointervEXT" },
- { (PROC)glArrayElementEXT, "glArrayElementEXT" },
- { (PROC)glDrawArraysEXT, "glDrawArrayEXT" },
- { (PROC)glAreTexturesResidentEXT, "glAreTexturesResidentEXT" },
- { (PROC)glBindTextureEXT, "glBindTextureEXT" },
- { (PROC)glDeleteTexturesEXT, "glDeleteTexturesEXT" },
- { (PROC)glGenTexturesEXT, "glGenTexturesEXT" },
- { (PROC)glIsTextureEXT, "glIsTextureEXT" },
- { (PROC)glPrioritizeTexturesEXT, "glPrioritizeTexturesEXT" },
- { (PROC)glCopyTexSubImage3DEXT, "glCopyTexSubImage3DEXT" },
- { (PROC)glTexImage3DEXT, "glTexImage3DEXT" },
- { (PROC)glTexSubImage3DEXT, "glTexSubImage3DEXT" },
- { (PROC)gl3DfxSetPaletteEXT, "3DFX_set_global_palette" },
- { (PROC)glColorTableEXT, "glColorTableEXT" },
- { (PROC)glColorSubTableEXT, "glColorSubTableEXT" },
- { (PROC)glGetColorTableEXT, "glGetColorTableEXT" },
- { (PROC)glGetColorTableParameterfvEXT, "glGetColorTableParameterfvEXT" },
- { (PROC)glGetColorTableParameterivEXT, "glGetColorTableParameterivEXT" },
- { (PROC)glPointParameterfEXT, "glPointParameterfEXT" },
- { (PROC)glPointParameterfvEXT, "glPointParameterfvEXT" },
- { (PROC)glBlendFuncSeparateINGR, "glBlendFuncSeparateINGR" },
- { (PROC)glActiveTextureARB, "glActiveTextureARB" },
- { (PROC)glClientActiveTextureARB, "glClientActiveTextureARB" },
- { (PROC)glMultiTexCoord1dARB, "glMultiTexCoord1dARB" },
- { (PROC)glMultiTexCoord1dvARB, "glMultiTexCoord1dvARB" },
- { (PROC)glMultiTexCoord1fARB, "glMultiTexCoord1fARB" },
- { (PROC)glMultiTexCoord1fvARB, "glMultiTexCoord1fvARB" },
- { (PROC)glMultiTexCoord1iARB, "glMultiTexCoord1iARB" },
- { (PROC)glMultiTexCoord1ivARB, "glMultiTexCoord1ivARB" },
- { (PROC)glMultiTexCoord1sARB, "glMultiTexCoord1sARB" },
- { (PROC)glMultiTexCoord1svARB, "glMultiTexCoord1svARB" },
- { (PROC)glMultiTexCoord2dARB, "glMultiTexCoord2dARB" },
- { (PROC)glMultiTexCoord2dvARB, "glMultiTexCoord2dvARB" },
- { (PROC)glMultiTexCoord2fARB, "glMultiTexCoord2fARB" },
- { (PROC)glMultiTexCoord2fvARB, "glMultiTexCoord2fvARB" },
- { (PROC)glMultiTexCoord2iARB, "glMultiTexCoord2iARB" },
- { (PROC)glMultiTexCoord2ivARB, "glMultiTexCoord2ivARB" },
- { (PROC)glMultiTexCoord2sARB, "glMultiTexCoord2sARB" },
- { (PROC)glMultiTexCoord2svARB, "glMultiTexCoord2svARB" },
- { (PROC)glMultiTexCoord3dARB, "glMultiTexCoord3dARB" },
- { (PROC)glMultiTexCoord3dvARB, "glMultiTexCoord3dvARB" },
- { (PROC)glMultiTexCoord3fARB, "glMultiTexCoord3fARB" },
- { (PROC)glMultiTexCoord3fvARB, "glMultiTexCoord3fvARB" },
- { (PROC)glMultiTexCoord3iARB, "glMultiTexCoord3iARB" },
- { (PROC)glMultiTexCoord3ivARB, "glMultiTexCoord3ivARB" },
- { (PROC)glMultiTexCoord3sARB, "glMultiTexCoord3sARB" },
- { (PROC)glMultiTexCoord3svARB, "glMultiTexCoord3svARB" },
- { (PROC)glMultiTexCoord4dARB, "glMultiTexCoord4dARB" },
- { (PROC)glMultiTexCoord4dvARB, "glMultiTexCoord4dvARB" },
- { (PROC)glMultiTexCoord4fARB, "glMultiTexCoord4fARB" },
- { (PROC)glMultiTexCoord4fvARB, "glMultiTexCoord4fvARB" },
- { (PROC)glMultiTexCoord4iARB, "glMultiTexCoord4iARB" },
- { (PROC)glMultiTexCoord4ivARB, "glMultiTexCoord4ivARB" },
- { (PROC)glMultiTexCoord4sARB, "glMultiTexCoord4sARB" },
- { (PROC)glMultiTexCoord4svARB, "glMultiTexCoord4svARB" },
- { (PROC)glLockArraysEXT, "glLockArraysEXT" },
- { (PROC)glUnlockArraysEXT, "glUnlockArraysEXT" }
+ {(PROC) glBlendEquationEXT, "glBlendEquationEXT"},
+ {(PROC) glBlendColorEXT, "glBlendColorExt"},
+ {(PROC) glVertexPointerEXT, "glVertexPointerEXT"},
+ {(PROC) glNormalPointerEXT, "glNormalPointerEXT"},
+ {(PROC) glColorPointerEXT, "glColorPointerEXT"},
+ {(PROC) glIndexPointerEXT, "glIndexPointerEXT"},
+ {(PROC) glTexCoordPointerEXT, "glTexCoordPointer"},
+ {(PROC) glEdgeFlagPointerEXT, "glEdgeFlagPointerEXT"},
+ {(PROC) glGetPointervEXT, "glGetPointervEXT"},
+ {(PROC) glArrayElementEXT, "glArrayElementEXT"},
+ {(PROC) glDrawArraysEXT, "glDrawArrayEXT"},
+ {(PROC) glAreTexturesResidentEXT, "glAreTexturesResidentEXT"},
+ {(PROC) glBindTextureEXT, "glBindTextureEXT"},
+ {(PROC) glDeleteTexturesEXT, "glDeleteTexturesEXT"},
+ {(PROC) glGenTexturesEXT, "glGenTexturesEXT"},
+ {(PROC) glIsTextureEXT, "glIsTextureEXT"},
+ {(PROC) glPrioritizeTexturesEXT, "glPrioritizeTexturesEXT"},
+ {(PROC) glCopyTexSubImage3DEXT, "glCopyTexSubImage3DEXT"},
+ {(PROC) glTexImage3DEXT, "glTexImage3DEXT"},
+ {(PROC) glTexSubImage3DEXT, "glTexSubImage3DEXT"},
+ {(PROC) gl3DfxSetPaletteEXT, "3DFX_set_global_palette"},
+ {(PROC) glColorTableEXT, "glColorTableEXT"},
+ {(PROC) glColorSubTableEXT, "glColorSubTableEXT"},
+ {(PROC) glGetColorTableEXT, "glGetColorTableEXT"},
+ {(PROC) glGetColorTableParameterfvEXT, "glGetColorTableParameterfvEXT"},
+ {(PROC) glGetColorTableParameterivEXT, "glGetColorTableParameterivEXT"},
+ {(PROC) glPointParameterfEXT, "glPointParameterfEXT"},
+ {(PROC) glPointParameterfvEXT, "glPointParameterfvEXT"},
+ {(PROC) glBlendFuncSeparateINGR, "glBlendFuncSeparateINGR"},
+ {(PROC) glActiveTextureARB, "glActiveTextureARB"},
+ {(PROC) glClientActiveTextureARB, "glClientActiveTextureARB"},
+ {(PROC) glMultiTexCoord1dARB, "glMultiTexCoord1dARB"},
+ {(PROC) glMultiTexCoord1dvARB, "glMultiTexCoord1dvARB"},
+ {(PROC) glMultiTexCoord1fARB, "glMultiTexCoord1fARB"},
+ {(PROC) glMultiTexCoord1fvARB, "glMultiTexCoord1fvARB"},
+ {(PROC) glMultiTexCoord1iARB, "glMultiTexCoord1iARB"},
+ {(PROC) glMultiTexCoord1ivARB, "glMultiTexCoord1ivARB"},
+ {(PROC) glMultiTexCoord1sARB, "glMultiTexCoord1sARB"},
+ {(PROC) glMultiTexCoord1svARB, "glMultiTexCoord1svARB"},
+ {(PROC) glMultiTexCoord2dARB, "glMultiTexCoord2dARB"},
+ {(PROC) glMultiTexCoord2dvARB, "glMultiTexCoord2dvARB"},
+ {(PROC) glMultiTexCoord2fARB, "glMultiTexCoord2fARB"},
+ {(PROC) glMultiTexCoord2fvARB, "glMultiTexCoord2fvARB"},
+ {(PROC) glMultiTexCoord2iARB, "glMultiTexCoord2iARB"},
+ {(PROC) glMultiTexCoord2ivARB, "glMultiTexCoord2ivARB"},
+ {(PROC) glMultiTexCoord2sARB, "glMultiTexCoord2sARB"},
+ {(PROC) glMultiTexCoord2svARB, "glMultiTexCoord2svARB"},
+ {(PROC) glMultiTexCoord3dARB, "glMultiTexCoord3dARB"},
+ {(PROC) glMultiTexCoord3dvARB, "glMultiTexCoord3dvARB"},
+ {(PROC) glMultiTexCoord3fARB, "glMultiTexCoord3fARB"},
+ {(PROC) glMultiTexCoord3fvARB, "glMultiTexCoord3fvARB"},
+ {(PROC) glMultiTexCoord3iARB, "glMultiTexCoord3iARB"},
+ {(PROC) glMultiTexCoord3ivARB, "glMultiTexCoord3ivARB"},
+ {(PROC) glMultiTexCoord3sARB, "glMultiTexCoord3sARB"},
+ {(PROC) glMultiTexCoord3svARB, "glMultiTexCoord3svARB"},
+ {(PROC) glMultiTexCoord4dARB, "glMultiTexCoord4dARB"},
+ {(PROC) glMultiTexCoord4dvARB, "glMultiTexCoord4dvARB"},
+ {(PROC) glMultiTexCoord4fARB, "glMultiTexCoord4fARB"},
+ {(PROC) glMultiTexCoord4fvARB, "glMultiTexCoord4fvARB"},
+ {(PROC) glMultiTexCoord4iARB, "glMultiTexCoord4iARB"},
+ {(PROC) glMultiTexCoord4ivARB, "glMultiTexCoord4ivARB"},
+ {(PROC) glMultiTexCoord4sARB, "glMultiTexCoord4sARB"},
+ {(PROC) glMultiTexCoord4svARB, "glMultiTexCoord4svARB"},
+ {(PROC) glLockArraysEXT, "glLockArraysEXT"},
+ {(PROC) glUnlockArraysEXT, "glUnlockArraysEXT"}
};
static int qt_ext = sizeof(ext) / sizeof(ext[0]);
-struct __pixelformat__ pix[] =
-{
- /* None */
- {
+struct __pixelformat__ pix[] = {
+ /* None */
+ {
{
- sizeof(PIXELFORMATDESCRIPTOR), 1,
- PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
- PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
- PFD_TYPE_RGBA,
- 32,
- 8,0,8,8,8,16,0,24,
- 0,0,0,0,0,
- 0,
- 0,
- 0,
- PFD_MAIN_PLANE,
- 0,0,0,0
- },
+ sizeof(PIXELFORMATDESCRIPTOR), 1,
+ PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
+ PFD_DOUBLEBUFFER | PFD_SWAP_COPY,
+ PFD_TYPE_RGBA,
+ 32,
+ 8, 0, 8, 8, 8, 16, 0, 24,
+ 0, 0, 0, 0, 0,
+ 0,
+ 0,
+ 0,
+ PFD_MAIN_PLANE,
+ 0, 0, 0, 0}
+ ,
{
- FXMESA_DOUBLEBUFFER,
- FXMESA_ALPHA_SIZE, 0,
- FXMESA_DEPTH_SIZE, 0,
- FXMESA_STENCIL_SIZE, 0,
- FXMESA_ACCUM_SIZE, 0,
- FXMESA_NONE
+ FXMESA_DOUBLEBUFFER,
+ FXMESA_ALPHA_SIZE, 0,
+ FXMESA_DEPTH_SIZE, 0,
+ FXMESA_STENCIL_SIZE, 0,
+ FXMESA_ACCUM_SIZE, 0,
+ FXMESA_NONE}
}
- },
+ ,
- /* Alpha */
- {
+ /* Alpha */
+ {
{
- sizeof(PIXELFORMATDESCRIPTOR), 1,
- PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
- PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
- PFD_TYPE_RGBA,
- 32,
- 8,0,8,8,8,16,8,24,
- 0,0,0,0,0,
- 0,
- 0,
- 0,
- PFD_MAIN_PLANE,
- 0,0,0,0
- },
+ sizeof(PIXELFORMATDESCRIPTOR), 1,
+ PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
+ PFD_DOUBLEBUFFER | PFD_SWAP_COPY,
+ PFD_TYPE_RGBA,
+ 32,
+ 8, 0, 8, 8, 8, 16, 8, 24,
+ 0, 0, 0, 0, 0,
+ 0,
+ 0,
+ 0,
+ PFD_MAIN_PLANE,
+ 0, 0, 0, 0}
+ ,
{
- FXMESA_DOUBLEBUFFER,
- FXMESA_ALPHA_SIZE, 8,
- FXMESA_DEPTH_SIZE, 0,
- FXMESA_STENCIL_SIZE, 0,
- FXMESA_ACCUM_SIZE, 0,
- FXMESA_NONE
+ FXMESA_DOUBLEBUFFER,
+ FXMESA_ALPHA_SIZE, 8,
+ FXMESA_DEPTH_SIZE, 0,
+ FXMESA_STENCIL_SIZE, 0,
+ FXMESA_ACCUM_SIZE, 0,
+ FXMESA_NONE}
}
- },
+ ,
- /* Depth */
- {
+ /* Depth */
+ {
{
- sizeof(PIXELFORMATDESCRIPTOR), 1,
- PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
- PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
- PFD_TYPE_RGBA,
- 32,
- 8,0,8,8,8,16,0,24,
- 0,0,0,0,0,
- 16,
- 0,
- 0,
- PFD_MAIN_PLANE,
- 0,0,0,0
- },
+ sizeof(PIXELFORMATDESCRIPTOR), 1,
+ PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
+ PFD_DOUBLEBUFFER | PFD_SWAP_COPY,
+ PFD_TYPE_RGBA,
+ 32,
+ 8, 0, 8, 8, 8, 16, 0, 24,
+ 0, 0, 0, 0, 0,
+ 16,
+ 0,
+ 0,
+ PFD_MAIN_PLANE,
+ 0, 0, 0, 0}
+ ,
{
- FXMESA_DOUBLEBUFFER,
- FXMESA_ALPHA_SIZE, 0,
- FXMESA_DEPTH_SIZE, 16,
- FXMESA_STENCIL_SIZE, 0,
- FXMESA_ACCUM_SIZE, 0,
- FXMESA_NONE
+ FXMESA_DOUBLEBUFFER,
+ FXMESA_ALPHA_SIZE, 0,
+ FXMESA_DEPTH_SIZE, 16,
+ FXMESA_STENCIL_SIZE, 0,
+ FXMESA_ACCUM_SIZE, 0,
+ FXMESA_NONE}
}
- }
};
static int qt_pix = sizeof(pix) / sizeof(pix[0]);
@@ -247,623 +246,651 @@ static GLboolean haveDualHead;
/* For the in-window-rendering hack */
-static GLboolean gdiWindowHack;
-static GLboolean gdiWindowHackEna;
-static void *dibSurfacePtr;
-static BITMAPINFO *dibBMI;
-static HBITMAP dibHBM;
-static HWND dibWnd;
-
-LONG GLAPIENTRY __wglMonitor(HWND hwnd,UINT message,UINT wParam,LONG lParam)
-
-{
- long ret; /* Now gives the resized window at the end to hWNDOldProc */
-
- if(ctx && hwnd == hWND) {
- switch(message) {
- case WM_PAINT:
- case WM_MOVE:
- break;
- case WM_DISPLAYCHANGE:
- case WM_SIZE:
- if (wParam != SIZE_MINIMIZED) {
- static int moving = 0;
- if (!moving) {
- if(fxQueryHardware()!=GR_SSTTYPE_VOODOO) {
- if(!FX_grSstControl(GR_CONTROL_RESIZE)) {
- moving = 1;
- SetWindowPos(hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOZORDER);
- moving = 0;
- if(!FX_grSstControl(GR_CONTROL_RESIZE)) {
- /*MessageBox(0,_T("Error changing windowsize"),_T("fxMESA"),MB_OK);*/
- PostMessage(hWND,WM_CLOSE,0,0);
- }
- }
- }
-
- /* Do the clipping in the glide library */
- FX_grClipWindow(0,0,FX_grSstScreenWidth(),FX_grSstScreenHeight());
- /* And let the new size set in the context */
- fxMesaUpdateScreenSize(ctx);
- }
+static GLboolean gdiWindowHack;
+static GLboolean gdiWindowHackEna;
+static void *dibSurfacePtr;
+static BITMAPINFO *dibBMI;
+static HBITMAP dibHBM;
+static HWND dibWnd;
+
+LONG GLAPIENTRY
+__wglMonitor(HWND hwnd, UINT message, UINT wParam, LONG lParam)
+ {
+ long ret; /* Now gives the resized window at the end to hWNDOldProc */
+
+ if (ctx && hwnd == hWND) {
+ switch (message) {
+ case WM_PAINT:
+ case WM_MOVE:
+ break;
+ case WM_DISPLAYCHANGE:
+ case WM_SIZE:
+ if (wParam != SIZE_MINIMIZED) {
+ static int moving = 0;
+ if (!moving) {
+ if (fxQueryHardware() != GR_SSTTYPE_VOODOO) {
+ if (!FX_grSstControl(GR_CONTROL_RESIZE)) {
+ moving = 1;
+ SetWindowPos(hwnd, 0, 0, 0, 300, 300,
+ SWP_NOMOVE | SWP_NOZORDER);
+ moving = 0;
+ if (!FX_grSstControl(GR_CONTROL_RESIZE)) {
+ /*MessageBox(0,_T("Error changing windowsize"),_T("fxMESA"),MB_OK); */
+ PostMessage(hWND, WM_CLOSE, 0, 0);
+ }
+ }
+ }
+
+ /* Do the clipping in the glide library */
+ FX_grClipWindow(0, 0, FX_grSstScreenWidth(),
+ FX_grSstScreenHeight());
+ /* And let the new size set in the context */
+ fxMesaUpdateScreenSize(ctx);
+ }
+ }
+ break;
+ case WM_ACTIVATE:
+ if ((fxQueryHardware() == GR_SSTTYPE_VOODOO) &&
+ (!gdiWindowHack) && (!haveDualHead)) {
+ WORD fActive = LOWORD(wParam);
+ BOOL fMinimized = (BOOL) HIWORD(wParam);
+
+ if ((fActive == WA_INACTIVE) || fMinimized)
+ FX_grSstControl(GR_CONTROL_DEACTIVATE);
+ else
+ FX_grSstControl(GR_CONTROL_ACTIVATE);
+ }
+ break;
+ case WM_SHOWWINDOW:
+ break;
+ case WM_SYSKEYDOWN:
+ case WM_SYSCHAR:
+ if (gdiWindowHackEna && (VK_RETURN == wParam)) {
+ if (gdiWindowHack) {
+ gdiWindowHack = GL_FALSE;
+ FX_grSstControl(GR_CONTROL_ACTIVATE);
+ }
+ else {
+ gdiWindowHack = GL_TRUE;
+ FX_grSstControl(GR_CONTROL_DEACTIVATE);
+ }
+ }
+ break;
}
- break;
- case WM_ACTIVATE:
- if((fxQueryHardware()==GR_SSTTYPE_VOODOO) &&
- (!gdiWindowHack) &&
- (!haveDualHead)) {
- WORD fActive = LOWORD(wParam);
- BOOL fMinimized = (BOOL) HIWORD(wParam);
-
- if((fActive == WA_INACTIVE) || fMinimized)
- FX_grSstControl(GR_CONTROL_DEACTIVATE);
- else
- FX_grSstControl(GR_CONTROL_ACTIVATE);
- }
- break;
- case WM_SHOWWINDOW:
- break;
- case WM_SYSKEYDOWN:
- case WM_SYSCHAR:
- if(gdiWindowHackEna && (VK_RETURN == wParam)) {
- if(gdiWindowHack) {
- gdiWindowHack = GL_FALSE;
- FX_grSstControl(GR_CONTROL_ACTIVATE);
- } else {
- gdiWindowHack = GL_TRUE;
- FX_grSstControl(GR_CONTROL_DEACTIVATE);
- }
- }
- break;
- }
- }
+ }
- /* Finaly call the hWNDOldProc, which handles the resize witch the
- now changed window sizes */
- ret = CallWindowProc( hWNDOldProc, hwnd, message, wParam, lParam );
+ /* Finaly call the hWNDOldProc, which handles the resize witch the
+ now changed window sizes */
+ ret = CallWindowProc(hWNDOldProc, hwnd, message, wParam, lParam);
- return(ret);
+ return (ret);
}
-BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc,HGLRC hglrcDst,UINT mask)
+BOOL GLAPIENTRY
+wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
{
- return(FALSE);
+ return (FALSE);
}
-HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
+HGLRC GLAPIENTRY
+wglCreateContext(HDC hdc)
{
- HWND hWnd;
- WNDPROC oldProc;
- int error;
-
- if(ctx) {
- SetLastError(0);
- return(NULL);
- }
-
- if(!(hWnd = WindowFromDC(hdc))) {
- SetLastError(0);
- return(NULL);
- }
-
- if(curPFD == 0) {
- SetLastError(0);
- return(NULL);
- }
-
- if((oldProc = (WNDPROC)GetWindowLong(hWnd,GWL_WNDPROC)) != __wglMonitor) {
- hWNDOldProc = oldProc;
- SetWindowLong(hWnd,GWL_WNDPROC,(LONG)__wglMonitor);
- }
+ HWND hWnd;
+ WNDPROC oldProc;
+ int error;
+
+ if (ctx) {
+ SetLastError(0);
+ return (NULL);
+ }
+
+ if (!(hWnd = WindowFromDC(hdc))) {
+ SetLastError(0);
+ return (NULL);
+ }
+
+ if (curPFD == 0) {
+ SetLastError(0);
+ return (NULL);
+ }
+
+ if ((oldProc = (WNDPROC) GetWindowLong(hWnd, GWL_WNDPROC)) != __wglMonitor) {
+ hWNDOldProc = oldProc;
+ SetWindowLong(hWnd, GWL_WNDPROC, (LONG) __wglMonitor);
+ }
#ifndef FX_SILENT
- freopen("MESA.LOG","w",stderr);
+ freopen("MESA.LOG", "w", stderr);
#endif
- ShowWindow(hWnd, SW_SHOWNORMAL);
- SetForegroundWindow(hWnd);
- Sleep(100); /* an hack for win95 */
-
- if(fxQueryHardware() == GR_SSTTYPE_VOODOO) {
- RECT cliRect;
-
- GetClientRect(hWnd,&cliRect);
- error = !(ctx = fxMesaCreateBestContext((GLuint)hWnd,cliRect.right,cliRect.bottom,
- pix[curPFD - 1].mesaAttr));
+ ShowWindow(hWnd, SW_SHOWNORMAL);
+ SetForegroundWindow(hWnd);
+ Sleep(100); /* an hack for win95 */
- if(!error) {
- /* create the DIB section for windowed rendering */
- DWORD *p;
-
- dibWnd = hWnd;
-
- hDC = GetDC(dibWnd);
-
- dibBMI = (BITMAPINFO*) MALLOC( sizeof(BITMAPINFO) + (256*sizeof(RGBQUAD)));
-
- memset(dibBMI,0,sizeof(BITMAPINFO) + (256*sizeof(RGBQUAD)));
-
- dibBMI->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- dibBMI->bmiHeader.biWidth = ctx->width;
- dibBMI->bmiHeader.biHeight = -ctx->height;
- dibBMI->bmiHeader.biPlanes = (short)1;
- dibBMI->bmiHeader.biBitCount = (short)16;
- dibBMI->bmiHeader.biCompression = BI_BITFIELDS;
- dibBMI->bmiHeader.biSizeImage = 0;
- dibBMI->bmiHeader.biXPelsPerMeter = 0;
- dibBMI->bmiHeader.biYPelsPerMeter = 0;
- dibBMI->bmiHeader.biClrUsed = 3;
- dibBMI->bmiHeader.biClrImportant = 3;
-
- p = (DWORD*)dibBMI->bmiColors;
- p[0] = 0xF800;
- p[1] = 0x07E0;
- p[2] = 0x001F;
-
- dibHBM = CreateDIBSection(hDC, dibBMI, DIB_RGB_COLORS, &dibSurfacePtr, NULL, 0);
-
- ReleaseDC(dibWnd, hDC);
-
- gdiWindowHackEna = (dibHBM != NULL ? GL_TRUE : GL_FALSE);
-
- if (!getenv("MESA_WGL_FX") || !strcmp(getenv("MESA_WGL_FX"),"fullscreen"))
- gdiWindowHack = GL_FALSE;
- else {
- gdiWindowHack = GL_TRUE;
- FX_grSstControl(GR_CONTROL_DEACTIVATE);
- }
- }
- } else {
- /* For the Voodoo Rush */
-
- if(getenv("MESA_WGL_FX") && !strcmp(getenv("MESA_WGL_FX"),"fullscreen")) {
+ if (fxQueryHardware() == GR_SSTTYPE_VOODOO) {
RECT cliRect;
- GetClientRect(hWnd,&cliRect);
- error = !(ctx = fxMesaCreateBestContext((GLuint)hWnd,cliRect.right,cliRect.bottom,
- pix[curPFD - 1].mesaAttr));
- } else
- error = !(ctx = fxMesaCreateContext((GLuint)hWnd,GR_RESOLUTION_NONE,GR_REFRESH_75Hz,
- pix[curPFD - 1].mesaAttr));
- }
-
- if(getenv("SST_DUALHEAD"))
- haveDualHead=((atoi(getenv("SST_DUALHEAD"))==1) ? GL_TRUE:GL_FALSE);
- else
- haveDualHead=GL_FALSE;
-
- if(error) {
- SetLastError(0);
- return(NULL);
- }
-
- hDC = hdc;
- hWND = hWnd;
-
- /* Required by the OpenGL Optimizer 1.1 (is it a Optimizer bug ?) */
- wglMakeCurrent(hdc,(HGLRC)1);
-
- return((HGLRC)1);
+ GetClientRect(hWnd, &cliRect);
+ error = !(ctx =
+ fxMesaCreateBestContext((GLuint) hWnd, cliRect.right,
+ cliRect.bottom,
+ pix[curPFD - 1].mesaAttr));
+
+ if (!error) {
+ /* create the DIB section for windowed rendering */
+ DWORD *p;
+
+ dibWnd = hWnd;
+
+ hDC = GetDC(dibWnd);
+
+ dibBMI =
+ (BITMAPINFO *) MALLOC(sizeof(BITMAPINFO) +
+ (256 * sizeof(RGBQUAD)));
+
+ memset(dibBMI, 0, sizeof(BITMAPINFO) + (256 * sizeof(RGBQUAD)));
+
+ dibBMI->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ dibBMI->bmiHeader.biWidth = ctx->width;
+ dibBMI->bmiHeader.biHeight = -ctx->height;
+ dibBMI->bmiHeader.biPlanes = (short) 1;
+ dibBMI->bmiHeader.biBitCount = (short) 16;
+ dibBMI->bmiHeader.biCompression = BI_BITFIELDS;
+ dibBMI->bmiHeader.biSizeImage = 0;
+ dibBMI->bmiHeader.biXPelsPerMeter = 0;
+ dibBMI->bmiHeader.biYPelsPerMeter = 0;
+ dibBMI->bmiHeader.biClrUsed = 3;
+ dibBMI->bmiHeader.biClrImportant = 3;
+
+ p = (DWORD *) dibBMI->bmiColors;
+ p[0] = 0xF800;
+ p[1] = 0x07E0;
+ p[2] = 0x001F;
+
+ dibHBM =
+ CreateDIBSection(hDC, dibBMI, DIB_RGB_COLORS, &dibSurfacePtr,
+ NULL, 0);
+
+ ReleaseDC(dibWnd, hDC);
+
+ gdiWindowHackEna = (dibHBM != NULL ? GL_TRUE : GL_FALSE);
+
+ if (!getenv("MESA_WGL_FX")
+ || !strcmp(getenv("MESA_WGL_FX"), "fullscreen"))
+ gdiWindowHack = GL_FALSE;
+ else {
+ gdiWindowHack = GL_TRUE;
+ FX_grSstControl(GR_CONTROL_DEACTIVATE);
+ }
+ }
+ }
+ else {
+ /* For the Voodoo Rush */
+
+ if (getenv("MESA_WGL_FX")
+ && !strcmp(getenv("MESA_WGL_FX"), "fullscreen")) {
+ RECT cliRect;
+
+ GetClientRect(hWnd, &cliRect);
+ error = !(ctx =
+ fxMesaCreateBestContext((GLuint) hWnd, cliRect.right,
+ cliRect.bottom,
+ pix[curPFD - 1].mesaAttr));
+ }
+ else
+ error = !(ctx =
+ fxMesaCreateContext((GLuint) hWnd, GR_RESOLUTION_NONE,
+ GR_REFRESH_75Hz,
+ pix[curPFD - 1].mesaAttr));
+ }
+
+ if (getenv("SST_DUALHEAD"))
+ haveDualHead =
+ ((atoi(getenv("SST_DUALHEAD")) == 1) ? GL_TRUE : GL_FALSE);
+ else
+ haveDualHead = GL_FALSE;
+
+ if (error) {
+ SetLastError(0);
+ return (NULL);
+ }
+
+ hDC = hdc;
+ hWND = hWnd;
+
+ /* Required by the OpenGL Optimizer 1.1 (is it a Optimizer bug ?) */
+ wglMakeCurrent(hdc, (HGLRC) 1);
+
+ return ((HGLRC) 1);
}
-HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc,int iLayerPlane)
+HGLRC GLAPIENTRY
+wglCreateLayerContext(HDC hdc, int iLayerPlane)
{
- SetLastError(0);
- return(NULL);
+ SetLastError(0);
+ return (NULL);
}
-BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc)
+BOOL GLAPIENTRY
+wglDeleteContext(HGLRC hglrc)
{
- if(ctx && hglrc == (HGLRC)1) {
- if (gdiWindowHackEna) {
- DeleteObject(dibHBM);
- FREE(dibBMI);
-
- dibSurfacePtr = NULL;
- dibBMI = NULL;
- dibHBM = NULL;
- dibWnd = NULL;
- }
+ if (ctx && hglrc == (HGLRC) 1) {
+ if (gdiWindowHackEna) {
+ DeleteObject(dibHBM);
+ FREE(dibBMI);
+
+ dibSurfacePtr = NULL;
+ dibBMI = NULL;
+ dibHBM = NULL;
+ dibWnd = NULL;
+ }
- fxMesaDestroyContext(ctx);
+ fxMesaDestroyContext(ctx);
- SetWindowLong(WindowFromDC(hDC),GWL_WNDPROC,(LONG)hWNDOldProc);
+ SetWindowLong(WindowFromDC(hDC), GWL_WNDPROC, (LONG) hWNDOldProc);
- ctx = NULL;
- hDC = 0;
- return(TRUE);
- }
+ ctx = NULL;
+ hDC = 0;
+ return (TRUE);
+ }
- SetLastError(0);
+ SetLastError(0);
- return(FALSE);
+ return (FALSE);
}
-HGLRC GLAPIENTRY wglGetCurrentContext(VOID)
+HGLRC GLAPIENTRY
+wglGetCurrentContext(VOID)
{
- if(ctx)
- return((HGLRC)1);
+ if (ctx)
+ return ((HGLRC) 1);
- SetLastError(0);
- return(NULL);
+ SetLastError(0);
+ return (NULL);
}
-HDC GLAPIENTRY wglGetCurrentDC(VOID)
+HDC GLAPIENTRY
+wglGetCurrentDC(VOID)
{
- if(ctx)
- return(hDC);
+ if (ctx)
+ return (hDC);
- SetLastError(0);
- return(NULL);
+ SetLastError(0);
+ return (NULL);
}
-PROC GLAPIENTRY wglGetProcAddress(LPCSTR lpszProc)
+PROC GLAPIENTRY
+wglGetProcAddress(LPCSTR lpszProc)
{
- int i;
+ int i;
- /*fprintf(stderr,"fxMesa: looking for extension %s\n",lpszProc);
- fflush(stderr);*/
+ /*fprintf(stderr,"fxMesa: looking for extension %s\n",lpszProc);
+ fflush(stderr); */
- for(i = 0;i < qt_ext;i++)
- if(!strcmp(lpszProc,ext[i].name)) {
- /*fprintf(stderr,"fxMesa: found extension %s\n",lpszProc);
- fflush(stderr);*/
+ for (i = 0; i < qt_ext; i++)
+ if (!strcmp(lpszProc, ext[i].name)) {
+ /*fprintf(stderr,"fxMesa: found extension %s\n",lpszProc);
+ fflush(stderr); */
- return(ext[i].proc);
- }
- SetLastError(0);
- return(NULL);
+ return (ext[i].proc);
+ }
+ SetLastError(0);
+ return (NULL);
}
-BOOL GLAPIENTRY wglMakeCurrent(HDC hdc,HGLRC hglrc)
+BOOL GLAPIENTRY
+wglMakeCurrent(HDC hdc, HGLRC hglrc)
{
- if((hdc==NULL) && (hglrc==NULL))
- return(TRUE);
+ if ((hdc == NULL) && (hglrc == NULL))
+ return (TRUE);
- if(!ctx || hglrc != (HGLRC)1 || WindowFromDC(hdc) != hWND) {
- SetLastError(0);
- return(FALSE);
- }
+ if (!ctx || hglrc != (HGLRC) 1 || WindowFromDC(hdc) != hWND) {
+ SetLastError(0);
+ return (FALSE);
+ }
- hDC = hdc;
+ hDC = hdc;
- fxMesaMakeCurrent(ctx);
+ fxMesaMakeCurrent(ctx);
- return(TRUE);
+ return (TRUE);
}
-BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1,HGLRC hglrc2)
+BOOL GLAPIENTRY
+wglShareLists(HGLRC hglrc1, HGLRC hglrc2)
{
- if(!ctx || hglrc1 != (HGLRC)1 || hglrc1 != hglrc2) {
- SetLastError(0);
- return(FALSE);
- }
+ if (!ctx || hglrc1 != (HGLRC) 1 || hglrc1 != hglrc2) {
+ SetLastError(0);
+ return (FALSE);
+ }
- return(TRUE);
+ return (TRUE);
}
-BOOL GLAPIENTRY wglUseFontBitmaps(HDC fontDevice, DWORD firstChar, DWORD numChars, DWORD listBase)
+BOOL GLAPIENTRY
+wglUseFontBitmaps(HDC fontDevice, DWORD firstChar, DWORD numChars,
+ DWORD listBase)
{
#define VERIFY(a) a
- TEXTMETRIC metric;
- BITMAPINFO *dibInfo;
- HDC bitDevice;
- COLORREF tempColor;
- int i;
-
- VERIFY(GetTextMetrics(fontDevice, &metric));
-
- dibInfo = (BITMAPINFO *) calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1);
- dibInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- dibInfo->bmiHeader.biPlanes = 1;
- dibInfo->bmiHeader.biBitCount = 1;
- dibInfo->bmiHeader.biCompression = BI_RGB;
-
- bitDevice = CreateCompatibleDC(fontDevice);
- // HDC bitDevice = CreateDC("DISPLAY", NULL, NULL, NULL);
- // VERIFY(bitDevice);
-
- // Swap fore and back colors so the bitmap has the right polarity
- tempColor = GetBkColor(bitDevice);
- SetBkColor(bitDevice, GetTextColor(bitDevice));
- SetTextColor(bitDevice, tempColor);
-
- // Place chars based on base line
- VERIFY(SetTextAlign(bitDevice, TA_BASELINE) >= 0 ? 1 : 0);
-
- for(i = 0; i < numChars; i++) {
- SIZE size;
- char curChar;
- int charWidth,charHeight,bmapWidth,bmapHeight,numBytes,res;
- HBITMAP bitObject;
- HGDIOBJ origBmap;
- unsigned char *bmap;
-
- curChar = i + firstChar;
-
- // Find how high/wide this character is
- VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size));
-
- // Create the output bitmap
- charWidth = size.cx;
- charHeight = size.cy;
- bmapWidth = ((charWidth + 31) / 32) * 32; // Round up to the next multiple of 32 bits
- bmapHeight = charHeight;
- bitObject = CreateCompatibleBitmap(bitDevice,
- bmapWidth,
- bmapHeight);
- //VERIFY(bitObject);
-
- // Assign the output bitmap to the device
- origBmap = SelectObject(bitDevice, bitObject);
- VERIFY(origBmap);
-
- VERIFY( PatBlt( bitDevice, 0, 0, bmapWidth, bmapHeight,BLACKNESS ) );
-
- // Use our source font on the device
- VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice,OBJ_FONT)));
-
- // Draw the character
- VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1));
-
- // Unselect our bmap object
- VERIFY(SelectObject(bitDevice, origBmap));
-
- // Convert the display dependant representation to a 1 bit deep DIB
- numBytes = (bmapWidth * bmapHeight) / 8;
- bmap = MALLOC(numBytes);
- dibInfo->bmiHeader.biWidth = bmapWidth;
- dibInfo->bmiHeader.biHeight = bmapHeight;
- res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap,
- dibInfo,
- DIB_RGB_COLORS);
- //VERIFY(res);
-
- // Create the GL object
- glNewList(i + listBase, GL_COMPILE);
- glBitmap(bmapWidth, bmapHeight, 0.0, metric.tmDescent,
- charWidth, 0.0,
- bmap);
- glEndList();
- // CheckGL();
-
- // Destroy the bmap object
- DeleteObject(bitObject);
-
- // Deallocate the bitmap data
- FREE(bmap);
- }
-
- // Destroy the DC
- VERIFY(DeleteDC(bitDevice));
-
- FREE(dibInfo);
-
- return TRUE;
+ TEXTMETRIC metric;
+ BITMAPINFO *dibInfo;
+ HDC bitDevice;
+ COLORREF tempColor;
+ int i;
+
+ VERIFY(GetTextMetrics(fontDevice, &metric));
+
+ dibInfo = (BITMAPINFO *) calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1);
+ dibInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ dibInfo->bmiHeader.biPlanes = 1;
+ dibInfo->bmiHeader.biBitCount = 1;
+ dibInfo->bmiHeader.biCompression = BI_RGB;
+
+ bitDevice = CreateCompatibleDC(fontDevice);
+ // HDC bitDevice = CreateDC("DISPLAY", NULL, NULL, NULL);
+ // VERIFY(bitDevice);
+
+ // Swap fore and back colors so the bitmap has the right polarity
+ tempColor = GetBkColor(bitDevice);
+ SetBkColor(bitDevice, GetTextColor(bitDevice));
+ SetTextColor(bitDevice, tempColor);
+
+ // Place chars based on base line
+ VERIFY(SetTextAlign(bitDevice, TA_BASELINE) >= 0 ? 1 : 0);
+
+ for (i = 0; i < numChars; i++) {
+ SIZE size;
+ char curChar;
+ int charWidth, charHeight, bmapWidth, bmapHeight, numBytes, res;
+ HBITMAP bitObject;
+ HGDIOBJ origBmap;
+ unsigned char *bmap;
+
+ curChar = i + firstChar;
+
+ // Find how high/wide this character is
+ VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size));
+
+ // Create the output bitmap
+ charWidth = size.cx;
+ charHeight = size.cy;
+ bmapWidth = ((charWidth + 31) / 32) * 32; // Round up to the next multiple of 32 bits
+ bmapHeight = charHeight;
+ bitObject = CreateCompatibleBitmap(bitDevice, bmapWidth, bmapHeight);
+ //VERIFY(bitObject);
+
+ // Assign the output bitmap to the device
+ origBmap = SelectObject(bitDevice, bitObject);
+ VERIFY(origBmap);
+
+ VERIFY(PatBlt(bitDevice, 0, 0, bmapWidth, bmapHeight, BLACKNESS));
+
+ // Use our source font on the device
+ VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice, OBJ_FONT)));
+
+ // Draw the character
+ VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1));
+
+ // Unselect our bmap object
+ VERIFY(SelectObject(bitDevice, origBmap));
+
+ // Convert the display dependant representation to a 1 bit deep DIB
+ numBytes = (bmapWidth * bmapHeight) / 8;
+ bmap = MALLOC(numBytes);
+ dibInfo->bmiHeader.biWidth = bmapWidth;
+ dibInfo->bmiHeader.biHeight = bmapHeight;
+ res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap,
+ dibInfo, DIB_RGB_COLORS);
+ //VERIFY(res);
+
+ // Create the GL object
+ glNewList(i + listBase, GL_COMPILE);
+ glBitmap(bmapWidth, bmapHeight, 0.0, metric.tmDescent,
+ charWidth, 0.0, bmap);
+ glEndList();
+ // CheckGL();
+
+ // Destroy the bmap object
+ DeleteObject(bitObject);
+
+ // Deallocate the bitmap data
+ FREE(bmap);
+ }
+
+ // Destroy the DC
+ VERIFY(DeleteDC(bitDevice));
+
+ FREE(dibInfo);
+
+ return TRUE;
#undef VERIFY
}
-BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc,DWORD first,DWORD count,DWORD listBase)
+BOOL GLAPIENTRY
+wglUseFontBitmapsW(HDC hdc, DWORD first, DWORD count, DWORD listBase)
{
- return(FALSE);
+ return (FALSE);
}
-BOOL GLAPIENTRY wglUseFontOutlinesA(HDC hdc,DWORD first,DWORD count,
- DWORD listBase,FLOAT deviation,
- FLOAT extrusion,int format,
- LPGLYPHMETRICSFLOAT lpgmf)
+BOOL GLAPIENTRY
+wglUseFontOutlinesA(HDC hdc, DWORD first, DWORD count,
+ DWORD listBase, FLOAT deviation,
+ FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf)
{
- SetLastError(0);
- return(FALSE);
+ SetLastError(0);
+ return (FALSE);
}
-BOOL GLAPIENTRY wglUseFontOutlinesW(HDC hdc,DWORD first,DWORD count,
- DWORD listBase,FLOAT deviation,
- FLOAT extrusion,int format,
- LPGLYPHMETRICSFLOAT lpgmf)
+BOOL GLAPIENTRY
+wglUseFontOutlinesW(HDC hdc, DWORD first, DWORD count,
+ DWORD listBase, FLOAT deviation,
+ FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf)
{
- SetLastError(0);
- return(FALSE);
+ SetLastError(0);
+ return (FALSE);
}
-BOOL GLAPIENTRY wglSwapLayerBuffers(HDC hdc,UINT fuPlanes)
+BOOL GLAPIENTRY
+wglSwapLayerBuffers(HDC hdc, UINT fuPlanes)
{
- if(ctx && WindowFromDC(hdc) == hWND) {
- fxMesaSwapBuffers();
+ if (ctx && WindowFromDC(hdc) == hWND) {
+ fxMesaSwapBuffers();
- return(TRUE);
- }
+ return (TRUE);
+ }
- SetLastError(0);
- return(FALSE);
+ SetLastError(0);
+ return (FALSE);
}
-int GLAPIENTRY wglChoosePixelFormat(HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd)
+int GLAPIENTRY
+wglChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR * ppfd)
{
- int i,best=-1,qt_valid_pix;
-
- qt_valid_pix = qt_pix;
-
- if(ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1) {
- SetLastError(0);
- return(0);
- }
-
- for(i = 0;i < qt_valid_pix;i++) {
- if((ppfd->dwFlags & PFD_DRAW_TO_WINDOW) && !(pix[i].pfd.dwFlags & PFD_DRAW_TO_WINDOW))
- continue;
- if((ppfd->dwFlags & PFD_DRAW_TO_BITMAP) && !(pix[i].pfd.dwFlags & PFD_DRAW_TO_BITMAP))
- continue;
- if((ppfd->dwFlags & PFD_SUPPORT_GDI) && !(pix[i].pfd.dwFlags & PFD_SUPPORT_GDI))
- continue;
- if((ppfd->dwFlags & PFD_SUPPORT_OPENGL) && !(pix[i].pfd.dwFlags & PFD_SUPPORT_OPENGL))
- continue;
- if(!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
- ((ppfd->dwFlags & PFD_DOUBLEBUFFER) != (pix[i].pfd.dwFlags & PFD_DOUBLEBUFFER)))
- continue;
- if(!(ppfd->dwFlags & PFD_STEREO_DONTCARE) &&
- ((ppfd->dwFlags & PFD_STEREO) != (pix[i].pfd.dwFlags & PFD_STEREO)))
- continue;
-
- if (ppfd->cDepthBits > 0 && pix[i].pfd.cDepthBits == 0)
- continue; /* need depth buffer */
-
- if (ppfd->cAlphaBits > 0 && pix[i].pfd.cAlphaBits == 0)
- continue; /* need alpha buffer */
-
- if(ppfd->iPixelType == pix[i].pfd.iPixelType) {
- best = i + 1;
- break;
- }
- }
+ int i, best = -1, qt_valid_pix;
+
+ qt_valid_pix = qt_pix;
+
+ if (ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1) {
+ SetLastError(0);
+ return (0);
+ }
+
+ for (i = 0; i < qt_valid_pix; i++) {
+ if ((ppfd->dwFlags & PFD_DRAW_TO_WINDOW)
+ && !(pix[i].pfd.dwFlags & PFD_DRAW_TO_WINDOW)) continue;
+ if ((ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
+ && !(pix[i].pfd.dwFlags & PFD_DRAW_TO_BITMAP)) continue;
+ if ((ppfd->dwFlags & PFD_SUPPORT_GDI)
+ && !(pix[i].pfd.dwFlags & PFD_SUPPORT_GDI)) continue;
+ if ((ppfd->dwFlags & PFD_SUPPORT_OPENGL)
+ && !(pix[i].pfd.dwFlags & PFD_SUPPORT_OPENGL)) continue;
+ if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE)
+ && ((ppfd->dwFlags & PFD_DOUBLEBUFFER) !=
+ (pix[i].pfd.dwFlags & PFD_DOUBLEBUFFER))) continue;
+ if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE)
+ && ((ppfd->dwFlags & PFD_STEREO) !=
+ (pix[i].pfd.dwFlags & PFD_STEREO))) continue;
+
+ if (ppfd->cDepthBits > 0 && pix[i].pfd.cDepthBits == 0)
+ continue; /* need depth buffer */
+
+ if (ppfd->cAlphaBits > 0 && pix[i].pfd.cAlphaBits == 0)
+ continue; /* need alpha buffer */
+
+ if (ppfd->iPixelType == pix[i].pfd.iPixelType) {
+ best = i + 1;
+ break;
+ }
+ }
- if(best == -1) {
- SetLastError(0);
- return(0);
- }
+ if (best == -1) {
+ SetLastError(0);
+ return (0);
+ }
- return(best);
+ return (best);
}
-int GLAPIENTRY ChoosePixelFormat(HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd)
+int GLAPIENTRY
+ChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR * ppfd)
{
- return wglChoosePixelFormat(hdc,ppfd);
+ return wglChoosePixelFormat(hdc, ppfd);
}
-int GLAPIENTRY wglDescribePixelFormat(HDC hdc,int iPixelFormat,UINT nBytes,
- LPPIXELFORMATDESCRIPTOR ppfd)
+int GLAPIENTRY
+wglDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd)
{
- int qt_valid_pix;
+ int qt_valid_pix;
- qt_valid_pix = qt_pix;
+ qt_valid_pix = qt_pix;
- if(iPixelFormat < 1 || iPixelFormat > qt_valid_pix ||
- ((nBytes != sizeof(PIXELFORMATDESCRIPTOR)) && (nBytes != 0))) {
- SetLastError(0);
- return(0);
- }
+ if (iPixelFormat < 1 || iPixelFormat > qt_valid_pix ||
+ ((nBytes != sizeof(PIXELFORMATDESCRIPTOR)) && (nBytes != 0))) {
+ SetLastError(0);
+ return (0);
+ }
- if(nBytes != 0)
- *ppfd = pix[iPixelFormat - 1].pfd;
+ if (nBytes != 0)
+ *ppfd = pix[iPixelFormat - 1].pfd;
- return(qt_valid_pix);
+ return (qt_valid_pix);
}
-int GLAPIENTRY DescribePixelFormat(HDC hdc,int iPixelFormat,UINT nBytes,
- LPPIXELFORMATDESCRIPTOR ppfd)
+int GLAPIENTRY
+DescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd)
{
- return wglDescribePixelFormat(hdc,iPixelFormat,nBytes,ppfd);
+ return wglDescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd);
}
-int GLAPIENTRY wglGetPixelFormat(HDC hdc)
+int GLAPIENTRY
+wglGetPixelFormat(HDC hdc)
{
- if(curPFD == 0) {
- SetLastError(0);
- return(0);
- }
+ if (curPFD == 0) {
+ SetLastError(0);
+ return (0);
+ }
- return(curPFD);
+ return (curPFD);
}
-int GLAPIENTRY GetPixelFormat(HDC hdc)
+int GLAPIENTRY
+GetPixelFormat(HDC hdc)
{
- return wglGetPixelFormat(hdc);
+ return wglGetPixelFormat(hdc);
}
-BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat,
- CONST PIXELFORMATDESCRIPTOR *ppfd)
+BOOL GLAPIENTRY
+wglSetPixelFormat(HDC hdc, int iPixelFormat,
+ CONST PIXELFORMATDESCRIPTOR * ppfd)
{
- int qt_valid_pix;
+ int qt_valid_pix;
- qt_valid_pix = qt_pix;
+ qt_valid_pix = qt_pix;
- if(iPixelFormat < 1 || iPixelFormat > qt_valid_pix || ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR)) {
- SetLastError(0);
- return(FALSE);
- }
- curPFD = iPixelFormat;
+ if (iPixelFormat < 1 || iPixelFormat > qt_valid_pix
+ || ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR)) {
+ SetLastError(0);
+ return (FALSE);
+ }
+ curPFD = iPixelFormat;
- return(TRUE);
+ return (TRUE);
}
-BOOL GLAPIENTRY wglSwapBuffers(HDC hdc)
+BOOL GLAPIENTRY
+wglSwapBuffers(HDC hdc)
{
- if(!ctx) {
- SetLastError(0);
- return(FALSE);
- }
-
- fxMesaSwapBuffers();
-
- if(gdiWindowHack) {
- GLuint width=ctx->width;
- GLuint height=ctx->height;
-
- HDC hdcScreen = GetDC(dibWnd);
- HDC hdcDIBSection = CreateCompatibleDC(hdcScreen);
- HBITMAP holdBitmap = (HBITMAP) SelectObject(hdcDIBSection, dibHBM);
-
- FX_grLfbReadRegion(GR_BUFFER_FRONTBUFFER, 0, 0,
- width, height,
- width * 2,
- dibSurfacePtr);
-
- /* Since the hardware is configured for GR_COLORFORMAT_ABGR the pixel data is
- * going to come out as BGR 565, which is reverse of what we need for blitting
- * to screen, so we need to convert it here pixel-by-pixel (ick). This loop would NOT
- * be required if the color format was changed to GR_COLORFORMAT_ARGB, but I do
- * not know the ramifications of that, so this will work until that is resolved.
- *
- * This routine CRIES out for MMX implementation, however since that's not
- * guaranteed to be running on MMX enabled hardware so I'm not going to do
- * that. I'm just going to try to make a reasonably efficient C
- * version. -TAJ
- *
- * This routine drops frame rate by <1 fps on a 200Mhz MMX processor with a 640x480
- * display. Obviously, it's performance hit will be higher on larger displays and
- * less on smaller displays. To support the window-hack display this is probably fine.
- */
+ if (!ctx) {
+ SetLastError(0);
+ return (FALSE);
+ }
+
+ fxMesaSwapBuffers();
+
+ if (gdiWindowHack) {
+ GLuint width = ctx->width;
+ GLuint height = ctx->height;
+
+ HDC hdcScreen = GetDC(dibWnd);
+ HDC hdcDIBSection = CreateCompatibleDC(hdcScreen);
+ HBITMAP holdBitmap = (HBITMAP) SelectObject(hdcDIBSection, dibHBM);
+
+ FX_grLfbReadRegion(GR_BUFFER_FRONTBUFFER, 0, 0,
+ width, height, width * 2, dibSurfacePtr);
+
+ /* Since the hardware is configured for GR_COLORFORMAT_ABGR the pixel data is
+ * going to come out as BGR 565, which is reverse of what we need for blitting
+ * to screen, so we need to convert it here pixel-by-pixel (ick). This loop would NOT
+ * be required if the color format was changed to GR_COLORFORMAT_ARGB, but I do
+ * not know the ramifications of that, so this will work until that is resolved.
+ *
+ * This routine CRIES out for MMX implementation, however since that's not
+ * guaranteed to be running on MMX enabled hardware so I'm not going to do
+ * that. I'm just going to try to make a reasonably efficient C
+ * version. -TAJ
+ *
+ * This routine drops frame rate by <1 fps on a 200Mhz MMX processor with a 640x480
+ * display. Obviously, it's performance hit will be higher on larger displays and
+ * less on smaller displays. To support the window-hack display this is probably fine.
+ */
#if FXMESA_USE_ARGB
- {
- unsigned long *pixel = dibSurfacePtr;
- unsigned long count = (width * height) / 2;
-
- while (count--)
- {
- *pixel++ = (*pixel & 0x07e007e0) /* greens */
- | ((*pixel & 0xf800f800) >> 11) /* swap blues */
- | ((*pixel & 0x001f001f) << 11) /* swap reds */
- ;
- }
- }
+ {
+ unsigned long *pixel = dibSurfacePtr;
+ unsigned long count = (width * height) / 2;
+
+ while (count--) {
+ *pixel++ = (*pixel & 0x07e007e0) /* greens */
+ |((*pixel & 0xf800f800) >> 11) /* swap blues */
+ |((*pixel & 0x001f001f) << 11) /* swap reds */
+ ;
+ }
+ }
#endif
-
- BitBlt(hdcScreen, 0, 0,
- width, height,
- hdcDIBSection,
- 0, 0, SRCCOPY);
-
- ReleaseDC(dibWnd, hdcScreen);
- SelectObject(hdcDIBSection, holdBitmap);
- DeleteDC(hdcDIBSection);
- }
-
- return(TRUE);
+
+ BitBlt(hdcScreen, 0, 0, width, height, hdcDIBSection, 0, 0, SRCCOPY);
+
+ ReleaseDC(dibWnd, hdcScreen);
+ SelectObject(hdcDIBSection, holdBitmap);
+ DeleteDC(hdcDIBSection);
+ }
+
+ return (TRUE);
}
-BOOL GLAPIENTRY SetPixelFormat(HDC hdc, int iPixelFormat,
- CONST PIXELFORMATDESCRIPTOR *ppfd)
+BOOL GLAPIENTRY
+SetPixelFormat(HDC hdc, int iPixelFormat, CONST PIXELFORMATDESCRIPTOR * ppfd)
{
- return wglSetPixelFormat(hdc,iPixelFormat,ppfd);
+ return wglSetPixelFormat(hdc, iPixelFormat, ppfd);
}
-BOOL GLAPIENTRY SwapBuffers(HDC hdc)
+BOOL GLAPIENTRY
+SwapBuffers(HDC hdc)
{
- return wglSwapBuffers(hdc);
+ return wglSwapBuffers(hdc);
}
#endif /* FX */