update/merge with Daryll's X server changes

This commit is contained in:
Brian Paul 1999-11-15 18:05:00 +00:00
parent e23e2759fc
commit 5a95679e58
10 changed files with 1867 additions and 707 deletions

View File

@ -1,24 +1,52 @@
/* -*- mode: C; tab-width:8; -*-
fxapi.c - 3Dfx VooDoo/Mesa interface
*/
/* -*- mode: C; tab-width:8; -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* Mesa 3-D graphics library
* Version: 3.1
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
********************************************************************
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
* terms stated above.
*
* Thank you for your contribution, David!
*
* Please make note of the above copyright/license statement. If you
* contributed code or bug fixes to this code under the previous (GNU
* Library) license and object to the new license, your code will be
* removed at your request. Please see the Mesa docs/COPYRIGHT file
* for more information.
*
* Additional Mesa/3Dfx driver developers:
* Daryll Strauss <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)
@ -820,9 +848,10 @@ void fxsignals()
/*
* Create a new FX/Mesa context and return a handle to it.
*/
fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,GrScreenResolution_t res,
GrScreenRefresh_t ref,
const GLint attribList[])
fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
GrScreenResolution_t res,
GrScreenRefresh_t ref,
const GLint attribList[])
{
fxMesaContext fxMesa = NULL;
int i,type;
@ -835,7 +864,7 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,GrScreenResolution_t res
GLint accumSize=0;
GLcontext *shareCtx = NULL;
GLcontext *ctx = 0;
FX_GrContext_t glideContext = 0;
/*FX_GrContext_t glideContext = 0;*/
char *errorstr;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
@ -942,10 +971,30 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,GrScreenResolution_t res
goto errorhandler;
}
/* Pixel tables are use during pixel read-back */
if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) {
fxInitPixelTables(GL_TRUE); /* use BGR pixel order on Voodoo1/2 */
}
else {
fxInitPixelTables(GL_FALSE); /* use RGB pixel order otherwise */
}
fxMesa->width=FX_grSstScreenWidth();
fxMesa->height=FX_grSstScreenHeight();
fxMesa->clipMinX = 0;
fxMesa->clipMaxX = fxMesa->width;
fxMesa->clipMinY = 0;
fxMesa->clipMaxY = fxMesa->height;
fxMesa->screen_width = fxMesa->width;
fxMesa->screen_height = fxMesa->height;
fxMesa->x_offset = 0;
fxMesa->y_offset = 0;
fxMesa->y_delta = 0;
fxMesa->needClip = 0;
if(verbose)
fprintf(stderr,"Glide screen size: %dx%d\n",
(int)FX_grSstScreenWidth(),(int)FX_grSstScreenHeight());
@ -1204,7 +1253,7 @@ int GLAPIENTRY fxQueryHardware(void)
char buf[80];
FX_grGlideGetVersion(buf);
fprintf(stderr,"Using Glide V%s\n",0);
fprintf(stderr,"Using Glide V%s\n","");
fprintf(stderr,"Number of boards: %d\n",glbHWConfig.num_sst);
if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) {

View File

@ -1,28 +1,51 @@
/* -*- mode: C; tab-width:8; -*-
fxdd.c - 3Dfx VooDoo Mesa device driver functions
*/
/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* Mesa 3-D graphics library
* Version: 3.1
*
* 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:
*
* See the file fxapi.c for more informations about authors
* 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.
*/
/* fxdd.c - 3Dfx VooDoo Mesa device driver functions */
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
@ -34,6 +57,44 @@
#include "enums.h"
#include "extensions.h"
/* These lookup table are used to extract RGB values in [0,255] from
* 16-bit pixel values.
*/
GLubyte FX_PixelToR[0x10000];
GLubyte FX_PixelToG[0x10000];
GLubyte FX_PixelToB[0x10000];
/*
* Initialize the FX_PixelTo{RGB} arrays.
* Input: bgrOrder - if TRUE, pixels are in BGR order, else RGB order.
*/
void fxInitPixelTables(GLboolean bgrOrder)
{
GLuint pixel;
for (pixel = 0; pixel <= 0xffff; pixel++) {
GLuint r, g, b;
if (bgrOrder) {
r = (pixel & 0x001F) << 3;
g = (pixel & 0x07E0) >> 3;
b = (pixel & 0xF800) >> 8;
}
else {
r = (pixel & 0xF800) >> 8;
g = (pixel & 0x07E0) >> 3;
b = (pixel & 0x001F) << 3;
}
r = r * 255 / 0xF8; /* fill in low-order bits */
g = g * 255 / 0xFC;
b = b * 255 / 0xF8;
FX_PixelToR[pixel] = r;
FX_PixelToG[pixel] = g;
FX_PixelToB[pixel] = b;
}
}
/**********************************************************************/
/***** Miscellaneous functions *****/
/**********************************************************************/
@ -45,10 +106,11 @@ void fxDDDither(GLcontext *ctx, GLboolean enable)
fprintf(stderr,"fxmesa: fxDDDither()\n");
}
if(enable)
grDitherMode(GR_DITHER_4x4);
else
grDitherMode(GR_DITHER_DISABLE);
if (enable) {
FX_grDitherMode(GR_DITHER_4x4);
} else {
FX_grDitherMode(GR_DITHER_DISABLE);
}
}
@ -121,14 +183,14 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
/* clear color and depth buffer */
if (ctx->Color.DrawDestMask & BACK_LEFT_BIT) {
grRenderBuffer(GR_BUFFER_BACKBUFFER);
grBufferClear(fxMesa->clearC, fxMesa->clearA,
(FxU16)(ctx->Depth.Clear*0xffff));
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA,
(FxU16)(ctx->Depth.Clear*0xffff));
}
if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT) {
grRenderBuffer(GR_BUFFER_FRONTBUFFER);
grBufferClear(fxMesa->clearC, fxMesa->clearA,
(FxU16)(ctx->Depth.Clear*0xffff));
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA,
(FxU16)(ctx->Depth.Clear*0xffff));
}
newmask=mask & (~(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT));
@ -137,19 +199,20 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
/* clear color buffer */
if(ctx->Color.ColorMask) {
grDepthMask(FXFALSE);
FX_grDepthMask(FXFALSE);
if (ctx->Color.DrawDestMask & BACK_LEFT_BIT) {
grRenderBuffer(GR_BUFFER_BACKBUFFER);
grBufferClear(fxMesa->clearC, fxMesa->clearA, 0);
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 0);
}
if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT) {
grRenderBuffer(GR_BUFFER_FRONTBUFFER);
grBufferClear(fxMesa->clearC, fxMesa->clearA, 0);
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 0);
}
if(ctx->Depth.Mask)
grDepthMask(FXTRUE);
if(ctx->Depth.Mask) {
FX_grDepthMask(FXTRUE);
}
}
newmask=mask & (~(GL_COLOR_BUFFER_BIT));
@ -158,14 +221,14 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
/* clear depth buffer */
if(ctx->Depth.Mask) {
grColorMask(FXFALSE,FXFALSE);
grBufferClear(fxMesa->clearC, fxMesa->clearA,
(FxU16)(ctx->Depth.Clear*0xffff));
FX_grColorMask(FXFALSE,FXFALSE);
FX_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(ctx->Color.ColorMask[RCOMP] ||
ctx->Color.ColorMask[GCOMP] ||
ctx->Color.ColorMask[BCOMP],
ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
}
newmask=mask & (~(GL_DEPTH_BUFFER_BIT));
@ -190,12 +253,12 @@ static GLboolean fxDDSetBuffer(GLcontext *ctx, GLenum mode )
if (mode == GL_FRONT_LEFT) {
fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
grRenderBuffer(fxMesa->currentFB);
FX_grRenderBuffer(fxMesa->currentFB);
return GL_TRUE;
}
else if (mode == GL_BACK_LEFT) {
fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
grRenderBuffer(fxMesa->currentFB);
FX_grRenderBuffer(fxMesa->currentFB);
return GL_TRUE;
}
else {
@ -204,6 +267,22 @@ static GLboolean fxDDSetBuffer(GLcontext *ctx, GLenum mode )
}
#ifdef XF86DRI
static GLboolean inClipRects(fxMesaContext fxMesa, int px, int py)
{
int i;
py=fxMesa->height+fxMesa->y_offset-py;
for (i=0; 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,
@ -241,10 +320,16 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py,
ymax=fxMesa->height;
}
xmin+=fxMesa->x_offset;
xmax+=fxMesa->x_offset;
#define ISCLIPPED(rx) ( ((rx)<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++; \
@ -258,7 +343,7 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py,
scrwidth=fxMesa->width;
scrheight=fxMesa->height;
if((px>=scrwidth) || (px+width<=0) || (py>=scrheight) || (py+height<=0))
if ((px>=scrwidth) || (px+width<=0) || (py>=scrheight) || (py+height<=0))
return GL_TRUE;
pb=bitmap;
@ -269,16 +354,16 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py,
py=0;
}
if(py+height>=scrheight)
if (py+height>=scrheight)
height-=(py+height)-scrheight;
info.size=sizeof(info);
if(!grLfbLock(GR_LFB_WRITE_ONLY,
fxMesa->currentFB,
GR_LFBWRITEMODE_565,
GR_ORIGIN_UPPER_LEFT,
FXFALSE,
&info)) {
if(!FX_grLfbLock(GR_LFB_WRITE_ONLY,
fxMesa->currentFB,
GR_LFBWRITEMODE_565,
GR_ORIGIN_UPPER_LEFT,
FXFALSE,
&info)) {
#ifndef FX_SILENT
fprintf(stderr,"fx Driver: error locking the linear frame buffer\n");
#endif
@ -298,13 +383,13 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py,
/* This code is a bit slow... */
for(y=py;y<(py+height);y++) {
if (py>ymin) ymin=py;
if (py+height<ymax) 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);
@ -315,7 +400,7 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py,
}
}
grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB);
FX_grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB);
#undef ISCLIPPED
#undef DRAWBIT
@ -347,8 +432,6 @@ void fxDDSetNearFar(GLcontext *ctx, GLfloat n, GLfloat f)
{
FX_CONTEXT(ctx)->new_state |= FX_NEW_FOG;
ctx->Driver.RenderStart = fxSetupFXUnits;
FX_CONTEXT(ctx)->wscale = fabs(f)/65535.0f;
}
/* KW: Put the word Mesa in the render string because quakeworld
@ -459,13 +542,13 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa )
fxMesa->unitsState.depthMask =GL_TRUE;
fxMesa->unitsState.depthTestFunc =GR_CMP_LESS;
grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE);
FX_grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE);
if(fxMesa->haveDoubleBuffer) {
fxMesa->currentFB=GR_BUFFER_BACKBUFFER;
grRenderBuffer(GR_BUFFER_BACKBUFFER);
FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
} else {
fxMesa->currentFB=GR_BUFFER_FRONTBUFFER;
grRenderBuffer(GR_BUFFER_FRONTBUFFER);
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
}
fxMesa->state = NULL;
@ -481,10 +564,10 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa )
}
if(fxMesa->haveZBuffer)
grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
FX_grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
#if (!FXMESA_USE_ARGB)
grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); /* Not every Glide has this */
FX_grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); /* Not every Glide has this */
#endif
fxMesa->glCtx->Const.MaxTextureLevels=9;
@ -505,7 +588,7 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa )
fxDDSetNearFar(fxMesa->glCtx,1.0,100.0);
grGlideGetState((GrState*)fxMesa->state);
FX_grGlideGetState((GrState*)fxMesa->state);
/* XXX Fix me: callback not registered when main VB is created.
*/
@ -546,6 +629,12 @@ void fxDDInitExtensions( GLcontext *ctx )
gl_extensions_disable( ctx, "GL_ARB_multitexture" );
}
/*
This driver may need to move the drawing operations to a different sub
window. This modifies the viewport command to add our X,Y offset to all
drawn objects that go through the viewport transformation.
*/
/************************************************************************/
/************************************************************************/
/************************************************************************/
@ -591,16 +680,19 @@ static GLboolean fxIsInHardware(GLcontext *ctx)
/* Not very well written ... */
((ctx->Enabled & (TEXTURE0_1D | TEXTURE1_1D)) &&
((ctx->Enabled & (TEXTURE0_2D | TEXTURE1_2D))!=(TEXTURE0_2D | TEXTURE1_2D)))
)
) {
return GL_FALSE;
}
if((ctx->Texture.ReallyEnabled & TEXTURE0_2D) &&
(ctx->Texture.Unit[0].EnvMode==GL_BLEND))
(ctx->Texture.Unit[0].EnvMode==GL_BLEND)) {
return GL_FALSE;
}
if((ctx->Texture.ReallyEnabled & TEXTURE1_2D) &&
(ctx->Texture.Unit[1].EnvMode==GL_BLEND))
(ctx->Texture.Unit[1].EnvMode==GL_BLEND)) {
return GL_FALSE;
}
if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE))
@ -617,8 +709,9 @@ static GLboolean fxIsInHardware(GLcontext *ctx)
/* Can't use multipass to blend a multitextured triangle - fall
* back to software.
*/
if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled)
if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled) {
return GL_FALSE;
}
if ((ctx->Texture.Unit[0].EnvMode!=ctx->Texture.Unit[1].EnvMode) &&
(ctx->Texture.Unit[0].EnvMode!=GL_MODULATE) &&
@ -626,7 +719,6 @@ static GLboolean fxIsInHardware(GLcontext *ctx)
{
if (MESA_VERBOSE&VERBOSE_DRIVER)
fprintf(stderr, "fxMesa: unsupported multitex env mode\n");
return GL_FALSE;
}
}
@ -635,13 +727,15 @@ static GLboolean fxIsInHardware(GLcontext *ctx)
/* Not very well written ... */
((ctx->Enabled & TEXTURE0_1D) &&
(!(ctx->Enabled & TEXTURE0_2D)))
)
) {
return GL_FALSE;
}
if((ctx->Texture.ReallyEnabled & TEXTURE0_2D) &&
(ctx->Texture.Unit[0].EnvMode==GL_BLEND))
(ctx->Texture.Unit[0].EnvMode==GL_BLEND)) {
return GL_FALSE;
}
}
return GL_TRUE;
@ -680,11 +774,11 @@ static void fxDDUpdateDDPointers(GLcontext *ctx)
ctx->Driver.LineFunc=fxMesa->LineFunc;
ctx->Driver.TriangleFunc=fxMesa->TriangleFunc;
ctx->Driver.QuadFunc=fxMesa->QuadFunc;
} else
} else {
fxMesa->render_index = FX_FALLBACK;
}
}
void fxSetupDDPointers(GLcontext *ctx)
{
if (MESA_VERBOSE&VERBOSE_DRIVER) {
@ -748,7 +842,6 @@ void fxSetupDDPointers(GLcontext *ctx)
ctx->Driver.CullFace=fxDDCullFace;
ctx->Driver.ShadeModel=fxDDShadeModel;
ctx->Driver.Enable=fxDDEnable;
ctx->Driver.RegisterVB=fxDDRegisterVB;
ctx->Driver.UnregisterVB=fxDDUnregisterVB;
@ -786,3 +879,4 @@ int gl_fx_dummy_function_dd(void)
}
#endif /* FX */

View File

@ -1,27 +1,51 @@
/* -*- mode: C; tab-width:8; -*-
fxdd.c - 3Dfx VooDoo Mesa span and pixel functions
*/
/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* Mesa 3-D graphics library
* Version: 3.1
*
* 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:
*
* See the file fxapi.c for more informations about authors
* 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.
*/
/* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
@ -50,7 +74,7 @@
src_width, \
src_stride, \
src_data) \
grLfbWriteRegion(dst_buffer, \
writeRegionClipped(fxMesa, dst_buffer, \
dst_x, \
dst_y, \
GR_LFB_SRC_FMT_8888, \
@ -84,7 +108,7 @@ void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer,
{
argb[i] = MESACOLOR_TO_ARGB(rgba[i]);
}
FX_grLfbWriteRegion(dst_buffer,
writeRegionClipped(fxMesa, dst_buffer,
dst_x,
dst_y,
GR_LFB_SRC_FMT_8888,
@ -96,6 +120,59 @@ void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer,
#endif
#if defined(FX_GLIDE3) && defined(XF86DRI)
FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
FxU32 src_width, FxU32 src_height, FxI32 src_stride,
void *src_data)
{
int i, x, w;
void *data;
if (src_width==1 && src_height==1) { /* Easy case writing a point */
for (i=0; 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 *****/
/************************************************************************/
@ -107,12 +184,13 @@ static void fxDDWriteRGBASpan(const GLcontext *ctx,
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
GLint bottom=fxMesa->height-1;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDWriteRGBASpan(...)\n");
}
x+=fxMesa->x_offset;
if (mask) {
int span=0;
@ -143,13 +221,14 @@ static void fxDDWriteRGBSpan(const GLcontext *ctx,
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
GLint bottom=fxMesa->height-1;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
GLubyte rgba[MAX_WIDTH][4];
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDWriteRGBSpan()\n");
}
x+=fxMesa->x_offset;
if (mask) {
int span=0;
@ -192,13 +271,14 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
GLint bottom=fxMesa->height-1;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
GLuint data[MAX_WIDTH];
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDWriteMonoRGBASpan(...)\n");
}
x+=fxMesa->x_offset;
if (mask) {
int span=0;
@ -208,7 +288,7 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
++span;
} else {
if (span > 0) {
FX_grLfbWriteRegion( fxMesa->currentFB, x+i-span, bottom-y,
writeRegionClipped(fxMesa, fxMesa->currentFB, x+i-span, bottom-y,
GR_LFB_SRC_FMT_8888, span, 1, 0,
(void *) data );
span = 0;
@ -217,7 +297,7 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
}
if (span > 0)
FX_grLfbWriteRegion( fxMesa->currentFB, x+n-span, bottom-y,
writeRegionClipped(fxMesa, fxMesa->currentFB, x+n-span, bottom-y,
GR_LFB_SRC_FMT_8888, span, 1, 0,
(void *) data );
} else {
@ -225,7 +305,7 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
data[i]=(GLuint) fxMesa->color;
}
FX_grLfbWriteRegion( fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888,
writeRegionClipped(fxMesa, fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888,
n, 1, 0, (void *) data );
}
}
@ -237,7 +317,7 @@ static void fxDDReadRGBASpan(const GLcontext *ctx,
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLushort data[MAX_WIDTH];
GLuint i;
GLint bottom=fxMesa->height-1;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDReadRGBASpan(...)\n");
@ -245,20 +325,16 @@ static void fxDDReadRGBASpan(const GLcontext *ctx,
assert(n < MAX_WIDTH);
grLfbReadRegion( fxMesa->currentFB, x, bottom-y, n, 1, 0, data);
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;
}
x+=fxMesa->x_offset;
FX_grLfbReadRegion( fxMesa->currentFB, x, bottom-y, n, 1, 0, data);
for (i=0;i<n;i++) {
GLushort pixel = data[i];
rgba[i][RCOMP] = FX_PixelToR[pixel];
rgba[i][GCOMP] = FX_PixelToG[pixel];
rgba[i][BCOMP] = FX_PixelToB[pixel];
rgba[i][ACOMP] = 255;
}
}
/************************************************************************/
@ -271,7 +347,7 @@ static void fxDDWriteRGBAPixels(const GLcontext *ctx,
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
GLint bottom=fxMesa->height-1;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n");
@ -279,8 +355,8 @@ static void fxDDWriteRGBAPixels(const GLcontext *ctx,
for(i=0;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,
@ -289,7 +365,7 @@ static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx,
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
GLint bottom=fxMesa->height-1;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n");
@ -297,7 +373,7 @@ static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx,
for(i=0;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);
}
@ -307,31 +383,25 @@ static void fxDDReadRGBAPixels(const GLcontext *ctx,
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
GLint bottom=fxMesa->height-1;
GLushort data;
GLint bottom=fxMesa->y_delta-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n");
}
for(i=0;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 *****/
/************************************************************************/
@ -341,14 +411,15 @@ void fxDDReadDepthSpanFloat(GLcontext *ctx,
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
GLint bottom=fxMesa->height-1;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
GLushort data[MAX_WIDTH];
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDReadDepthSpanFloat(...)\n");
}
grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,data);
x+=fxMesa->x_offset;
FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,data);
/*
convert the read values to float values [0.0 .. 1.0].
@ -361,13 +432,14 @@ void fxDDReadDepthSpanInt(GLcontext *ctx,
GLuint n, GLint x, GLint y, GLdepth depth[])
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLint bottom=fxMesa->height-1;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
}
grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depth);
x+=fxMesa->x_offset;
FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depth);
}
GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx,
@ -380,13 +452,14 @@ GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx,
GLubyte *m=mask;
GLuint i;
GLuint passed=0;
GLint bottom=fxMesa->height-1;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDDepthTestSpanGeneric(...)\n");
}
grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depthdata);
x+=fxMesa->x_offset;
FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depthdata);
/* switch cases ordered from most frequent to less frequent */
switch (ctx->Depth.Func) {
@ -578,7 +651,7 @@ GLuint fxDDDepthTestSpanGeneric(GLcontext *ctx,
} /*switch*/
if(passed)
FX_grLfbWriteRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,GR_LFB_SRC_FMT_ZA16,n,1,0,depthdata);
writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER,x,bottom-y,GR_LFB_SRC_FMT_ZA16,n,1,0,depthdata);
return passed;
}
@ -590,7 +663,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLdepth zval;
GLuint i;
GLint bottom=fxMesa->height-1;
GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDDepthTestPixelsGeneric(...)\n");
@ -603,10 +676,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* Update Z buffer */
for (i=0; 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;
@ -617,7 +690,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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 */
}
@ -634,10 +707,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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;
@ -648,7 +721,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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 {
@ -664,10 +737,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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;
@ -678,7 +751,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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 {
@ -694,10 +767,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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;
@ -708,7 +781,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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 {
@ -724,10 +797,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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;
@ -738,7 +811,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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 */
}
@ -755,10 +828,10 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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;
@ -769,7 +842,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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 {
@ -785,7 +858,7 @@ void fxDDDepthTestPixelsGeneric(GLcontext* ctx,
/* 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 {

View File

@ -1,27 +1,51 @@
/* -*- mode: C; tab-width:8; -*-
fxddtex.c - 3Dfx VooDoo Texture mapping functions
*/
/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* Mesa 3-D graphics library
* Version: 3.1
*
* 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:
*
* See the file fxapi.c for more informations about authors
* 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.
*/
/* fxddtex.c - 3Dfx VooDoo Texture mapping functions */
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
@ -219,7 +243,6 @@ void fxDDTexParam(GLcontext *ctx, GLenum target, struct gl_texture_object *tObj,
ti->sClamp=GR_TEXTURECLAMP_WRAP;
break;
default:
fprintf(stderr, "BAD CLAMP\n");
break;
}
fxMesa->new_state|=FX_NEW_TEXTURING;

View File

@ -1,27 +1,48 @@
/* -*- mode: C; tab-width:8; -*-
fxdrv.h - 3Dfx VooDoo driver types
*/
/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* Mesa 3-D graphics library
* Version: 3.1
*
* 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:
*
* See the file fxapi.c for more informations about authors
* 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 FXDRV_H
#define FXDRV_H
@ -54,14 +75,18 @@
#include "clip.h"
#include "vbrender.h"
#ifdef XF86DRI
typedef struct tfxMesaContext *fxMesaContext;
#else
#include "GL/fxmesa.h"
#endif
#include "fxglidew.h"
/* use gl/gl.h GLAPI/GLAPIENTRY/GLCALLBACK in place of WINGDIAPI/APIENTRY/CALLBACK, */
/* these are defined in mesa gl/gl.h - tjump@spgs.com */
#if 0
#if defined(MESA_DEBUG) && 0
extern void fx_sanity_triangle( GrVertex *, GrVertex *, GrVertex * );
#define grDrawTriangle fx_sanity_triangle
#endif
@ -140,17 +165,17 @@ typedef struct {
#endif
#endif
#define FX_VB_COLOR(fxm, color) \
do { \
if (sizeof(GLint) == 4*sizeof(GLubyte)) { \
if (fxm->constColor != *(GLuint*)color) { \
fxm->constColor = *(GLuint*)color; \
grConstantColorValue(FXCOLOR4(color)); \
} \
} else { \
grConstantColorValue(FXCOLOR4(color)); \
} \
} while (0)
#define FX_VB_COLOR(fxm, color) \
do { \
if (sizeof(GLint) == 4*sizeof(GLubyte)) { \
if (fxm->constColor != *(GLuint*)color) { \
fxm->constColor = *(GLuint*)color; \
FX_grConstantColorValue(FXCOLOR4(color)); \
} \
} else { \
FX_grConstantColorValue(FXCOLOR4(color)); \
} \
} while (0)
#define GOURAUD(x) { \
GLubyte *col = VB->ColorPtr->data[(x)]; \
@ -390,8 +415,21 @@ struct tfxMesaVertexBuffer {
#include "tdfx_init.h"
#else
#define DRI_FX_CONTEXT
#define BEGIN_BOARD_LOCK()
#define END_BOARD_LOCK()
#define BEGIN_CLIP_LOOP()
#define END_CLIP_LOOP()
#endif
/* These lookup table are used to extract RGB values in [0,255] from
* 16-bit pixel values.
*/
extern GLubyte FX_PixelToR[0x10000];
extern GLubyte FX_PixelToG[0x10000];
extern GLubyte FX_PixelToB[0x10000];
struct tfxMesaContext {
GuTexPalette glbPalette;
@ -412,7 +450,6 @@ struct tfxMesaContext {
tfxUnitsState unitsState;
tfxUnitsState restoreUnitsState; /* saved during multipass */
GLuint tmu_source[FX_NUM_TMU];
GLuint tex_dest[MAX_TEXTURE_UNITS];
GLuint setupindex;
@ -477,8 +514,21 @@ struct tfxMesaContext {
FX_GrContext_t glideContext;
GLfloat wscale;
int x_offset;
int y_offset;
int y_delta;
int screen_width;
int screen_height;
int initDone;
int clipMinX;
int clipMaxX;
int clipMinY;
int clipMaxY;
int needClip;
int numClipRects;
#ifdef FX86DRI
XF86DRIClipRectPtr pClipRects;
#endif
DRI_FX_CONTEXT
};
@ -622,4 +672,16 @@ extern void fxDDDoRenderVB( struct vertex_buffer *VB );
extern int fxDDInitFxMesaContext( fxMesaContext fxMesa );
extern void fxCloseHardware(void);
extern tfxTMFreeNode *fxTMNewTMFreeNode(FxU32 start, FxU32 end);
extern void fxSetScissorValues(GLcontext *ctx);
extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
struct gl_texture_object *tObj,
GLint where);
extern void fxSetupTexture_NoLock(GLcontext *ctx);
extern void fxSetupTexture(GLcontext *ctx);
extern void fxInitPixelTables(GLboolean bgrOrder);
#endif

View File

@ -1,28 +1,47 @@
/* $Id: fxglidew.c,v 1.3 1999/10/05 19:26:54 miklos Exp $ */
/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
/*
* Mesa 3-D graphics library
* Version: 3.1
*
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
* terms stated above.
*
* Thank you for your contribution, David!
*
* Please make note of the above copyright/license statement. If you
* contributed code or bug fixes to this code under the previous (GNU
* Library) license and object to the new license, your code will be
* removed at your request. Please see the Mesa docs/COPYRIGHT file
* for more information.
*
* Additional Mesa/3Dfx driver developers:
* Daryll Strauss <daryll@precisioninsight.com>
* Keith Whitwell <keith@precisioninsight.com>
*
* See fxapi.h for more revision/author details.
*/
#ifdef HAVE_CONFIG_H
#include "conf.h"
@ -36,8 +55,7 @@
#include <stdlib.h>
#include <string.h>
FxI32 FX_grGetInteger(FxU32 pname)
FxI32 grGetInteger(FxU32 pname)
{
#if !defined(FX_GLIDE3)
switch (pname)
@ -49,7 +67,7 @@ FxI32 FX_grGetInteger(FxU32 pname)
case FX_LFB_PIXEL_PIPE:
return FXFALSE;
case FX_PENDING_BUFFERSWAPS:
return grBufferNumPending();
return grBufferNumPending();
default:
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n");
@ -74,13 +92,60 @@ FxI32 FX_grGetInteger(FxU32 pname)
}
return -1;
}
grGet(grname,4,&result);
return result;
#endif
}
FxI32 FX_grGetInteger(FxU32 pname)
{
int result;
BEGIN_BOARD_LOCK();
result=grGetInteger(pname);
END_BOARD_LOCK();
return result;
}
FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
FxBool pixelPipeline, GrLfbInfo_t *info ) {
FxBool result;
BEGIN_BOARD_LOCK();
result=grLfbLock(type, buffer, writeMode, origin, pixelPipeline, info);
END_BOARD_LOCK();
return result;
}
FxU32 FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info) {
FxU32 result;
BEGIN_BOARD_LOCK();
result=grTexTextureMemRequired(evenOdd, info);
END_BOARD_LOCK();
return result;
}
FxU32 FX_grTexMinAddress(GrChipID_t tmu) {
FxU32 result;
BEGIN_BOARD_LOCK();
result=grTexMinAddress(tmu);
END_BOARD_LOCK();
return result;
}
extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu) {
FxU32 result;
BEGIN_BOARD_LOCK();
result=grTexMaxAddress(tmu);
END_BOARD_LOCK();
return result;
}
#if defined(FX_GLIDE3)
@ -98,31 +163,30 @@ void FX_grSstControl(int par)
int FX_getFogTableSize(void)
{
int result;
BEGIN_BOARD_LOCK();
grGet(GR_FOG_TABLE_ENTRIES,sizeof(int),(void*)&result);
END_BOARD_LOCK();
return result;
}
int FX_getGrStateSize(void)
{
int result;
BEGIN_BOARD_LOCK();
grGet(GR_GLIDE_STATE_SIZE,sizeof(int),(void*)&result);
END_BOARD_LOCK();
return result;
}
int FX_grBufferNumPending()
{
int result;
grGet(GR_PENDING_BUFFERSWAPS,sizeof(int),(void*)&result);
return result;
}
int FX_grSstScreenWidth()
{
FxI32 result[4];
BEGIN_BOARD_LOCK();
grGet(GR_VIEWPORT,sizeof(FxI32)*4,result);
END_BOARD_LOCK();
return result[2];
}
@ -130,15 +194,19 @@ int FX_grSstScreenWidth()
int FX_grSstScreenHeight()
{
FxI32 result[4];
BEGIN_BOARD_LOCK();
grGet(GR_VIEWPORT,sizeof(FxI32)*4,result);
END_BOARD_LOCK();
return result[3];
}
void FX_grGlideGetVersion(char *buf)
{
strcpy(buf,grGetString(GR_VERSION));
BEGIN_BOARD_LOCK();
strcpy(buf,grGetString(GR_VERSION));
END_BOARD_LOCK();
}
void FX_grSstPerfStats(GrSstPerfStats_t *st)
@ -154,11 +222,16 @@ void FX_grSstPerfStats(GrSstPerfStats_t *st)
void FX_grAADrawLine(GrVertex *a,GrVertex *b)
{
/* ToDo */
BEGIN_CLIP_LOOP();
grDrawLine(a,b);
END_CLIP_LOOP();
}
void FX_grAADrawPoint(GrVertex *a)
{
BEGIN_CLIP_LOOP();
grDrawPoint(a);
END_CLIP_LOOP();
}
#if FX_USE_PARGB
@ -195,33 +268,42 @@ void FX_setupGrVertexLayout(void)
}
#endif
void FX_grHints(GrHint_t hintType, FxU32 hintMask)
void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask)
{
switch(hintType) {
case GR_HINT_STWHINT:
{
if (hintMask & GR_STWHINT_W_DIFF_TMU0)
grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
else
grVertexLayout(GR_PARAM_Q0,GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
if (hintMask & GR_STWHINT_ST_DIFF_TMU1)
grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
else
grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
switch(hintType) {
case GR_HINT_STWHINT:
{
if (hintMask & GR_STWHINT_W_DIFF_TMU0)
grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
else
grVertexLayout(GR_PARAM_Q0,GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
if (hintMask & GR_STWHINT_ST_DIFF_TMU1)
grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
else
grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
if (hintMask & GR_STWHINT_W_DIFF_TMU1)
grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
else
grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
}
}
if (hintMask & GR_STWHINT_W_DIFF_TMU1)
grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
else
grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
}
}
}
void FX_grHints(GrHint_t hintType, FxU32 hintMask) {
BEGIN_BOARD_LOCK();
FX_grHints_NoLock(hintType, hintMask);
END_BOARD_LOCK();
}
int FX_grSstQueryHardware(GrHwConfiguration *config)
{
int i,j;
int numFB;
BEGIN_BOARD_LOCK();
grGet(GR_NUM_BOARDS,4,(void*)&(config->num_sst));
if (config->num_sst == 0)
return 0;
@ -246,11 +328,77 @@ int FX_grSstQueryHardware(GrHwConfiguration *config)
config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRam /= 1024*1024;
}
}
END_BOARD_LOCK();
return 1;
}
#endif
FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd,
GrScreenResolution_t screen_resolution,
GrScreenRefresh_t refresh_rate,
GrColorFormat_t color_format,
GrOriginLocation_t origin_location,
int nColBuffers,
int nAuxBuffers)
{
FX_GrContext_t i;
BEGIN_BOARD_LOCK();
i = grSstWinOpen( hWnd,
screen_resolution,
refresh_rate,
color_format,
origin_location,
nColBuffers,
nAuxBuffers );
fprintf(stderr,
"grSstWinOpen( win %d res %d ref %d fmt %d\n"
" org %d ncol %d naux %d )\n"
" ==> %d\n",
hWnd,
screen_resolution,
refresh_rate,
color_format,
origin_location,
nColBuffers,
nAuxBuffers,
i);
END_BOARD_LOCK();
return i;
}
#else /* FX_GLIDE3 */
int FX_grSstScreenWidth()
{
return grSstScreenWidth();
}
int FX_grSstScreenHeight()
{
return grSstScreenHeight();
}
int FX_grSstQueryHardware(GrHwConfiguration *config)
{
return grSstQueryHardware(config);
}
FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd,
GrScreenResolution_t screen_resolution,
GrScreenRefresh_t refresh_rate,
GrColorFormat_t color_format,
GrOriginLocation_t origin_location,
int nColBuffers,
int nAuxBuffers)
{
return grSstWinOpen(hWnd, screen_resolution, refresh_rate,
color_format, origin_location, nColBuffers, nAuxBuffers);
}
#endif /* FX_GLIDE3 */
#else
/*

View File

@ -1,26 +1,48 @@
/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
/*
* Mesa 3-D graphics library
* Version: 3.1
*
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
* terms stated above.
*
* Thank you for your contribution, David!
*
* Please make note of the above copyright/license statement. If you
* contributed code or bug fixes to this code under the previous (GNU
* Library) license and object to the new license, your code will be
* removed at your request. Please see the Mesa docs/COPYRIGHT file
* for more information.
*
* Additional Mesa/3Dfx driver developers:
* Daryll Strauss <daryll@precisioninsight.com>
* Keith Whitwell <keith@precisioninsight.com>
*
* See fxapi.h for more revision/author details.
*/
#ifndef __FX_GLIDE_WARPER__
#define __FX_GLIDE_WARPER__
@ -54,6 +76,7 @@
/*
* Genral warper functions for Glide2/Glide3:
*/
extern FxI32 grGetInteger(FxU32 pname);
extern FxI32 FX_grGetInteger(FxU32 pname);
/*
@ -233,29 +256,97 @@ typedef struct
* Glide2 functions for Glide3
*/
#if defined(FX_GLIDE3)
#define FX_grTexDownloadTable(TMU,type,data) grTexDownloadTable(type,data)
#define FX_grTexDownloadTable(TMU,type,data) \
do { \
BEGIN_BOARD_LOCK(); \
grTexDownloadTable(type,data); \
END_BOARD_LOCK(); \
} while (0);
#define FX_grTexDownloadTable_NoLock(TMU,type,data) \
grTexDownloadTable(type, data)
#else
#define FX_grTexDownloadTable(TMU,type,data) grTexDownloadTable(TMU,type,data)
#define FX_grTexDownloadTable(TMU,type,data) \
do { \
BEGIN_BOARD_LOCK(); \
grTexDownloadTable(TMU,type,data); \
END_BOARD_LOCK(); \
} while (0);
#define FX_grTexDownloadTable_NoLock grTexDownloadTable
#endif
/*
* Flush
*/
#if defined(FX_GLIDE3)
#define FX_grFlush grFlush
#define FX_grFlush() \
do { \
BEGIN_BOARD_LOCK(); \
grFlush(); \
END_BOARD_LOCK(); \
} while (0)
#else
#define FX_grFlush grSstIdle
#define FX_grFlush() \
do { \
BEGIN_BOARD_LOCK(); \
grSstIdle(); \
END_BOARD_LOCK(); \
} while (0)
#endif
#define FX_grFinish() \
do { \
BEGIN_BOARD_LOCK(); \
grFinish(); \
END_BOARD_LOCK(); \
} while (0)
/*
* Write region: ToDo possible exploit the PixelPipe parameter.
*/
#if defined(FX_GLIDE3)
#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data)
#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
do { \
BEGIN_BOARD_LOCK(); \
grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data); \
END_BOARD_LOCK(); \
} while(0)
#else
#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
do { \
BEGIN_BOARD_LOCK(); \
grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data); \
END_BOARD_LOCK(); \
} while (0)
#endif
/*
* Read region
*/
#define FX_grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data) \
do { \
BEGIN_BOARD_LOCK(); \
grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data); \
END_BOARD_LOCK(); \
} while (0);
/*
* Draw triangle
*/
#define FX_grDrawTriangle(a,b,c) \
do { \
/* int big=0; */ \
BEGIN_CLIP_LOOP(); \
/* if (((GrVertex*)a)->x>2000 || ((GrVertex*)a)->x<-2000 || \
((GrVertex*)a)->y>2000 || ((GrVertex*)a)->y<-2000 || \
((GrVertex*)a)->z>65000 || ((GrVertex*)a)->z<-65000) { \
fprintf(stderr, "Extreme triangle (%f,%f,%f)\n", \
((GrVertex*)a)->x, ((GrVertex*)a)->y, ((GrVertex*)a)->z); \
big=1; \
} else */ \
grDrawTriangle(a,b,c); \
END_CLIP_LOOP(); \
} while (0)
/*
* For Lod/LodLog2 conversion.
*/
@ -288,12 +379,14 @@ typedef struct
#else
#define FX_largeLodValue(info) ((int)(info).largeLod)
#endif
#define FX_largeLodValue_NoLock FX_largeLodValue
#if defined(FX_GLIDE3)
#define FX_smallLodValue(info) ((int)(GR_LOD_256-(info).smallLodLog2))
#else
#define FX_smallLodValue(info) ((int)(info).smallLod)
#endif
#define FX_smallLodValue_NoLock FX_smallLodValue
#if defined(FX_GLIDE3)
#define FX_valueToLod(val) ((GrLOD_t)(GR_LOD_256-val))
@ -304,13 +397,9 @@ typedef struct
/*
* ScreenWidth/Height stuff.
*/
#if defined(FX_GLIDE3)
extern int FX_grSstScreenWidth();
extern int FX_grSstScreenHeight();
#else
#define FX_grSstScreenWidth() grSstScreenWidth()
#define FX_grSstScreenHeight() grSstScreenHeight()
#endif
extern int FX_grSstScreenWidth(void);
extern int FX_grSstScreenHeight(void);
/*
@ -319,7 +408,12 @@ typedef struct
#if defined(FX_GLIDE3)
extern void FX_grGlideGetVersion(char *buf);
#else
#define FX_grGlideGetVersion grGlideGetVersion
#define FX_grGlideGetVersion(b) \
do { \
BEGIN_BOARD_LOCK(); \
grGlideGetVersion(b); \
END_BOARD_LOCK(); \
} while (0)
#endif
/*
* Performance statistics
@ -327,25 +421,33 @@ typedef struct
#if defined(FX_GLIDE3)
extern void FX_grSstPerfStats(GrSstPerfStats_t *st);
#else
#define FX_grSstPerfStats grSstPerfStats
#define FX_grSstPerfStats(s) \
do { \
BEGIN_BOARD_LOCK(); \
grSstPerfStats(s); \
END_BOARD_LOCK(); \
} while (0)
#endif
/*
* Hardware Query
*/
#if defined(FX_GLIDE3)
extern int FX_grSstQueryHardware(GrHwConfiguration *config);
#else
#define FX_grSstQueryHardware grSstQueryHardware
#endif
/*
* GrHints
*/
#if defined(FX_GLIDE3)
extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask);
extern void FX_grHints(GrHint_t hintType, FxU32 hintMask);
#else
#define FX_grHints grHints
#define FX_grHints(t,m) \
do { \
BEGIN_BOARD_LOCK(); \
grHints(t, m); \
END_BOARD_LOCK(); \
} while(0)
#define FX_grHints_NoLock grHints
#endif
/*
* Antialiashed line+point drawing.
@ -353,13 +455,23 @@ typedef struct
#if defined(FX_GLIDE3)
extern void FX_grAADrawLine(GrVertex *a,GrVertex *b);
#else
#define FX_grAADrawLine grAADrawLine
#define FX_grAADrawLine(a,b) \
do { \
BEGIN_CLIP_LOOP(); \
grAADrawLine(a,b); \
END_CLIP_LOOP(); \
} while (0)
#endif
#if defined(FX_GLIDE3)
extern void FX_grAADrawPoint(GrVertex *a);
#else
#define FX_grAADrawPoint grAADrawPoint
#define FX_grAADrawPoint(a) \
do { \
BEGIN_CLIP_LOOP(); \
grAADrawPoint(a); \
END_CLIP_LOOP(); \
} while (0)
#endif
/*
@ -376,7 +488,12 @@ typedef struct
#if defined(FX_GLIDE3)
extern void FX_grSstControl(int par);
#else
#define FX_grSstControl grSstControl
#define FX_grSstControl(p) \
do { \
BEGIN_BOARD_LOCK(); \
grSstControl(p); \
END_BOARD_LOCK(); \
} while (0)
#endif
/*
* grGammaCorrectionValue
@ -384,20 +501,337 @@ typedef struct
#if defined(FX_GLIDE3)
extern void FX_grGammaCorrectionValue(float val);
#else
#define FX_grGammaCorrectionValue grGammaCorrectionValue
#define FX_grGammaCorrectionValue(v) \
do { \
BEGIN_BOARD_LOCK(); \
grGammaCorrectionValue(v) \
END_BOARD_LOCK(); \
} while (0)
#endif
/*
* WinOpen/Close.
*/
#if defined(FX_GLIDE3)
#define FX_grSstWinOpen(hWnd,screen_resolution,refresh_rate,color_format,origin_location,nColBuffers,nAuxBuffers) \
grSstWinOpen(-1,screen_resolution,refresh_rate,color_format,origin_location,nColBuffers,nAuxBuffers)
#define FX_grSstWinClose grSstWinClose
#define FX_grSstWinClose(w) \
do { \
BEGIN_BOARD_LOCK(); \
grSstWinClose(w); \
END_BOARD_LOCK(); \
} while (0)
#else
#define FX_grSstWinOpen grSstWinOpen
#define FX_grSstWinClose(win) grSstWinClose()
#define FX_grSstWinClose(w) \
do { \
BEGIN_BOARD_LOCK(); \
grSstWinClose(); \
END_BOARD_LOCK(); \
} while (0)
#endif
extern FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd,
GrScreenResolution_t screen_resolution,
GrScreenRefresh_t refresh_rate,
GrColorFormat_t color_format,
GrOriginLocation_t origin_location,
int nColBuffers,
int nAuxBuffers);
#define FX_grDrawLine(v1, v2) \
do { \
BEGIN_CLIP_LOOP(); \
grDrawLine(v1, v2); \
END_CLIP_LOOP(); \
} while (0)
#define FX_grDrawPoint(p) \
do { \
BEGIN_CLIP_LOOP(); \
grDrawPoint(p); \
END_CLIP_LOOP(); \
} while (0)
#define FX_grDitherMode(m) \
do { \
BEGIN_BOARD_LOCK(); \
grDitherMode(m); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grRenderBuffer(b) \
do { \
BEGIN_BOARD_LOCK(); \
grRenderBuffer(b); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grBufferClear(c, a, d) \
do { \
BEGIN_CLIP_LOOP(); \
grBufferClear(c, a, d); \
END_CLIP_LOOP(); \
} while (0)
#define FX_grDepthMask(m) \
do { \
BEGIN_BOARD_LOCK(); \
grDepthMask(m); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grColorMask(c, a) \
do { \
BEGIN_BOARD_LOCK(); \
grColorMask(c, a); \
END_BOARD_LOCK(); \
} while (0)
extern FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
GrLfbWriteMode_t writeMode,
GrOriginLocation_t origin, FxBool pixelPipeline,
GrLfbInfo_t *info );
#define FX_grLfbUnlock(t, b) \
do { \
BEGIN_BOARD_LOCK(); \
grLfbUnlock(t, b); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grConstantColorValue(v) \
do { \
BEGIN_BOARD_LOCK(); \
grConstantColorValue(v); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grConstantColorValue_NoLock grConstantColorValue
#define FX_grAADrawTriangle(a, b, c, ab, bc, ca) \
do { \
BEGIN_CLIP_LOOP(); \
grAADrawTriangle(a, b, c, ab, bc, ca); \
END_CLIP_LOOP(); \
} while (0)
#define FX_grAlphaBlendFunction(rs, rd, as, ad) \
do { \
BEGIN_BOARD_LOCK(); \
grAlphaBlendFunction(rs, rd, as, ad); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grAlphaCombine(func, fact, loc, oth, inv) \
do { \
BEGIN_BOARD_LOCK(); \
grAlphaCombine(func, fact, loc, oth, inv); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grAlphaCombine_NoLock grAlphaCombine
#define FX_grAlphaTestFunction(f) \
do { \
BEGIN_BOARD_LOCK(); \
grAlphaTestFunction(f); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grAlphaTestReferenceValue(v) \
do { \
BEGIN_BOARD_LOCK(); \
grAlphaTestReferenceValue(v); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grClipWindow(minx, miny, maxx, maxy) \
do { \
BEGIN_BOARD_LOCK(); \
grClipWindow(minx, miny, maxx, maxy); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grClipWindow_NoLock grClipWindow
#define FX_grColorCombine(func, fact, loc, oth, inv) \
do { \
BEGIN_BOARD_LOCK(); \
grColorCombine(func, fact, loc, oth, inv); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grColorCombine_NoLock grColorCombine
#define FX_grCullMode(m) \
do { \
BEGIN_BOARD_LOCK(); \
grCullMode(m); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grDepthBiasLevel(lev) \
do { \
BEGIN_BOARD_LOCK(); \
grDepthBiasLevel(lev); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grDepthBufferFunction(func) \
do { \
BEGIN_BOARD_LOCK(); \
grDepthBufferFunction(func); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grFogColorValue(c) \
do { \
BEGIN_BOARD_LOCK(); \
grFogColorValue(c); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grFogMode(m) \
do { \
BEGIN_BOARD_LOCK(); \
grFogMode(m); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grFogTable(t) \
do { \
BEGIN_BOARD_LOCK(); \
grFogTable(t); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grTexClampMode(t, sc, tc) \
do { \
BEGIN_BOARD_LOCK(); \
grTexClampMode(t, sc, tc); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grTexClampMode_NoLock grTexClampMode
#define FX_grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv) \
do { \
BEGIN_BOARD_LOCK(); \
grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grTexCombine_NoLock grTexCombine
#define FX_grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d) \
do { \
BEGIN_BOARD_LOCK(); \
grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grTexDownloadMipMapLevel_NoLock grTexDownloadMipMapLevel
#define FX_grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \
do { \
BEGIN_BOARD_LOCK(); \
grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grTexFilterMode(t, minf, magf) \
do { \
BEGIN_BOARD_LOCK(); \
grTexFilterMode(t, minf, magf); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grTexFilterMode_NoLock grTexFilterMode
extern FxU32 FX_grTexMinAddress(GrChipID_t tmu);
extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu);
#define FX_grTexMipMapMode(t, m, lod) \
do { \
BEGIN_BOARD_LOCK(); \
grTexMipMapMode(t, m, lod); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grTexMipMapMode_NoLock grTexMipMapMode
#define FX_grTexSource(t, sa, eo, i) \
do { \
BEGIN_BOARD_LOCK(); \
grTexSource(t, sa, eo, i); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grTexSource_NoLock grTexSource
extern FxU32 FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info);
#define FX_grTexTextureMemRequired_NoLock grTexTextureMemRequired
#define FX_grGlideGetState(s) \
do { \
BEGIN_BOARD_LOCK(); \
grGlideGetState(s); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grDRIBufferSwap(i) \
do { \
BEGIN_BOARD_LOCK(); \
grDRIBufferSwap(i); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grSstSelect(b) \
do { \
BEGIN_BOARD_LOCK(); \
grSstSelect(b); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grSstSelect_NoLock grSstSelect
#define FX_grGlideSetState(s) \
do { \
BEGIN_BOARD_LOCK(); \
grGlideSetState(s); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grDepthBufferMode(m) \
do { \
BEGIN_BOARD_LOCK(); \
grDepthBufferMode(m); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grLfbWriteColorFormat(f) \
do { \
BEGIN_BOARD_LOCK(); \
grLfbWriteColorFormat(f); \
END_BOARD_LOCK(); \
} while (0)
#define FX_grDrawVertexArray(m, c, p) \
do { \
BEGIN_CLIP_LOOP(); \
grDrawVertexArray(m, c, p); \
END_CLIP_LOOP(); \
} while (0)
#define FX_grGlideShutdown() \
do { \
BEGIN_CLIP_LOOP(); \
grGlideShutdown(); \
END_CLIP_LOOP(); \
} while (0)
#define FX_grGlideInit_NoLock grGlideInit
#define FX_grSstWinOpen_NoLock grSstWinOpen
extern int FX_getFogTableSize(void);
extern int FX_getGrStateSize(void);
#endif /* __FX_GLIDE_WARPER__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,51 @@
/* -*- mode: C; tab-width:8; -*-
fxtexman.c - 3Dfx VooDoo texture memory functions
*/
/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* Mesa 3-D graphics library
* Version: 3.1
*
* 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:
*
* See the file fxapi.c for more informations about authors
* 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.
*/
/* fxtexman.c - 3Dfx VooDoo texture memory functions */
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
@ -47,13 +71,15 @@ static tfxTMFreeNode *fxTMNewTMFreeNode(FxU32 start, FxU32 end)
return tmn;
}
/* Notice this uses grTex{Min,Max}Address directly with FX_ because it
is only used during initialization where the lock is already held. */
static void fxTMUInit(fxMesaContext fxMesa, int tmu)
{
tfxTMFreeNode *tmn,*tmntmp;
FxU32 start,end,blockstart,blockend;
start=grTexMinAddress(tmu);
end=grTexMaxAddress(tmu);
start=FX_grTexMinAddress(tmu);
end=FX_grTexMaxAddress(tmu);
if(fxMesa->verbose) {
fprintf(stderr,"%s configuration:",(tmu==FX_TMU0) ? "TMU0" : "TMU1");
@ -224,7 +250,7 @@ static tfxTMAllocNode *fxTMGetTMBlock(fxMesaContext fxMesa, struct gl_texture_ob
}
}
void fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint where)
void fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint where)
{
tfxTexInfo *ti=(tfxTexInfo *)tObj->DriverData;
int i,l;
@ -254,36 +280,50 @@ void fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint wh
switch(where) {
case FX_TMU0:
case FX_TMU1:
texmemsize=(int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH,&(ti->info));
texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
&(ti->info));
ti->tmi.tm[where]=fxTMGetTMBlock(fxMesa,tObj,where,texmemsize);
fxMesa->stats.memTexUpload+=texmemsize;
for(i=FX_largeLodValue(ti->info),l=ti->minLevel;i<=FX_smallLodValue(ti->info);i++,l++)
grTexDownloadMipMapLevel(where,
ti->tmi.tm[where]->startAddress,FX_valueToLod(i),
FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info),
ti->info.format,GR_MIPMAPLEVELMASK_BOTH,
ti->tmi.mipmapLevel[l].data);
FX_grTexDownloadMipMapLevel_NoLock(where,
ti->tmi.tm[where]->startAddress,
FX_valueToLod(i),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
GR_MIPMAPLEVELMASK_BOTH,
ti->tmi.mipmapLevel[l].data);
break;
case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
texmemsize=(int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_ODD,&(ti->info));
texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_ODD,
&(ti->info));
ti->tmi.tm[FX_TMU0]=fxTMGetTMBlock(fxMesa,tObj,FX_TMU0,texmemsize);
fxMesa->stats.memTexUpload+=texmemsize;
texmemsize=(int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_EVEN,&(ti->info));
texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_EVEN,
&(ti->info));
ti->tmi.tm[FX_TMU1]=fxTMGetTMBlock(fxMesa,tObj,FX_TMU1,texmemsize);
fxMesa->stats.memTexUpload+=texmemsize;
for(i=FX_largeLodValue(ti->info),l=ti->minLevel;i<=FX_smallLodValue(ti->info);i++,l++) {
grTexDownloadMipMapLevel(GR_TMU0,ti->tmi.tm[FX_TMU0]->startAddress,FX_valueToLod(i),
FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info),
ti->info.format,GR_MIPMAPLEVELMASK_ODD,
ti->tmi.mipmapLevel[l].data);
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);
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_TMU1,
ti->tmi.tm[FX_TMU1]->startAddress,
FX_valueToLod(i),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
GR_MIPMAPLEVELMASK_EVEN,
ti->tmi.mipmapLevel[l].data);
}
break;
default:
@ -297,6 +337,12 @@ void fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint wh
ti->tmi.isInTM=GL_TRUE;
}
void fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint where) {
BEGIN_BOARD_LOCK();
fxTMMoveInTM_NoLock(fxMesa, tObj, where);
END_BOARD_LOCK();
}
void fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj, GLint level)
{
tfxTexInfo *ti=(tfxTexInfo *)tObj->DriverData;
@ -318,20 +364,20 @@ void fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj,
switch(tmu) {
case FX_TMU0:
case FX_TMU1:
grTexDownloadMipMapLevel(tmu,
FX_grTexDownloadMipMapLevel(tmu,
ti->tmi.tm[tmu]->startAddress,FX_valueToLod(FX_lodToValue(lodlevel)+level),
FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info),
ti->info.format,GR_MIPMAPLEVELMASK_BOTH,
ti->tmi.mipmapLevel[level].data);
break;
case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
grTexDownloadMipMapLevel(GR_TMU0,
FX_grTexDownloadMipMapLevel(GR_TMU0,
ti->tmi.tm[GR_TMU0]->startAddress,FX_valueToLod(FX_lodToValue(lodlevel)+level),
FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info),
ti->info.format,GR_MIPMAPLEVELMASK_ODD,
ti->tmi.mipmapLevel[level].data);
grTexDownloadMipMapLevel(GR_TMU1,
FX_grTexDownloadMipMapLevel(GR_TMU1,
ti->tmi.tm[GR_TMU1]->startAddress,FX_valueToLod(FX_lodToValue(lodlevel)+level),
FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info),
ti->info.format,GR_MIPMAPLEVELMASK_EVEN,
@ -374,7 +420,7 @@ void fxTMReloadSubMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tO
switch(tmu) {
case FX_TMU0:
case FX_TMU1:
grTexDownloadMipMapLevelPartial(tmu,
FX_grTexDownloadMipMapLevelPartial(tmu,
ti->tmi.tm[tmu]->startAddress,FX_valueToLod(FX_lodToValue(lodlevel)+level),
FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info),
ti->info.format,GR_MIPMAPLEVELMASK_BOTH,
@ -382,14 +428,14 @@ void fxTMReloadSubMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tO
yoffset,yoffset+height-1);
break;
case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
grTexDownloadMipMapLevelPartial(GR_TMU0,
FX_grTexDownloadMipMapLevelPartial(GR_TMU0,
ti->tmi.tm[FX_TMU0]->startAddress,FX_valueToLod(FX_lodToValue(lodlevel)+level),
FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info),
ti->info.format,GR_MIPMAPLEVELMASK_ODD,
data,
yoffset,yoffset+height-1);
grTexDownloadMipMapLevelPartial(GR_TMU1,
FX_grTexDownloadMipMapLevelPartial(GR_TMU1,
ti->tmi.tm[FX_TMU1]->startAddress,FX_valueToLod(FX_lodToValue(lodlevel)+level),
FX_largeLodLog2(ti->info),FX_aspectRatioLog2(ti->info),
ti->info.format,GR_MIPMAPLEVELMASK_EVEN,
@ -563,6 +609,98 @@ void fxTMClose(fxMesaContext fxMesa)
}
}
void fxTMRestore_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj)
{
tfxTexInfo *ti=(tfxTexInfo *)tObj->DriverData;
int i,l, where;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxRestore(%d)\n",tObj->Name);
}
if (!ti->validated) {
fprintf(stderr,"fxDriver: internal error in fxRestore -> not validated\n");
fxCloseHardware();
exit(-1);
}
where=ti->tmi.whichTMU;
if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_TEXTURE)) {
fprintf(stderr,"fxmesa: reloading %x (%d) in texture memory in %d\n",(GLuint)tObj,tObj->Name,where);
}
switch(where) {
case FX_TMU0:
case FX_TMU1:
for (i=FX_largeLodValue_NoLock(ti->info), l=ti->minLevel;
i<=FX_smallLodValue_NoLock(ti->info);
i++,l++)
if (ti->tmi.mipmapLevel[l].data)
FX_grTexDownloadMipMapLevel_NoLock(where,
ti->tmi.tm[where]->startAddress,
FX_valueToLod(i),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
GR_MIPMAPLEVELMASK_BOTH,
ti->tmi.mipmapLevel[l].data);
break;
case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
for (i=FX_largeLodValue_NoLock(ti->info),l=ti->minLevel;
i<=FX_smallLodValue_NoLock(ti->info);
i++,l++) {
if (ti->tmi.mipmapLevel[l].data)
FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
ti->tmi.tm[FX_TMU0]->startAddress,
FX_valueToLod(i),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
GR_MIPMAPLEVELMASK_ODD,
ti->tmi.mipmapLevel[l].data);
if (ti->tmi.mipmapLevel[l].data)
FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
ti->tmi.tm[FX_TMU1]->startAddress,
FX_valueToLod(i),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
GR_MIPMAPLEVELMASK_EVEN,
ti->tmi.mipmapLevel[l].data);
}
break;
default:
fprintf(stderr,"fxDriver: internal error in fxRestore -> bad tmu (%d)\n",
where);
fxCloseHardware();
exit(-1);
}
}
void
fxTMRestoreTextures(fxMesaContext ctx) {
tfxTexInfo *ti;
struct gl_texture_object *tObj;
int i;
tObj=ctx->glCtx->Shared->TexObjectList;
while (tObj) {
ti=(tfxTexInfo*)tObj->DriverData;
if (ti && ti->tmi.isInTM) {
for (i=0; 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

View File

@ -1,25 +1,53 @@
/* -*- 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.
*/
/* fxwgl.c - Microsoft wgl functions emulation for
* 3Dfx VooDoo/Mesa interface
*/
/*
* 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.
*
* 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.
*
* See the file fxapi.c for more informations about authors
*
*/
#ifdef __WIN32__
@ -243,11 +271,11 @@ LONG GLAPIENTRY __wglMonitor(HWND hwnd,UINT message,UINT wParam,LONG lParam)
static int moving = 0;
if (!moving) {
if(fxQueryHardware()!=GR_SSTTYPE_VOODOO) {
if(!grSstControl(GR_CONTROL_RESIZE)) {
if(!FX_grSstControl(GR_CONTROL_RESIZE)) {
moving = 1;
SetWindowPos(hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOZORDER);
moving = 0;
if(!grSstControl(GR_CONTROL_RESIZE)) {
if(!FX_grSstControl(GR_CONTROL_RESIZE)) {
/*MessageBox(0,_T("Error changing windowsize"),_T("fxMESA"),MB_OK);*/
PostMessage(hWND,WM_CLOSE,0,0);
}
@ -255,7 +283,7 @@ LONG GLAPIENTRY __wglMonitor(HWND hwnd,UINT message,UINT wParam,LONG lParam)
}
/* Do the clipping in the glide library */
grClipWindow(0,0,grSstScreenWidth(),grSstScreenHeight());
FX_grClipWindow(0,0,FX_grSstScreenWidth(),FX_grSstScreenHeight());
/* And let the new size set in the context */
fxMesaUpdateScreenSize(ctx);
}
@ -269,9 +297,9 @@ LONG GLAPIENTRY __wglMonitor(HWND hwnd,UINT message,UINT wParam,LONG lParam)
BOOL fMinimized = (BOOL) HIWORD(wParam);
if((fActive == WA_INACTIVE) || fMinimized)
grSstControl(GR_CONTROL_DEACTIVATE);
FX_grSstControl(GR_CONTROL_DEACTIVATE);
else
grSstControl(GR_CONTROL_ACTIVATE);
FX_grSstControl(GR_CONTROL_ACTIVATE);
}
break;
case WM_SHOWWINDOW:
@ -280,10 +308,10 @@ LONG GLAPIENTRY __wglMonitor(HWND hwnd,UINT message,UINT wParam,LONG lParam)
if(gdiWindowHackEna && (VK_RETURN == wParam)) {
if(gdiWindowHack) {
gdiWindowHack = GL_FALSE;
grSstControl(GR_CONTROL_ACTIVATE);
FX_grSstControl(GR_CONTROL_ACTIVATE);
} else {
gdiWindowHack = GL_TRUE;
grSstControl(GR_CONTROL_DEACTIVATE);
FX_grSstControl(GR_CONTROL_DEACTIVATE);
}
}
break;
@ -382,7 +410,7 @@ HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
gdiWindowHack = GL_FALSE;
else {
gdiWindowHack = GL_TRUE;
grSstControl(GR_CONTROL_DEACTIVATE);
FX_grSstControl(GR_CONTROL_DEACTIVATE);
}
}
} else {
@ -779,7 +807,7 @@ BOOL GLAPIENTRY wglSwapBuffers(HDC hdc)
HDC hdcDIBSection = CreateCompatibleDC(hdcScreen);
HBITMAP holdBitmap = (HBITMAP) SelectObject(hdcDIBSection, dibHBM);
grLfbReadRegion(GR_BUFFER_FRONTBUFFER, 0, 0,
FX_grLfbReadRegion(GR_BUFFER_FRONTBUFFER, 0, 0,
width, height,
width * 2,
dibSurfacePtr);