-/* $Id: fxapi.c,v 1.39 2003/10/09 15:12:21 dborca Exp $ */
+/* $Id: fxapi.c,v 1.40 2003/10/13 11:14:58 dborca Exp $ */
/*
* Mesa 3-D graphics library
return NULL;
}
- return fxMesaCreateContext(win, res, GR_REFRESH_60Hz/*ZZZ: GR_REFRESH_75Hz*/, attribList);
+ return fxMesaCreateContext(win, res, GR_REFRESH_60Hz, attribList);
}
int i;
const char *str;
- int numChips, sliaa, fsaa;
+ int sliaa, numSLI, samplesPerChip, tmuRam, fbRam;
struct SstCard_St *voodoo;
struct tdfx_glide *Glide;
GrPixelFormat_t pixFmt;
GLboolean useBGR;
- GLboolean verbose = GL_FALSE;
if (TDFX_DEBUG & VERBOSE_DRIVER) {
fprintf(stderr, "%s(...)\n", __FUNCTION__);
}
- if (getenv("MESA_FX_INFO")) {
- verbose = GL_TRUE;
- }
-
/* Okay, first process the user flags */
aux = GL_FALSE;
doubleBuffer = GL_FALSE;
and disables the splash screen due to y-origin swapping.
Note: We only want the former. */
voodoo = &glbHWConfig.SSTs[glbCurrentBoard];
- numChips = voodoo->numChips;
fxMesa = (fxMesaContext)CALLOC_STRUCT(tfxMesaContext);
if (!fxMesa) {
goto errorhandler;
}
+ if (getenv("MESA_FX_INFO")) {
+ fxMesa->verbose = GL_TRUE;
+ }
+
fxMesa->type = voodoo->type;
fxMesa->HavePixExt = voodoo->HavePixExt;
fxMesa->HaveTexFmt = voodoo->HaveTexFmt;
fxMesa->HaveTexus2 = voodoo->HaveTexus2;
fxMesa->Glide = glbHWConfig.Glide;
Glide = &fxMesa->Glide;
- sprintf(fxMesa->rendererString, "Mesa %s v0.51 %s %dMB FB, %dMB TM, %d TMU, %s",
- grGetString(GR_RENDERER),
- grGetString(GR_HARDWARE),
- voodoo->fbRam,
- (voodoo->tmuConfig[GR_TMU0].tmuRam + ((voodoo->nTexelfx > 1) ? voodoo->tmuConfig[GR_TMU1].tmuRam : 0)),
- voodoo->nTexelfx,
- (numChips > 1) ? "SLI" : "NOSLI");
- switch (fxMesa->colDepth = colDepth) {
- case 15:
- redBits = 5;
- greenBits = 5;
- blueBits = 5;
- alphaBits = 1;
- pixFmt = GR_PIXFMT_ARGB_1555;
- break;
- case 16:
- redBits = 5;
- greenBits = 6;
- blueBits = 5;
- alphaBits = depthSize ? 0 : 8;
- pixFmt = GR_PIXFMT_RGB_565;
+ /*
+ * Pixel tables are used during pixel read-back
+ * Either initialize them for RGB or BGR order;
+ * However, 32bit capable cards have the right order.
+ * As a consequence, 32bit read-back is not swizzled!
+ * Also determine if we need vertex snapping.
+ */
+ /* number of SLI units and AA Samples per chip */
+ sliaa = 0;
+ switch (voodoo->type) {
+ case GR_SSTTYPE_VOODOO:
+ case GR_SSTTYPE_Banshee:
+ useBGR = GL_TRUE;
+ fxMesa->snapVertices = GL_TRUE;
break;
- case 32:
- redBits = 8;
- greenBits = 8;
- blueBits = 8;
- alphaBits = 8;
- pixFmt = GR_PIXFMT_ARGB_8888;
+ case GR_SSTTYPE_Voodoo2:
+ useBGR = GL_TRUE;
+ fxMesa->snapVertices = GL_FALSE;
break;
+ case GR_SSTTYPE_Voodoo4:
+ case GR_SSTTYPE_Voodoo5:
+ if ((str = Glide->grGetRegistryOrEnvironmentStringExt("SSTH3_SLI_AA_CONFIGURATION")) != NULL) {
+ sliaa = atoi(str);
+ }
+ case GR_SSTTYPE_Voodoo3:
default:
- str = "pixelFormat";
- goto errorhandler;
+ useBGR = GL_FALSE;
+ fxMesa->snapVertices = GL_FALSE;
+ break;
+ }
+ /* ZZZ TO DO: Add the old SLI/AA settings for Napalm. */
+ switch(voodoo->numChips) {
+ case 4: /* 4 chips */
+ switch(sliaa) {
+ case 8: /* 8 Sample AA */
+ numSLI = 1;
+ samplesPerChip = 2;
+ break;
+ case 7: /* 4 Sample AA */
+ numSLI = 1;
+ samplesPerChip = 1;
+ break;
+ case 6: /* 2 Sample AA */
+ numSLI = 2;
+ samplesPerChip = 1;
+ break;
+ default:
+ numSLI = 4;
+ samplesPerChip = 1;
+ }
+ break;
+ case 2: /* 2 chips */
+ switch(sliaa) {
+ case 4: /* 4 Sample AA */
+ numSLI = 1;
+ samplesPerChip = 2;
+ break;
+ case 3: /* 2 Sample AA */
+ numSLI = 1;
+ samplesPerChip = 1;
+ break;
+ default:
+ numSLI = 2;
+ samplesPerChip = 1;
+ }
+ break;
+ default: /* 1 chip */
+ switch(sliaa) {
+ case 1: /* 2 Sample AA */
+ numSLI = 1;
+ samplesPerChip = 2;
+ break;
+ default:
+ numSLI = 1;
+ samplesPerChip = 1;
+ }
+ }
+
+ fxMesa->fsaa = samplesPerChip * voodoo->numChips / numSLI; /* 1:noFSAA, 2:2xFSAA, 4:4xFSAA, 8:8xFSAA */
+
+ switch (fxMesa->colDepth = colDepth) {
+ case 15:
+ redBits = 5;
+ greenBits = 5;
+ blueBits = 5;
+ alphaBits = 1;
+ switch(fxMesa->fsaa) {
+ case 8:
+ pixFmt = GR_PIXFMT_AA_8_ARGB_1555;
+ break;
+ case 4:
+ pixFmt = GR_PIXFMT_AA_4_ARGB_1555;
+ break;
+ case 2:
+ pixFmt = GR_PIXFMT_AA_2_ARGB_1555;
+ break;
+ default:
+ pixFmt = GR_PIXFMT_ARGB_1555;
+ }
+ break;
+ case 16:
+ redBits = 5;
+ greenBits = 6;
+ blueBits = 5;
+ alphaBits = depthSize ? 0 : 8;
+ switch(fxMesa->fsaa) {
+ case 8:
+ pixFmt = GR_PIXFMT_AA_8_RGB_565;
+ break;
+ case 4:
+ pixFmt = GR_PIXFMT_AA_4_RGB_565;
+ break;
+ case 2:
+ pixFmt = GR_PIXFMT_AA_2_RGB_565;
+ break;
+ default:
+ pixFmt = GR_PIXFMT_RGB_565;
+ }
+ break;
+ case 32:
+ redBits = 8;
+ greenBits = 8;
+ blueBits = 8;
+ alphaBits = 8;
+ switch(fxMesa->fsaa) {
+ case 8:
+ pixFmt = GR_PIXFMT_AA_8_ARGB_8888;
+ break;
+ case 4:
+ pixFmt = GR_PIXFMT_AA_4_ARGB_8888;
+ break;
+ case 2:
+ pixFmt = GR_PIXFMT_AA_2_ARGB_8888;
+ break;
+ default:
+ pixFmt = GR_PIXFMT_ARGB_8888;
+ }
+ break;
+ default:
+ str = "pixelFormat";
+ goto errorhandler;
}
+ /* ZZZ TODO: check if there is enough fbRam */
+
/* Tips:
* 1. we don't bother setting/checking AUX for stencil, because we'll decide
* later whether we have HW stencil, based on depth buffer (thus AUX is
fxMesa->haveZBuffer = depthSize > 0;
fxMesa->haveDoubleBuffer = doubleBuffer;
fxMesa->haveGlobalPaletteTexture = GL_FALSE;
- fxMesa->verbose = verbose;
fxMesa->board = glbCurrentBoard;
fxMesa->haveTwoTMUs = (voodoo->nTexelfx > 1);
fxMesa->swapInterval = 0;
}
- if ((str = Glide->grGetRegistryOrEnvironmentStringExt("SSTH3_SLI_AA_CONFIGURATION"))) {
- sliaa = atoi(str);
- } else {
- sliaa = 0;
- }
- switch (colDepth) {
- case 15:
- if ((numChips == 4) && (sliaa == 8)) {
- pixFmt = GR_PIXFMT_AA_8_ARGB_1555;
- fsaa = 8;
- } else if (((numChips == 4) && (sliaa == 7)) || ((numChips == 2) && (sliaa == 4))) {
- pixFmt = GR_PIXFMT_AA_4_ARGB_1555;
- fsaa = 4;
- } else if (((numChips == 4) && (sliaa == 6)) || ((numChips == 2) && (sliaa == 3)) || ((numChips == 1) && (sliaa == 1))) {
- pixFmt = GR_PIXFMT_AA_2_ARGB_1555;
- fsaa = 2;
- } else {
- fsaa = 0;
- }
- break;
- case 16:
- if ((numChips == 4) && (sliaa == 8)) {
- pixFmt = GR_PIXFMT_AA_8_RGB_565;
- fsaa = 8;
- } else if (((numChips == 4) && (sliaa == 7)) || ((numChips == 2) && (sliaa == 4))) {
- pixFmt = GR_PIXFMT_AA_4_RGB_565;
- fsaa = 4;
- } else if (((numChips == 4) && (sliaa == 6)) || ((numChips == 2) && (sliaa == 3)) || ((numChips == 1) && (sliaa == 1))) {
- pixFmt = GR_PIXFMT_AA_2_RGB_565;
- fsaa = 2;
- } else {
- fsaa = 0;
- }
- break;
- case 32:
- if ((numChips == 4) && (sliaa == 8)) {
- pixFmt = GR_PIXFMT_AA_8_ARGB_8888;
- fsaa = 8;
- } else if (((numChips == 4) && (sliaa == 7)) || ((numChips == 2) && (sliaa == 4))) {
- pixFmt = GR_PIXFMT_AA_4_ARGB_8888;
- fsaa = 4;
- } else if (((numChips == 4) && (sliaa == 6)) || ((numChips == 2) && (sliaa == 3)) || ((numChips == 1) && (sliaa == 1))) {
- pixFmt = GR_PIXFMT_AA_2_ARGB_8888;
- fsaa = 2;
- } else {
- fsaa = 0;
- }
- break;
- default: /* NOTREACHED */
- str = "pixelFormat";
- goto errorhandler;
- }
- fxMesa->fsaa = fsaa;
-
BEGIN_BOARD_LOCK();
if (fxMesa->HavePixExt) {
fxMesa->glideContext = Glide->grSstWinOpenExt((FxU32)win, res, ref,
goto errorhandler;
}
- /*
- * Pixel tables are used during pixel read-back
- * Either initialize them for RGB or BGR order;
- * However, 32bit capable cards have the right order.
- * As a consequence, 32bit read-back is not swizzled!
- * Also determine if we need vertex snapping.
- */
- switch (voodoo->type) {
- case GR_SSTTYPE_VOODOO:
- case GR_SSTTYPE_Banshee:
- useBGR = GL_TRUE;
- fxMesa->snapVertices = GL_TRUE;
- break;
- case GR_SSTTYPE_Voodoo2:
- useBGR = GL_TRUE;
- fxMesa->snapVertices = GL_FALSE;
- break;
- case GR_SSTTYPE_Voodoo3:
- case GR_SSTTYPE_Voodoo4:
- case GR_SSTTYPE_Voodoo5:
- default:
- useBGR = GL_FALSE;
- fxMesa->snapVertices = GL_FALSE;
- break;
- }
-
+ /* Not that it matters, but tmuRam and fbRam change after grSstWinOpen. */
+ tmuRam = voodoo->tmuConfig[GR_TMU0].tmuRam;
+ fbRam = voodoo->fbRam;
+ BEGIN_BOARD_LOCK();
+ {
+ FxI32 result;
+ grGet(GR_MEMORY_TMU, 4, &result);
+ tmuRam = result / (1024 * 1024);
+ grGet(GR_MEMORY_FB, 4, &result);
+ fbRam = result / 1024;
+ }
+ END_BOARD_LOCK();
+
+ sprintf(fxMesa->rendererString, "Mesa %s v0.51 %s %dkB FB, %dMB TM, %d TMU, %s",
+ grGetString(GR_RENDERER),
+ grGetString(GR_HARDWARE),
+ fbRam,
+ tmuRam * voodoo->nTexelfx,
+ voodoo->nTexelfx,
+ (voodoo->numChips > 1) ? "SLI" : "NOSLI");
+
fxInitPixelTables(fxMesa, useBGR);
/* screen */
fxMesa->clipMinY = 0;
fxMesa->clipMaxY = fxMesa->height;
- if (verbose) {
+ if (fxMesa->verbose) {
char buf[80];
strcpy(buf, grGetString(GR_VERSION));
fprintf(stderr, "Voodoo pixel order = %s, vertex snapping = %d\n",
useBGR ? "BGR" : "RGB",
fxMesa->snapVertices);
- fprintf(stderr, "Voodoo screen: %dx%d.%d\n",
+ fprintf(stderr, "Voodoo screen: %dx%d:%d\n",
fxMesa->screen_width, fxMesa->screen_height, colDepth);
}
-/* $Id: fxglidew.c,v 1.22 2003/10/02 17:36:44 brianp Exp $ */
+/* $Id: fxglidew.c,v 1.23 2003/10/13 11:14:58 dborca Exp $ */
/*
* Mesa 3-D graphics library
} else if (strstr(extension, "Voodoo5")) {
config->SSTs[i].type = GR_SSTTYPE_Voodoo5;
} else { /* Voodoo1,2,rush */
- /* ZZZ TO DO */
+ /* ZZZ TO DO: Need to distinguish whether we have V1 or V2 or Rush. */
config->SSTs[i].type = GR_SSTTYPE_VOODOO;
}
- grGet(GR_MEMORY_FB, 4, &result);
+ grGet(GR_MEMORY_FB, 4, &result); /* ZZZ: differs after grSstWinOpen */
config->SSTs[i].fbRam = result / (1024 * 1024);
grGet(GR_NUM_TMU, 4, &result);
config->SSTs[i].fbiRev = result;
for (j = 0; j < config->SSTs[i].nTexelfx; j++) {
- grGet(GR_MEMORY_TMU, 4, &result);
+ grGet(GR_MEMORY_TMU, 4, &result); /* ZZZ: differs after grSstWinOpen */
config->SSTs[i].tmuConfig[j].tmuRam = result / (1024 * 1024);
grGet(GR_REVISION_TMU, 4, &result);
config->SSTs[i].tmuConfig[j].tmuRev = result;
config->SSTs[i].HaveMirExt = (strstr(extension, " TEXMIRROR ") != NULL);
config->SSTs[i].HaveTexus2 = GL_FALSE;
- /* need to get the number of SLI units for napalm */
+ /* number of Voodoo chips */
grGet(GR_NUM_FB, 4, (void *) &numFB);
config->SSTs[i].numChips = numFB;
- /* this can only be useful for Voodoo2:
- * sliDetect = ((config->SSTs[i].type == GR_SSTTYPE_Voodoo2) && (numFB > 1));
- */
+
}
tdfx_hook_glide(&config->Glide);