From fa21787b52d85a7aeaf5de64a39e019f39fcfa07 Mon Sep 17 00:00:00 2001 From: Daniel Borca Date: Tue, 2 Mar 2004 08:15:24 +0000 Subject: workaround for crash-upon-exit in verbose mode fxMesa now uses grQueryResolution minor fixes to X11 and DOS drivers --- docs/README.3DFX | 6 +-- src/mesa/Makefile.DJ | 2 +- src/mesa/Makefile.mgw | 1 - src/mesa/Makefile.wfx | 2 +- src/mesa/drivers/dos/dmesa.c | 39 +------------- src/mesa/drivers/glide/fxapi.c | 113 ++++++++++++++++++++++++++--------------- src/mesa/drivers/glide/fxwgl.c | 2 + src/mesa/drivers/x11/xm_api.c | 23 +++++---- 8 files changed, 93 insertions(+), 95 deletions(-) diff --git a/docs/README.3DFX b/docs/README.3DFX index 4b8e13fb9c..3169d298e2 100644 --- a/docs/README.3DFX +++ b/docs/README.3DFX @@ -6,9 +6,9 @@ Mesa-6.0 release notes: ----------------------- -1) Glide2 support has been ceased; in order to keep Voodoo Graphics - and Voodoo Rush compatibility, please visit the Glide SourceForge - and help us to fix Glide3 for those cards. +1) Glide2 support has been ceased; in order to keep Voodoo Rush + compatibility, please visit the Glide SourceForge and help us + to fix Glide3 for those cards. 2) The current release is a WIP; among other things, the Linux build works only to some extent. Any help will be appreciated. 3) Glide3 can be found at http://sourceforge.net/projects/glide/ diff --git a/src/mesa/Makefile.DJ b/src/mesa/Makefile.DJ index f01c9b1e4c..ee14aa6c5a 100644 --- a/src/mesa/Makefile.DJ +++ b/src/mesa/Makefile.DJ @@ -73,7 +73,7 @@ export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH);$(LIBDIR);$(GLIDE)/lib CC = gcc CFLAGS += -I$(TOP)/include -I. -Imain -Iglapi ifeq ($(FX),1) -CFLAGS += -D__DOS__ -DH3 +CFLAGS += -D__DOS__ CFLAGS += -I$(GLIDE)/include -DFX LIBNAME = "Mesa/FX DJGPP" else diff --git a/src/mesa/Makefile.mgw b/src/mesa/Makefile.mgw index 7db07bc176..31b57959f9 100644 --- a/src/mesa/Makefile.mgw +++ b/src/mesa/Makefile.mgw @@ -74,7 +74,6 @@ CC = mingw32-gcc CFLAGS += -DBUILD_GL32 -D_OPENGL32_ -D_MSC_VER CFLAGS += -I$(TOP)/include -I. -Imain -Iglapi ifeq ($(FX),1) -CFLAGS += -DH3 CFLAGS += -I$(GLIDE)/include -DFX LDLIBS += -L$(GLIDE)/lib -lglide3x GL_DEF = drivers/glide/fxopengl.def diff --git a/src/mesa/Makefile.wfx b/src/mesa/Makefile.wfx index 0a8b8c3b0e..543dcfad0c 100644 --- a/src/mesa/Makefile.wfx +++ b/src/mesa/Makefile.wfx @@ -59,7 +59,7 @@ HAVE_3DNOW = 1 ################################## # build flags ################################## -FLAGS = -DH3 -DFX -DBUILD_GL32 +FLAGS = -DFX -DBUILD_GL32 !if "$(USE_IEEE)"=="1" FLAGS = $(FLAGS) -D__i386__ diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c index 752f13e909..f6ff5eb50b 100644 --- a/src/mesa/drivers/dos/dmesa.c +++ b/src/mesa/drivers/dos/dmesa.c @@ -1360,44 +1360,7 @@ int DMesaGetIntegerv (GLenum pname, GLint *params) #ifndef FX return vl_get(VL_GET_VIDEO_MODES, params); #else - { - /* `vmode' struct must be sync'ed with `internal.h' (vl_mode) - * `vmode' list must be sync'ed with `fxapi.c' - * `hw >= 6' means Napalm and can do 32bit rendering - * TODO: we should take an envvar for `fxMesaSelectCurrentBoard' - */ - static struct { - int width, height; - int bpp; - } vmode[] = { - { 320, 200, 16 }, - { 320, 240, 16 }, - { 512, 384, 16 }, - { 640, 400, 16 }, - { 640, 480, 16 }, - { 800, 600, 16 }, - {1024, 768, 16 }, - - { 320, 200, 32 }, - { 320, 240, 32 }, - { 512, 384, 32 }, - { 640, 400, 32 }, - { 640, 480, 32 }, - { 800, 600, 32 }, - {1024, 768, 32 } - }; - int hw = fxMesaSelectCurrentBoard(0); - int i, n = sizeof(vmode) / sizeof(vmode[0]); - if (hw < 6) { - n /= 2; - } - if (params) { - for (i = 0; i < n; i++) { - params[i] = (GLint)(&vmode[i]); - } - } - return n; - } + return -1; /* TODO */ #endif case DMESA_GET_BUFFER_ADDR: #ifndef FX diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c index 10d572a9e0..930534fcd8 100644 --- a/src/mesa/drivers/glide/fxapi.c +++ b/src/mesa/drivers/glide/fxapi.c @@ -203,34 +203,65 @@ gl3DfxSetPaletteEXT(GLuint * pal) static GrScreenResolution_t fxBestResolution (int width, int height) { - static int resolutions[][5] = { -#if 1 /* Voodoo^2 can't fullscreen these, because of Glide */ - { 320, 200, GR_RESOLUTION_320x200 }, - { 320, 240, GR_RESOLUTION_320x240 }, -#endif - { 512, 384, GR_RESOLUTION_512x384 }, - { 640, 400, GR_RESOLUTION_640x400 }, - { 640, 480, GR_RESOLUTION_640x480 }, - { 800, 600, GR_RESOLUTION_800x600 }, - {1024, 768, GR_RESOLUTION_1024x768 }, - {1280, 1024, GR_RESOLUTION_1280x1024}, - {1600, 1200, GR_RESOLUTION_1600x1200}, + static int resolutions[][3] = { + { GR_RESOLUTION_320x200, 320, 200 }, + { GR_RESOLUTION_320x240, 320, 240 }, + { GR_RESOLUTION_400x256, 400, 256 }, + { GR_RESOLUTION_512x384, 512, 384 }, + { GR_RESOLUTION_640x200, 640, 200 }, + { GR_RESOLUTION_640x350, 640, 350 }, + { GR_RESOLUTION_640x400, 640, 400 }, + { GR_RESOLUTION_640x480, 640, 480 }, + { GR_RESOLUTION_800x600, 800, 600 }, + { GR_RESOLUTION_960x720, 960, 720 }, + { GR_RESOLUTION_856x480, 856, 480 }, + { GR_RESOLUTION_512x256, 512, 256 }, + { GR_RESOLUTION_1024x768, 1024, 768 }, + { GR_RESOLUTION_1280x1024, 1280, 1024 }, + { GR_RESOLUTION_1600x1200, 1600, 1200 }, + { GR_RESOLUTION_400x300, 400, 300 }, + { GR_RESOLUTION_1152x864, 1152, 864 }, + { GR_RESOLUTION_1280x960, 1280, 960 }, + { GR_RESOLUTION_1600x1024, 1600, 1024 }, + { GR_RESOLUTION_1792x1344, 1792, 1344 }, + { GR_RESOLUTION_1856x1392, 1856, 1392 }, + { GR_RESOLUTION_1920x1440, 1920, 1440 }, + { GR_RESOLUTION_2048x1536, 2048, 1536 }, + { GR_RESOLUTION_2048x2048, 2048, 2048 } }; - int i, NUM_RESOLUTIONS = sizeof(resolutions) / sizeof(resolutions[0]); - int lastvalidres = 4; /* set default to GR_RESOLUTION_640x480 */ + int i, size; + int lastvalidres = GR_RESOLUTION_640x480; int min = 2048 * 2048; /* max is GR_RESOLUTION_2048x2048 */ - - for (i = 0; i < NUM_RESOLUTIONS; i++) { - if ((width <= resolutions[i][0]) && (height <= resolutions[i][1])) { - if (min > (resolutions[i][0] * resolutions[i][1])) { - min = resolutions[i][0] * resolutions[i][1]; - lastvalidres = i; + GrResolution resTemplate = { + GR_QUERY_ANY, + GR_QUERY_ANY, + 2 /*GR_QUERY_ANY */, + GR_QUERY_ANY + }; + GrResolution *presSupported; + + fxQueryHardware(); + + size = grQueryResolutions(&resTemplate, NULL); + presSupported = malloc(size); + + size /= sizeof(GrResolution); + grQueryResolutions(&resTemplate, presSupported); + + for (i = 0; i < size; i++) { + int r = presSupported[i].resolution; + if ((width <= resolutions[r][1]) && (height <= resolutions[r][2])) { + if (min > (resolutions[r][1] * resolutions[r][2])) { + min = resolutions[r][1] * resolutions[r][2]; + lastvalidres = r; } } } - return resolutions[lastvalidres][2]; + free(presSupported); + + return resolutions[lastvalidres][0]; } @@ -770,6 +801,25 @@ fxMesaDestroyContext(fxMesaContext fxMesa) glbTotNumCtx--; + if (!glbTotNumCtx && 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); + } + /* [dBorca] * close the hardware first, so we can debug * atexit problems (memory leaks, etc). @@ -886,27 +936,6 @@ 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; diff --git a/src/mesa/drivers/glide/fxwgl.c b/src/mesa/drivers/glide/fxwgl.c index 3abb1a0c85..3a581ef66a 100644 --- a/src/mesa/drivers/glide/fxwgl.c +++ b/src/mesa/drivers/glide/fxwgl.c @@ -746,8 +746,10 @@ wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR * ppfd) if (pfd.cAlphaBits > 0 && pix[i].pfd.cAlphaBits == 0) continue; /* need alpha buffer */ +#if 0 /* [dBorca] regression bug? */ if (pfd.cStencilBits > 0 && pix[i].pfd.cStencilBits == 0) continue; /* need stencil buffer */ +#endif if (pfd.iPixelType == pix[i].pfd.iPixelType) { best = i + 1; diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 16963ab71c..c36c9c9c6a 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1830,15 +1830,19 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w, } attribs[numAttribs++] = FXMESA_NONE; - /* [dBorca] we should take an envvar for `fxMesaSelectCurrentBoard'!!! */ - if ((hw = fxMesaSelectCurrentBoard(0))==GR_SSTTYPE_VOODOO) { + /* [dBorca] we should take an envvar for `fxMesaSelectCurrentBoard'!!! */ + hw = fxMesaSelectCurrentBoard(0); + if ((hw == GR_SSTTYPE_VOODOO) || (hw == GR_SSTTYPE_Voodoo2)) { b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs); if ((v->undithered_pf!=PF_Index) && (b->backimage)) { b->FXisHackUsable = b->FXctx ? GL_TRUE : GL_FALSE; - if (fxEnvVar[0]=='w' || fxEnvVar[0]=='W') - b->FXwindowHack = b->FXctx ? GL_TRUE : GL_FALSE; - else + if (b->FXctx && (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')) { + b->FXwindowHack = GL_TRUE; + FX_grSstControl(GR_CONTROL_DEACTIVATE); + } + else { b->FXwindowHack = GL_FALSE; + } } } else { @@ -2210,6 +2214,10 @@ GLboolean XMesaSetFXmode( GLint mode ) return GL_FALSE; } if (ctx) { + /* [dBorca] Hack alert: + * oh, this is sooo wrong: ctx above is + * really an fxMesaContext, not an XMesaContext + */ XMesaContext xmesa = XMESA_CONTEXT(ctx); if (mode == XMESA_FX_WINDOW) { if (xmesa->xm_draw_buffer->FXisHackUsable) { @@ -2269,10 +2277,7 @@ static void FXgetImage( XMesaBuffer b ) xmesa_alloc_back_buffer( b ); } - /* [dBorca] - * not needed for Voodoo2 anymore. - * should we test fxMesa->bgrOrder? - */ + /* [dBorca] we're always in the right GR_COLORFORMAT... aren't we? */ /* grLfbWriteColorFormat(GR_COLORFORMAT_ARGB); */ if (b->xm_visual->undithered_pf==PF_5R6G5B) { /* Special case: 16bpp RGB */ -- cgit v1.2.3