From 5a95679e58b3861eae5b276a1ff0b508f409f066 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 15 Nov 1999 18:05:00 +0000 Subject: update/merge with Daryll's X server changes --- src/mesa/drivers/glide/fxapi.c | 91 ++++- src/mesa/drivers/glide/fxdd.c | 248 ++++++++---- src/mesa/drivers/glide/fxddspan.c | 243 +++++++----- src/mesa/drivers/glide/fxddtex.c | 57 ++- src/mesa/drivers/glide/fxdrv.h | 124 ++++-- src/mesa/drivers/glide/fxglidew.c | 230 +++++++++-- src/mesa/drivers/glide/fxglidew.h | 510 +++++++++++++++++++++++-- src/mesa/drivers/glide/fxsetup.c | 783 ++++++++++++++++++++++---------------- src/mesa/drivers/glide/fxtexman.c | 222 +++++++++-- src/mesa/drivers/glide/fxwgl.c | 76 ++-- 10 files changed, 1872 insertions(+), 712 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c index baa9f3e15c..ca56188103 100644 --- a/src/mesa/drivers/glide/fxapi.c +++ b/src/mesa/drivers/glide/fxapi.c @@ -1,24 +1,52 @@ -/* -*- mode: C; tab-width:8; -*- - - fxapi.c - 3Dfx VooDoo/Mesa interface -*/ +/* -*- mode: C; tab-width:8; -*- */ /* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * Mesa 3-D graphics library + * Version: 3.1 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. + * Copyright (C) 1999 Brian Paul All Rights Reserved. * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: * - ******************************************************************** + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * + * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the + * terms stated above. + * + * Thank you for your contribution, David! + * + * Please make note of the above copyright/license statement. If you + * contributed code or bug fixes to this code under the previous (GNU + * Library) license and object to the new license, your code will be + * removed at your request. Please see the Mesa docs/COPYRIGHT file + * for more information. + * + * Additional Mesa/3Dfx driver developers: + * Daryll Strauss + * Keith Whitwell + * + * See fxapi.h for more revision/author details. + */ + + +/* fxapi.c - 3Dfx VooDoo/Mesa interface */ + + +/******************************************************************** * * Function names: * fxMesa.... (The driver API) @@ -820,9 +848,10 @@ void fxsignals() /* * 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; @@ -835,7 +864,7 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,GrScreenResolution_t res GLint accumSize=0; GLcontext *shareCtx = NULL; GLcontext *ctx = 0; - FX_GrContext_t glideContext = 0; + /*FX_GrContext_t glideContext = 0;*/ char *errorstr; if (MESA_VERBOSE&VERBOSE_DRIVER) { @@ -942,10 +971,30 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,GrScreenResolution_t res goto errorhandler; } + /* Pixel tables are use during pixel read-back */ + if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) { + fxInitPixelTables(GL_TRUE); /* use BGR pixel order on Voodoo1/2 */ + } + else { + fxInitPixelTables(GL_FALSE); /* use RGB pixel order otherwise */ + } fxMesa->width=FX_grSstScreenWidth(); fxMesa->height=FX_grSstScreenHeight(); + fxMesa->clipMinX = 0; + fxMesa->clipMaxX = fxMesa->width; + fxMesa->clipMinY = 0; + fxMesa->clipMaxY = fxMesa->height; + + fxMesa->screen_width = fxMesa->width; + fxMesa->screen_height = fxMesa->height; + fxMesa->x_offset = 0; + fxMesa->y_offset = 0; + fxMesa->y_delta = 0; + + fxMesa->needClip = 0; + if(verbose) fprintf(stderr,"Glide screen size: %dx%d\n", (int)FX_grSstScreenWidth(),(int)FX_grSstScreenHeight()); @@ -1204,7 +1253,7 @@ int GLAPIENTRY fxQueryHardware(void) char buf[80]; FX_grGlideGetVersion(buf); - fprintf(stderr,"Using Glide V%s\n",0); + fprintf(stderr,"Using Glide V%s\n",""); fprintf(stderr,"Number of boards: %d\n",glbHWConfig.num_sst); if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) { diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 3580971ae8..cbe63695fa 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -1,28 +1,51 @@ -/* -*- mode: C; tab-width:8; -*- - - fxdd.c - 3Dfx VooDoo Mesa device driver functions -*/ +/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */ /* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * Mesa 3-D graphics library + * Version: 3.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. + * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the + * terms stated above. * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Thank you for your contribution, David! * - * See the file fxapi.c for more informations about authors + * Please make note of the above copyright/license statement. If you + * contributed code or bug fixes to this code under the previous (GNU + * Library) license and object to the new license, your code will be + * removed at your request. Please see the Mesa docs/COPYRIGHT file + * for more information. * + * Additional Mesa/3Dfx driver developers: + * Daryll Strauss + * Keith Whitwell + * + * See fxapi.h for more revision/author details. */ +/* fxdd.c - 3Dfx VooDoo Mesa device driver functions */ + + #ifdef HAVE_CONFIG_H #include "conf.h" #endif @@ -34,6 +57,44 @@ #include "enums.h" #include "extensions.h" + +/* These lookup table are used to extract RGB values in [0,255] from + * 16-bit pixel values. + */ +GLubyte FX_PixelToR[0x10000]; +GLubyte FX_PixelToG[0x10000]; +GLubyte FX_PixelToB[0x10000]; + + +/* + * Initialize the FX_PixelTo{RGB} arrays. + * Input: bgrOrder - if TRUE, pixels are in BGR order, else RGB order. + */ +void fxInitPixelTables(GLboolean bgrOrder) +{ + GLuint pixel; + 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; + } +} + + /**********************************************************************/ /***** Miscellaneous functions *****/ /**********************************************************************/ @@ -45,10 +106,11 @@ void fxDDDither(GLcontext *ctx, GLboolean enable) fprintf(stderr,"fxmesa: fxDDDither()\n"); } - if(enable) - grDitherMode(GR_DITHER_4x4); - else - grDitherMode(GR_DITHER_DISABLE); + if (enable) { + FX_grDitherMode(GR_DITHER_4x4); + } else { + FX_grDitherMode(GR_DITHER_DISABLE); + } } @@ -121,14 +183,14 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all, /* clear color and depth buffer */ if (ctx->Color.DrawDestMask & BACK_LEFT_BIT) { - grRenderBuffer(GR_BUFFER_BACKBUFFER); - grBufferClear(fxMesa->clearC, fxMesa->clearA, - (FxU16)(ctx->Depth.Clear*0xffff)); + FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, + (FxU16)(ctx->Depth.Clear*0xffff)); } if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT) { - grRenderBuffer(GR_BUFFER_FRONTBUFFER); - grBufferClear(fxMesa->clearC, fxMesa->clearA, - (FxU16)(ctx->Depth.Clear*0xffff)); + FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, + (FxU16)(ctx->Depth.Clear*0xffff)); } newmask=mask & (~(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)); @@ -137,19 +199,20 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all, /* clear color buffer */ if(ctx->Color.ColorMask) { - grDepthMask(FXFALSE); + FX_grDepthMask(FXFALSE); if (ctx->Color.DrawDestMask & BACK_LEFT_BIT) { - grRenderBuffer(GR_BUFFER_BACKBUFFER); - grBufferClear(fxMesa->clearC, fxMesa->clearA, 0); + FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 0); } if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT) { - grRenderBuffer(GR_BUFFER_FRONTBUFFER); - grBufferClear(fxMesa->clearC, fxMesa->clearA, 0); + FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 0); } - if(ctx->Depth.Mask) - grDepthMask(FXTRUE); + if(ctx->Depth.Mask) { + FX_grDepthMask(FXTRUE); + } } newmask=mask & (~(GL_COLOR_BUFFER_BIT)); @@ -158,14 +221,14 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all, /* clear depth buffer */ if(ctx->Depth.Mask) { - grColorMask(FXFALSE,FXFALSE); - grBufferClear(fxMesa->clearC, fxMesa->clearA, - (FxU16)(ctx->Depth.Clear*0xffff)); - - grColorMask(ctx->Color.ColorMask[RCOMP] || - ctx->Color.ColorMask[GCOMP] || - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); + FX_grColorMask(FXFALSE,FXFALSE); + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, + (FxU16)(ctx->Depth.Clear*0xffff)); + + FX_grColorMask(ctx->Color.ColorMask[RCOMP] || + ctx->Color.ColorMask[GCOMP] || + ctx->Color.ColorMask[BCOMP], + ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); } newmask=mask & (~(GL_DEPTH_BUFFER_BIT)); @@ -190,12 +253,12 @@ static GLboolean fxDDSetBuffer(GLcontext *ctx, GLenum mode ) if (mode == GL_FRONT_LEFT) { fxMesa->currentFB = GR_BUFFER_FRONTBUFFER; - grRenderBuffer(fxMesa->currentFB); + FX_grRenderBuffer(fxMesa->currentFB); return GL_TRUE; } else if (mode == GL_BACK_LEFT) { fxMesa->currentFB = GR_BUFFER_BACKBUFFER; - grRenderBuffer(fxMesa->currentFB); + FX_grRenderBuffer(fxMesa->currentFB); return GL_TRUE; } else { @@ -204,6 +267,22 @@ static GLboolean fxDDSetBuffer(GLcontext *ctx, GLenum mode ) } +#ifdef XF86DRI +static GLboolean inClipRects(fxMesaContext fxMesa, int px, int py) +{ + int i; + + py=fxMesa->height+fxMesa->y_offset-py; + for (i=0; inumClipRects; i++) { + if ((px>=fxMesa->pClipRects[i].x1) && + (pxpClipRects[i].x2) && + (py>=fxMesa->pClipRects[i].y1) && + (pypClipRects[i].y2)) return GL_TRUE; + } + return GL_FALSE; +} +#endif + static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py, GLsizei width, GLsizei height, @@ -241,10 +320,16 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py, ymax=fxMesa->height; } + xmin+=fxMesa->x_offset; + xmax+=fxMesa->x_offset; -#define ISCLIPPED(rx) ( ((rx)=xmax) ) +#ifdef XF86DRI +#define ISCLIPPED(rx, ry) ( ((rx)=xmax) || !inClipRects(fxMesa, rx, ry)) +#else +#define ISCLIPPED(rx, ry) ( ((rx)=xmax) ) +#endif #define DRAWBIT(i) { \ - if(!ISCLIPPED(x+px)) \ + if(!ISCLIPPED(x+px, y)) \ if( (*pb) & (1<<(i)) ) \ (*p)=color; \ p++; \ @@ -258,7 +343,7 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py, scrwidth=fxMesa->width; scrheight=fxMesa->height; - if((px>=scrwidth) || (px+width<=0) || (py>=scrheight) || (py+height<=0)) + if ((px>=scrwidth) || (px+width<=0) || (py>=scrheight) || (py+height<=0)) return GL_TRUE; pb=bitmap; @@ -269,16 +354,16 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py, py=0; } - if(py+height>=scrheight) + if (py+height>=scrheight) height-=(py+height)-scrheight; info.size=sizeof(info); - if(!grLfbLock(GR_LFB_WRITE_ONLY, - fxMesa->currentFB, - GR_LFBWRITEMODE_565, - GR_ORIGIN_UPPER_LEFT, - FXFALSE, - &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"); #endif @@ -298,13 +383,13 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py, /* This code is a bit slow... */ - for(y=py;y<(py+height);y++) { + if (py>ymin) ymin=py; + if (py+height=ymax) - break; + px+=fxMesa->x_offset; + scrheight=fxMesa->height+fxMesa->y_offset; - if (y<=ymin) - continue; + for(y=ymin; ycurrentFB); + FX_grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB); #undef ISCLIPPED #undef DRAWBIT @@ -347,8 +432,6 @@ void fxDDSetNearFar(GLcontext *ctx, GLfloat n, GLfloat f) { FX_CONTEXT(ctx)->new_state |= FX_NEW_FOG; ctx->Driver.RenderStart = fxSetupFXUnits; - - FX_CONTEXT(ctx)->wscale = fabs(f)/65535.0f; } /* KW: Put the word Mesa in the render string because quakeworld @@ -459,13 +542,13 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) fxMesa->unitsState.depthMask =GL_TRUE; fxMesa->unitsState.depthTestFunc =GR_CMP_LESS; - grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE); + FX_grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE); if(fxMesa->haveDoubleBuffer) { fxMesa->currentFB=GR_BUFFER_BACKBUFFER; - grRenderBuffer(GR_BUFFER_BACKBUFFER); + FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); } else { fxMesa->currentFB=GR_BUFFER_FRONTBUFFER; - grRenderBuffer(GR_BUFFER_FRONTBUFFER); + FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); } fxMesa->state = NULL; @@ -481,10 +564,10 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) } if(fxMesa->haveZBuffer) - grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); + FX_grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); #if (!FXMESA_USE_ARGB) - grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); /* Not every Glide has this */ + FX_grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); /* Not every Glide has this */ #endif fxMesa->glCtx->Const.MaxTextureLevels=9; @@ -505,7 +588,7 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) fxDDSetNearFar(fxMesa->glCtx,1.0,100.0); - grGlideGetState((GrState*)fxMesa->state); + FX_grGlideGetState((GrState*)fxMesa->state); /* XXX Fix me: callback not registered when main VB is created. */ @@ -546,6 +629,12 @@ void fxDDInitExtensions( GLcontext *ctx ) gl_extensions_disable( ctx, "GL_ARB_multitexture" ); } +/* + This driver may need to move the drawing operations to a different sub + window. This modifies the viewport command to add our X,Y offset to all + drawn objects that go through the viewport transformation. +*/ + /************************************************************************/ /************************************************************************/ /************************************************************************/ @@ -591,16 +680,19 @@ static GLboolean fxIsInHardware(GLcontext *ctx) /* Not very well written ... */ ((ctx->Enabled & (TEXTURE0_1D | TEXTURE1_1D)) && ((ctx->Enabled & (TEXTURE0_2D | TEXTURE1_2D))!=(TEXTURE0_2D | TEXTURE1_2D))) - ) + ) { return GL_FALSE; + } if((ctx->Texture.ReallyEnabled & TEXTURE0_2D) && - (ctx->Texture.Unit[0].EnvMode==GL_BLEND)) + (ctx->Texture.Unit[0].EnvMode==GL_BLEND)) { return GL_FALSE; + } if((ctx->Texture.ReallyEnabled & TEXTURE1_2D) && - (ctx->Texture.Unit[1].EnvMode==GL_BLEND)) + (ctx->Texture.Unit[1].EnvMode==GL_BLEND)) { return GL_FALSE; + } if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE)) @@ -617,8 +709,9 @@ static GLboolean fxIsInHardware(GLcontext *ctx) /* Can't use multipass to blend a multitextured triangle - fall * back to software. */ - if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled) + 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) && @@ -626,7 +719,6 @@ static GLboolean fxIsInHardware(GLcontext *ctx) { if (MESA_VERBOSE&VERBOSE_DRIVER) fprintf(stderr, "fxMesa: unsupported multitex env mode\n"); - return GL_FALSE; } } @@ -635,13 +727,15 @@ static GLboolean fxIsInHardware(GLcontext *ctx) /* 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)) + (ctx->Texture.Unit[0].EnvMode==GL_BLEND)) { return GL_FALSE; + } } return GL_TRUE; @@ -680,11 +774,11 @@ static void fxDDUpdateDDPointers(GLcontext *ctx) ctx->Driver.LineFunc=fxMesa->LineFunc; ctx->Driver.TriangleFunc=fxMesa->TriangleFunc; ctx->Driver.QuadFunc=fxMesa->QuadFunc; - } else + } else { fxMesa->render_index = FX_FALLBACK; + } } - void fxSetupDDPointers(GLcontext *ctx) { if (MESA_VERBOSE&VERBOSE_DRIVER) { @@ -748,7 +842,6 @@ void fxSetupDDPointers(GLcontext *ctx) ctx->Driver.CullFace=fxDDCullFace; ctx->Driver.ShadeModel=fxDDShadeModel; ctx->Driver.Enable=fxDDEnable; - ctx->Driver.RegisterVB=fxDDRegisterVB; ctx->Driver.UnregisterVB=fxDDUnregisterVB; @@ -786,3 +879,4 @@ int gl_fx_dummy_function_dd(void) } #endif /* FX */ + diff --git a/src/mesa/drivers/glide/fxddspan.c b/src/mesa/drivers/glide/fxddspan.c index 21b48ae789..1cb13397bb 100644 --- a/src/mesa/drivers/glide/fxddspan.c +++ b/src/mesa/drivers/glide/fxddspan.c @@ -1,27 +1,51 @@ -/* -*- mode: C; tab-width:8; -*- - - fxdd.c - 3Dfx VooDoo Mesa span and pixel functions -*/ +/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */ /* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * Mesa 3-D graphics library + * Version: 3.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the + * terms stated above. * - * See the file fxapi.c for more informations about authors + * Thank you for your contribution, David! * + * Please make note of the above copyright/license statement. If you + * contributed code or bug fixes to this code under the previous (GNU + * Library) license and object to the new license, your code will be + * removed at your request. Please see the Mesa docs/COPYRIGHT file + * for more information. + * + * Additional Mesa/3Dfx driver developers: + * Daryll Strauss + * Keith Whitwell + * + * See fxapi.h for more revision/author details. */ + +/* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */ + + #ifdef HAVE_CONFIG_H #include "conf.h" #endif @@ -50,7 +74,7 @@ src_width, \ src_stride, \ src_data) \ - grLfbWriteRegion(dst_buffer, \ + writeRegionClipped(fxMesa, dst_buffer, \ dst_x, \ dst_y, \ GR_LFB_SRC_FMT_8888, \ @@ -84,7 +108,7 @@ void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer, { argb[i] = MESACOLOR_TO_ARGB(rgba[i]); } - FX_grLfbWriteRegion(dst_buffer, + writeRegionClipped(fxMesa, dst_buffer, dst_x, dst_y, GR_LFB_SRC_FMT_8888, @@ -96,6 +120,59 @@ void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer, #endif +#if defined(FX_GLIDE3) && defined(XF86DRI) + +FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer, + FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format, + FxU32 src_width, FxU32 src_height, FxI32 src_stride, + void *src_data) +{ + int i, x, w; + void *data; + + if (src_width==1 && src_height==1) { /* Easy case writing a point */ + for (i=0; inumClipRects; i++) { + if ((dst_x>=fxMesa->pClipRects[i].x1) && + (dst_xpClipRects[i].x2) && + (dst_y>=fxMesa->pClipRects[i].y1) && + (dst_ypClipRects[i].y2)) { + FX_grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format, + src_width, src_height, src_stride, src_data); + return GL_TRUE; + } + } + } else if (src_height==1) { /* Writing a span */ + for (i=0; inumClipRects; i++) { + if (dst_y>=fxMesa->pClipRects[i].y1 && dst_ypClipRects[i].y2) { + if (dst_xpClipRects[i].x1) { + x=fxMesa->pClipRects[i].x1; + data=((char*)src_data)+2*(dst_x-x); + w=src_width-(x-dst_x); + } else { + x=dst_x; + data=src_data; + w=src_width; + } + if (x+w>fxMesa->pClipRects[i].x2) { + w=fxMesa->pClipRects[i].x2-x; + } + FX_grLfbWriteRegion(dst_buffer, x, dst_y, src_format, w, src_height, + src_stride, data); + } + } + } else { /* Punt on the case of arbitrary rectangles */ + return GL_FALSE; + } + return GL_TRUE; +} + +#else + +#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \ + FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) + +#endif + /************************************************************************/ /***** Span functions *****/ /************************************************************************/ @@ -107,12 +184,13 @@ static void fxDDWriteRGBASpan(const GLcontext *ctx, { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; - GLint bottom=fxMesa->height-1; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDWriteRGBASpan(...)\n"); } + x+=fxMesa->x_offset; if (mask) { int span=0; @@ -143,13 +221,14 @@ static void fxDDWriteRGBSpan(const GLcontext *ctx, { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; - GLint bottom=fxMesa->height-1; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; GLubyte rgba[MAX_WIDTH][4]; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDWriteRGBSpan()\n"); } + x+=fxMesa->x_offset; if (mask) { int span=0; @@ -192,13 +271,14 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx, { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; - GLint bottom=fxMesa->height-1; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; GLuint data[MAX_WIDTH]; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDWriteMonoRGBASpan(...)\n"); } + x+=fxMesa->x_offset; if (mask) { int span=0; @@ -208,7 +288,7 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx, ++span; } else { if (span > 0) { - FX_grLfbWriteRegion( fxMesa->currentFB, x+i-span, bottom-y, + writeRegionClipped(fxMesa, fxMesa->currentFB, x+i-span, bottom-y, GR_LFB_SRC_FMT_8888, span, 1, 0, (void *) data ); span = 0; @@ -217,7 +297,7 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx, } if (span > 0) - FX_grLfbWriteRegion( fxMesa->currentFB, x+n-span, bottom-y, + writeRegionClipped(fxMesa, fxMesa->currentFB, x+n-span, bottom-y, GR_LFB_SRC_FMT_8888, span, 1, 0, (void *) data ); } else { @@ -225,7 +305,7 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx, data[i]=(GLuint) fxMesa->color; } - FX_grLfbWriteRegion( fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888, + writeRegionClipped(fxMesa, fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888, n, 1, 0, (void *) data ); } } @@ -237,7 +317,7 @@ static void fxDDReadRGBASpan(const GLcontext *ctx, fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLushort data[MAX_WIDTH]; GLuint i; - GLint bottom=fxMesa->height-1; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDReadRGBASpan(...)\n"); @@ -245,20 +325,16 @@ static void fxDDReadRGBASpan(const GLcontext *ctx, assert(n < MAX_WIDTH); - grLfbReadRegion( fxMesa->currentFB, x, bottom-y, n, 1, 0, data); + x+=fxMesa->x_offset; + FX_grLfbReadRegion( fxMesa->currentFB, x, bottom-y, n, 1, 0, data); + for (i=0;i> 8; - rgba[i][GCOMP]=(data[i] & 0x07E0) >> 3; - rgba[i][BCOMP]=(data[i] & 0x001F) << 3; -#else - rgba[i][RCOMP]=(data[i] & 0x001f) << 3; - rgba[i][GCOMP]=(data[i] & 0x07e0) >> 3; - rgba[i][BCOMP]=(data[i] & 0xf800) >> 8; -#endif - rgba[i][ACOMP]=255; + 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; } - } /************************************************************************/ @@ -271,7 +347,7 @@ static void fxDDWriteRGBAPixels(const GLcontext *ctx, { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; - GLint bottom=fxMesa->height-1; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n"); @@ -279,8 +355,8 @@ static void fxDDWriteRGBAPixels(const GLcontext *ctx, for(i=0;icurrentFB,x[i],bottom-y[i], - /*GR_LFB_SRC_FMT_8888,*/1,/*1,*/0,(void *)rgba[i]); + LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i]+fxMesa->x_offset, bottom-y[i], + 1, 1, (void *)rgba[i]); } static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx, @@ -289,7 +365,7 @@ static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx, { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; - GLint bottom=fxMesa->height-1; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n"); @@ -297,7 +373,7 @@ static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx, for(i=0;icurrentFB,x[i],bottom-y[i], + writeRegionClipped(fxMesa, fxMesa->currentFB,x[i]+fxMesa->x_offset,bottom-y[i], GR_LFB_SRC_FMT_8888,1,1,0,(void *) &fxMesa->color); } @@ -307,31 +383,25 @@ static void fxDDReadRGBAPixels(const GLcontext *ctx, { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; - GLint bottom=fxMesa->height-1; - GLushort data; + GLint bottom=fxMesa->y_delta-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n"); } - for(i=0;icurrentFB,x[i],bottom-y[i],1,1,0,&data); - #if FXMESA_USE_ARGB - rgba[i][RCOMP]=(data & 0xF800) >> 8; - rgba[i][GCOMP]=(data & 0x07E0) >> 3; - rgba[i][BCOMP]=(data & 0x001F) >> 8; - #else - rgba[i][RCOMP]=(data & 0x001f) << 3; - rgba[i][GCOMP]=(data & 0x07e0) >> 3; - rgba[i][BCOMP]=(data & 0xf800) >> 8; - #endif - /* the alpha value should be read from the auxiliary buffer when required */ - - rgba[i][ACOMP]=255; + GLushort pixel; + FX_grLfbReadRegion(fxMesa->currentFB,x[i],bottom-y[i],1,1,0,&pixel); + rgba[i][RCOMP] = FX_PixelToR[pixel]; + rgba[i][GCOMP] = FX_PixelToG[pixel]; + rgba[i][BCOMP] = FX_PixelToB[pixel]; + rgba[i][ACOMP] = 255; } + } } + /************************************************************************/ /***** Depth functions *****/ /************************************************************************/ @@ -341,14 +411,15 @@ void fxDDReadDepthSpanFloat(GLcontext *ctx, { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; - GLint bottom=fxMesa->height-1; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; GLushort data[MAX_WIDTH]; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDReadDepthSpanFloat(...)\n"); } - grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,data); + x+=fxMesa->x_offset; + FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,data); /* convert the read values to float values [0.0 .. 1.0]. @@ -361,13 +432,14 @@ void fxDDReadDepthSpanInt(GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth depth[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLint bottom=fxMesa->height-1; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n"); } - grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depth); + x+=fxMesa->x_offset; + FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depth); } GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx, @@ -380,13 +452,14 @@ GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx, GLubyte *m=mask; GLuint i; GLuint passed=0; - GLint bottom=fxMesa->height-1; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDDepthTestSpanGeneric(...)\n"); } - grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depthdata); + x+=fxMesa->x_offset; + FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depthdata); /* switch cases ordered from most frequent to less frequent */ switch (ctx->Depth.Func) { @@ -578,7 +651,7 @@ GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx, } /*switch*/ if(passed) - FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,GR_LFB_SRC_FMT_ZA16,n,1,0,depthdata); + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x,bottom-y,GR_LFB_SRC_FMT_ZA16,n,1,0,depthdata); return passed; } @@ -590,7 +663,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLdepth zval; GLuint i; - GLint bottom=fxMesa->height-1; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDDepthTestPixelsGeneric(...)\n"); @@ -603,10 +676,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] < zval) { /* pass */ - FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); } else { /* fail */ mask[i] = 0; @@ -617,7 +690,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Don't update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] < zval) { /* pass */ } @@ -634,10 +707,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] <= zval) { /* pass */ - FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); } else { /* fail */ mask[i] = 0; @@ -648,7 +721,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Don't update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] <= zval) { /* pass */ } else { @@ -664,10 +737,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] >= zval) { /* pass */ - FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); } else { /* fail */ mask[i] = 0; @@ -678,7 +751,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Don't update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] >= zval) { /* pass */ } else { @@ -694,10 +767,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] > zval) { /* pass */ - FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); } else { /* fail */ mask[i] = 0; @@ -708,7 +781,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Don't update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] > zval) { /* pass */ } else { @@ -724,10 +797,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] != zval) { /* pass */ - FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); } else { /* fail */ mask[i] = 0; @@ -738,7 +811,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Don't update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] != zval) { /* pass */ } @@ -755,10 +828,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] == zval) { /* pass */ - FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); } else { /* fail */ mask[i] = 0; @@ -769,7 +842,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Don't update Z buffer */ for (i=0; ix_offset,bottom-y[i],1,1,0,&zval); if (z[i] == zval) { /* pass */ } else { @@ -785,7 +858,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx, /* Update Z buffer */ for (i=0; ix_offset,bottom-y[i],GR_LFB_SRC_FMT_ZA16,1,1,0,(void*)&z[i]); } } } else { diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c index ecfd5e3a8a..2c2fca9e5e 100644 --- a/src/mesa/drivers/glide/fxddtex.c +++ b/src/mesa/drivers/glide/fxddtex.c @@ -1,27 +1,51 @@ -/* -*- mode: C; tab-width:8; -*- - - fxddtex.c - 3Dfx VooDoo Texture mapping functions -*/ +/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */ /* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * Mesa 3-D graphics library + * Version: 3.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the + * terms stated above. * - * See the file fxapi.c for more informations about authors + * Thank you for your contribution, David! * + * Please make note of the above copyright/license statement. If you + * contributed code or bug fixes to this code under the previous (GNU + * Library) license and object to the new license, your code will be + * removed at your request. Please see the Mesa docs/COPYRIGHT file + * for more information. + * + * Additional Mesa/3Dfx driver developers: + * Daryll Strauss + * Keith Whitwell + * + * See fxapi.h for more revision/author details. */ + +/* fxddtex.c - 3Dfx VooDoo Texture mapping functions */ + + #ifdef HAVE_CONFIG_H #include "conf.h" #endif @@ -219,7 +243,6 @@ void fxDDTexParam(GLcontext *ctx, GLenum target, struct gl_texture_object *tObj, ti->sClamp=GR_TEXTURECLAMP_WRAP; break; default: - fprintf(stderr, "BAD CLAMP\n"); break; } fxMesa->new_state|=FX_NEW_TEXTURING; diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index aeb56e9a5d..158b873add 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -1,27 +1,48 @@ -/* -*- mode: C; tab-width:8; -*- - - fxdrv.h - 3Dfx VooDoo driver types -*/ +/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */ /* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * Mesa 3-D graphics library + * Version: 3.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the + * terms stated above. * - * See the file fxapi.c for more informations about authors + * Thank you for your contribution, David! * + * Please make note of the above copyright/license statement. If you + * contributed code or bug fixes to this code under the previous (GNU + * Library) license and object to the new license, your code will be + * removed at your request. Please see the Mesa docs/COPYRIGHT file + * for more information. + * + * Additional Mesa/3Dfx driver developers: + * Daryll Strauss + * Keith Whitwell + * + * See fxapi.h for more revision/author details. */ + #ifndef FXDRV_H #define FXDRV_H @@ -54,14 +75,18 @@ #include "clip.h" #include "vbrender.h" +#ifdef XF86DRI +typedef struct tfxMesaContext *fxMesaContext; +#else #include "GL/fxmesa.h" +#endif #include "fxglidew.h" /* use gl/gl.h GLAPI/GLAPIENTRY/GLCALLBACK in place of WINGDIAPI/APIENTRY/CALLBACK, */ /* these are defined in mesa gl/gl.h - tjump@spgs.com */ -#if 0 +#if defined(MESA_DEBUG) && 0 extern void fx_sanity_triangle( GrVertex *, GrVertex *, GrVertex * ); #define grDrawTriangle fx_sanity_triangle #endif @@ -140,17 +165,17 @@ typedef struct { #endif #endif -#define FX_VB_COLOR(fxm, color) \ -do { \ - if (sizeof(GLint) == 4*sizeof(GLubyte)) { \ - if (fxm->constColor != *(GLuint*)color) { \ - fxm->constColor = *(GLuint*)color; \ - grConstantColorValue(FXCOLOR4(color)); \ - } \ - } else { \ - grConstantColorValue(FXCOLOR4(color)); \ - } \ -} while (0) +#define FX_VB_COLOR(fxm, color) \ + do { \ + if (sizeof(GLint) == 4*sizeof(GLubyte)) { \ + if (fxm->constColor != *(GLuint*)color) { \ + fxm->constColor = *(GLuint*)color; \ + FX_grConstantColorValue(FXCOLOR4(color)); \ + } \ + } else { \ + FX_grConstantColorValue(FXCOLOR4(color)); \ + } \ + } while (0) #define GOURAUD(x) { \ GLubyte *col = VB->ColorPtr->data[(x)]; \ @@ -390,8 +415,21 @@ struct tfxMesaVertexBuffer { #include "tdfx_init.h" #else #define DRI_FX_CONTEXT +#define BEGIN_BOARD_LOCK() +#define END_BOARD_LOCK() +#define BEGIN_CLIP_LOOP() +#define END_CLIP_LOOP() #endif + +/* These lookup table are used to extract RGB values in [0,255] from + * 16-bit pixel values. + */ +extern GLubyte FX_PixelToR[0x10000]; +extern GLubyte FX_PixelToG[0x10000]; +extern GLubyte FX_PixelToB[0x10000]; + + struct tfxMesaContext { GuTexPalette glbPalette; @@ -412,7 +450,6 @@ struct tfxMesaContext { tfxUnitsState unitsState; tfxUnitsState restoreUnitsState; /* saved during multipass */ - GLuint tmu_source[FX_NUM_TMU]; GLuint tex_dest[MAX_TEXTURE_UNITS]; GLuint setupindex; @@ -477,8 +514,21 @@ struct tfxMesaContext { FX_GrContext_t glideContext; - GLfloat wscale; - + int x_offset; + int y_offset; + int y_delta; + int screen_width; + int screen_height; + int initDone; + int clipMinX; + int clipMaxX; + int clipMinY; + int clipMaxY; + int needClip; + int numClipRects; +#ifdef FX86DRI + XF86DRIClipRectPtr pClipRects; +#endif DRI_FX_CONTEXT }; @@ -622,4 +672,16 @@ extern void fxDDDoRenderVB( struct vertex_buffer *VB ); extern int fxDDInitFxMesaContext( fxMesaContext fxMesa ); + +extern void fxCloseHardware(void); +extern tfxTMFreeNode *fxTMNewTMFreeNode(FxU32 start, FxU32 end); +extern void fxSetScissorValues(GLcontext *ctx); +extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa, + struct gl_texture_object *tObj, + GLint where); +extern void fxSetupTexture_NoLock(GLcontext *ctx); +extern void fxSetupTexture(GLcontext *ctx); + +extern void fxInitPixelTables(GLboolean bgrOrder); + #endif diff --git a/src/mesa/drivers/glide/fxglidew.c b/src/mesa/drivers/glide/fxglidew.c index 3dd52d504b..696b8eff6c 100644 --- a/src/mesa/drivers/glide/fxglidew.c +++ b/src/mesa/drivers/glide/fxglidew.c @@ -1,28 +1,47 @@ -/* $Id: fxglidew.c,v 1.3 1999/10/05 19:26:54 miklos Exp $ */ +/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */ /* * Mesa 3-D graphics library * Version: 3.1 - * + * * Copyright (C) 1999 Brian Paul All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * + * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the + * terms stated above. + * + * Thank you for your contribution, David! + * + * Please make note of the above copyright/license statement. If you + * contributed code or bug fixes to this code under the previous (GNU + * Library) license and object to the new license, your code will be + * removed at your request. Please see the Mesa docs/COPYRIGHT file + * for more information. + * + * Additional Mesa/3Dfx driver developers: + * Daryll Strauss + * Keith Whitwell + * + * See fxapi.h for more revision/author details. */ + #ifdef HAVE_CONFIG_H #include "conf.h" @@ -36,8 +55,7 @@ #include #include - -FxI32 FX_grGetInteger(FxU32 pname) +FxI32 grGetInteger(FxU32 pname) { #if !defined(FX_GLIDE3) switch (pname) @@ -49,7 +67,7 @@ FxI32 FX_grGetInteger(FxU32 pname) case FX_LFB_PIXEL_PIPE: return FXFALSE; case FX_PENDING_BUFFERSWAPS: - return grBufferNumPending(); + return grBufferNumPending(); default: if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n"); @@ -74,13 +92,60 @@ FxI32 FX_grGetInteger(FxU32 pname) } return -1; } - + grGet(grname,4,&result); return result; #endif } +FxI32 FX_grGetInteger(FxU32 pname) +{ + int result; + + BEGIN_BOARD_LOCK(); + result=grGetInteger(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; + + 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; + + BEGIN_BOARD_LOCK(); + result=grTexTextureMemRequired(evenOdd, info); + END_BOARD_LOCK(); + return result; +} +FxU32 FX_grTexMinAddress(GrChipID_t tmu) { + FxU32 result; + + BEGIN_BOARD_LOCK(); + result=grTexMinAddress(tmu); + END_BOARD_LOCK(); + return result; +} + +extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu) { + FxU32 result; + + BEGIN_BOARD_LOCK(); + result=grTexMaxAddress(tmu); + END_BOARD_LOCK(); + return result; +} #if defined(FX_GLIDE3) @@ -98,31 +163,30 @@ void FX_grSstControl(int par) int FX_getFogTableSize(void) { int result; + BEGIN_BOARD_LOCK(); grGet(GR_FOG_TABLE_ENTRIES,sizeof(int),(void*)&result); + END_BOARD_LOCK(); return result; } int FX_getGrStateSize(void) { int result; + BEGIN_BOARD_LOCK(); grGet(GR_GLIDE_STATE_SIZE,sizeof(int),(void*)&result); - + END_BOARD_LOCK(); + return result; } -int FX_grBufferNumPending() -{ - int result; - grGet(GR_PENDING_BUFFERSWAPS,sizeof(int),(void*)&result); - - return result; -} int FX_grSstScreenWidth() { FxI32 result[4]; - + + BEGIN_BOARD_LOCK(); grGet(GR_VIEWPORT,sizeof(FxI32)*4,result); + END_BOARD_LOCK(); return result[2]; } @@ -130,15 +194,19 @@ int FX_grSstScreenWidth() int FX_grSstScreenHeight() { FxI32 result[4]; - + + BEGIN_BOARD_LOCK(); grGet(GR_VIEWPORT,sizeof(FxI32)*4,result); + END_BOARD_LOCK(); return result[3]; } void FX_grGlideGetVersion(char *buf) { - strcpy(buf,grGetString(GR_VERSION)); + BEGIN_BOARD_LOCK(); + strcpy(buf,grGetString(GR_VERSION)); + END_BOARD_LOCK(); } void FX_grSstPerfStats(GrSstPerfStats_t *st) @@ -154,11 +222,16 @@ void FX_grSstPerfStats(GrSstPerfStats_t *st) void FX_grAADrawLine(GrVertex *a,GrVertex *b) { /* ToDo */ + BEGIN_CLIP_LOOP(); grDrawLine(a,b); + END_CLIP_LOOP(); } + void FX_grAADrawPoint(GrVertex *a) { + BEGIN_CLIP_LOOP(); grDrawPoint(a); + END_CLIP_LOOP(); } #if FX_USE_PARGB @@ -195,33 +268,42 @@ void FX_setupGrVertexLayout(void) } #endif -void FX_grHints(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); + 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); - - } - } + 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(); } + int FX_grSstQueryHardware(GrHwConfiguration *config) { int i,j; int numFB; + + BEGIN_BOARD_LOCK(); grGet(GR_NUM_BOARDS,4,(void*)&(config->num_sst)); if (config->num_sst == 0) return 0; @@ -246,11 +328,77 @@ int FX_grSstQueryHardware(GrHwConfiguration *config) config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRam /= 1024*1024; } } + END_BOARD_LOCK(); return 1; } -#endif +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 ); + + 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; +} + +#else /* FX_GLIDE3 */ + +int FX_grSstScreenWidth() +{ + return grSstScreenWidth(); +} + +int FX_grSstScreenHeight() +{ + return grSstScreenHeight(); +} + +int FX_grSstQueryHardware(GrHwConfiguration *config) +{ + return grSstQueryHardware(config); +} + +FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd, + GrScreenResolution_t screen_resolution, + GrScreenRefresh_t refresh_rate, + GrColorFormat_t color_format, + GrOriginLocation_t origin_location, + int nColBuffers, + int nAuxBuffers) +{ + return grSstWinOpen(hWnd, screen_resolution, refresh_rate, + color_format, origin_location, nColBuffers, nAuxBuffers); +} + + +#endif /* FX_GLIDE3 */ + #else /* diff --git a/src/mesa/drivers/glide/fxglidew.h b/src/mesa/drivers/glide/fxglidew.h index c02045f459..a03ff477a9 100644 --- a/src/mesa/drivers/glide/fxglidew.h +++ b/src/mesa/drivers/glide/fxglidew.h @@ -1,26 +1,48 @@ +/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */ + /* * Mesa 3-D graphics library * Version: 3.1 - * + * * Copyright (C) 1999 Brian Paul All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * + * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the + * terms stated above. + * + * Thank you for your contribution, David! + * + * Please make note of the above copyright/license statement. If you + * contributed code or bug fixes to this code under the previous (GNU + * Library) license and object to the new license, your code will be + * removed at your request. Please see the Mesa docs/COPYRIGHT file + * for more information. + * + * Additional Mesa/3Dfx driver developers: + * Daryll Strauss + * Keith Whitwell + * + * See fxapi.h for more revision/author details. */ + + #ifndef __FX_GLIDE_WARPER__ #define __FX_GLIDE_WARPER__ @@ -54,6 +76,7 @@ /* * Genral warper functions for Glide2/Glide3: */ +extern FxI32 grGetInteger(FxU32 pname); extern FxI32 FX_grGetInteger(FxU32 pname); /* @@ -233,29 +256,97 @@ typedef struct * Glide2 functions for Glide3 */ #if defined(FX_GLIDE3) -#define FX_grTexDownloadTable(TMU,type,data) grTexDownloadTable(type,data) +#define FX_grTexDownloadTable(TMU,type,data) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grTexDownloadTable(type,data); \ + END_BOARD_LOCK(); \ + } while (0); +#define FX_grTexDownloadTable_NoLock(TMU,type,data) \ + grTexDownloadTable(type, data) #else -#define FX_grTexDownloadTable(TMU,type,data) grTexDownloadTable(TMU,type,data) +#define FX_grTexDownloadTable(TMU,type,data) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grTexDownloadTable(TMU,type,data); \ + END_BOARD_LOCK(); \ + } while (0); +#define FX_grTexDownloadTable_NoLock grTexDownloadTable #endif /* * Flush */ #if defined(FX_GLIDE3) -#define FX_grFlush grFlush +#define FX_grFlush() \ + do { \ + BEGIN_BOARD_LOCK(); \ + grFlush(); \ + END_BOARD_LOCK(); \ + } while (0) #else -#define FX_grFlush grSstIdle +#define FX_grFlush() \ + do { \ + BEGIN_BOARD_LOCK(); \ + grSstIdle(); \ + END_BOARD_LOCK(); \ + } while (0) #endif + +#define FX_grFinish() \ + do { \ + BEGIN_BOARD_LOCK(); \ + grFinish(); \ + END_BOARD_LOCK(); \ + } while (0) + /* * Write region: ToDo possible exploit the PixelPipe parameter. */ #if defined(FX_GLIDE3) -#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \ - grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data) +#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data); \ + END_BOARD_LOCK(); \ + } while(0) #else -#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \ - grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) +#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data); \ + END_BOARD_LOCK(); \ + } while (0) #endif + +/* + * Read region + */ +#define FX_grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data); \ + END_BOARD_LOCK(); \ + } while (0); + +/* + * Draw triangle + */ +#define FX_grDrawTriangle(a,b,c) \ + do { \ + /* int big=0; */ \ + BEGIN_CLIP_LOOP(); \ + /* if (((GrVertex*)a)->x>2000 || ((GrVertex*)a)->x<-2000 || \ + ((GrVertex*)a)->y>2000 || ((GrVertex*)a)->y<-2000 || \ + ((GrVertex*)a)->z>65000 || ((GrVertex*)a)->z<-65000) { \ + fprintf(stderr, "Extreme triangle (%f,%f,%f)\n", \ + ((GrVertex*)a)->x, ((GrVertex*)a)->y, ((GrVertex*)a)->z); \ + big=1; \ + } else */ \ + grDrawTriangle(a,b,c); \ + END_CLIP_LOOP(); \ + } while (0) + /* * For Lod/LodLog2 conversion. */ @@ -288,12 +379,14 @@ typedef struct #else #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)) #else #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)) @@ -304,13 +397,9 @@ typedef struct /* * ScreenWidth/Height stuff. */ -#if defined(FX_GLIDE3) - extern int FX_grSstScreenWidth(); - extern int FX_grSstScreenHeight(); -#else - #define FX_grSstScreenWidth() grSstScreenWidth() - #define FX_grSstScreenHeight() grSstScreenHeight() -#endif + extern int FX_grSstScreenWidth(void); + extern int FX_grSstScreenHeight(void); + /* @@ -319,7 +408,12 @@ typedef struct #if defined(FX_GLIDE3) extern void FX_grGlideGetVersion(char *buf); #else - #define FX_grGlideGetVersion grGlideGetVersion + #define FX_grGlideGetVersion(b) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grGlideGetVersion(b); \ + END_BOARD_LOCK(); \ + } while (0) #endif /* * Performance statistics @@ -327,25 +421,33 @@ typedef struct #if defined(FX_GLIDE3) extern void FX_grSstPerfStats(GrSstPerfStats_t *st); #else - #define FX_grSstPerfStats grSstPerfStats + #define FX_grSstPerfStats(s) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grSstPerfStats(s); \ + END_BOARD_LOCK(); \ + } while (0) #endif /* * Hardware Query */ -#if defined(FX_GLIDE3) extern int FX_grSstQueryHardware(GrHwConfiguration *config); -#else - #define FX_grSstQueryHardware grSstQueryHardware -#endif /* * GrHints */ #if defined(FX_GLIDE3) + extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask); extern void FX_grHints(GrHint_t hintType, FxU32 hintMask); #else - #define FX_grHints grHints + #define FX_grHints(t,m) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grHints(t, m); \ + END_BOARD_LOCK(); \ + } while(0) + #define FX_grHints_NoLock grHints #endif /* * Antialiashed line+point drawing. @@ -353,13 +455,23 @@ typedef struct #if defined(FX_GLIDE3) extern void FX_grAADrawLine(GrVertex *a,GrVertex *b); #else - #define FX_grAADrawLine grAADrawLine + #define FX_grAADrawLine(a,b) \ + do { \ + BEGIN_CLIP_LOOP(); \ + grAADrawLine(a,b); \ + END_CLIP_LOOP(); \ + } while (0) #endif #if defined(FX_GLIDE3) extern void FX_grAADrawPoint(GrVertex *a); #else - #define FX_grAADrawPoint grAADrawPoint + #define FX_grAADrawPoint(a) \ + do { \ + BEGIN_CLIP_LOOP(); \ + grAADrawPoint(a); \ + END_CLIP_LOOP(); \ + } while (0) #endif /* @@ -376,7 +488,12 @@ typedef struct #if defined(FX_GLIDE3) extern void FX_grSstControl(int par); #else - #define FX_grSstControl grSstControl + #define FX_grSstControl(p) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grSstControl(p); \ + END_BOARD_LOCK(); \ + } while (0) #endif /* * grGammaCorrectionValue @@ -384,20 +501,337 @@ typedef struct #if defined(FX_GLIDE3) extern void FX_grGammaCorrectionValue(float val); #else - #define FX_grGammaCorrectionValue grGammaCorrectionValue + #define FX_grGammaCorrectionValue(v) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grGammaCorrectionValue(v) \ + END_BOARD_LOCK(); \ + } while (0) #endif -/* - * WinOpen/Close. - */ #if defined(FX_GLIDE3) - #define FX_grSstWinOpen(hWnd,screen_resolution,refresh_rate,color_format,origin_location,nColBuffers,nAuxBuffers) \ - grSstWinOpen(-1,screen_resolution,refresh_rate,color_format,origin_location,nColBuffers,nAuxBuffers) - #define FX_grSstWinClose grSstWinClose +#define FX_grSstWinClose(w) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grSstWinClose(w); \ + END_BOARD_LOCK(); \ + } while (0) #else - #define FX_grSstWinOpen grSstWinOpen - #define FX_grSstWinClose(win) grSstWinClose() +#define FX_grSstWinClose(w) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grSstWinClose(); \ + END_BOARD_LOCK(); \ + } while (0) #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); + + +#define FX_grDrawLine(v1, v2) \ + do { \ + BEGIN_CLIP_LOOP(); \ + grDrawLine(v1, v2); \ + END_CLIP_LOOP(); \ + } while (0) + +#define FX_grDrawPoint(p) \ + do { \ + BEGIN_CLIP_LOOP(); \ + grDrawPoint(p); \ + END_CLIP_LOOP(); \ + } while (0) + +#define FX_grDitherMode(m) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grDitherMode(m); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grRenderBuffer(b) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grRenderBuffer(b); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grBufferClear(c, a, d) \ + do { \ + BEGIN_CLIP_LOOP(); \ + grBufferClear(c, a, d); \ + END_CLIP_LOOP(); \ + } while (0) + +#define FX_grDepthMask(m) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grDepthMask(m); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grColorMask(c, a) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grColorMask(c, a); \ + 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 ); + +#define FX_grLfbUnlock(t, b) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grLfbUnlock(t, b); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grConstantColorValue(v) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grConstantColorValue(v); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grConstantColorValue_NoLock grConstantColorValue + +#define FX_grAADrawTriangle(a, b, c, ab, bc, ca) \ + do { \ + BEGIN_CLIP_LOOP(); \ + grAADrawTriangle(a, b, c, ab, bc, ca); \ + END_CLIP_LOOP(); \ + } while (0) + +#define FX_grAlphaBlendFunction(rs, rd, as, ad) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grAlphaBlendFunction(rs, rd, as, ad); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grAlphaCombine(func, fact, loc, oth, inv) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grAlphaCombine(func, fact, loc, oth, inv); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grAlphaCombine_NoLock grAlphaCombine + +#define FX_grAlphaTestFunction(f) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grAlphaTestFunction(f); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grAlphaTestReferenceValue(v) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grAlphaTestReferenceValue(v); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grClipWindow(minx, miny, maxx, maxy) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grClipWindow(minx, miny, maxx, maxy); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grClipWindow_NoLock grClipWindow + +#define FX_grColorCombine(func, fact, loc, oth, inv) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grColorCombine(func, fact, loc, oth, inv); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grColorCombine_NoLock grColorCombine + +#define FX_grCullMode(m) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grCullMode(m); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grDepthBiasLevel(lev) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grDepthBiasLevel(lev); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grDepthBufferFunction(func) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grDepthBufferFunction(func); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grFogColorValue(c) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grFogColorValue(c); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grFogMode(m) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grFogMode(m); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grFogTable(t) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grFogTable(t); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grTexClampMode(t, sc, tc) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grTexClampMode(t, sc, tc); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grTexClampMode_NoLock grTexClampMode + +#define FX_grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grTexCombine_NoLock grTexCombine + +#define FX_grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grTexDownloadMipMapLevel_NoLock grTexDownloadMipMapLevel + +#define FX_grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \ + do { \ + BEGIN_BOARD_LOCK(); \ + grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grTexFilterMode(t, minf, magf) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grTexFilterMode(t, minf, magf); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grTexFilterMode_NoLock grTexFilterMode + +extern FxU32 FX_grTexMinAddress(GrChipID_t tmu); +extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu); + +#define FX_grTexMipMapMode(t, m, lod) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grTexMipMapMode(t, m, lod); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grTexMipMapMode_NoLock grTexMipMapMode + +#define FX_grTexSource(t, sa, eo, i) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grTexSource(t, sa, eo, i); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grTexSource_NoLock grTexSource + +extern FxU32 FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info); +#define FX_grTexTextureMemRequired_NoLock grTexTextureMemRequired + +#define FX_grGlideGetState(s) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grGlideGetState(s); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grDRIBufferSwap(i) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grDRIBufferSwap(i); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grSstSelect(b) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grSstSelect(b); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grSstSelect_NoLock grSstSelect + +#define FX_grGlideSetState(s) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grGlideSetState(s); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grDepthBufferMode(m) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grDepthBufferMode(m); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grLfbWriteColorFormat(f) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grLfbWriteColorFormat(f); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grDrawVertexArray(m, c, p) \ + do { \ + BEGIN_CLIP_LOOP(); \ + grDrawVertexArray(m, c, p); \ + END_CLIP_LOOP(); \ + } while (0) + +#define FX_grGlideShutdown() \ + do { \ + BEGIN_CLIP_LOOP(); \ + grGlideShutdown(); \ + END_CLIP_LOOP(); \ + } while (0) + +#define FX_grGlideInit_NoLock grGlideInit +#define FX_grSstWinOpen_NoLock grSstWinOpen + +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 8367a1f1ff..8de34ef90c 100644 --- a/src/mesa/drivers/glide/fxsetup.c +++ b/src/mesa/drivers/glide/fxsetup.c @@ -1,27 +1,51 @@ -/* -*- mode: C; tab-width:8; -*- - - fxsetup.c - 3Dfx VooDoo rendering mode setup functions -*/ +/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */ /* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * Mesa 3-D graphics library + * Version: 3.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * + * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the + * terms stated above. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. + * Thank you for your contribution, David! * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Please make note of the above copyright/license statement. If you + * contributed code or bug fixes to this code under the previous (GNU + * Library) license and object to the new license, your code will be + * removed at your request. Please see the Mesa docs/COPYRIGHT file + * for more information. * - * See the file fxapi.c for more informations about authors + * Additional Mesa/3Dfx driver developers: + * Daryll Strauss + * Keith Whitwell * + * See fxapi.h for more revision/author details. */ + +/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */ + + #ifdef HAVE_CONFIG_H #include "conf.h" #endif @@ -31,14 +55,32 @@ #include "fxdrv.h" #include "enums.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 fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset); +static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, + struct gl_texture_object *tObj0, + struct gl_texture_object *tObj1); +static void fxSetupBlend(GLcontext *ctx); +static void fxSetupDepthTest(GLcontext *ctx); +static void fxFogTableGenerate(GLcontext *ctx); +static void fxSetupFog(GLcontext *ctx, GLboolean forceTableRebuild); +static void fxSetupScissor(GLcontext *ctx); +static void fxSetupCull(GLcontext *ctx); +static void gl_print_fx_state_flags( const char *msg, GLuint flags); +static GLboolean fxMultipassTexture( struct vertex_buffer *, GLuint ); + + static void fxTexValidate(GLcontext *ctx, struct gl_texture_object *tObj) { tfxTexInfo *ti=(tfxTexInfo *)tObj->DriverData; GLint minl,maxl; - if (MESA_VERBOSE&VERBOSE_DRIVER) + if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxTexValidate(...) Start\n"); - + } if(ti->validated) { if (MESA_VERBOSE&VERBOSE_DRIVER) { @@ -50,13 +92,13 @@ static void fxTexValidate(GLcontext *ctx, struct gl_texture_object *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, @@ -109,9 +151,9 @@ static void fxPrintUnitsMode( const char *msg, GLuint mode ) (mode & FX_UM_ALPHA_CONSTANT) ? "ALPHA_CONSTANT, " : ""); } -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; @@ -239,50 +281,52 @@ GLuint fxGetTexSetConfiguration(GLcontext *ctx, /************************* Single Texture Set ***************************/ -static void fxSetupSingleTMU(fxMesaContext fxMesa, struct gl_texture_object *tObj) +static void fxSetupSingleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj) { tfxTexInfo *ti=(tfxTexInfo *)tObj->DriverData; - if(!ti->tmi.isInTM) { - if(ti->LODblend) - fxTMMoveInTM(fxMesa,tObj,FX_TMU_SPLIT); + if (!ti->tmi.isInTM) { + if (ti->LODblend) + fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU_SPLIT); else { - if(fxMesa->haveTwoTMUs) { - if(fxMesa->freeTexMem[FX_TMU0]>grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH,&(ti->info))) - fxTMMoveInTM(fxMesa,tObj,FX_TMU0); + if (fxMesa->haveTwoTMUs) { + if (fxMesa->freeTexMem[FX_TMU0] > + FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH, + &(ti->info))) + fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU0); else - fxTMMoveInTM(fxMesa,tObj,FX_TMU1); + fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU1); } else - fxTMMoveInTM(fxMesa,tObj,FX_TMU0); + fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU0); } } - if(ti->LODblend && ti->tmi.whichTMU == FX_TMU_SPLIT) { - if((ti->info.format==GR_TEXFMT_P_8) && (!fxMesa->haveGlobalPaletteTexture)) { + if (ti->LODblend && ti->tmi.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(GR_TMU0,GR_TEXTABLE_PALETTE,&(ti->palette)); - FX_grTexDownloadTable(GR_TMU1,GR_TEXTABLE_PALETTE,&(ti->palette)); + FX_grTexDownloadTable_NoLock(GR_TMU0,GR_TEXTABLE_PALETTE,&(ti->palette)); + FX_grTexDownloadTable_NoLock(GR_TMU1,GR_TEXTABLE_PALETTE,&(ti->palette)); } - grTexClampMode(GR_TMU0,ti->sClamp,ti->tClamp); - grTexClampMode(GR_TMU1,ti->sClamp,ti->tClamp); - grTexFilterMode(GR_TMU0,ti->minFilt,ti->maxFilt); - grTexFilterMode(GR_TMU1,ti->minFilt,ti->maxFilt); - grTexMipMapMode(GR_TMU0,ti->mmMode,ti->LODblend); - grTexMipMapMode(GR_TMU1,ti->mmMode,ti->LODblend); - - grTexSource(GR_TMU0,ti->tmi.tm[FX_TMU0]->startAddress, - GR_MIPMAPLEVELMASK_ODD,&(ti->info)); - grTexSource(GR_TMU1,ti->tmi.tm[FX_TMU1]->startAddress, - GR_MIPMAPLEVELMASK_EVEN,&(ti->info)); + 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->tmi.tm[FX_TMU0]->startAddress, + GR_MIPMAPLEVELMASK_ODD,&(ti->info)); + FX_grTexSource_NoLock(GR_TMU1,ti->tmi.tm[FX_TMU1]->startAddress, + GR_MIPMAPLEVELMASK_EVEN,&(ti->info)); } else { if((ti->info.format==GR_TEXFMT_P_8) && (!fxMesa->haveGlobalPaletteTexture)) { if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: uploading texture palette\n"); } - FX_grTexDownloadTable(ti->tmi.whichTMU,GR_TEXTABLE_PALETTE,&(ti->palette)); + FX_grTexDownloadTable_NoLock(ti->tmi.whichTMU,GR_TEXTABLE_PALETTE,&(ti->palette)); } /* KW: The alternative is to do the download to the other tmu. If @@ -292,63 +336,69 @@ static void fxSetupSingleTMU(fxMesaContext fxMesa, struct gl_texture_object *tOb if (ti->LODblend && (MESA_VERBOSE&VERBOSE_DRIVER)) fprintf(stderr, "fxmesa: not blending texture - only on one tmu\n"); + FX_grTexClampMode_NoLock(ti->tmi.whichTMU,ti->sClamp,ti->tClamp); + FX_grTexFilterMode_NoLock(ti->tmi.whichTMU,ti->minFilt,ti->maxFilt); + FX_grTexMipMapMode_NoLock(ti->tmi.whichTMU,ti->mmMode,FXFALSE); - grTexClampMode(ti->tmi.whichTMU,ti->sClamp,ti->tClamp); - grTexFilterMode(ti->tmi.whichTMU,ti->minFilt,ti->maxFilt); - grTexMipMapMode(ti->tmi.whichTMU,ti->mmMode,FXFALSE); - - grTexSource(ti->tmi.whichTMU,ti->tmi.tm[ti->tmi.whichTMU]->startAddress, - GR_MIPMAPLEVELMASK_BOTH,&(ti->info)); + FX_grTexSource_NoLock(ti->tmi.whichTMU, + ti->tmi.tm[ti->tmi.whichTMU]->startAddress, + GR_MIPMAPLEVELMASK_BOTH,&(ti->info)); } } -static void fxSelectSingleTMUSrc(fxMesaContext fxMesa, GLint tmu, FxBool LODblend) +static void fxSetupSingleTMU(fxMesaContext fxMesa, struct gl_texture_object *tObj) { + BEGIN_BOARD_LOCK(); + fxSetupSingleTMU_NoLock(fxMesa, tObj); + END_BOARD_LOCK(); +} + +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) { - grTexCombine(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); - - grTexCombine(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, + GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION, + GR_COMBINE_FUNCTION_BLEND, + GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION, + FXFALSE,FXFALSE); + + 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_TMU0) { - grTexCombine(GR_TMU0, - 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_LOCAL,GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, + FXFALSE,FXFALSE); fxMesa->tmuSrc=FX_TMU0; } else { - grTexCombine(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); + 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 ?!? */ - grTexCombine(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND,GR_COMBINE_FACTOR_ONE, - GR_COMBINE_FUNCTION_BLEND,GR_COMBINE_FACTOR_ONE, - FXFALSE,FXFALSE); + 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; } } } -void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) +static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GrCombineLocal_t localc,locala; @@ -357,18 +407,18 @@ void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) tfxTexInfo *ti; struct gl_texture_object *tObj=ctx->Texture.Unit[textureset].CurrentD[2]; - if (MESA_VERBOSE&VERBOSE_DRIVER) + if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxSetupTextureSingleTMU(...) Start\n"); - + } ti=(tfxTexInfo *)tObj->DriverData; fxTexValidate(ctx,tObj); - fxSetupSingleTMU(fxMesa,tObj); + fxSetupSingleTMU_NoLock(fxMesa,tObj); if(fxMesa->tmuSrc!=ti->tmi.whichTMU) - fxSelectSingleTMUSrc(fxMesa,ti->tmi.whichTMU,ti->LODblend); + fxSelectSingleTMUSrc_NoLock(fxMesa,ti->tmi.whichTMU,ti->LODblend); if(textureset==0 || !fxMesa->haveTwoTMUs) unitsmode=fxGetTexSetConfiguration(ctx,tObj,NULL); @@ -381,7 +431,7 @@ void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) fxMesa->lastUnitsMode=unitsmode; fxMesa->stw_hint_state = 0; - FX_grHints(GR_HINT_STWHINT,0); + FX_grHints_NoLock(GR_HINT_STWHINT,0); ifmt=ti->baseLevelInternalFormat; @@ -401,37 +451,37 @@ void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) switch(ctx->Texture.Unit[textureset].EnvMode) { case GL_DECAL: - grAlphaCombine(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - grColorCombine(GR_COMBINE_FUNCTION_BLEND, - GR_COMBINE_FACTOR_TEXTURE_ALPHA, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); + 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: - grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - locala, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_LOCAL, + locala, + GR_COMBINE_OTHER_TEXTURE, + FXFALSE); if(ifmt==GL_ALPHA) - grColorCombine(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - localc, - GR_COMBINE_OTHER_NONE, - FXFALSE); + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + localc, + GR_COMBINE_OTHER_NONE, + FXFALSE); else - grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_LOCAL, + localc, + GR_COMBINE_OTHER_TEXTURE, + FXFALSE); break; case GL_BLEND: #ifndef FX_SILENT @@ -441,30 +491,30 @@ void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) break; case GL_REPLACE: if((ifmt==GL_RGB) || (ifmt==GL_LUMINANCE)) - grAlphaCombine(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + locala, + GR_COMBINE_OTHER_NONE, + FXFALSE); else - grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - locala, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_ONE, + locala, + GR_COMBINE_OTHER_TEXTURE, + FXFALSE); if(ifmt==GL_ALPHA) - grColorCombine(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - localc, - GR_COMBINE_OTHER_NONE, - FXFALSE); + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + localc, + GR_COMBINE_OTHER_NONE, + FXFALSE); else - grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_ONE, + localc, + GR_COMBINE_OTHER_TEXTURE, + FXFALSE); break; default: #ifndef FX_SILENT @@ -478,10 +528,17 @@ void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) } } +static void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) { + BEGIN_BOARD_LOCK(); + fxSetupTextureSingleTMU_NoLock(ctx, textureset); + END_BOARD_LOCK(); +} + /************************* Double Texture Set ***************************/ -void fxSetupDoubleTMU(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 @@ -531,36 +588,36 @@ void fxSetupDoubleTMU(fxMesaContext fxMesa, struct gl_texture_object *tObj0, case (T0_IN_TMU0 | T1_IN_TMU0): fxTMMoveOutTM(fxMesa,tObj1); - fxTMMoveInTM(fxMesa,tObj1,FX_TMU1); + fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU1); break; case (T0_IN_TMU1 | T1_IN_TMU1): fxTMMoveOutTM(fxMesa,tObj0); - fxTMMoveInTM(fxMesa,tObj0,FX_TMU0); + fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU0); break; case (T0_NOT_IN_TMU | T1_NOT_IN_TMU): - fxTMMoveInTM(fxMesa,tObj0,FX_TMU0); - fxTMMoveInTM(fxMesa,tObj1,FX_TMU1); + fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU0); + fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU1); break; /*** T0/T1 ***/ case (T0_NOT_IN_TMU | T1_IN_TMU0): - fxTMMoveInTM(fxMesa,tObj0,FX_TMU1); + fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU1); break; case (T0_NOT_IN_TMU | T1_IN_TMU1): - fxTMMoveInTM(fxMesa,tObj0,FX_TMU0); + fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU0); break; case (T0_IN_TMU0 | T1_NOT_IN_TMU): - fxTMMoveInTM(fxMesa,tObj1,FX_TMU1); + fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU1); break; case (T0_IN_TMU1 | T1_NOT_IN_TMU): - fxTMMoveInTM(fxMesa,tObj1,FX_TMU0); + fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU0); break; /*** Best Case ***/ @@ -576,33 +633,35 @@ void fxSetupDoubleTMU(fxMesaContext fxMesa, struct gl_texture_object *tObj0, break; } - if(!fxMesa->haveGlobalPaletteTexture) { - if(ti0->info.format==GR_TEXFMT_P_8) { + 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(ti0->tmi.whichTMU,GR_TEXTABLE_PALETTE,&(ti0->palette)); + FX_grTexDownloadTable_NoLock(ti0->tmi.whichTMU,GR_TEXTABLE_PALETTE,&(ti0->palette)); } - if(ti1->info.format==GR_TEXFMT_P_8) { + if (ti1->info.format==GR_TEXFMT_P_8) { if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: uploading texture palette TMU1\n"); } - FX_grTexDownloadTable(ti1->tmi.whichTMU,GR_TEXTABLE_PALETTE,&(ti1->palette)); + FX_grTexDownloadTable_NoLock(ti1->tmi.whichTMU, GR_TEXTABLE_PALETTE,&(ti1->palette)); } } - grTexClampMode(ti0->tmi.whichTMU,ti0->sClamp,ti0->tClamp); - grTexFilterMode(ti0->tmi.whichTMU,ti0->minFilt,ti0->maxFilt); - grTexMipMapMode(ti0->tmi.whichTMU,ti0->mmMode,FXFALSE); - grTexSource(ti0->tmi.whichTMU,ti0->tmi.tm[ti0->tmi.whichTMU]->startAddress, - GR_MIPMAPLEVELMASK_BOTH,&(ti0->info)); + FX_grTexClampMode_NoLock(ti0->tmi.whichTMU,ti0->sClamp,ti0->tClamp); + FX_grTexFilterMode_NoLock(ti0->tmi.whichTMU,ti0->minFilt,ti0->maxFilt); + FX_grTexMipMapMode_NoLock(ti0->tmi.whichTMU,ti0->mmMode,FXFALSE); + FX_grTexSource_NoLock(ti0->tmi.whichTMU, + ti0->tmi.tm[ti0->tmi.whichTMU]->startAddress, + GR_MIPMAPLEVELMASK_BOTH,&(ti0->info)); - grTexClampMode(ti1->tmi.whichTMU,ti1->sClamp,ti1->tClamp); - grTexFilterMode(ti1->tmi.whichTMU,ti1->minFilt,ti1->maxFilt); - grTexMipMapMode(ti1->tmi.whichTMU,ti1->mmMode,FXFALSE); - grTexSource(ti1->tmi.whichTMU,ti1->tmi.tm[ti1->tmi.whichTMU]->startAddress, - GR_MIPMAPLEVELMASK_BOTH,&(ti1->info)); + FX_grTexClampMode_NoLock(ti1->tmi.whichTMU,ti1->sClamp,ti1->tClamp); + FX_grTexFilterMode_NoLock(ti1->tmi.whichTMU,ti1->minFilt,ti1->maxFilt); + FX_grTexMipMapMode_NoLock(ti1->tmi.whichTMU,ti1->mmMode,FXFALSE); + FX_grTexSource_NoLock(ti1->tmi.whichTMU, + ti1->tmi.tm[ti1->tmi.whichTMU]->startAddress, + GR_MIPMAPLEVELMASK_BOTH,&(ti1->info)); #undef T0_NOT_IN_TMU #undef T1_NOT_IN_TMU @@ -612,7 +671,7 @@ void fxSetupDoubleTMU(fxMesaContext fxMesa, struct gl_texture_object *tObj0, #undef T1_IN_TMU1 } -static void fxSetupTextureDoubleTMU(GLcontext *ctx) +static void fxSetupTextureDoubleTMU_NoLock(GLcontext *ctx) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GrCombineLocal_t localc,locala; @@ -631,7 +690,7 @@ static void fxSetupTextureDoubleTMU(GLcontext *ctx) ti1=(tfxTexInfo *)tObj1->DriverData; fxTexValidate(ctx,tObj1); - fxSetupDoubleTMU(fxMesa,tObj0,tObj1); + fxSetupDoubleTMU_NoLock(fxMesa,tObj0,tObj1); unitsmode=fxGetTexSetConfiguration(ctx,tObj0,tObj1); @@ -641,7 +700,7 @@ static void fxSetupTextureDoubleTMU(GLcontext *ctx) fxMesa->lastUnitsMode=unitsmode; fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1; - FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state); + FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state); envmode=unitsmode & FX_UM_E_ENVMODE; ifmt=unitsmode & FX_UM_E_IFMT; @@ -680,118 +739,142 @@ static void fxSetupTextureDoubleTMU(GLcontext *ctx) isalpha[ti1->tmi.whichTMU]=GL_FALSE; if(isalpha[FX_TMU1]) - grTexCombine(GR_TMU1, - GR_COMBINE_FUNCTION_ZERO,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - FXTRUE,FXFALSE); + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_ZERO, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + FXTRUE,FXFALSE); else - grTexCombine(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); + 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]) - grTexCombine(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND_OTHER,GR_COMBINE_FACTOR_ONE, - GR_COMBINE_FUNCTION_BLEND_OTHER,GR_COMBINE_FACTOR_LOCAL, - FXFALSE,FXFALSE); + 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 - grTexCombine(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND_OTHER,GR_COMBINE_FACTOR_LOCAL, - GR_COMBINE_FUNCTION_BLEND_OTHER,GR_COMBINE_FACTOR_LOCAL, - FXFALSE,FXFALSE); - - grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - - grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - locala, - GR_COMBINE_OTHER_TEXTURE, - 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); + + 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(ti1->tmi.whichTMU==FX_TMU1) { - grTexCombine(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - FXTRUE,FXFALSE); + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + FXTRUE,FXFALSE); - grTexCombine(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND_OTHER,GR_COMBINE_FACTOR_LOCAL, - GR_COMBINE_FUNCTION_BLEND_OTHER,GR_COMBINE_FACTOR_LOCAL, - FXFALSE,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 { - grTexCombine(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + FXFALSE,FXFALSE); - grTexCombine(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_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); } - grAlphaCombine(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - localc, - GR_COMBINE_OTHER_TEXTURE, - 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(ti1->tmi.whichTMU==FX_TMU1) { - grTexCombine(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_ZERO,GR_COMBINE_FACTOR_NONE, - FXFALSE,FXTRUE); + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_ZERO, + GR_COMBINE_FACTOR_NONE, + FXFALSE,FXTRUE); - grTexCombine(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND_OTHER,GR_COMBINE_FACTOR_LOCAL, - GR_COMBINE_FUNCTION_BLEND_OTHER,GR_COMBINE_FACTOR_LOCAL, - FXFALSE,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 { - grTexCombine(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + FXFALSE,FXFALSE); - grTexCombine(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND_OTHER,GR_COMBINE_FACTOR_LOCAL, - GR_COMBINE_FUNCTION_BLEND_OTHER,GR_COMBINE_FACTOR_ONE, - 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) - grAlphaCombine(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + locala, + GR_COMBINE_OTHER_NONE, + FXFALSE); else - grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - - grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); + 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; @@ -810,37 +893,46 @@ static void fxSetupTextureDoubleTMU(GLcontext *ctx) isalpha[ti1->tmi.whichTMU]=GL_FALSE; if(isalpha[FX_TMU1]) - grTexCombine(GR_TMU1, - GR_COMBINE_FUNCTION_ZERO,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - FXTRUE,FXFALSE); + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_ZERO, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + FXTRUE,FXFALSE); else - grTexCombine(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); + 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]) - grTexCombine(GR_TMU0, - GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE, - GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,GR_COMBINE_FACTOR_ONE, - FXFALSE,FXFALSE); + 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 - grTexCombine(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); - - grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - - grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - locala, GR_COMBINE_OTHER_TEXTURE, - FXFALSE); + 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; } @@ -853,7 +945,7 @@ static void fxSetupTextureDoubleTMU(GLcontext *ctx) /************************* No Texture ***************************/ -static void fxSetupTextureNone(GLcontext *ctx) +static void fxSetupTextureNone_NoLock(GLcontext *ctx) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GrCombineLocal_t localc,locala; @@ -875,32 +967,26 @@ static void fxSetupTextureNone(GLcontext *ctx) else localc=GR_COMBINE_LOCAL_CONSTANT; - grAlphaCombine(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - grColorCombine(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - localc, - GR_COMBINE_OTHER_NONE, - FXFALSE); + 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; } -/* See below. - */ -static GLboolean fxMultipassTexture( struct vertex_buffer *, GLuint ); - - - /************************************************************************/ /************************** Texture Mode SetUp **************************/ /************************************************************************/ -void fxSetupTexture(GLcontext *ctx) +void fxSetupTexture_NoLock(GLcontext *ctx) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint tex2Denabled; @@ -922,28 +1008,34 @@ void fxSetupTexture(GLcontext *ctx) switch(tex2Denabled) { case TEXTURE0_2D: - fxSetupTextureSingleTMU(ctx,0); + fxSetupTextureSingleTMU_NoLock(ctx,0); break; case TEXTURE1_2D: - fxSetupTextureSingleTMU(ctx,1); + fxSetupTextureSingleTMU_NoLock(ctx,1); break; case (TEXTURE0_2D|TEXTURE1_2D): if (fxMesa->haveTwoTMUs) - fxSetupTextureDoubleTMU(ctx); + fxSetupTextureDoubleTMU_NoLock(ctx); else { if (MESA_VERBOSE&VERBOSE_DRIVER) fprintf(stderr, "fxmesa: enabling fake multitexture\n"); - fxSetupTextureSingleTMU(ctx,0); + fxSetupTextureSingleTMU_NoLock(ctx,0); ctx->Driver.MultipassFunc = fxMultipassTexture; } break; default: - fxSetupTextureNone(ctx); + fxSetupTextureNone_NoLock(ctx); break; } } +void fxSetupTexture(GLcontext *ctx) { + BEGIN_BOARD_LOCK(); + fxSetupTexture_NoLock(ctx); + END_BOARD_LOCK(); +} + /************************************************************************/ /**************************** Blend SetUp *******************************/ /************************************************************************/ @@ -1065,16 +1157,16 @@ void fxDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor) } } -void fxSetupBlend(GLcontext *ctx) +static void fxSetupBlend(GLcontext *ctx) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; tfxUnitsState *us=&fxMesa->unitsState; if(us->blendEnabled) - grAlphaBlendFunction(us->blendSrcFuncRGB,us->blendDstFuncRGB, + FX_grAlphaBlendFunction(us->blendSrcFuncRGB,us->blendDstFuncRGB, us->blendSrcFuncAlpha,us->blendDstFuncAlpha); else - grAlphaBlendFunction(GR_BLEND_ONE,GR_BLEND_ZERO,GR_BLEND_ONE,GR_BLEND_ZERO); + FX_grAlphaBlendFunction(GR_BLEND_ONE,GR_BLEND_ZERO,GR_BLEND_ONE,GR_BLEND_ZERO); } /************************************************************************/ @@ -1138,10 +1230,10 @@ static void fxSetupAlphaTest(GLcontext *ctx) tfxUnitsState *us=&fxMesa->unitsState; if(us->alphaTestEnabled) { - grAlphaTestFunction(us->alphaTestFunc); - grAlphaTestReferenceValue(us->alphaTestRefValue); + FX_grAlphaTestFunction(us->alphaTestFunc); + FX_grAlphaTestReferenceValue(us->alphaTestRefValue); } else - grAlphaTestFunction(GR_CMP_ALWAYS); + FX_grAlphaTestFunction(GR_CMP_ALWAYS); } /************************************************************************/ @@ -1206,17 +1298,17 @@ void fxDDDepthMask(GLcontext *ctx, GLboolean flag) } } -void fxSetupDepthTest(GLcontext *ctx) +static void fxSetupDepthTest(GLcontext *ctx) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; tfxUnitsState *us=&fxMesa->unitsState; if(us->depthTestEnabled) - grDepthBufferFunction(us->depthTestFunc); + FX_grDepthBufferFunction(us->depthTestFunc); else - grDepthBufferFunction(GR_CMP_ALWAYS); + FX_grDepthBufferFunction(GR_CMP_ALWAYS); - grDepthMask(us->depthMask); + FX_grDepthMask(us->depthMask); } /************************************************************************/ @@ -1238,7 +1330,7 @@ static void fxSetupColorMask(GLcontext *ctx) { fxMesaContext fxMesa = FX_CONTEXT(ctx); - grColorMask(ctx->Color.ColorMask[RCOMP] || + FX_grColorMask(ctx->Color.ColorMask[RCOMP] || ctx->Color.ColorMask[GCOMP] || ctx->Color.ColorMask[BCOMP], ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); @@ -1250,7 +1342,7 @@ static void fxSetupColorMask(GLcontext *ctx) /**************************** Fog Mode SetUp ****************************/ /************************************************************************/ -void fxFogTableGenerate(GLcontext *ctx) +static void fxFogTableGenerate(GLcontext *ctx) { int i; float f,eyez; @@ -1278,20 +1370,20 @@ void fxFogTableGenerate(GLcontext *ctx) } } -void fxSetupFog(GLcontext *ctx, GLboolean forceTableRebuild) +static void fxSetupFog(GLcontext *ctx, GLboolean forceTableRebuild) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; if(ctx->Fog.Enabled && ctx->FogMode==FOG_FRAGMENT) { GLubyte col[4]; - grFogMode(GR_FOG_WITH_TABLE); + FX_grFogMode(GR_FOG_WITH_TABLE); 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]); - grFogColorValue(FXCOLOR4(col)); + FX_grFogColorValue(FXCOLOR4(col)); if(forceTableRebuild || (fxMesa->fogTableMode!=ctx->Fog.Mode) || @@ -1302,9 +1394,9 @@ void fxSetupFog(GLcontext *ctx, GLboolean forceTableRebuild) fxMesa->fogDensity=ctx->Fog.Density; } - grFogTable(fxMesa->fogTable); + FX_grFogTable(fxMesa->fogTable); } else - grFogMode(GR_FOG_DISABLE); + FX_grFogMode(GR_FOG_DISABLE); } void fxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) @@ -1317,26 +1409,47 @@ void fxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) /************************** Scissor Test SetUp **************************/ /************************************************************************/ -static void fxSetupScissor(GLcontext *ctx) +/* This routine is used in managing the lock state, and therefore can't lock */ +void fxSetScissorValues(GLcontext *ctx) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + int xmin, xmax; + int ymin, ymax, check; if (ctx->Scissor.Enabled) { - int ymin, ymax; - + 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; + } + xmin+=fxMesa->x_offset; + xmax+=fxMesa->x_offset; + ymin+=fxMesa->y_delta; + ymax+=fxMesa->y_delta; + if (xminclipMinX) xmin=fxMesa->clipMinX; + if (xmax>fxMesa->clipMaxX) xmax=fxMesa->clipMaxX; + if (yminscreen_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); +} - if (ymin<0) ymin=0; - - if (ymax>fxMesa->height) ymax=fxMesa->height; - - grClipWindow(ctx->Scissor.X, - ymin, - ctx->Scissor.X+ctx->Scissor.Width, - ymax); - } else - grClipWindow(0,0,fxMesa->width,fxMesa->height); +static void fxSetupScissor(GLcontext *ctx) +{ + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + if (!fxMesa->needClip) { + BEGIN_BOARD_LOCK(); + fxSetScissorValues(ctx); + END_BOARD_LOCK(); + } } void fxDDScissor( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) @@ -1365,30 +1478,30 @@ void fxDDFrontFace(GLcontext *ctx, GLenum mode) } -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) - grCullMode(GR_CULL_NEGATIVE); + FX_grCullMode(GR_CULL_NEGATIVE); else - grCullMode(GR_CULL_POSITIVE); + FX_grCullMode(GR_CULL_POSITIVE); break; case GL_FRONT: if(ctx->Polygon.FrontFace==GL_CCW) - grCullMode(GR_CULL_POSITIVE); + FX_grCullMode(GR_CULL_POSITIVE); else - grCullMode(GR_CULL_NEGATIVE); + FX_grCullMode(GR_CULL_NEGATIVE); break; case GL_FRONT_AND_BACK: - grCullMode(GR_CULL_DISABLE); + FX_grCullMode(GR_CULL_DISABLE); break; default: break; } } else - grCullMode(GR_CULL_DISABLE); + FX_grCullMode(GR_CULL_DISABLE); } @@ -1540,7 +1653,7 @@ void fxDDShadeModel(GLcontext *ctx, GLenum mode) /************************************************************************/ /****************************** Units SetUp *****************************/ /************************************************************************/ -void gl_print_fx_state_flags( const char *msg, GLuint flags ) +static void gl_print_fx_state_flags( const char *msg, GLuint flags ) { fprintf(stderr, "%s: (0x%x) %s%s%s%s%s%s%s\n", @@ -1560,11 +1673,9 @@ void fxSetupFXUnits( GLcontext *ctx ) fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint newstate = fxMesa->new_state; - if (MESA_VERBOSE&VERBOSE_DRIVER) gl_print_fx_state_flags("fxmesa: fxSetupFXUnits", newstate); - if (newstate) { if (newstate & FX_NEW_TEXTURING) fxSetupTexture(ctx); diff --git a/src/mesa/drivers/glide/fxtexman.c b/src/mesa/drivers/glide/fxtexman.c index 3f899cbf5a..97577fca26 100644 --- a/src/mesa/drivers/glide/fxtexman.c +++ b/src/mesa/drivers/glide/fxtexman.c @@ -1,27 +1,51 @@ -/* -*- mode: C; tab-width:8; -*- - - fxtexman.c - 3Dfx VooDoo texture memory functions -*/ +/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */ /* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * Mesa 3-D graphics library + * Version: 3.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. + * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the + * terms stated above. * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Thank you for your contribution, David! * - * See the file fxapi.c for more informations about authors + * Please make note of the above copyright/license statement. If you + * contributed code or bug fixes to this code under the previous (GNU + * Library) license and object to the new license, your code will be + * removed at your request. Please see the Mesa docs/COPYRIGHT file + * for more information. * + * Additional Mesa/3Dfx driver developers: + * Daryll Strauss + * Keith Whitwell + * + * See fxapi.h for more revision/author details. */ + +/* fxtexman.c - 3Dfx VooDoo texture memory functions */ + + #ifdef HAVE_CONFIG_H #include "conf.h" #endif @@ -47,13 +71,15 @@ static tfxTMFreeNode *fxTMNewTMFreeNode(FxU32 start, FxU32 end) return tmn; } +/* Notice this uses grTex{Min,Max}Address directly with FX_ because it + is only used during initialization where the lock is already held. */ static void fxTMUInit(fxMesaContext fxMesa, int tmu) { tfxTMFreeNode *tmn,*tmntmp; FxU32 start,end,blockstart,blockend; - start=grTexMinAddress(tmu); - end=grTexMaxAddress(tmu); + start=FX_grTexMinAddress(tmu); + end=FX_grTexMaxAddress(tmu); if(fxMesa->verbose) { fprintf(stderr,"%s configuration:",(tmu==FX_TMU0) ? "TMU0" : "TMU1"); @@ -224,7 +250,7 @@ static tfxTMAllocNode *fxTMGetTMBlock(fxMesaContext fxMesa, struct gl_texture_ob } } -void fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint where) +void fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint where) { tfxTexInfo *ti=(tfxTexInfo *)tObj->DriverData; int i,l; @@ -254,36 +280,50 @@ void fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint wh switch(where) { case FX_TMU0: case FX_TMU1: - texmemsize=(int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH,&(ti->info)); + texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH, + &(ti->info)); ti->tmi.tm[where]=fxTMGetTMBlock(fxMesa,tObj,where,texmemsize); fxMesa->stats.memTexUpload+=texmemsize; for(i=FX_largeLodValue(ti->info),l=ti->minLevel;i<=FX_smallLodValue(ti->info);i++,l++) - grTexDownloadMipMapLevel(where, - ti->tmi.tm[where]->startAddress,FX_valueToLod(i), - FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info), - ti->info.format,GR_MIPMAPLEVELMASK_BOTH, - ti->tmi.mipmapLevel[l].data); + FX_grTexDownloadMipMapLevel_NoLock(where, + ti->tmi.tm[where]->startAddress, + FX_valueToLod(i), + FX_largeLodLog2(ti->info), + FX_aspectRatioLog2(ti->info), + ti->info.format, + GR_MIPMAPLEVELMASK_BOTH, + ti->tmi.mipmapLevel[l].data); break; case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */ - texmemsize=(int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_ODD,&(ti->info)); + texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_ODD, + &(ti->info)); ti->tmi.tm[FX_TMU0]=fxTMGetTMBlock(fxMesa,tObj,FX_TMU0,texmemsize); fxMesa->stats.memTexUpload+=texmemsize; - texmemsize=(int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_EVEN,&(ti->info)); + texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_EVEN, + &(ti->info)); ti->tmi.tm[FX_TMU1]=fxTMGetTMBlock(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++) { - grTexDownloadMipMapLevel(GR_TMU0,ti->tmi.tm[FX_TMU0]->startAddress,FX_valueToLod(i), - FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info), - ti->info.format,GR_MIPMAPLEVELMASK_ODD, - ti->tmi.mipmapLevel[l].data); - - grTexDownloadMipMapLevel(GR_TMU1,ti->tmi.tm[FX_TMU1]->startAddress,FX_valueToLod(i), - FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info), - ti->info.format,GR_MIPMAPLEVELMASK_EVEN, - ti->tmi.mipmapLevel[l].data); + FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0, + ti->tmi.tm[FX_TMU0]->startAddress, + FX_valueToLod(i), + FX_largeLodLog2(ti->info), + FX_aspectRatioLog2(ti->info), + ti->info.format, + GR_MIPMAPLEVELMASK_ODD, + ti->tmi.mipmapLevel[l].data); + + FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1, + ti->tmi.tm[FX_TMU1]->startAddress, + FX_valueToLod(i), + FX_largeLodLog2(ti->info), + FX_aspectRatioLog2(ti->info), + ti->info.format, + GR_MIPMAPLEVELMASK_EVEN, + ti->tmi.mipmapLevel[l].data); } break; default: @@ -297,6 +337,12 @@ void fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint wh ti->tmi.isInTM=GL_TRUE; } +void fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint where) { + BEGIN_BOARD_LOCK(); + fxTMMoveInTM_NoLock(fxMesa, tObj, where); + END_BOARD_LOCK(); +} + void fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint level) { tfxTexInfo *ti=(tfxTexInfo *)tObj->DriverData; @@ -318,20 +364,20 @@ void fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj, switch(tmu) { case FX_TMU0: case FX_TMU1: - grTexDownloadMipMapLevel(tmu, + FX_grTexDownloadMipMapLevel(tmu, ti->tmi.tm[tmu]->startAddress,FX_valueToLod(FX_lodToValue(lodlevel)+level), FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info), ti->info.format,GR_MIPMAPLEVELMASK_BOTH, ti->tmi.mipmapLevel[level].data); break; case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */ - grTexDownloadMipMapLevel(GR_TMU0, + FX_grTexDownloadMipMapLevel(GR_TMU0, ti->tmi.tm[GR_TMU0]->startAddress,FX_valueToLod(FX_lodToValue(lodlevel)+level), FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info), ti->info.format,GR_MIPMAPLEVELMASK_ODD, ti->tmi.mipmapLevel[level].data); - grTexDownloadMipMapLevel(GR_TMU1, + FX_grTexDownloadMipMapLevel(GR_TMU1, ti->tmi.tm[GR_TMU1]->startAddress,FX_valueToLod(FX_lodToValue(lodlevel)+level), FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info), ti->info.format,GR_MIPMAPLEVELMASK_EVEN, @@ -374,7 +420,7 @@ void fxTMReloadSubMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tO switch(tmu) { case FX_TMU0: case FX_TMU1: - grTexDownloadMipMapLevelPartial(tmu, + FX_grTexDownloadMipMapLevelPartial(tmu, ti->tmi.tm[tmu]->startAddress,FX_valueToLod(FX_lodToValue(lodlevel)+level), FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info), ti->info.format,GR_MIPMAPLEVELMASK_BOTH, @@ -382,14 +428,14 @@ void fxTMReloadSubMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tO yoffset,yoffset+height-1); break; case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */ - grTexDownloadMipMapLevelPartial(GR_TMU0, + FX_grTexDownloadMipMapLevelPartial(GR_TMU0, ti->tmi.tm[FX_TMU0]->startAddress,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); - grTexDownloadMipMapLevelPartial(GR_TMU1, + FX_grTexDownloadMipMapLevelPartial(GR_TMU1, ti->tmi.tm[FX_TMU1]->startAddress,FX_valueToLod(FX_lodToValue(lodlevel)+level), FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info), ti->info.format,GR_MIPMAPLEVELMASK_EVEN, @@ -563,6 +609,98 @@ void fxTMClose(fxMesaContext fxMesa) } } +void fxTMRestore_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj) +{ + tfxTexInfo *ti=(tfxTexInfo *)tObj->DriverData; + int i,l, where; + + if (MESA_VERBOSE&VERBOSE_DRIVER) { + fprintf(stderr,"fxmesa: fxRestore(%d)\n",tObj->Name); + } + + if (!ti->validated) { + fprintf(stderr,"fxDriver: internal error in fxRestore -> not validated\n"); + fxCloseHardware(); + exit(-1); + } + + where=ti->tmi.whichTMU; + if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_TEXTURE)) { + fprintf(stderr,"fxmesa: reloading %x (%d) in texture memory in %d\n",(GLuint)tObj,tObj->Name,where); + } + + switch(where) { + case FX_TMU0: + case FX_TMU1: + for (i=FX_largeLodValue_NoLock(ti->info), l=ti->minLevel; + i<=FX_smallLodValue_NoLock(ti->info); + i++,l++) + if (ti->tmi.mipmapLevel[l].data) + FX_grTexDownloadMipMapLevel_NoLock(where, + ti->tmi.tm[where]->startAddress, + FX_valueToLod(i), + FX_largeLodLog2(ti->info), + FX_aspectRatioLog2(ti->info), + ti->info.format, + GR_MIPMAPLEVELMASK_BOTH, + ti->tmi.mipmapLevel[l].data); + break; + case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */ + for (i=FX_largeLodValue_NoLock(ti->info),l=ti->minLevel; + i<=FX_smallLodValue_NoLock(ti->info); + i++,l++) { + if (ti->tmi.mipmapLevel[l].data) + FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0, + ti->tmi.tm[FX_TMU0]->startAddress, + FX_valueToLod(i), + FX_largeLodLog2(ti->info), + FX_aspectRatioLog2(ti->info), + ti->info.format, + GR_MIPMAPLEVELMASK_ODD, + ti->tmi.mipmapLevel[l].data); + if (ti->tmi.mipmapLevel[l].data) + FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1, + ti->tmi.tm[FX_TMU1]->startAddress, + FX_valueToLod(i), + FX_largeLodLog2(ti->info), + FX_aspectRatioLog2(ti->info), + ti->info.format, + GR_MIPMAPLEVELMASK_EVEN, + ti->tmi.mipmapLevel[l].data); + } + break; + default: + fprintf(stderr,"fxDriver: internal error in fxRestore -> bad tmu (%d)\n", + where); + fxCloseHardware(); + exit(-1); + } +} + +void +fxTMRestoreTextures(fxMesaContext ctx) { + tfxTexInfo *ti; + struct gl_texture_object *tObj; + int i; + + tObj=ctx->glCtx->Shared->TexObjectList; + while (tObj) { + ti=(tfxTexInfo*)tObj->DriverData; + if (ti && ti->tmi.isInTM) { + for (i=0; iglCtx->Texture.Unit[i].Current==tObj) { + /* Force the texture onto the board, as it could be in use */ + fxTMRestore_NoLock(ctx, tObj); + break; + } + if (i==MAX_TEXTURE_UNITS) /* Mark the texture as off the board */ + fxTMMoveOutTM(ctx, tObj); + } + tObj=tObj->Next; + } + ctx->lastUnitsMode=0; + fxSetupTexture_NoLock(ctx->glCtx); +} #else diff --git a/src/mesa/drivers/glide/fxwgl.c b/src/mesa/drivers/glide/fxwgl.c index c1db7b88bd..3d779cde46 100644 --- a/src/mesa/drivers/glide/fxwgl.c +++ b/src/mesa/drivers/glide/fxwgl.c @@ -1,26 +1,54 @@ -/* fxwgl.c - Microsoft wgl functions emulation for - * 3Dfx VooDoo/Mesa interface - */ +/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */ /* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * Mesa 3-D graphics library + * Version: 3.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. + * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the + * terms stated above. * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Thank you for your contribution, David! * - * See the file fxapi.c for more informations about authors + * Please make note of the above copyright/license statement. If you + * contributed code or bug fixes to this code under the previous (GNU + * Library) license and object to the new license, your code will be + * removed at your request. Please see the Mesa docs/COPYRIGHT file + * for more information. * + * Additional Mesa/3Dfx driver developers: + * Daryll Strauss + * Keith Whitwell + * + * See fxapi.h for more revision/author details. + */ + + + +/* fxwgl.c - Microsoft wgl functions emulation for + * 3Dfx VooDoo/Mesa interface */ + #ifdef __WIN32__ #ifdef __cplusplus @@ -243,11 +271,11 @@ LONG GLAPIENTRY __wglMonitor(HWND hwnd,UINT message,UINT wParam,LONG lParam) static int moving = 0; if (!moving) { if(fxQueryHardware()!=GR_SSTTYPE_VOODOO) { - if(!grSstControl(GR_CONTROL_RESIZE)) { + if(!FX_grSstControl(GR_CONTROL_RESIZE)) { moving = 1; SetWindowPos(hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOZORDER); moving = 0; - if(!grSstControl(GR_CONTROL_RESIZE)) { + if(!FX_grSstControl(GR_CONTROL_RESIZE)) { /*MessageBox(0,_T("Error changing windowsize"),_T("fxMESA"),MB_OK);*/ PostMessage(hWND,WM_CLOSE,0,0); } @@ -255,7 +283,7 @@ LONG GLAPIENTRY __wglMonitor(HWND hwnd,UINT message,UINT wParam,LONG lParam) } /* Do the clipping in the glide library */ - grClipWindow(0,0,grSstScreenWidth(),grSstScreenHeight()); + FX_grClipWindow(0,0,FX_grSstScreenWidth(),FX_grSstScreenHeight()); /* And let the new size set in the context */ fxMesaUpdateScreenSize(ctx); } @@ -269,9 +297,9 @@ LONG GLAPIENTRY __wglMonitor(HWND hwnd,UINT message,UINT wParam,LONG lParam) BOOL fMinimized = (BOOL) HIWORD(wParam); if((fActive == WA_INACTIVE) || fMinimized) - grSstControl(GR_CONTROL_DEACTIVATE); + FX_grSstControl(GR_CONTROL_DEACTIVATE); else - grSstControl(GR_CONTROL_ACTIVATE); + FX_grSstControl(GR_CONTROL_ACTIVATE); } break; case WM_SHOWWINDOW: @@ -280,10 +308,10 @@ LONG GLAPIENTRY __wglMonitor(HWND hwnd,UINT message,UINT wParam,LONG lParam) if(gdiWindowHackEna && (VK_RETURN == wParam)) { if(gdiWindowHack) { gdiWindowHack = GL_FALSE; - grSstControl(GR_CONTROL_ACTIVATE); + FX_grSstControl(GR_CONTROL_ACTIVATE); } else { gdiWindowHack = GL_TRUE; - grSstControl(GR_CONTROL_DEACTIVATE); + FX_grSstControl(GR_CONTROL_DEACTIVATE); } } break; @@ -382,7 +410,7 @@ HGLRC GLAPIENTRY wglCreateContext(HDC hdc) gdiWindowHack = GL_FALSE; else { gdiWindowHack = GL_TRUE; - grSstControl(GR_CONTROL_DEACTIVATE); + FX_grSstControl(GR_CONTROL_DEACTIVATE); } } } else { @@ -779,7 +807,7 @@ BOOL GLAPIENTRY wglSwapBuffers(HDC hdc) HDC hdcDIBSection = CreateCompatibleDC(hdcScreen); HBITMAP holdBitmap = (HBITMAP) SelectObject(hdcDIBSection, dibHBM); - grLfbReadRegion(GR_BUFFER_FRONTBUFFER, 0, 0, + FX_grLfbReadRegion(GR_BUFFER_FRONTBUFFER, 0, 0, width, height, width * 2, dibSurfacePtr); -- cgit v1.2.3