-/* -*- 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 <daryll@precisioninsight.com>
+ * Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+/* fxapi.c - 3Dfx VooDoo/Mesa interface */
+
+
+/********************************************************************
*
* Function names:
* fxMesa.... (The driver API)
/*
* 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;
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) {
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());
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) {
-/* -*- 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 <daryll@precisioninsight.com>
+ * Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
*/
+/* fxdd.c - 3Dfx VooDoo Mesa device driver functions */
+
+
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
#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 *****/
/**********************************************************************/
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);
+ }
}
/* 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));
/* 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));
/* 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));
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 {
}
+#ifdef XF86DRI
+static GLboolean inClipRects(fxMesaContext fxMesa, int px, int py)
+{
+ int i;
+
+ py=fxMesa->height+fxMesa->y_offset-py;
+ for (i=0; i<fxMesa->numClipRects; i++) {
+ if ((px>=fxMesa->pClipRects[i].x1) &&
+ (px<fxMesa->pClipRects[i].x2) &&
+ (py>=fxMesa->pClipRects[i].y1) &&
+ (py<fxMesa->pClipRects[i].y2)) return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+#endif
+
static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py,
GLsizei width, GLsizei height,
ymax=fxMesa->height;
}
+ xmin+=fxMesa->x_offset;
+ xmax+=fxMesa->x_offset;
-#define ISCLIPPED(rx) ( ((rx)<xmin) || ((rx)>=xmax) )
+#ifdef XF86DRI
+#define ISCLIPPED(rx, ry) ( ((rx)<xmin) || ((rx)>=xmax) || !inClipRects(fxMesa, rx, ry))
+#else
+#define ISCLIPPED(rx, ry) ( ((rx)<xmin) || ((rx)>=xmax) )
+#endif
#define DRAWBIT(i) { \
- if(!ISCLIPPED(x+px)) \
+ if(!ISCLIPPED(x+px, y)) \
if( (*pb) & (1<<(i)) ) \
(*p)=color; \
p++; \
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;
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
/* This code is a bit slow... */
- for(y=py;y<(py+height);y++) {
+ if (py>ymin) ymin=py;
+ if (py+height<ymax) ymax=py+height;
- if (y>=ymax)
- break;
+ px+=fxMesa->x_offset;
+ scrheight=fxMesa->height+fxMesa->y_offset;
- if (y<=ymin)
- continue;
+ for(y=ymin; y<ymax; y++) {
p=((FxU16 *)info.lfbPtr)+px+((scrheight-y)*stride);
}
}
- grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB);
+ FX_grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB);
#undef ISCLIPPED
#undef DRAWBIT
{
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
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;
}
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;
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.
*/
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.
+*/
+
/************************************************************************/
/************************************************************************/
/************************************************************************/
/* 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))
/* 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) &&
{
if (MESA_VERBOSE&VERBOSE_DRIVER)
fprintf(stderr, "fxMesa: unsupported multitex env mode\n");
-
return GL_FALSE;
}
}
/* 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;
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) {
ctx->Driver.CullFace=fxDDCullFace;
ctx->Driver.ShadeModel=fxDDShadeModel;
ctx->Driver.Enable=fxDDEnable;
-
ctx->Driver.RegisterVB=fxDDRegisterVB;
ctx->Driver.UnregisterVB=fxDDUnregisterVB;
}
#endif /* FX */
+
-/* -*- 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 <daryll@precisioninsight.com>
+ * Keith Whitwell <keith@precisioninsight.com>
+ *
+ * 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
src_width, \
src_stride, \
src_data) \
- grLfbWriteRegion(dst_buffer, \
+ writeRegionClipped(fxMesa, dst_buffer, \
dst_x, \
dst_y, \
GR_LFB_SRC_FMT_8888, \
{
argb[i] = MESACOLOR_TO_ARGB(rgba[i]);
}
- FX_grLfbWriteRegion(dst_buffer,
+ writeRegionClipped(fxMesa, dst_buffer,
dst_x,
dst_y,
GR_LFB_SRC_FMT_8888,
#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; i<fxMesa->numClipRects; i++) {
+ if ((dst_x>=fxMesa->pClipRects[i].x1) &&
+ (dst_x<fxMesa->pClipRects[i].x2) &&
+ (dst_y>=fxMesa->pClipRects[i].y1) &&
+ (dst_y<fxMesa->pClipRects[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; i<fxMesa->numClipRects; i++) {
+ if (dst_y>=fxMesa->pClipRects[i].y1 && dst_y<fxMesa->pClipRects[i].y2) {
+ if (dst_x<fxMesa->pClipRects[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 *****/
/************************************************************************/
{
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;
{
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;
{
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;
++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;
}
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 {
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 );
}
}
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");
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<n;i++) {
-#if FXMESA_USE_ARGB
- rgba[i][RCOMP]=(data[i] & 0xF800) >> 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;
}
-
}
/************************************************************************/
{
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");
for(i=0;i<n;i++)
if(mask[i])
- LFB_WRITE_SPAN_MESA(fxMesa->currentFB,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,
{
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");
for(i=0;i<n;i++)
if(mask[i])
- FX_grLfbWriteRegion(fxMesa->currentFB,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);
}
{
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;i<n;i++)
+ for(i=0;i<n;i++) {
if(mask[i]) {
- grLfbReadRegion(fxMesa->currentFB,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 *****/
/************************************************************************/
{
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].
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,
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) {
} /*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;
}
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");
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_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;
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
if (z[i] < zval) {
/* pass */
}
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_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;
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
if (z[i] <= zval) {
/* pass */
} else {
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_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;
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
if (z[i] >= zval) {
/* pass */
} else {
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_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;
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
if (z[i] > zval) {
/* pass */
} else {
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_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;
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
if (z[i] != zval) {
/* pass */
}
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_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;
/* Don't update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i],bottom-y[i],1,1,0,&zval);
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x[i]+fxMesa->x_offset,bottom-y[i],1,1,0,&zval);
if (z[i] == zval) {
/* pass */
} else {
/* Update Z buffer */
for (i=0; i<n; i++) {
if (mask[i]) {
- 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 {
-/* -*- 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 <daryll@precisioninsight.com>
+ * Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
*/
+
+/* fxddtex.c - 3Dfx VooDoo Texture mapping functions */
+
+
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
ti->sClamp=GR_TEXTURECLAMP_WRAP;
break;
default:
- fprintf(stderr, "BAD CLAMP\n");
break;
}
fxMesa->new_state|=FX_NEW_TEXTURING;
-/* -*- 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 <daryll@precisioninsight.com>
+ * Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
*/
+
#ifndef FXDRV_H
#define FXDRV_H
#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
#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)]; \
#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;
tfxUnitsState unitsState;
tfxUnitsState restoreUnitsState; /* saved during multipass */
-
GLuint tmu_source[FX_NUM_TMU];
GLuint tex_dest[MAX_TEXTURE_UNITS];
GLuint setupindex;
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
};
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
-/* $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 <daryll@precisioninsight.com>
+ * Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
*/
+
#ifdef HAVE_CONFIG_H
#include "conf.h"
#include <stdlib.h>
#include <string.h>
-
-FxI32 FX_grGetInteger(FxU32 pname)
+FxI32 grGetInteger(FxU32 pname)
{
#if !defined(FX_GLIDE3)
switch (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");
}
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)
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];
}
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)
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
}
#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;
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
/*
+/* -*- 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 <daryll@precisioninsight.com>
+ * Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
*/
+
+
#ifndef __FX_GLIDE_WARPER__
#define __FX_GLIDE_WARPER__
/*
* Genral warper functions for Glide2/Glide3:
*/
+extern FxI32 grGetInteger(FxU32 pname);
extern FxI32 FX_grGetInteger(FxU32 pname);
/*
* 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.
*/
#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))
/*
* 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);
+
/*
#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
#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.
#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
/*
#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
#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__ */
+
-/* -*- 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 <daryll@precisioninsight.com>
+ * Keith Whitwell <keith@precisioninsight.com>
*
+ * See fxapi.h for more revision/author details.
*/
+
+/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
+
+
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
#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) {
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,
(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;
/************************* 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
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;
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);
fxMesa->lastUnitsMode=unitsmode;
fxMesa->stw_hint_state = 0;
- FX_grHints(GR_HINT_STWHINT,0);
+ FX_grHints_NoLock(GR_HINT_STWHINT,0);
ifmt=ti->baseLevelInternalFormat;
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
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
}
}
+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
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 ***/
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
#undef T1_IN_TMU1
}
-static void fxSetupTextureDoubleTMU(GLcontext *ctx)
+static void fxSetupTextureDoubleTMU_NoLock(GLcontext *ctx)
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GrCombineLocal_t localc,locala;
ti1=(tfxTexInfo *)tObj1->DriverData;
fxTexValidate(ctx,tObj1);
- fxSetupDoubleTMU(fxMesa,tObj0,tObj1);
+ fxSetupDoubleTMU_NoLock(fxMesa,tObj0,tObj1);
unitsmode=fxGetTexSetConfiguration(ctx,tObj0,tObj1);
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;
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;
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;
}
/************************* No Texture ***************************/
-static void fxSetupTextureNone(GLcontext *ctx)
+static void fxSetupTextureNone_NoLock(GLcontext *ctx)
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GrCombineLocal_t localc,locala;
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;
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 *******************************/
/************************************************************************/
}
}
-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);
}
/************************************************************************/
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);
}
/************************************************************************/
}
}
-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);
}
/************************************************************************/
{
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);
/**************************** Fog Mode SetUp ****************************/
/************************************************************************/
-void fxFogTableGenerate(GLcontext *ctx)
+static void fxFogTableGenerate(GLcontext *ctx)
{
int i;
float f,eyez;
}
}
-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) ||
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 )
/************************** 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 (xmin<fxMesa->clipMinX) xmin=fxMesa->clipMinX;
+ if (xmax>fxMesa->clipMaxX) xmax=fxMesa->clipMaxX;
+ if (ymin<fxMesa->screen_height-fxMesa->clipMaxY)
+ ymin=fxMesa->screen_height-fxMesa->clipMaxY;
+ if (ymax>fxMesa->screen_height-fxMesa->clipMinY)
+ ymax=fxMesa->screen_height-fxMesa->clipMinY;
+ FX_grClipWindow_NoLock(xmin, ymin, xmax, ymax);
+}
- 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 )
}
-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);
}
/************************************************************************/
/****************************** 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",
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);
-/* -*- 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 <daryll@precisioninsight.com>
+ * Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
*/
+
+/* fxtexman.c - 3Dfx VooDoo texture memory functions */
+
+
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
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");
}
}
-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;
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:
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;
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,
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,
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,
}
}
+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; i<MAX_TEXTURE_UNITS; i++)
+ if (ctx->glCtx->Texture.Unit[i].Current==tObj) {
+ /* Force the texture onto the board, as it could be in use */
+ 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
-/* 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 <daryll@precisioninsight.com>
+ * Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+
+/* fxwgl.c - Microsoft wgl functions emulation for
+ * 3Dfx VooDoo/Mesa interface
*/
+
#ifdef __WIN32__
#ifdef __cplusplus
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);
}
}
/* 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);
}
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:
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;
gdiWindowHack = GL_FALSE;
else {
gdiWindowHack = GL_TRUE;
- grSstControl(GR_CONTROL_DEACTIVATE);
+ FX_grSstControl(GR_CONTROL_DEACTIVATE);
}
}
} else {
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);