mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
Drop glide driver
This commit is contained in:
parent
230d263aca
commit
e14a5b14b2
18 changed files with 0 additions and 16621 deletions
3
Makefile
3
Makefile
|
|
@ -118,7 +118,6 @@ linux-dri-xcb \
|
|||
linux-egl \
|
||||
linux-indirect \
|
||||
linux-fbdev \
|
||||
linux-glide \
|
||||
linux-ia64-icc \
|
||||
linux-ia64-icc-static \
|
||||
linux-icc \
|
||||
|
|
@ -149,7 +148,6 @@ linux-x86-64 \
|
|||
linux-x86-64-debug \
|
||||
linux-x86-64-profile \
|
||||
linux-x86-64-static \
|
||||
linux-x86-glide \
|
||||
linux-x86-profile \
|
||||
linux-x86-static \
|
||||
netbsd \
|
||||
|
|
@ -271,7 +269,6 @@ MAIN_FILES = \
|
|||
$(DIRECTORY)/src/mesa/drivers/common/descrip.mms \
|
||||
$(DIRECTORY)/src/mesa/drivers/fbdev/Makefile \
|
||||
$(DIRECTORY)/src/mesa/drivers/fbdev/glfbdev.c \
|
||||
$(DIRECTORY)/src/mesa/drivers/glide/*.[ch] \
|
||||
$(DIRECTORY)/src/mesa/drivers/osmesa/Makefile \
|
||||
$(DIRECTORY)/src/mesa/drivers/osmesa/Makefile.win \
|
||||
$(DIRECTORY)/src/mesa/drivers/osmesa/descrip.mms \
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
# Configuration for generic Linux with 3Dfx Glide driver
|
||||
|
||||
include $(TOP)/configs/default
|
||||
|
||||
CONFIG_NAME = linux-glide
|
||||
|
||||
# Compiler and flags
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
|
||||
CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include -DFX -I/usr/include/glide -I/usr/local/glide/include
|
||||
CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
|
||||
GLUT_CFLAGS = -fexceptions
|
||||
|
||||
# Work around aliasing bugs - developers should comment this out
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
CXXFLAGS += -fno-strict-aliasing
|
||||
|
||||
# Library/program dependencies
|
||||
GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -L/usr/local/glide/lib -lglide3x -lm -lpthread
|
||||
GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
|
||||
GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
|
||||
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/local/glide/lib -lglide3x -lm
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# Configuration for Linux with 3Dfx Glide driver and x86 optimizations
|
||||
|
||||
include $(TOP)/configs/default
|
||||
|
||||
CONFIG_NAME = linux-x86-glide
|
||||
|
||||
# Compiler and flags
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
|
||||
CFLAGS = -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -I/usr/X11R6/include -DFX -I/usr/include/glide -I/usr/local/glide/include
|
||||
|
||||
CXXFLAGS = -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
|
||||
|
||||
GLUT_CFLAGS = -fexceptions
|
||||
|
||||
# Work around aliasing bugs - developers should comment this out
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
CXXFLAGS += -fno-strict-aliasing
|
||||
|
||||
MESA_ASM_SOURCES = $(X86_SOURCES)
|
||||
GLAPI_ASM_SOURCES = $(X86_API)
|
||||
|
||||
# Library/program dependencies
|
||||
GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -L/usr/local/glide/lib -lglide3x -lm -lpthread
|
||||
GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
|
||||
GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
|
||||
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/local/glide/lib -lglide3x -lm
|
||||
|
|
@ -1,951 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.0
|
||||
*
|
||||
* Copyright (C) 1999-2001 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.
|
||||
*/
|
||||
|
||||
/* Authors:
|
||||
* David Bucciarelli
|
||||
* Brian Paul
|
||||
* Daryll Strauss
|
||||
* Keith Whitwell
|
||||
* Daniel Borca
|
||||
* Hiroshi Morii
|
||||
*/
|
||||
|
||||
|
||||
/* fxapi.c - public interface to FX/Mesa functions (fxmesa.h) */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "conf.h"
|
||||
#endif
|
||||
|
||||
#if defined(FX)
|
||||
#include "fxdrv.h"
|
||||
|
||||
#include "drivers/common/driverfuncs.h"
|
||||
#include "main/framebuffer.h"
|
||||
|
||||
#ifndef TDFX_DEBUG
|
||||
int TDFX_DEBUG = (0
|
||||
/* | VERBOSE_VARRAY */
|
||||
/* | VERBOSE_TEXTURE */
|
||||
/* | VERBOSE_IMMEDIATE */
|
||||
/* | VERBOSE_PIPELINE */
|
||||
/* | VERBOSE_DRIVER */
|
||||
/* | VERBOSE_STATE */
|
||||
/* | VERBOSE_API */
|
||||
/* | VERBOSE_DISPLAY_LIST */
|
||||
/* | VERBOSE_LIGHTING */
|
||||
/* | VERBOSE_PRIMS */
|
||||
/* | VERBOSE_VERTS */
|
||||
);
|
||||
#endif
|
||||
|
||||
static fxMesaContext fxMesaCurrentCtx = NULL;
|
||||
|
||||
/*
|
||||
* Status of 3Dfx hardware initialization
|
||||
*/
|
||||
|
||||
static int glbGlideInitialized = 0;
|
||||
static int glb3DfxPresent = 0;
|
||||
static int glbTotNumCtx = 0;
|
||||
|
||||
static GrHwConfiguration glbHWConfig;
|
||||
static int glbCurrentBoard = 0;
|
||||
|
||||
|
||||
#if defined(__WIN32__)
|
||||
static int
|
||||
cleangraphics(void)
|
||||
{
|
||||
glbTotNumCtx = 1;
|
||||
fxMesaDestroyContext(fxMesaCurrentCtx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
static void
|
||||
cleangraphics(void)
|
||||
{
|
||||
glbTotNumCtx = 1;
|
||||
fxMesaDestroyContext(fxMesaCurrentCtx);
|
||||
}
|
||||
|
||||
static void
|
||||
cleangraphics_handler(int s)
|
||||
{
|
||||
fprintf(stderr, "fxmesa: ERROR: received a not handled signal %d\n", s);
|
||||
|
||||
cleangraphics();
|
||||
/* abort(); */
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Query 3Dfx hardware presence/kind
|
||||
*/
|
||||
static GLboolean GLAPIENTRY fxQueryHardware (void)
|
||||
{
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxQueryHardware()\n");
|
||||
}
|
||||
|
||||
if (!glbGlideInitialized) {
|
||||
grGlideInit();
|
||||
glb3DfxPresent = FX_grSstQueryHardware(&glbHWConfig);
|
||||
|
||||
glbGlideInitialized = 1;
|
||||
|
||||
#if defined(__WIN32__)
|
||||
_onexit((_onexit_t) cleangraphics);
|
||||
#elif defined(__linux__)
|
||||
/* Only register handler if environment variable is not defined. */
|
||||
if (!getenv("MESA_FX_NO_SIGNALS")) {
|
||||
atexit(cleangraphics);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return glb3DfxPresent;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Select the Voodoo board to use when creating
|
||||
* a new context.
|
||||
*/
|
||||
GLint GLAPIENTRY fxMesaSelectCurrentBoard (int n)
|
||||
{
|
||||
fxQueryHardware();
|
||||
|
||||
if ((n < 0) || (n >= glbHWConfig.num_sst))
|
||||
return -1;
|
||||
|
||||
return glbHWConfig.SSTs[glbCurrentBoard = n].type;
|
||||
}
|
||||
|
||||
|
||||
fxMesaContext GLAPIENTRY fxMesaGetCurrentContext (void)
|
||||
{
|
||||
return fxMesaCurrentCtx;
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY fxGetScreenGeometry (GLint *w, GLint *h)
|
||||
{
|
||||
GLint width = 0;
|
||||
GLint height = 0;
|
||||
|
||||
if (fxMesaCurrentCtx != NULL) {
|
||||
width = fxMesaCurrentCtx->screen_width;
|
||||
height = fxMesaCurrentCtx->screen_height;
|
||||
}
|
||||
|
||||
if (w != NULL) {
|
||||
*w = width;
|
||||
}
|
||||
if (h != NULL) {
|
||||
*h = height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The 3Dfx Global Palette extension for GLQuake.
|
||||
* More a trick than a real extesion, use the shared global
|
||||
* palette extension.
|
||||
*/
|
||||
extern void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint * pal); /* silence warning */
|
||||
void GLAPIENTRY
|
||||
gl3DfxSetPaletteEXT(GLuint * pal)
|
||||
{
|
||||
fxMesaContext fxMesa = fxMesaCurrentCtx;
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
int i;
|
||||
|
||||
fprintf(stderr, "gl3DfxSetPaletteEXT(...)\n");
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
fprintf(stderr, "\t%x\n", pal[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (fxMesa) {
|
||||
fxMesa->haveGlobalPaletteTexture = 1;
|
||||
|
||||
grTexDownloadTable(GR_TEXTABLE_PALETTE, (GuTexPalette *) pal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static GrScreenResolution_t fxBestResolution (int width, int height)
|
||||
{
|
||||
static int resolutions[][3] = {
|
||||
{ GR_RESOLUTION_320x200, 320, 200 },
|
||||
{ GR_RESOLUTION_320x240, 320, 240 },
|
||||
{ GR_RESOLUTION_400x256, 400, 256 },
|
||||
{ GR_RESOLUTION_512x384, 512, 384 },
|
||||
{ GR_RESOLUTION_640x200, 640, 200 },
|
||||
{ GR_RESOLUTION_640x350, 640, 350 },
|
||||
{ GR_RESOLUTION_640x400, 640, 400 },
|
||||
{ GR_RESOLUTION_640x480, 640, 480 },
|
||||
{ GR_RESOLUTION_800x600, 800, 600 },
|
||||
{ GR_RESOLUTION_960x720, 960, 720 },
|
||||
{ GR_RESOLUTION_856x480, 856, 480 },
|
||||
{ GR_RESOLUTION_512x256, 512, 256 },
|
||||
{ GR_RESOLUTION_1024x768, 1024, 768 },
|
||||
{ GR_RESOLUTION_1280x1024, 1280, 1024 },
|
||||
{ GR_RESOLUTION_1600x1200, 1600, 1200 },
|
||||
{ GR_RESOLUTION_400x300, 400, 300 },
|
||||
{ GR_RESOLUTION_1152x864, 1152, 864 },
|
||||
{ GR_RESOLUTION_1280x960, 1280, 960 },
|
||||
{ GR_RESOLUTION_1600x1024, 1600, 1024 },
|
||||
{ GR_RESOLUTION_1792x1344, 1792, 1344 },
|
||||
{ GR_RESOLUTION_1856x1392, 1856, 1392 },
|
||||
{ GR_RESOLUTION_1920x1440, 1920, 1440 },
|
||||
{ GR_RESOLUTION_2048x1536, 2048, 1536 },
|
||||
{ GR_RESOLUTION_2048x2048, 2048, 2048 }
|
||||
};
|
||||
|
||||
int i, size;
|
||||
int lastvalidres = GR_RESOLUTION_640x480;
|
||||
int min = 2048 * 2048; /* max is GR_RESOLUTION_2048x2048 */
|
||||
GrResolution resTemplate = {
|
||||
GR_QUERY_ANY,
|
||||
GR_QUERY_ANY,
|
||||
2 /*GR_QUERY_ANY */,
|
||||
GR_QUERY_ANY
|
||||
};
|
||||
GrResolution *presSupported;
|
||||
|
||||
fxQueryHardware();
|
||||
|
||||
size = grQueryResolutions(&resTemplate, NULL);
|
||||
presSupported = malloc(size);
|
||||
|
||||
size /= sizeof(GrResolution);
|
||||
grQueryResolutions(&resTemplate, presSupported);
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
int r = presSupported[i].resolution;
|
||||
if ((width <= resolutions[r][1]) && (height <= resolutions[r][2])) {
|
||||
if (min > (resolutions[r][1] * resolutions[r][2])) {
|
||||
min = resolutions[r][1] * resolutions[r][2];
|
||||
lastvalidres = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(presSupported);
|
||||
|
||||
return resolutions[lastvalidres][0];
|
||||
}
|
||||
|
||||
|
||||
fxMesaContext GLAPIENTRY
|
||||
fxMesaCreateBestContext(GLuint win, GLint width, GLint height,
|
||||
const GLint attribList[])
|
||||
{
|
||||
int res = fxBestResolution(width, height);
|
||||
|
||||
if (res == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fxMesaCreateContext(win, res, GR_REFRESH_60Hz, attribList);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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 fxMesa = NULL;
|
||||
GLcontext *ctx = NULL, *shareCtx = NULL;
|
||||
struct dd_function_table functions;
|
||||
|
||||
int i;
|
||||
const char *str;
|
||||
int sliaa, numSLI, samplesPerChip;
|
||||
struct SstCard_St *voodoo;
|
||||
struct tdfx_glide *Glide;
|
||||
|
||||
GLboolean aux;
|
||||
GLboolean doubleBuffer;
|
||||
GLuint colDepth;
|
||||
GLuint depthSize, alphaSize, stencilSize, accumSize;
|
||||
GLuint redBits, greenBits, blueBits, alphaBits;
|
||||
GrPixelFormat_t pixFmt;
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxMesaCreateContext(...)\n");
|
||||
}
|
||||
|
||||
/* Okay, first process the user flags */
|
||||
aux = GL_FALSE;
|
||||
doubleBuffer = GL_FALSE;
|
||||
colDepth = 16;
|
||||
depthSize = alphaSize = stencilSize = accumSize = 0;
|
||||
|
||||
i = 0;
|
||||
while (attribList[i] != FXMESA_NONE) {
|
||||
switch (attribList[i]) {
|
||||
case FXMESA_COLORDEPTH:
|
||||
colDepth = attribList[++i];
|
||||
break;
|
||||
case FXMESA_DOUBLEBUFFER:
|
||||
doubleBuffer = GL_TRUE;
|
||||
break;
|
||||
case FXMESA_ALPHA_SIZE:
|
||||
if ((alphaSize = attribList[++i])) {
|
||||
aux = GL_TRUE;
|
||||
}
|
||||
break;
|
||||
case FXMESA_DEPTH_SIZE:
|
||||
if ((depthSize = attribList[++i])) {
|
||||
aux = GL_TRUE;
|
||||
}
|
||||
break;
|
||||
case FXMESA_STENCIL_SIZE:
|
||||
stencilSize = attribList[++i];
|
||||
break;
|
||||
case FXMESA_ACCUM_SIZE:
|
||||
accumSize = attribList[++i];
|
||||
break;
|
||||
/* XXX ugly hack here for sharing display lists */
|
||||
case FXMESA_SHARE_CONTEXT:
|
||||
shareCtx = (GLcontext *)attribList[++i];
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "fxMesaCreateContext: ERROR: wrong parameter (%d) passed\n", attribList[i]);
|
||||
return NULL;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (!fxQueryHardware()) {
|
||||
str = "no Voodoo hardware!";
|
||||
goto errorhandler;
|
||||
}
|
||||
|
||||
grSstSelect(glbCurrentBoard);
|
||||
/*grEnable(GR_OPENGL_MODE_EXT);*/ /* [koolsmoky] */
|
||||
voodoo = &glbHWConfig.SSTs[glbCurrentBoard];
|
||||
|
||||
fxMesa = (fxMesaContext)CALLOC_STRUCT(tfxMesaContext);
|
||||
if (!fxMesa) {
|
||||
str = "private context";
|
||||
goto errorhandler;
|
||||
}
|
||||
|
||||
if (getenv("MESA_FX_INFO")) {
|
||||
fxMesa->verbose = GL_TRUE;
|
||||
}
|
||||
|
||||
fxMesa->type = voodoo->type;
|
||||
fxMesa->HavePalExt = voodoo->HavePalExt && !getenv("MESA_FX_IGNORE_PALEXT");
|
||||
fxMesa->HavePixExt = voodoo->HavePixExt && !getenv("MESA_FX_IGNORE_PIXEXT");
|
||||
fxMesa->HaveTexFmt = voodoo->HaveTexFmt && !getenv("MESA_FX_IGNORE_TEXFMT");
|
||||
fxMesa->HaveCmbExt = voodoo->HaveCmbExt && !getenv("MESA_FX_IGNORE_CMBEXT");
|
||||
fxMesa->HaveMirExt = voodoo->HaveMirExt && !getenv("MESA_FX_IGNORE_MIREXT");
|
||||
fxMesa->HaveTexUma = voodoo->HaveTexUma && !getenv("MESA_FX_IGNORE_TEXUMA");
|
||||
fxMesa->Glide = glbHWConfig.Glide;
|
||||
Glide = &fxMesa->Glide;
|
||||
fxMesa->HaveTexus2 = Glide->txImgQuantize &&
|
||||
Glide->txMipQuantize &&
|
||||
Glide->txPalToNcc && !getenv("MESA_FX_IGNORE_TEXUS2");
|
||||
|
||||
/* Determine if we need vertex swapping, RGB order and SLI/AA */
|
||||
sliaa = 0;
|
||||
switch (fxMesa->type) {
|
||||
case GR_SSTTYPE_VOODOO:
|
||||
case GR_SSTTYPE_SST96:
|
||||
case GR_SSTTYPE_Banshee:
|
||||
fxMesa->bgrOrder = GL_TRUE;
|
||||
fxMesa->snapVertices = (getenv("MESA_FX_NOSNAP") == NULL);
|
||||
break;
|
||||
case GR_SSTTYPE_Voodoo2:
|
||||
fxMesa->bgrOrder = GL_TRUE;
|
||||
fxMesa->snapVertices = GL_FALSE;
|
||||
break;
|
||||
case GR_SSTTYPE_Voodoo4:
|
||||
case GR_SSTTYPE_Voodoo5:
|
||||
/* number of SLI units and AA Samples per chip */
|
||||
if ((str = Glide->grGetRegistryOrEnvironmentStringExt("SSTH3_SLI_AA_CONFIGURATION")) != NULL) {
|
||||
sliaa = atoi(str);
|
||||
}
|
||||
case GR_SSTTYPE_Voodoo3:
|
||||
default:
|
||||
fxMesa->bgrOrder = GL_FALSE;
|
||||
fxMesa->snapVertices = GL_FALSE;
|
||||
break;
|
||||
}
|
||||
/* XXX todo - Add the old SLI/AA settings for Napalm. */
|
||||
switch(voodoo->numChips) {
|
||||
case 4: /* 4 chips */
|
||||
switch(sliaa) {
|
||||
case 8: /* 8 Sample AA */
|
||||
numSLI = 1;
|
||||
samplesPerChip = 2;
|
||||
break;
|
||||
case 7: /* 4 Sample AA */
|
||||
numSLI = 1;
|
||||
samplesPerChip = 1;
|
||||
break;
|
||||
case 6: /* 2 Sample AA */
|
||||
numSLI = 2;
|
||||
samplesPerChip = 1;
|
||||
break;
|
||||
default:
|
||||
numSLI = 4;
|
||||
samplesPerChip = 1;
|
||||
}
|
||||
break;
|
||||
case 2: /* 2 chips */
|
||||
switch(sliaa) {
|
||||
case 4: /* 4 Sample AA */
|
||||
numSLI = 1;
|
||||
samplesPerChip = 2;
|
||||
break;
|
||||
case 3: /* 2 Sample AA */
|
||||
numSLI = 1;
|
||||
samplesPerChip = 1;
|
||||
break;
|
||||
default:
|
||||
numSLI = 2;
|
||||
samplesPerChip = 1;
|
||||
}
|
||||
break;
|
||||
default: /* 1 chip */
|
||||
switch(sliaa) {
|
||||
case 1: /* 2 Sample AA */
|
||||
numSLI = 1;
|
||||
samplesPerChip = 2;
|
||||
break;
|
||||
default:
|
||||
numSLI = 1;
|
||||
samplesPerChip = 1;
|
||||
}
|
||||
}
|
||||
|
||||
fxMesa->fsaa = samplesPerChip * voodoo->numChips / numSLI; /* 1:noFSAA, 2:2xFSAA, 4:4xFSAA, 8:8xFSAA */
|
||||
|
||||
switch (fxMesa->colDepth = colDepth) {
|
||||
case 15:
|
||||
redBits = 5;
|
||||
greenBits = 5;
|
||||
blueBits = 5;
|
||||
alphaBits = depthSize ? 1 : 8;
|
||||
switch(fxMesa->fsaa) {
|
||||
case 8:
|
||||
pixFmt = GR_PIXFMT_AA_8_ARGB_1555;
|
||||
break;
|
||||
case 4:
|
||||
pixFmt = GR_PIXFMT_AA_4_ARGB_1555;
|
||||
break;
|
||||
case 2:
|
||||
pixFmt = GR_PIXFMT_AA_2_ARGB_1555;
|
||||
break;
|
||||
default:
|
||||
pixFmt = GR_PIXFMT_ARGB_1555;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
redBits = 5;
|
||||
greenBits = 6;
|
||||
blueBits = 5;
|
||||
alphaBits = depthSize ? 0 : 8;
|
||||
switch(fxMesa->fsaa) {
|
||||
case 8:
|
||||
pixFmt = GR_PIXFMT_AA_8_RGB_565;
|
||||
break;
|
||||
case 4:
|
||||
pixFmt = GR_PIXFMT_AA_4_RGB_565;
|
||||
break;
|
||||
case 2:
|
||||
pixFmt = GR_PIXFMT_AA_2_RGB_565;
|
||||
break;
|
||||
default:
|
||||
pixFmt = GR_PIXFMT_RGB_565;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
fxMesa->colDepth = 32;
|
||||
case 32:
|
||||
redBits = 8;
|
||||
greenBits = 8;
|
||||
blueBits = 8;
|
||||
alphaBits = 8;
|
||||
switch(fxMesa->fsaa) {
|
||||
case 8:
|
||||
pixFmt = GR_PIXFMT_AA_8_ARGB_8888;
|
||||
break;
|
||||
case 4:
|
||||
pixFmt = GR_PIXFMT_AA_4_ARGB_8888;
|
||||
break;
|
||||
case 2:
|
||||
pixFmt = GR_PIXFMT_AA_2_ARGB_8888;
|
||||
break;
|
||||
default:
|
||||
pixFmt = GR_PIXFMT_ARGB_8888;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
str = "pixelFormat";
|
||||
goto errorhandler;
|
||||
}
|
||||
|
||||
/* Tips:
|
||||
* 1. we don't bother setting/checking AUX for stencil, because we'll decide
|
||||
* later whether we have HW stencil, based on depth buffer (thus AUX is
|
||||
* properly set)
|
||||
* 2. when both DEPTH and ALPHA are enabled, depth should win. However, it is
|
||||
* not clear whether 15bpp and 32bpp require AUX alpha buffer. Furthermore,
|
||||
* alpha buffering is required only if destination alpha is used in alpha
|
||||
* blending; alpha blending modes that do not use destination alpha can be
|
||||
* used w/o alpha buffer.
|
||||
* 3. `alphaBits' is what we can provide
|
||||
* `alphaSize' is what app requests
|
||||
* if we cannot provide enough bits for alpha buffer, we should fallback to
|
||||
* SW alpha. However, setting `alphaBits' to `alphaSize' might confuse some
|
||||
* of the span functions...
|
||||
*/
|
||||
|
||||
fxMesa->haveHwAlpha = GL_FALSE;
|
||||
if (alphaSize && (alphaSize <= alphaBits)) {
|
||||
alphaSize = alphaBits;
|
||||
fxMesa->haveHwAlpha = GL_TRUE;
|
||||
}
|
||||
|
||||
fxMesa->haveHwStencil = (fxMesa->HavePixExt && stencilSize && depthSize == 24);
|
||||
|
||||
fxMesa->haveZBuffer = depthSize > 0;
|
||||
fxMesa->haveDoubleBuffer = doubleBuffer;
|
||||
fxMesa->haveGlobalPaletteTexture = GL_FALSE;
|
||||
fxMesa->board = glbCurrentBoard;
|
||||
|
||||
fxMesa->haveTwoTMUs = (voodoo->nTexelfx > 1);
|
||||
|
||||
if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_NUM_TMU"))) {
|
||||
if (atoi(str) <= 1) {
|
||||
fxMesa->haveTwoTMUs = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_SWAPPENDINGCOUNT"))) {
|
||||
fxMesa->maxPendingSwapBuffers = atoi(str);
|
||||
if (fxMesa->maxPendingSwapBuffers > 6) {
|
||||
fxMesa->maxPendingSwapBuffers = 6;
|
||||
} else if (fxMesa->maxPendingSwapBuffers < 0) {
|
||||
fxMesa->maxPendingSwapBuffers = 0;
|
||||
}
|
||||
} else {
|
||||
fxMesa->maxPendingSwapBuffers = 2;
|
||||
}
|
||||
|
||||
if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_SWAPINTERVAL"))) {
|
||||
fxMesa->swapInterval = atoi(str);
|
||||
} else {
|
||||
fxMesa->swapInterval = 0;
|
||||
}
|
||||
|
||||
BEGIN_BOARD_LOCK();
|
||||
if (fxMesa->HavePixExt) {
|
||||
fxMesa->glideContext = Glide->grSstWinOpenExt((FxU32)win, res, ref,
|
||||
GR_COLORFORMAT_ABGR, GR_ORIGIN_LOWER_LEFT,
|
||||
pixFmt,
|
||||
2, aux);
|
||||
} else if (pixFmt == GR_PIXFMT_RGB_565) {
|
||||
fxMesa->glideContext = grSstWinOpen((FxU32)win, res, ref,
|
||||
GR_COLORFORMAT_ABGR, GR_ORIGIN_LOWER_LEFT,
|
||||
2, aux);
|
||||
} else {
|
||||
fxMesa->glideContext = 0;
|
||||
}
|
||||
END_BOARD_LOCK();
|
||||
if (!fxMesa->glideContext) {
|
||||
str = "grSstWinOpen";
|
||||
goto errorhandler;
|
||||
}
|
||||
|
||||
/* screen */
|
||||
fxMesa->screen_width = FX_grSstScreenWidth();
|
||||
fxMesa->screen_height = FX_grSstScreenHeight();
|
||||
|
||||
/* window inside screen */
|
||||
fxMesa->width = fxMesa->screen_width;
|
||||
fxMesa->height = fxMesa->screen_height;
|
||||
|
||||
/* scissor inside window */
|
||||
fxMesa->clipMinX = 0;
|
||||
fxMesa->clipMaxX = fxMesa->width;
|
||||
fxMesa->clipMinY = 0;
|
||||
fxMesa->clipMaxY = fxMesa->height;
|
||||
|
||||
if (fxMesa->verbose) {
|
||||
FxI32 tmuRam, fbRam;
|
||||
|
||||
/* Not that it matters, but tmuRam and fbRam change after grSstWinOpen. */
|
||||
tmuRam = voodoo->tmuConfig[GR_TMU0].tmuRam;
|
||||
fbRam = voodoo->fbRam;
|
||||
BEGIN_BOARD_LOCK();
|
||||
grGet(GR_MEMORY_TMU, 4, &tmuRam);
|
||||
grGet(GR_MEMORY_FB, 4, &fbRam);
|
||||
END_BOARD_LOCK();
|
||||
|
||||
fprintf(stderr, "Voodoo Using Glide %s\n", grGetString(GR_VERSION));
|
||||
fprintf(stderr, "Voodoo Board: %d/%d, %s, %d GPU\n",
|
||||
fxMesa->board + 1,
|
||||
glbHWConfig.num_sst,
|
||||
grGetString(GR_HARDWARE),
|
||||
voodoo->numChips);
|
||||
fprintf(stderr, "Voodoo Memory: FB = %ld, TM = %d x %ld\n",
|
||||
fbRam,
|
||||
voodoo->nTexelfx,
|
||||
tmuRam);
|
||||
fprintf(stderr, "Voodoo Screen: %dx%d:%d %s, %svertex snapping\n",
|
||||
fxMesa->screen_width,
|
||||
fxMesa->screen_height,
|
||||
colDepth,
|
||||
fxMesa->bgrOrder ? "BGR" : "RGB",
|
||||
fxMesa->snapVertices ? "" : "no ");
|
||||
}
|
||||
|
||||
sprintf(fxMesa->rendererString, "Mesa %s v0.63 %s%s",
|
||||
grGetString(GR_RENDERER),
|
||||
grGetString(GR_HARDWARE),
|
||||
((fxMesa->type < GR_SSTTYPE_Voodoo4) && (voodoo->numChips > 1)) ? " SLI" : "");
|
||||
|
||||
fxMesa->glVis = _mesa_create_visual(GL_TRUE, /* RGB mode */
|
||||
doubleBuffer,
|
||||
GL_FALSE, /* stereo */
|
||||
redBits, /* RGBA.R bits */
|
||||
greenBits, /* RGBA.G bits */
|
||||
blueBits, /* RGBA.B bits */
|
||||
alphaSize, /* RGBA.A bits */
|
||||
0, /* index bits */
|
||||
depthSize, /* depth_size */
|
||||
stencilSize, /* stencil_size */
|
||||
accumSize,
|
||||
accumSize,
|
||||
accumSize,
|
||||
alphaSize ? accumSize : 0,
|
||||
1);
|
||||
if (!fxMesa->glVis) {
|
||||
str = "_mesa_create_visual";
|
||||
goto errorhandler;
|
||||
}
|
||||
|
||||
_mesa_init_driver_functions(&functions);
|
||||
ctx = fxMesa->glCtx = _mesa_create_context(fxMesa->glVis, shareCtx,
|
||||
&functions, (void *) fxMesa);
|
||||
if (!ctx) {
|
||||
str = "_mesa_create_context";
|
||||
goto errorhandler;
|
||||
}
|
||||
|
||||
|
||||
if (!fxDDInitFxMesaContext(fxMesa)) {
|
||||
str = "fxDDInitFxMesaContext";
|
||||
goto errorhandler;
|
||||
}
|
||||
|
||||
|
||||
fxMesa->glBuffer = _mesa_create_framebuffer(fxMesa->glVis);
|
||||
#if 0
|
||||
/* XXX this is a complete mess :(
|
||||
* _mesa_add_soft_renderbuffers
|
||||
* driNewRenderbuffer
|
||||
*/
|
||||
GL_FALSE, /* no software depth */
|
||||
stencilSize && !fxMesa->haveHwStencil,
|
||||
fxMesa->glVis->accumRedBits > 0,
|
||||
alphaSize && !fxMesa->haveHwAlpha);
|
||||
#endif
|
||||
if (!fxMesa->glBuffer) {
|
||||
str = "_mesa_create_framebuffer";
|
||||
goto errorhandler;
|
||||
}
|
||||
|
||||
glbTotNumCtx++;
|
||||
|
||||
/* install signal handlers */
|
||||
#if defined(__linux__)
|
||||
/* Only install if environment var. is not set. */
|
||||
if (!getenv("MESA_FX_NO_SIGNALS")) {
|
||||
signal(SIGINT, cleangraphics_handler);
|
||||
signal(SIGHUP, cleangraphics_handler);
|
||||
signal(SIGPIPE, cleangraphics_handler);
|
||||
signal(SIGFPE, cleangraphics_handler);
|
||||
signal(SIGBUS, cleangraphics_handler);
|
||||
signal(SIGILL, cleangraphics_handler);
|
||||
signal(SIGSEGV, cleangraphics_handler);
|
||||
signal(SIGTERM, cleangraphics_handler);
|
||||
}
|
||||
#endif
|
||||
|
||||
return fxMesa;
|
||||
|
||||
errorhandler:
|
||||
if (fxMesa) {
|
||||
if (fxMesa->glideContext) {
|
||||
grSstWinClose(fxMesa->glideContext);
|
||||
fxMesa->glideContext = 0;
|
||||
}
|
||||
|
||||
if (fxMesa->state) {
|
||||
FREE(fxMesa->state);
|
||||
}
|
||||
if (fxMesa->fogTable) {
|
||||
FREE(fxMesa->fogTable);
|
||||
}
|
||||
if (fxMesa->glBuffer) {
|
||||
_mesa_reference_framebuffer(&fxMesa->glBuffer, NULL);
|
||||
}
|
||||
if (fxMesa->glVis) {
|
||||
_mesa_destroy_visual(fxMesa->glVis);
|
||||
}
|
||||
if (fxMesa->glCtx) {
|
||||
_mesa_destroy_context(fxMesa->glCtx);
|
||||
}
|
||||
FREE(fxMesa);
|
||||
}
|
||||
|
||||
fprintf(stderr, "fxMesaCreateContext: ERROR: %s\n", str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function to set the new window size in the context (mainly for the Voodoo Rush)
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
fxMesaUpdateScreenSize(fxMesaContext fxMesa)
|
||||
{
|
||||
fxMesa->width = FX_grSstScreenWidth();
|
||||
fxMesa->height = FX_grSstScreenHeight();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Destroy the given FX/Mesa context.
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
fxMesaDestroyContext(fxMesaContext fxMesa)
|
||||
{
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxMesaDestroyContext(...)\n");
|
||||
}
|
||||
|
||||
if (!fxMesa)
|
||||
return;
|
||||
|
||||
if (fxMesa->verbose) {
|
||||
fprintf(stderr, "Misc Stats:\n");
|
||||
fprintf(stderr, " # swap buffer: %u\n", fxMesa->stats.swapBuffer);
|
||||
|
||||
if (!fxMesa->stats.swapBuffer)
|
||||
fxMesa->stats.swapBuffer = 1;
|
||||
|
||||
fprintf(stderr, "Textures Stats:\n");
|
||||
fprintf(stderr, " Free texture memory on TMU0: %d\n",
|
||||
fxMesa->freeTexMem[FX_TMU0]);
|
||||
if (fxMesa->haveTwoTMUs)
|
||||
fprintf(stderr, " Free texture memory on TMU1: %d\n",
|
||||
fxMesa->freeTexMem[FX_TMU1]);
|
||||
fprintf(stderr, " # request to TMM to upload a texture objects: %u\n",
|
||||
fxMesa->stats.reqTexUpload);
|
||||
fprintf(stderr,
|
||||
" # request to TMM to upload a texture objects per swapbuffer: %.2f\n",
|
||||
fxMesa->stats.reqTexUpload / (float) fxMesa->stats.swapBuffer);
|
||||
fprintf(stderr, " # texture objects uploaded: %u\n",
|
||||
fxMesa->stats.texUpload);
|
||||
fprintf(stderr, " # texture objects uploaded per swapbuffer: %.2f\n",
|
||||
fxMesa->stats.texUpload / (float) fxMesa->stats.swapBuffer);
|
||||
fprintf(stderr, " # MBs uploaded to texture memory: %.2f\n",
|
||||
fxMesa->stats.memTexUpload / (float) (1 << 20));
|
||||
fprintf(stderr,
|
||||
" # MBs uploaded to texture memory per swapbuffer: %.2f\n",
|
||||
(fxMesa->stats.memTexUpload /
|
||||
(float) fxMesa->stats.swapBuffer) / (float) (1 << 20));
|
||||
}
|
||||
|
||||
glbTotNumCtx--;
|
||||
|
||||
if (!glbTotNumCtx && getenv("MESA_FX_INFO")) {
|
||||
GrSstPerfStats_t st;
|
||||
|
||||
FX_grSstPerfStats(&st);
|
||||
|
||||
fprintf(stderr, "Pixels Stats:\n");
|
||||
fprintf(stderr, " # pixels processed (minus buffer clears): %u\n",
|
||||
(unsigned) st.pixelsIn);
|
||||
fprintf(stderr, " # pixels not drawn due to chroma key test failure: %u\n",
|
||||
(unsigned) st.chromaFail);
|
||||
fprintf(stderr, " # pixels not drawn due to depth test failure: %u\n",
|
||||
(unsigned) st.zFuncFail);
|
||||
fprintf(stderr,
|
||||
" # pixels not drawn due to alpha test failure: %u\n",
|
||||
(unsigned) st.aFuncFail);
|
||||
fprintf(stderr, " # pixels drawn (including buffer clears and LFB writes): %u\n",
|
||||
(unsigned) st.pixelsOut);
|
||||
}
|
||||
|
||||
/* close the hardware first,
|
||||
* so we can debug atexit problems (memory leaks, etc).
|
||||
*/
|
||||
grSstWinClose(fxMesa->glideContext);
|
||||
fxCloseHardware();
|
||||
|
||||
fxDDDestroyFxMesaContext(fxMesa); /* must be before _mesa_destroy_context */
|
||||
_mesa_destroy_visual(fxMesa->glVis);
|
||||
_mesa_destroy_context(fxMesa->glCtx);
|
||||
_mesa_reference_framebuffer(&fxMesa->glBuffer, NULL);
|
||||
fxTMClose(fxMesa); /* must be after _mesa_destroy_context */
|
||||
|
||||
FREE(fxMesa);
|
||||
|
||||
if (fxMesa == fxMesaCurrentCtx)
|
||||
fxMesaCurrentCtx = NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Make the specified FX/Mesa context the current one.
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
fxMesaMakeCurrent(fxMesaContext fxMesa)
|
||||
{
|
||||
if (!fxMesa) {
|
||||
_mesa_make_current(NULL, NULL, NULL);
|
||||
fxMesaCurrentCtx = NULL;
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxMesaMakeCurrent(NULL)\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* if this context is already the current one, we can return early */
|
||||
if (fxMesaCurrentCtx == fxMesa
|
||||
&& fxMesaCurrentCtx->glCtx == _mesa_get_current_context()) {
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxMesaMakeCurrent(NOP)\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxMesaMakeCurrent(...)\n");
|
||||
}
|
||||
|
||||
if (fxMesaCurrentCtx)
|
||||
grGlideGetState((GrState *) fxMesaCurrentCtx->state);
|
||||
|
||||
fxMesaCurrentCtx = fxMesa;
|
||||
|
||||
grSstSelect(fxMesa->board);
|
||||
grGlideSetState((GrState *) fxMesa->state);
|
||||
|
||||
_mesa_make_current(fxMesa->glCtx, fxMesa->glBuffer, fxMesa->glBuffer);
|
||||
|
||||
fxSetupDDPointers(fxMesa->glCtx);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Swap front/back buffers for current context if double buffered.
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
fxMesaSwapBuffers(void)
|
||||
{
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxMesaSwapBuffers()\n");
|
||||
}
|
||||
|
||||
if (fxMesaCurrentCtx) {
|
||||
_mesa_notifySwapBuffers(fxMesaCurrentCtx->glCtx);
|
||||
|
||||
if (fxMesaCurrentCtx->haveDoubleBuffer) {
|
||||
|
||||
grBufferSwap(fxMesaCurrentCtx->swapInterval);
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Don't allow swap buffer commands to build up!
|
||||
*/
|
||||
while (FX_grGetInteger(GR_PENDING_BUFFERSWAPS) >
|
||||
fxMesaCurrentCtx->maxPendingSwapBuffers)
|
||||
/* The driver is able to sleep when waiting for the completation
|
||||
of multiple swapbuffer operations instead of wasting
|
||||
CPU time (NOTE: you must uncomment the following line in the
|
||||
in order to enable this option) */
|
||||
/* usleep(10000); */
|
||||
;
|
||||
#endif
|
||||
|
||||
fxMesaCurrentCtx->stats.swapBuffer++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Shutdown Glide library
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
fxCloseHardware(void)
|
||||
{
|
||||
if (glbGlideInitialized) {
|
||||
if (glbTotNumCtx == 0) {
|
||||
grGlideShutdown();
|
||||
glbGlideInitialized = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
/*
|
||||
* Need this to provide at least one external definition.
|
||||
*/
|
||||
extern int gl_fx_dummy_function_api(void);
|
||||
int
|
||||
gl_fx_dummy_function_api(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* FX */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,638 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.0
|
||||
*
|
||||
* Copyright (C) 1999-2001 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.
|
||||
*/
|
||||
|
||||
/* Authors:
|
||||
* David Bucciarelli
|
||||
* Brian Paul
|
||||
* Daryll Strauss
|
||||
* Keith Whitwell
|
||||
* Daniel Borca
|
||||
* Hiroshi Morii
|
||||
*/
|
||||
|
||||
|
||||
/* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "conf.h"
|
||||
#endif
|
||||
|
||||
#if defined(FX)
|
||||
|
||||
#include "fxdrv.h"
|
||||
#include "fxglidew.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/***** Span functions *****/
|
||||
/************************************************************************/
|
||||
|
||||
#define DBG 0
|
||||
|
||||
|
||||
#define LOCAL_VARS \
|
||||
GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER; \
|
||||
GLuint pitch = info.strideInBytes; \
|
||||
GLuint height = fxMesa->height; \
|
||||
char *buf = (char *)((char *)info.lfbPtr + 0 /* x, y offset */); \
|
||||
GLuint p; \
|
||||
(void) buf; (void) p;
|
||||
|
||||
#define CLIPPIXEL( _x, _y ) ( _x >= minx && _x < maxx && \
|
||||
_y >= miny && _y < maxy )
|
||||
|
||||
#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \
|
||||
if ( _y < miny || _y >= maxy ) { \
|
||||
_n1 = 0, _x1 = x; \
|
||||
} else { \
|
||||
_n1 = _n; \
|
||||
_x1 = _x; \
|
||||
if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx;\
|
||||
if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \
|
||||
}
|
||||
|
||||
#define Y_FLIP(_y) (height - _y - 1)
|
||||
|
||||
#define HW_WRITE_LOCK() \
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx); \
|
||||
GrLfbInfo_t info; \
|
||||
info.size = sizeof(GrLfbInfo_t); \
|
||||
if ( grLfbLock( GR_LFB_WRITE_ONLY, \
|
||||
currentFB, LFB_MODE, \
|
||||
GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
|
||||
|
||||
#define HW_WRITE_UNLOCK() \
|
||||
grLfbUnlock( GR_LFB_WRITE_ONLY, currentFB ); \
|
||||
}
|
||||
|
||||
#define HW_READ_LOCK() \
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx); \
|
||||
GrLfbInfo_t info; \
|
||||
info.size = sizeof(GrLfbInfo_t); \
|
||||
if ( grLfbLock( GR_LFB_READ_ONLY, currentFB, \
|
||||
LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
|
||||
|
||||
#define HW_READ_UNLOCK() \
|
||||
grLfbUnlock( GR_LFB_READ_ONLY, currentFB ); \
|
||||
}
|
||||
|
||||
#define HW_WRITE_CLIPLOOP() \
|
||||
do { \
|
||||
/* remember, we need to flip the scissor, too */ \
|
||||
/* is it better to do it inside fxDDScissor? */ \
|
||||
const int minx = fxMesa->clipMinX; \
|
||||
const int maxy = Y_FLIP(fxMesa->clipMinY); \
|
||||
const int maxx = fxMesa->clipMaxX; \
|
||||
const int miny = Y_FLIP(fxMesa->clipMaxY);
|
||||
|
||||
#define HW_READ_CLIPLOOP() \
|
||||
do { \
|
||||
/* remember, we need to flip the scissor, too */ \
|
||||
/* is it better to do it inside fxDDScissor? */ \
|
||||
const int minx = fxMesa->clipMinX; \
|
||||
const int maxy = Y_FLIP(fxMesa->clipMinY); \
|
||||
const int maxx = fxMesa->clipMaxX; \
|
||||
const int miny = Y_FLIP(fxMesa->clipMaxY);
|
||||
|
||||
#define HW_ENDCLIPLOOP() \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* 16 bit, ARGB1555 color spanline and pixel functions */
|
||||
|
||||
#undef LFB_MODE
|
||||
#define LFB_MODE GR_LFBWRITEMODE_1555
|
||||
|
||||
#undef BYTESPERPIXEL
|
||||
#define BYTESPERPIXEL 2
|
||||
|
||||
#undef INIT_MONO_PIXEL
|
||||
#define INIT_MONO_PIXEL(p, color) \
|
||||
p = TDFXPACKCOLOR1555( color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP] )
|
||||
|
||||
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
|
||||
*(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
|
||||
TDFXPACKCOLOR1555( r, g, b, a )
|
||||
|
||||
#define WRITE_PIXEL( _x, _y, p ) \
|
||||
*(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
|
||||
|
||||
#define READ_RGBA( rgba, _x, _y ) \
|
||||
do { \
|
||||
GLushort p = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch); \
|
||||
rgba[0] = FX_rgb_scale_5[(p >> 10) & 0x1F]; \
|
||||
rgba[1] = FX_rgb_scale_5[(p >> 5) & 0x1F]; \
|
||||
rgba[2] = FX_rgb_scale_5[ p & 0x1F]; \
|
||||
rgba[3] = (p & 0x8000) ? 255 : 0; \
|
||||
} while (0)
|
||||
|
||||
#define TAG(x) tdfx##x##_ARGB1555
|
||||
#include "../dri/common/spantmp.h"
|
||||
|
||||
|
||||
/* 16 bit, RGB565 color spanline and pixel functions */
|
||||
/* [dBorca] Hack alert:
|
||||
* This is wrong. The alpha value is lost, even when we provide
|
||||
* HW alpha (565 w/o depth buffering). To really update alpha buffer,
|
||||
* we would need to do the 565 writings via 8888 colorformat and rely
|
||||
* on the Voodoo to perform color scaling. In which case our 565 span
|
||||
* would look nicer! But this violates FSAA rules...
|
||||
*/
|
||||
|
||||
#undef LFB_MODE
|
||||
#define LFB_MODE GR_LFBWRITEMODE_565
|
||||
|
||||
#undef BYTESPERPIXEL
|
||||
#define BYTESPERPIXEL 2
|
||||
|
||||
#undef INIT_MONO_PIXEL
|
||||
#define INIT_MONO_PIXEL(p, color) \
|
||||
p = TDFXPACKCOLOR565( color[RCOMP], color[GCOMP], color[BCOMP] )
|
||||
|
||||
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
|
||||
*(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
|
||||
TDFXPACKCOLOR565( r, g, b )
|
||||
|
||||
#define WRITE_PIXEL( _x, _y, p ) \
|
||||
*(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
|
||||
|
||||
#define READ_RGBA( rgba, _x, _y ) \
|
||||
do { \
|
||||
GLushort p = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch); \
|
||||
rgba[0] = FX_rgb_scale_5[(p >> 11) & 0x1F]; \
|
||||
rgba[1] = FX_rgb_scale_6[(p >> 5) & 0x3F]; \
|
||||
rgba[2] = FX_rgb_scale_5[ p & 0x1F]; \
|
||||
rgba[3] = 0xff; \
|
||||
} while (0)
|
||||
|
||||
#define TAG(x) tdfx##x##_RGB565
|
||||
#include "../dri/common/spantmp.h"
|
||||
|
||||
|
||||
/* 32 bit, ARGB8888 color spanline and pixel functions */
|
||||
|
||||
#undef LFB_MODE
|
||||
#define LFB_MODE GR_LFBWRITEMODE_8888
|
||||
|
||||
#undef BYTESPERPIXEL
|
||||
#define BYTESPERPIXEL 4
|
||||
|
||||
#undef INIT_MONO_PIXEL
|
||||
#define INIT_MONO_PIXEL(p, color) \
|
||||
p = TDFXPACKCOLOR8888( color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP] )
|
||||
|
||||
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
|
||||
*(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
|
||||
TDFXPACKCOLOR8888( r, g, b, a )
|
||||
|
||||
#define WRITE_PIXEL( _x, _y, p ) \
|
||||
*(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
|
||||
|
||||
#define READ_RGBA( rgba, _x, _y ) \
|
||||
do { \
|
||||
GLuint p = *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch); \
|
||||
rgba[0] = (p >> 16) & 0xff; \
|
||||
rgba[1] = (p >> 8) & 0xff; \
|
||||
rgba[2] = (p >> 0) & 0xff; \
|
||||
rgba[3] = (p >> 24) & 0xff; \
|
||||
} while (0)
|
||||
|
||||
#define TAG(x) tdfx##x##_ARGB8888
|
||||
#include "../dri/common/spantmp.h"
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/***** Depth functions *****/
|
||||
/************************************************************************/
|
||||
|
||||
#define DBG 0
|
||||
|
||||
#undef HW_WRITE_LOCK
|
||||
#undef HW_WRITE_UNLOCK
|
||||
#undef HW_READ_LOCK
|
||||
#undef HW_READ_UNLOCK
|
||||
|
||||
#define HW_CLIPLOOP HW_WRITE_CLIPLOOP
|
||||
|
||||
#define LOCAL_DEPTH_VARS \
|
||||
GLuint pitch = info.strideInBytes; \
|
||||
GLuint height = fxMesa->height; \
|
||||
char *buf = (char *)((char *)info.lfbPtr + 0 /* x, y offset */); \
|
||||
(void) buf;
|
||||
|
||||
#define HW_WRITE_LOCK() \
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx); \
|
||||
GrLfbInfo_t info; \
|
||||
info.size = sizeof(GrLfbInfo_t); \
|
||||
if ( grLfbLock( GR_LFB_WRITE_ONLY, \
|
||||
GR_BUFFER_AUXBUFFER, LFB_MODE, \
|
||||
GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
|
||||
|
||||
#define HW_WRITE_UNLOCK() \
|
||||
grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_AUXBUFFER); \
|
||||
}
|
||||
|
||||
#define HW_READ_LOCK() \
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx); \
|
||||
GrLfbInfo_t info; \
|
||||
info.size = sizeof(GrLfbInfo_t); \
|
||||
if ( grLfbLock( GR_LFB_READ_ONLY, GR_BUFFER_AUXBUFFER, \
|
||||
LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
|
||||
|
||||
#define HW_READ_UNLOCK() \
|
||||
grLfbUnlock( GR_LFB_READ_ONLY, GR_BUFFER_AUXBUFFER); \
|
||||
}
|
||||
|
||||
|
||||
/* 16 bit, depth spanline and pixel functions */
|
||||
|
||||
#undef LFB_MODE
|
||||
#define LFB_MODE GR_LFBWRITEMODE_ZA16
|
||||
|
||||
#undef BYTESPERPIXEL
|
||||
#define BYTESPERPIXEL 2
|
||||
|
||||
#define VALUE_TYPE GLushort
|
||||
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
*(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
d = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch)
|
||||
|
||||
#define TAG(x) tdfx##x##_Z16
|
||||
#include "../dri/common/depthtmp.h"
|
||||
|
||||
|
||||
/* 24 bit, depth spanline and pixel functions (for use w/ stencil) */
|
||||
/* [dBorca] Hack alert:
|
||||
* This is evil. The incoming Mesa's 24bit depth value
|
||||
* is shifted left 8 bits, to obtain a full 32bit value,
|
||||
* which will be thrown into the framebuffer. We rely on
|
||||
* the fact that Voodoo hardware transforms a 32bit value
|
||||
* into 24bit value automatically and, MOST IMPORTANT, won't
|
||||
* alter the upper 8bits of the value already existing in the
|
||||
* framebuffer (where stencil resides).
|
||||
*/
|
||||
|
||||
#undef LFB_MODE
|
||||
#define LFB_MODE GR_LFBWRITEMODE_Z32
|
||||
|
||||
#undef BYTESPERPIXEL
|
||||
#define BYTESPERPIXEL 4
|
||||
|
||||
#define VALUE_TYPE GLuint
|
||||
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
*(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d << 8
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
d = (*(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch)) & 0xffffff
|
||||
|
||||
#define TAG(x) tdfx##x##_Z24
|
||||
#include "../dri/common/depthtmp.h"
|
||||
|
||||
|
||||
/* 32 bit, depth spanline and pixel functions (for use w/o stencil) */
|
||||
/* [dBorca] Hack alert:
|
||||
* This is more evil. We make Mesa run in 32bit depth, but
|
||||
* tha Voodoo HW can only handle 24bit depth. Well, exploiting
|
||||
* the pixel pipeline, we can achieve 24:8 format for greater
|
||||
* precision...
|
||||
* If anyone tells me how to really store 32bit values into the
|
||||
* depth buffer, I'll write the *_Z32 routines. Howver, bear in
|
||||
* mind that means running without stencil!
|
||||
*/
|
||||
|
||||
/************************************************************************/
|
||||
/***** Span functions (optimized) *****/
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
* Read a span of 15-bit RGB pixels. Note, we don't worry about cliprects
|
||||
* since OpenGL says obscured pixels have undefined values.
|
||||
*/
|
||||
static void fxReadRGBASpan_ARGB1555 (const GLcontext * ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n,
|
||||
GLint x, GLint y,
|
||||
GLubyte rgba[][4])
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
|
||||
GrLfbInfo_t info;
|
||||
info.size = sizeof(GrLfbInfo_t);
|
||||
if (grLfbLock(GR_LFB_READ_ONLY, currentFB,
|
||||
GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
|
||||
const GLint winX = 0;
|
||||
const GLint winY = fxMesa->height - 1;
|
||||
const GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr +
|
||||
(winY - y) * info.strideInBytes +
|
||||
(winX + x) * 2);
|
||||
const GLuint *data32 = (const GLuint *) data16;
|
||||
GLuint i, j;
|
||||
GLuint extraPixel = (n & 1);
|
||||
n -= extraPixel;
|
||||
|
||||
for (i = j = 0; i < n; i += 2, j++) {
|
||||
GLuint pixel = data32[j];
|
||||
rgba[i][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F];
|
||||
rgba[i][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F];
|
||||
rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F];
|
||||
rgba[i][3] = (pixel & 0x8000) ? 255 : 0;
|
||||
rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 26) & 0x1F];
|
||||
rgba[i+1][1] = FX_rgb_scale_5[(pixel >> 21) & 0x1F];
|
||||
rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F];
|
||||
rgba[i+1][3] = (pixel & 0x80000000) ? 255 : 0;
|
||||
}
|
||||
if (extraPixel) {
|
||||
GLushort pixel = data16[n];
|
||||
rgba[n][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F];
|
||||
rgba[n][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F];
|
||||
rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F];
|
||||
rgba[n][3] = (pixel & 0x8000) ? 255 : 0;
|
||||
}
|
||||
|
||||
grLfbUnlock(GR_LFB_READ_ONLY, currentFB);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects
|
||||
* since OpenGL says obscured pixels have undefined values.
|
||||
*/
|
||||
static void fxReadRGBASpan_RGB565 (const GLcontext * ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n,
|
||||
GLint x, GLint y,
|
||||
GLubyte rgba[][4])
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
|
||||
GrLfbInfo_t info;
|
||||
info.size = sizeof(GrLfbInfo_t);
|
||||
if (grLfbLock(GR_LFB_READ_ONLY, currentFB,
|
||||
GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
|
||||
const GLint winX = 0;
|
||||
const GLint winY = fxMesa->height - 1;
|
||||
const GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr +
|
||||
(winY - y) * info.strideInBytes +
|
||||
(winX + x) * 2);
|
||||
const GLuint *data32 = (const GLuint *) data16;
|
||||
GLuint i, j;
|
||||
GLuint extraPixel = (n & 1);
|
||||
n -= extraPixel;
|
||||
|
||||
for (i = j = 0; i < n; i += 2, j++) {
|
||||
GLuint pixel = data32[j];
|
||||
rgba[i][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F];
|
||||
rgba[i][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F];
|
||||
rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F];
|
||||
rgba[i][3] = 255;
|
||||
rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 27) & 0x1F];
|
||||
rgba[i+1][1] = FX_rgb_scale_6[(pixel >> 21) & 0x3F];
|
||||
rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F];
|
||||
rgba[i+1][3] = 255;
|
||||
}
|
||||
if (extraPixel) {
|
||||
GLushort pixel = data16[n];
|
||||
rgba[n][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F];
|
||||
rgba[n][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F];
|
||||
rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F];
|
||||
rgba[n][3] = 255;
|
||||
}
|
||||
|
||||
grLfbUnlock(GR_LFB_READ_ONLY, currentFB);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a span of 32-bit RGB pixels. Note, we don't worry about cliprects
|
||||
* since OpenGL says obscured pixels have undefined values.
|
||||
*/
|
||||
static void fxReadRGBASpan_ARGB8888 (const GLcontext * ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLuint n,
|
||||
GLint x, GLint y,
|
||||
GLubyte rgba[][4])
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
|
||||
GLuint i;
|
||||
grLfbReadRegion(currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba);
|
||||
for (i = 0; i < n; i++) {
|
||||
GLubyte c = rgba[i][0];
|
||||
rgba[i][0] = rgba[i][2];
|
||||
rgba[i][2] = c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/***** Depth functions (optimized) *****/
|
||||
/************************************************************************/
|
||||
|
||||
static void
|
||||
fxReadDepthSpan_Z16(GLcontext * ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, GLint x, GLint y, GLuint depth[])
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
GLint bottom = fxMesa->height - 1;
|
||||
GLushort depth16[MAX_WIDTH];
|
||||
GLuint i;
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxReadDepthSpan_Z16(...)\n");
|
||||
}
|
||||
|
||||
grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
|
||||
for (i = 0; i < n; i++) {
|
||||
depth[i] = depth16[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fxReadDepthSpan_Z24(GLcontext * ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, GLint x, GLint y, GLuint depth[])
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
GLint bottom = fxMesa->height - 1;
|
||||
GLuint i;
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxReadDepthSpan_Z24(...)\n");
|
||||
}
|
||||
|
||||
grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth);
|
||||
for (i = 0; i < n; i++) {
|
||||
depth[i] &= 0xffffff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/***** Stencil functions (optimized) *****/
|
||||
/************************************************************************/
|
||||
|
||||
static void
|
||||
fxWriteStencilSpan (GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, GLint x, GLint y,
|
||||
const GLstencil stencil[], const GLubyte mask[])
|
||||
{
|
||||
/*
|
||||
* XXX todo
|
||||
*/
|
||||
}
|
||||
|
||||
static void
|
||||
fxReadStencilSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, GLint x, GLint y, GLstencil stencil[])
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
GLint bottom = fxMesa->height - 1;
|
||||
GLuint zs32[MAX_WIDTH];
|
||||
GLuint i;
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxReadStencilSpan(...)\n");
|
||||
}
|
||||
|
||||
grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, zs32);
|
||||
for (i = 0; i < n; i++) {
|
||||
stencil[i] = zs32[i] >> 24;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fxWriteStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
const GLstencil stencil[],
|
||||
const GLubyte mask[])
|
||||
{
|
||||
/*
|
||||
* XXX todo
|
||||
*/
|
||||
}
|
||||
|
||||
static void
|
||||
fxReadStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
GLstencil stencil[])
|
||||
{
|
||||
/*
|
||||
* XXX todo
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fxSetupDDSpanPointers(GLcontext * ctx)
|
||||
{
|
||||
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
|
||||
switch (fxMesa->colDepth) {
|
||||
case 15:
|
||||
swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB1555;
|
||||
swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB1555;
|
||||
swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB1555;
|
||||
swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB1555;
|
||||
swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB1555;
|
||||
swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_ARGB1555;
|
||||
swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB1555;
|
||||
|
||||
swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z16;
|
||||
swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z16;
|
||||
swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z16;
|
||||
swdd->ReadDepthPixels = tdfxReadDepthPixels_Z16;
|
||||
break;
|
||||
case 16:
|
||||
swdd->WriteRGBASpan = tdfxWriteRGBASpan_RGB565;
|
||||
swdd->WriteRGBSpan = tdfxWriteRGBSpan_RGB565;
|
||||
swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_RGB565;
|
||||
swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_RGB565;
|
||||
swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_RGB565;
|
||||
swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_RGB565;
|
||||
swdd->ReadRGBAPixels = tdfxReadRGBAPixels_RGB565;
|
||||
|
||||
swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z16;
|
||||
swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z16;
|
||||
swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z16;
|
||||
swdd->ReadDepthPixels = tdfxReadDepthPixels_Z16;
|
||||
break;
|
||||
case 32:
|
||||
swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB8888;
|
||||
swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB8888;
|
||||
swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB8888;
|
||||
swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB8888;
|
||||
swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB8888;
|
||||
swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_ARGB8888;
|
||||
swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB8888;
|
||||
|
||||
swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z24;
|
||||
swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z24;
|
||||
swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z24;
|
||||
swdd->ReadDepthPixels = tdfxReadDepthPixels_Z24;
|
||||
break;
|
||||
}
|
||||
|
||||
if (fxMesa->haveHwStencil) {
|
||||
swdd->WriteStencilSpan = fxWriteStencilSpan;
|
||||
swdd->ReadStencilSpan = fxReadStencilSpan;
|
||||
swdd->WriteStencilPixels = fxWriteStencilPixels;
|
||||
swdd->ReadStencilPixels = fxReadStencilPixels;
|
||||
}
|
||||
#if 0
|
||||
swdd->WriteCI8Span = NULL;
|
||||
swdd->WriteCI32Span = NULL;
|
||||
swdd->WriteMonoCISpan = NULL;
|
||||
swdd->WriteCI32Pixels = NULL;
|
||||
swdd->WriteMonoCIPixels = NULL;
|
||||
swdd->ReadCI32Span = NULL;
|
||||
swdd->ReadCI32Pixels = NULL;
|
||||
|
||||
swdd->SpanRenderStart = tdfxSpanRenderStart; /* BEGIN_BOARD_LOCK */
|
||||
swdd->SpanRenderFinish = tdfxSpanRenderFinish; /* END_BOARD_LOCK */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
/*
|
||||
* Need this to provide at least one external definition.
|
||||
*/
|
||||
|
||||
extern int gl_fx_dummy_function_span(void);
|
||||
int
|
||||
gl_fx_dummy_function_span(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* FX */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,773 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.0
|
||||
*
|
||||
* Copyright (C) 1999-2001 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.
|
||||
*/
|
||||
|
||||
/* Authors:
|
||||
* David Bucciarelli
|
||||
* Brian Paul
|
||||
* Daryll Strauss
|
||||
* Keith Whitwell
|
||||
* Daniel Borca
|
||||
* Hiroshi Morii
|
||||
*/
|
||||
|
||||
/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
|
||||
|
||||
|
||||
#ifndef FXDRV_H
|
||||
#define FXDRV_H
|
||||
|
||||
/* If you comment out this define, a variable takes its place, letting
|
||||
* you turn debugging on/off from the debugger.
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "main/context.h"
|
||||
#include "main/imports.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/matrix.h"
|
||||
#include "main/mtypes.h"
|
||||
|
||||
#include "GL/fxmesa.h"
|
||||
#include "fxglidew.h"
|
||||
|
||||
#include "math/m_vector.h"
|
||||
|
||||
|
||||
#define COPY_FLOAT(dst, src) (dst) = (src)
|
||||
|
||||
/* Define some shorter names for these things.
|
||||
*/
|
||||
#define XCOORD GR_VERTEX_X_OFFSET
|
||||
#define YCOORD GR_VERTEX_Y_OFFSET
|
||||
#define ZCOORD GR_VERTEX_OOZ_OFFSET
|
||||
#define OOWCOORD GR_VERTEX_OOW_OFFSET
|
||||
|
||||
#define S0COORD GR_VERTEX_SOW_TMU0_OFFSET
|
||||
#define T0COORD GR_VERTEX_TOW_TMU0_OFFSET
|
||||
#define S1COORD GR_VERTEX_SOW_TMU1_OFFSET
|
||||
#define T1COORD GR_VERTEX_TOW_TMU1_OFFSET
|
||||
|
||||
|
||||
|
||||
#ifdef __i386__
|
||||
#define FXCOLOR4( c ) (* (int *)c)
|
||||
#else
|
||||
#define FXCOLOR4( c ) ( \
|
||||
( ((unsigned int)(c[3]))<<24 ) | \
|
||||
( ((unsigned int)(c[2]))<<16 ) | \
|
||||
( ((unsigned int)(c[1]))<<8 ) | \
|
||||
( (unsigned int)(c[0])) )
|
||||
#endif
|
||||
|
||||
#define TDFXPACKCOLOR1555( r, g, b, a ) \
|
||||
((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
|
||||
((a) ? 0x8000 : 0))
|
||||
#define TDFXPACKCOLOR565( r, g, b ) \
|
||||
((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
|
||||
#define TDFXPACKCOLOR8888( r, g, b, a ) \
|
||||
(((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
|
||||
|
||||
|
||||
|
||||
/* fastpath flags first
|
||||
*/
|
||||
#define SETUP_TMU0 0x1
|
||||
#define SETUP_TMU1 0x2
|
||||
#define SETUP_RGBA 0x4
|
||||
#define SETUP_SNAP 0x8
|
||||
#define SETUP_XYZW 0x10
|
||||
#define SETUP_PTEX 0x20
|
||||
#define SETUP_PSIZ 0x40
|
||||
#define SETUP_SPEC 0x80
|
||||
#define SETUP_FOGC 0x100
|
||||
#define MAX_SETUP 0x200
|
||||
|
||||
|
||||
#define FX_NUM_TMU 2
|
||||
|
||||
#define FX_TMU0 GR_TMU0
|
||||
#define FX_TMU1 GR_TMU1
|
||||
#define FX_TMU_SPLIT 98
|
||||
#define FX_TMU_BOTH 99
|
||||
#define FX_TMU_NONE 100
|
||||
|
||||
/* Used for fxMesa->lastUnitsMode */
|
||||
|
||||
#define FX_UM_NONE 0x00000000
|
||||
|
||||
#define FX_UM_E0_REPLACE 0x00000001
|
||||
#define FX_UM_E0_MODULATE 0x00000002
|
||||
#define FX_UM_E0_DECAL 0x00000004
|
||||
#define FX_UM_E0_BLEND 0x00000008
|
||||
#define FX_UM_E0_ADD 0x00000010
|
||||
|
||||
#define FX_UM_E1_REPLACE 0x00000020
|
||||
#define FX_UM_E1_MODULATE 0x00000040
|
||||
#define FX_UM_E1_DECAL 0x00000080
|
||||
#define FX_UM_E1_BLEND 0x00000100
|
||||
#define FX_UM_E1_ADD 0x00000200
|
||||
|
||||
#define FX_UM_E_ENVMODE 0x000003ff
|
||||
|
||||
#define FX_UM_E0_ALPHA 0x00001000
|
||||
#define FX_UM_E0_LUMINANCE 0x00002000
|
||||
#define FX_UM_E0_LUMINANCE_ALPHA 0x00004000
|
||||
#define FX_UM_E0_INTENSITY 0x00008000
|
||||
#define FX_UM_E0_RGB 0x00010000
|
||||
#define FX_UM_E0_RGBA 0x00020000
|
||||
|
||||
#define FX_UM_E1_ALPHA 0x00040000
|
||||
#define FX_UM_E1_LUMINANCE 0x00080000
|
||||
#define FX_UM_E1_LUMINANCE_ALPHA 0x00100000
|
||||
#define FX_UM_E1_INTENSITY 0x00200000
|
||||
#define FX_UM_E1_RGB 0x00400000
|
||||
#define FX_UM_E1_RGBA 0x00800000
|
||||
|
||||
#define FX_UM_E_IFMT 0x00fff000
|
||||
|
||||
#define FX_UM_COLOR_ITERATED 0x01000000
|
||||
#define FX_UM_COLOR_CONSTANT 0x02000000
|
||||
#define FX_UM_ALPHA_ITERATED 0x04000000
|
||||
#define FX_UM_ALPHA_CONSTANT 0x08000000
|
||||
|
||||
|
||||
/* for Voodoo3/Banshee's grColorCombine() and grAlphaCombine() */
|
||||
struct tdfx_combine {
|
||||
GrCombineFunction_t Function; /* Combine function */
|
||||
GrCombineFactor_t Factor; /* Combine scale factor */
|
||||
GrCombineLocal_t Local; /* Local combine source */
|
||||
GrCombineOther_t Other; /* Other combine source */
|
||||
FxBool Invert; /* Combine result inversion flag */
|
||||
};
|
||||
|
||||
/* for Voodoo3's grTexCombine() */
|
||||
struct tdfx_texcombine {
|
||||
GrCombineFunction_t FunctionRGB;
|
||||
GrCombineFactor_t FactorRGB;
|
||||
GrCombineFunction_t FunctionAlpha;
|
||||
GrCombineFactor_t FactorAlpha;
|
||||
FxBool InvertRGB;
|
||||
FxBool InvertAlpha;
|
||||
};
|
||||
|
||||
|
||||
/* for Voodoo5's grColorCombineExt() */
|
||||
struct tdfx_combine_color_ext {
|
||||
GrCCUColor_t SourceA;
|
||||
GrCombineMode_t ModeA;
|
||||
GrCCUColor_t SourceB;
|
||||
GrCombineMode_t ModeB;
|
||||
GrCCUColor_t SourceC;
|
||||
FxBool InvertC;
|
||||
GrCCUColor_t SourceD;
|
||||
FxBool InvertD;
|
||||
FxU32 Shift;
|
||||
FxBool Invert;
|
||||
};
|
||||
|
||||
/* for Voodoo5's grAlphaCombineExt() */
|
||||
struct tdfx_combine_alpha_ext {
|
||||
GrACUColor_t SourceA;
|
||||
GrCombineMode_t ModeA;
|
||||
GrACUColor_t SourceB;
|
||||
GrCombineMode_t ModeB;
|
||||
GrACUColor_t SourceC;
|
||||
FxBool InvertC;
|
||||
GrACUColor_t SourceD;
|
||||
FxBool InvertD;
|
||||
FxU32 Shift;
|
||||
FxBool Invert;
|
||||
};
|
||||
|
||||
/* for Voodoo5's grTexColorCombineExt() */
|
||||
struct tdfx_color_texenv {
|
||||
GrTCCUColor_t SourceA;
|
||||
GrCombineMode_t ModeA;
|
||||
GrTCCUColor_t SourceB;
|
||||
GrCombineMode_t ModeB;
|
||||
GrTCCUColor_t SourceC;
|
||||
FxBool InvertC;
|
||||
GrTCCUColor_t SourceD;
|
||||
FxBool InvertD;
|
||||
FxU32 Shift;
|
||||
FxBool Invert;
|
||||
};
|
||||
|
||||
/* for Voodoo5's grTexAlphaCombineExt() */
|
||||
struct tdfx_alpha_texenv {
|
||||
GrTACUColor_t SourceA;
|
||||
GrCombineMode_t ModeA;
|
||||
GrTACUColor_t SourceB;
|
||||
GrCombineMode_t ModeB;
|
||||
GrTACUColor_t SourceC;
|
||||
FxBool InvertC;
|
||||
GrTCCUColor_t SourceD;
|
||||
FxBool InvertD;
|
||||
FxU32 Shift;
|
||||
FxBool Invert;
|
||||
};
|
||||
|
||||
/* Voodoo5's texture combine environment */
|
||||
struct tdfx_texcombine_ext {
|
||||
struct tdfx_alpha_texenv Alpha;
|
||||
struct tdfx_color_texenv Color;
|
||||
GrColor_t EnvColor;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Memory range from startAddr to endAddr-1
|
||||
*/
|
||||
typedef struct MemRange_t
|
||||
{
|
||||
struct MemRange_t *next;
|
||||
FxU32 startAddr, endAddr;
|
||||
}
|
||||
MemRange;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLsizei width, height; /* image size */
|
||||
GLint wScale, hScale; /* image scale factor */
|
||||
GrTextureFormat_t glideFormat; /* Glide image format */
|
||||
}
|
||||
tfxMipMapLevel;
|
||||
|
||||
/*
|
||||
* TDFX-specific texture object data. This hangs off of the
|
||||
* struct gl_texture_object DriverData pointer.
|
||||
*/
|
||||
typedef struct tfxTexInfo_t
|
||||
{
|
||||
struct tfxTexInfo_t *next;
|
||||
struct gl_texture_object *tObj;
|
||||
|
||||
GLuint lastTimeUsed;
|
||||
FxU32 whichTMU;
|
||||
GLboolean isInTM;
|
||||
|
||||
MemRange *tm[FX_NUM_TMU];
|
||||
|
||||
GLint minLevel, maxLevel;
|
||||
GLint baseLevelInternalFormat;
|
||||
|
||||
GrTexInfo info;
|
||||
|
||||
GrTextureFilterMode_t minFilt;
|
||||
GrTextureFilterMode_t maxFilt;
|
||||
FxBool LODblend;
|
||||
|
||||
GrTextureClampMode_t sClamp;
|
||||
GrTextureClampMode_t tClamp;
|
||||
|
||||
GrMipMapMode_t mmMode;
|
||||
|
||||
GLfloat sScale, tScale;
|
||||
|
||||
GrTexTable_t paltype;
|
||||
GuTexPalette palette;
|
||||
|
||||
GLboolean fixedPalette;
|
||||
GLboolean validated;
|
||||
|
||||
GLboolean padded;
|
||||
}
|
||||
tfxTexInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLuint swapBuffer;
|
||||
GLuint reqTexUpload;
|
||||
GLuint texUpload;
|
||||
GLuint memTexUpload;
|
||||
}
|
||||
tfxStats;
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Alpha test */
|
||||
|
||||
GLboolean alphaTestEnabled;
|
||||
GrCmpFnc_t alphaTestFunc;
|
||||
GLfloat alphaTestRefValue;
|
||||
|
||||
/* Blend function */
|
||||
|
||||
GLboolean blendEnabled;
|
||||
GrAlphaBlendFnc_t blendSrcFuncRGB;
|
||||
GrAlphaBlendFnc_t blendDstFuncRGB;
|
||||
GrAlphaBlendFnc_t blendSrcFuncAlpha;
|
||||
GrAlphaBlendFnc_t blendDstFuncAlpha;
|
||||
GrAlphaBlendOp_t blendEqRGB;
|
||||
GrAlphaBlendOp_t blendEqAlpha;
|
||||
|
||||
/* Depth test */
|
||||
|
||||
GLboolean depthTestEnabled;
|
||||
GLboolean depthMask;
|
||||
GrCmpFnc_t depthTestFunc;
|
||||
FxI32 depthBias;
|
||||
|
||||
/* Stencil */
|
||||
|
||||
GLboolean stencilEnabled;
|
||||
GrCmpFnc_t stencilFunction; /* Stencil function */
|
||||
GrStencil_t stencilRefValue; /* Stencil reference value */
|
||||
GrStencil_t stencilValueMask; /* Value mask */
|
||||
GrStencil_t stencilWriteMask; /* Write mask */
|
||||
GrCmpFnc_t stencilFailFunc; /* Stencil fail function */
|
||||
GrCmpFnc_t stencilZFailFunc; /* Stencil pass, depth fail function */
|
||||
GrCmpFnc_t stencilZPassFunc; /* Stencil pass, depth pass function */
|
||||
GrStencil_t stencilClear; /* Buffer clear value */
|
||||
}
|
||||
tfxUnitsState;
|
||||
|
||||
|
||||
|
||||
|
||||
/* Flags for fxMesa->new_state
|
||||
*/
|
||||
#define FX_NEW_TEXTURING 0x1
|
||||
#define FX_NEW_BLEND 0x2
|
||||
#define FX_NEW_ALPHA 0x4
|
||||
#define FX_NEW_DEPTH 0x8
|
||||
#define FX_NEW_FOG 0x10
|
||||
#define FX_NEW_SCISSOR 0x20
|
||||
#define FX_NEW_COLOR_MASK 0x40
|
||||
#define FX_NEW_CULL 0x80
|
||||
#define FX_NEW_STENCIL 0x100
|
||||
|
||||
|
||||
#define FX_CONTEXT(ctx) ((fxMesaContext)((ctx)->DriverCtx))
|
||||
|
||||
#define FX_TEXTURE_DATA(texUnit) fxTMGetTexInfo((texUnit)->_Current)
|
||||
|
||||
#define fxTMGetTexInfo(o) ((tfxTexInfo*)((o)->DriverData))
|
||||
|
||||
#define FX_MIPMAP_DATA(img) ((tfxMipMapLevel *) (img)->DriverData)
|
||||
|
||||
#define BEGIN_BOARD_LOCK()
|
||||
#define END_BOARD_LOCK()
|
||||
#define BEGIN_CLIP_LOOP()
|
||||
#define END_CLIP_LOOP()
|
||||
|
||||
|
||||
|
||||
|
||||
/* Covers the state referenced by IsInHardware:
|
||||
*/
|
||||
#define _FX_NEW_IS_IN_HARDWARE (_NEW_TEXTURE| \
|
||||
_NEW_HINT| \
|
||||
_NEW_STENCIL| \
|
||||
_NEW_BUFFERS| \
|
||||
_NEW_COLOR| \
|
||||
_NEW_LIGHT)
|
||||
|
||||
/* Covers the state referenced by fxDDChooseRenderState
|
||||
*/
|
||||
#define _FX_NEW_RENDERSTATE (_FX_NEW_IS_IN_HARDWARE | \
|
||||
_DD_NEW_FLATSHADE | \
|
||||
_DD_NEW_TRI_LIGHT_TWOSIDE| \
|
||||
_DD_NEW_TRI_OFFSET | \
|
||||
_DD_NEW_TRI_UNFILLED | \
|
||||
_DD_NEW_TRI_SMOOTH | \
|
||||
_DD_NEW_TRI_STIPPLE | \
|
||||
_DD_NEW_LINE_SMOOTH | \
|
||||
_DD_NEW_LINE_STIPPLE | \
|
||||
_DD_NEW_LINE_WIDTH | \
|
||||
_DD_NEW_POINT_SMOOTH | \
|
||||
_DD_NEW_POINT_SIZE | \
|
||||
_NEW_LINE)
|
||||
|
||||
|
||||
/* Covers the state referenced by fxDDChooseSetupFunction.
|
||||
*/
|
||||
#define _FX_NEW_SETUP_FUNCTION (_NEW_LIGHT| \
|
||||
_NEW_FOG| \
|
||||
_NEW_TEXTURE| \
|
||||
_NEW_COLOR) \
|
||||
|
||||
|
||||
/* lookup table for scaling y bit colors up to 8 bits */
|
||||
extern GLuint FX_rgb_scale_4[16];
|
||||
extern GLuint FX_rgb_scale_5[32];
|
||||
extern GLuint FX_rgb_scale_6[64];
|
||||
|
||||
typedef void (*fx_tri_func) (fxMesaContext, GrVertex *, GrVertex *, GrVertex *);
|
||||
typedef void (*fx_line_func) (fxMesaContext, GrVertex *, GrVertex *);
|
||||
typedef void (*fx_point_func) (fxMesaContext, GrVertex *);
|
||||
|
||||
struct tfxMesaContext
|
||||
{
|
||||
GrTexTable_t glbPalType;
|
||||
GuTexPalette glbPalette;
|
||||
|
||||
GLcontext *glCtx; /* the core Mesa context */
|
||||
GLvisual *glVis; /* describes the color buffer */
|
||||
GLframebuffer *glBuffer; /* the ancillary buffers */
|
||||
|
||||
GLint board; /* the board used for this context */
|
||||
GLint width, height; /* size of color buffer */
|
||||
|
||||
GrBuffer_t currentFB;
|
||||
|
||||
GLboolean bgrOrder;
|
||||
GrColor_t color;
|
||||
GrColor_t clearC;
|
||||
GrAlpha_t clearA;
|
||||
GLuint constColor;
|
||||
GrCullMode_t cullMode;
|
||||
|
||||
tfxUnitsState unitsState;
|
||||
tfxUnitsState restoreUnitsState; /* saved during multipass */
|
||||
GLboolean multipass; /* true when drawing intermediate pass */
|
||||
|
||||
GLuint new_state;
|
||||
GLuint new_gl_state;
|
||||
|
||||
/* Texture Memory Manager Data
|
||||
*/
|
||||
GLuint texBindNumber;
|
||||
GLint tmuSrc;
|
||||
GLuint lastUnitsMode;
|
||||
GLuint freeTexMem[FX_NUM_TMU];
|
||||
MemRange *tmPool;
|
||||
MemRange *tmFree[FX_NUM_TMU];
|
||||
|
||||
GLenum fogTableMode;
|
||||
GLfloat fogDensity;
|
||||
GLfloat fogStart, fogEnd;
|
||||
GrFog_t *fogTable;
|
||||
GLint textureAlign;
|
||||
GLint textureMaxLod;
|
||||
|
||||
/* Vertex building and storage:
|
||||
*/
|
||||
GLuint tmu_source[FX_NUM_TMU];
|
||||
GLuint SetupIndex;
|
||||
GLuint stw_hint_state; /* for grHints */
|
||||
GrVertex *verts;
|
||||
GLboolean snapVertices; /* needed for older Voodoo hardware */
|
||||
|
||||
/* Rasterization:
|
||||
*/
|
||||
GLuint render_index;
|
||||
GLuint fallback;
|
||||
GLenum render_primitive;
|
||||
GLenum raster_primitive;
|
||||
|
||||
/* Current rasterization functions
|
||||
*/
|
||||
fx_point_func draw_point;
|
||||
fx_line_func draw_line;
|
||||
fx_tri_func draw_tri;
|
||||
|
||||
|
||||
/* Keep texture scales somewhere handy:
|
||||
*/
|
||||
GLfloat s0scale;
|
||||
GLfloat s1scale;
|
||||
GLfloat t0scale;
|
||||
GLfloat t1scale;
|
||||
|
||||
GLfloat inv_s0scale;
|
||||
GLfloat inv_s1scale;
|
||||
GLfloat inv_t0scale;
|
||||
GLfloat inv_t1scale;
|
||||
|
||||
/* Glide stuff
|
||||
*/
|
||||
tfxStats stats;
|
||||
void *state;
|
||||
|
||||
/* Options */
|
||||
|
||||
GLboolean verbose;
|
||||
GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */
|
||||
GLboolean haveHwAlpha;
|
||||
GLboolean haveHwStencil;
|
||||
GLboolean haveZBuffer;
|
||||
GLboolean haveDoubleBuffer;
|
||||
GLboolean haveGlobalPaletteTexture;
|
||||
GLint swapInterval;
|
||||
GLint maxPendingSwapBuffers;
|
||||
|
||||
GrContext_t glideContext;
|
||||
|
||||
int screen_width;
|
||||
int screen_height;
|
||||
int clipMinX;
|
||||
int clipMaxX;
|
||||
int clipMinY;
|
||||
int clipMaxY;
|
||||
|
||||
int colDepth;
|
||||
GLboolean fsaa;
|
||||
|
||||
/* Glide (per card) capabilities. These get mirrored
|
||||
* from `glbHWConfig' when creating a new context...
|
||||
*/
|
||||
GrSstType type;
|
||||
FxBool HavePalExt; /* PALETTE6666 */
|
||||
FxBool HavePixExt; /* PIXEXT */
|
||||
FxBool HaveTexFmt; /* TEXFMT */
|
||||
FxBool HaveCmbExt; /* COMBINE */
|
||||
FxBool HaveMirExt; /* TEXMIRROR */
|
||||
FxBool HaveTexUma; /* TEXUMA */
|
||||
FxBool HaveTexus2; /* Texus 2 - FXT1 */
|
||||
struct tdfx_glide Glide;
|
||||
char rendererString[64];
|
||||
};
|
||||
|
||||
|
||||
extern void fxSetupFXUnits(GLcontext *);
|
||||
extern void fxSetupDDPointers(GLcontext *);
|
||||
|
||||
/* fxvb.c:
|
||||
*/
|
||||
extern void fxAllocVB(GLcontext * ctx);
|
||||
extern void fxFreeVB(GLcontext * ctx);
|
||||
extern void fxPrintSetupFlags(char *msg, GLuint flags );
|
||||
extern void fxCheckTexSizes( GLcontext *ctx );
|
||||
extern void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint end,
|
||||
GLuint newinputs );
|
||||
extern void fxChooseVertexState( GLcontext *ctx );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* fxtrifuncs:
|
||||
*/
|
||||
extern void fxDDInitTriFuncs(GLcontext *);
|
||||
extern void fxDDChooseRenderState(GLcontext * ctx);
|
||||
|
||||
|
||||
extern void fxUpdateDDSpanPointers(GLcontext *);
|
||||
extern void fxSetupDDSpanPointers(GLcontext *);
|
||||
|
||||
extern void fxPrintTextureData(tfxTexInfo * ti);
|
||||
|
||||
extern const struct gl_texture_format *
|
||||
fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
|
||||
GLenum srcFormat, GLenum srcType );
|
||||
extern void fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
|
||||
GLint internalFormat, GLint width, GLint height,
|
||||
GLint border, GLenum format, GLenum type,
|
||||
const GLvoid * pixels,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage);
|
||||
extern void fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid * pixels,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage);
|
||||
extern void fxDDCompressedTexImage2D(GLcontext *ctx, GLenum target,
|
||||
GLint level, GLint internalFormat,
|
||||
GLsizei width, GLsizei height, GLint border,
|
||||
GLsizei imageSize, const GLvoid *data,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage);
|
||||
extern void fxDDCompressedTexSubImage2D(GLcontext *ctx, GLenum target,
|
||||
GLint level, GLint xoffset,
|
||||
GLint yoffset, GLsizei width,
|
||||
GLint height, GLenum format,
|
||||
GLsizei imageSize, const GLvoid *data,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage);
|
||||
extern void fxDDTexImage1D(GLcontext * ctx, GLenum target, GLint level,
|
||||
GLint internalFormat, GLint width,
|
||||
GLint border, GLenum format, GLenum type,
|
||||
const GLvoid * pixels,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage);
|
||||
extern void fxDDTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
|
||||
GLint xoffset, GLint width,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid * pixels,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage);
|
||||
extern GLboolean fxDDTestProxyTexImage (GLcontext *ctx, GLenum target,
|
||||
GLint level, GLint internalFormat,
|
||||
GLenum format, GLenum type,
|
||||
GLint width, GLint height,
|
||||
GLint depth, GLint border);
|
||||
extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *);
|
||||
extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *,
|
||||
GLenum, const GLfloat *);
|
||||
extern void fxDDTexBind(GLcontext *, GLenum, struct gl_texture_object *);
|
||||
extern struct gl_texture_object *fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target );
|
||||
extern void fxDDTexDel(GLcontext *, struct gl_texture_object *);
|
||||
extern GLboolean fxDDIsTextureResident(GLcontext *, struct gl_texture_object *);
|
||||
extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *);
|
||||
extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean);
|
||||
|
||||
extern void fxDDEnable(GLcontext *, GLenum, GLboolean);
|
||||
extern void fxDDAlphaFunc(GLcontext *, GLenum, GLfloat);
|
||||
extern void fxDDBlendFuncSeparate(GLcontext *, GLenum, GLenum, GLenum, GLenum);
|
||||
extern void fxDDBlendEquationSeparate(GLcontext *, GLenum, GLenum);
|
||||
extern void fxDDDepthMask(GLcontext *, GLboolean);
|
||||
extern void fxDDDepthFunc(GLcontext *, GLenum);
|
||||
extern void fxDDStencilFuncSeparate (GLcontext *ctx, GLenum face, GLenum func, GLint ref, GLuint mask);
|
||||
extern void fxDDStencilMaskSeparate (GLcontext *ctx, GLenum face, GLuint mask);
|
||||
extern void fxDDStencilOpSeparate (GLcontext *ctx, GLenum face, GLenum sfail, GLenum zfail, GLenum zpass);
|
||||
|
||||
extern void fxDDInitExtensions(GLcontext * ctx);
|
||||
|
||||
extern void fxTMInit(fxMesaContext ctx);
|
||||
extern void fxTMClose(fxMesaContext ctx);
|
||||
extern void fxTMRestoreTextures_NoLock(fxMesaContext ctx);
|
||||
extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint);
|
||||
extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *);
|
||||
#define fxTMMoveOutTM_NoLock fxTMMoveOutTM
|
||||
extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *);
|
||||
extern void fxTMReloadMipMapLevel(fxMesaContext, struct gl_texture_object *,
|
||||
GLint);
|
||||
extern void fxTMReloadSubMipMapLevel(fxMesaContext,
|
||||
struct gl_texture_object *, GLint, GLint,
|
||||
GLint);
|
||||
extern int fxTMCheckStartAddr (fxMesaContext fxMesa, GLint tmu, tfxTexInfo *ti);
|
||||
|
||||
extern void fxTexGetFormat(GLcontext *, GLenum, GrTextureFormat_t *, GLint *); /* [koolsmoky] */
|
||||
|
||||
extern int fxTexGetInfo(int, int, GrLOD_t *, GrAspectRatio_t *,
|
||||
float *, float *, int *, int *);
|
||||
|
||||
extern void fxDDScissor(GLcontext * ctx,
|
||||
GLint x, GLint y, GLsizei w, GLsizei h);
|
||||
extern void fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params);
|
||||
extern void fxDDColorMask(GLcontext * ctx,
|
||||
GLboolean r, GLboolean g, GLboolean b, GLboolean a);
|
||||
|
||||
extern void fxDDWriteDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
|
||||
const GLuint depth[], const GLubyte mask[]);
|
||||
|
||||
extern void fxDDReadDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
|
||||
GLuint depth[]);
|
||||
|
||||
extern void fxDDWriteDepthPixels(GLcontext * ctx, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
const GLuint depth[], const GLubyte mask[]);
|
||||
|
||||
extern void fxDDReadDepthPixels(GLcontext * ctx, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
GLuint depth[]);
|
||||
|
||||
extern void fxDDShadeModel(GLcontext * ctx, GLenum mode);
|
||||
|
||||
extern void fxDDCullFace(GLcontext * ctx, GLenum mode);
|
||||
extern void fxDDFrontFace(GLcontext * ctx, GLenum mode);
|
||||
|
||||
extern void fxPrintRenderState(const char *msg, GLuint state);
|
||||
extern void fxPrintHintState(const char *msg, GLuint state);
|
||||
|
||||
extern int fxDDInitFxMesaContext(fxMesaContext fxMesa);
|
||||
extern void fxDDDestroyFxMesaContext(fxMesaContext fxMesa);
|
||||
|
||||
|
||||
extern void fxSetScissorValues(GLcontext * ctx);
|
||||
extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
|
||||
struct gl_texture_object *tObj, GLint where);
|
||||
|
||||
extern void fxCheckIsInHardware(GLcontext *ctx);
|
||||
|
||||
/* fxsetup:
|
||||
* semi-private functions
|
||||
*/
|
||||
void fxSetupCull (GLcontext * ctx);
|
||||
void fxSetupScissor (GLcontext * ctx);
|
||||
void fxSetupColorMask (GLcontext * ctx);
|
||||
void fxSetupBlend (GLcontext *ctx);
|
||||
void fxSetupDepthTest (GLcontext *ctx);
|
||||
void fxSetupTexture (GLcontext *ctx);
|
||||
void fxSetupStencil (GLcontext *ctx);
|
||||
void fxSetupStencilFace (GLcontext *ctx, GLint face);
|
||||
|
||||
/* Flags for software fallback cases */
|
||||
#define FX_FALLBACK_TEXTURE_MAP 0x0001
|
||||
#define FX_FALLBACK_DRAW_BUFFER 0x0002
|
||||
#define FX_FALLBACK_SPECULAR 0x0004
|
||||
#define FX_FALLBACK_STENCIL 0x0008
|
||||
#define FX_FALLBACK_RENDER_MODE 0x0010
|
||||
#define FX_FALLBACK_LOGICOP 0x0020
|
||||
#define FX_FALLBACK_TEXTURE_ENV 0x0040
|
||||
#define FX_FALLBACK_TEXTURE_BORDER 0x0080
|
||||
#define FX_FALLBACK_COLORMASK 0x0100
|
||||
#define FX_FALLBACK_BLEND 0x0200
|
||||
#define FX_FALLBACK_TEXTURE_MULTI 0x0400
|
||||
|
||||
extern GLuint fx_check_IsInHardware(GLcontext *ctx);
|
||||
|
||||
/***
|
||||
*** CNORM: clamp float to [0,1] and map to float in [0,255]
|
||||
***/
|
||||
#if defined(USE_IEEE) && !defined(DEBUG)
|
||||
#define IEEE_0996 0x3f7f0000 /* 0.996 or so */
|
||||
#define CNORM(N, F) \
|
||||
do { \
|
||||
fi_type __tmp; \
|
||||
__tmp.f = (F); \
|
||||
if (__tmp.i < 0) \
|
||||
N = 0; \
|
||||
else if (__tmp.i >= IEEE_0996) \
|
||||
N = 255.0f; \
|
||||
else { \
|
||||
N = (F) * 255.0f; \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define CNORM(n, f) \
|
||||
n = (CLAMP((f), 0.0F, 1.0F) * 255.0F)
|
||||
#endif
|
||||
|
||||
/* run-time debugging */
|
||||
#ifndef FX_DEBUG
|
||||
#define FX_DEBUG 0
|
||||
#endif
|
||||
#if FX_DEBUG
|
||||
extern int TDFX_DEBUG;
|
||||
#else
|
||||
#define TDFX_DEBUG 0
|
||||
#endif
|
||||
|
||||
/* dirty hacks */
|
||||
#define FX_RESCALE_BIG_TEXURES_HACK 1
|
||||
#define FX_COMPRESS_S3TC_AS_FXT1_HACK 1
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,382 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 5.0.1
|
||||
*
|
||||
* Copyright (C) 1999-2003 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mesa/FX device driver. Interface to Glide3.
|
||||
*
|
||||
* Copyright (c) 2003 - Daniel Borca
|
||||
* Email : dborca@users.sourceforge.net
|
||||
* Web : http://www.geocities.com/dborca
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TDFX_GLIDE_H_included
|
||||
#define TDFX_GLIDE_H_included
|
||||
|
||||
#include <glide.h>
|
||||
#include <g3ext.h>
|
||||
|
||||
#ifndef FX_TRAP_GLIDE
|
||||
#define FX_TRAP_GLIDE 0
|
||||
#endif
|
||||
|
||||
#if FX_TRAP_GLIDE
|
||||
/*
|
||||
** rendering functions
|
||||
*/
|
||||
void FX_CALL trap_grDrawPoint (const void *pt);
|
||||
void FX_CALL trap_grDrawLine (const void *v1, const void *v2);
|
||||
void FX_CALL trap_grDrawTriangle (const void *a, const void *b, const void *c);
|
||||
void FX_CALL trap_grVertexLayout (FxU32 param, FxI32 offset, FxU32 mode);
|
||||
void FX_CALL trap_grDrawVertexArray (FxU32 mode, FxU32 Count, void *pointers);
|
||||
void FX_CALL trap_grDrawVertexArrayContiguous (FxU32 mode, FxU32 Count, void *pointers, FxU32 stride);
|
||||
|
||||
/*
|
||||
** Antialiasing Functions
|
||||
*/
|
||||
void FX_CALL trap_grAADrawTriangle (const void *a, const void *b, const void *c, FxBool ab_antialias, FxBool bc_antialias, FxBool ca_antialias);
|
||||
|
||||
/*
|
||||
** buffer management
|
||||
*/
|
||||
void FX_CALL trap_grBufferClear (GrColor_t color, GrAlpha_t alpha, FxU32 depth);
|
||||
void FX_CALL trap_grBufferSwap (FxU32 swap_interval);
|
||||
void FX_CALL trap_grRenderBuffer (GrBuffer_t buffer);
|
||||
|
||||
/*
|
||||
** error management
|
||||
*/
|
||||
void FX_CALL trap_grErrorSetCallback (GrErrorCallbackFnc_t fnc);
|
||||
|
||||
/*
|
||||
** SST routines
|
||||
*/
|
||||
void FX_CALL trap_grFinish (void);
|
||||
void FX_CALL trap_grFlush (void);
|
||||
GrContext_t FX_CALL trap_grSstWinOpen (FxU32 hWnd, GrScreenResolution_t screen_resolution, GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers);
|
||||
FxBool FX_CALL trap_grSstWinClose (GrContext_t context);
|
||||
FxBool FX_CALL trap_grSelectContext (GrContext_t context);
|
||||
void FX_CALL trap_grSstOrigin (GrOriginLocation_t origin);
|
||||
void FX_CALL trap_grSstSelect (int which_sst);
|
||||
|
||||
/*
|
||||
** Glide configuration and special effect maintenance functions
|
||||
*/
|
||||
void FX_CALL trap_grAlphaBlendFunction (GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df, GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df);
|
||||
void FX_CALL trap_grAlphaCombine (GrCombineFunction_t function, GrCombineFactor_t factor, GrCombineLocal_t local, GrCombineOther_t other, FxBool invert);
|
||||
void FX_CALL trap_grAlphaControlsITRGBLighting (FxBool enable);
|
||||
void FX_CALL trap_grAlphaTestFunction (GrCmpFnc_t function);
|
||||
void FX_CALL trap_grAlphaTestReferenceValue (GrAlpha_t value);
|
||||
void FX_CALL trap_grChromakeyMode (GrChromakeyMode_t mode);
|
||||
void FX_CALL trap_grChromakeyValue (GrColor_t value);
|
||||
void FX_CALL trap_grClipWindow (FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy);
|
||||
void FX_CALL trap_grColorCombine (GrCombineFunction_t function, GrCombineFactor_t factor, GrCombineLocal_t local, GrCombineOther_t other, FxBool invert);
|
||||
void FX_CALL trap_grColorMask (FxBool rgb, FxBool a);
|
||||
void FX_CALL trap_grCullMode (GrCullMode_t mode);
|
||||
void FX_CALL trap_grConstantColorValue (GrColor_t value);
|
||||
void FX_CALL trap_grDepthBiasLevel (FxI32 level);
|
||||
void FX_CALL trap_grDepthBufferFunction (GrCmpFnc_t function);
|
||||
void FX_CALL trap_grDepthBufferMode (GrDepthBufferMode_t mode);
|
||||
void FX_CALL trap_grDepthMask (FxBool mask);
|
||||
void FX_CALL trap_grDisableAllEffects (void);
|
||||
void FX_CALL trap_grDitherMode (GrDitherMode_t mode);
|
||||
void FX_CALL trap_grFogColorValue (GrColor_t fogcolor);
|
||||
void FX_CALL trap_grFogMode (GrFogMode_t mode);
|
||||
void FX_CALL trap_grFogTable (const GrFog_t ft[]);
|
||||
void FX_CALL trap_grLoadGammaTable (FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue);
|
||||
void FX_CALL trap_grSplash (float x, float y, float width, float height, FxU32 frame);
|
||||
FxU32 FX_CALL trap_grGet (FxU32 pname, FxU32 plength, FxI32 *params);
|
||||
const char * FX_CALL trap_grGetString (FxU32 pname);
|
||||
FxI32 FX_CALL trap_grQueryResolutions (const GrResolution *resTemplate, GrResolution *output);
|
||||
FxBool FX_CALL trap_grReset (FxU32 what);
|
||||
GrProc FX_CALL trap_grGetProcAddress (char *procName);
|
||||
void FX_CALL trap_grEnable (GrEnableMode_t mode);
|
||||
void FX_CALL trap_grDisable (GrEnableMode_t mode);
|
||||
void FX_CALL trap_grCoordinateSpace (GrCoordinateSpaceMode_t mode);
|
||||
void FX_CALL trap_grDepthRange (FxFloat n, FxFloat f);
|
||||
void FX_CALL trap_grStippleMode (GrStippleMode_t mode);
|
||||
void FX_CALL trap_grStipplePattern (GrStipplePattern_t mode);
|
||||
void FX_CALL trap_grViewport (FxI32 x, FxI32 y, FxI32 width, FxI32 height);
|
||||
|
||||
/*
|
||||
** texture mapping control functions
|
||||
*/
|
||||
FxU32 FX_CALL trap_grTexCalcMemRequired (GrLOD_t lodmin, GrLOD_t lodmax, GrAspectRatio_t aspect, GrTextureFormat_t fmt);
|
||||
FxU32 FX_CALL trap_grTexTextureMemRequired (FxU32 evenOdd, GrTexInfo *info);
|
||||
FxU32 FX_CALL trap_grTexMinAddress (GrChipID_t tmu);
|
||||
FxU32 FX_CALL trap_grTexMaxAddress (GrChipID_t tmu);
|
||||
void FX_CALL trap_grTexNCCTable (GrNCCTable_t table);
|
||||
void FX_CALL trap_grTexSource (GrChipID_t tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info);
|
||||
void FX_CALL trap_grTexClampMode (GrChipID_t tmu, GrTextureClampMode_t s_clampmode, GrTextureClampMode_t t_clampmode);
|
||||
void FX_CALL trap_grTexCombine (GrChipID_t tmu, GrCombineFunction_t rgb_function, GrCombineFactor_t rgb_factor, GrCombineFunction_t alpha_function, GrCombineFactor_t alpha_factor, FxBool rgb_invert, FxBool alpha_invert);
|
||||
void FX_CALL trap_grTexDetailControl (GrChipID_t tmu, int lod_bias, FxU8 detail_scale, float detail_max);
|
||||
void FX_CALL trap_grTexFilterMode (GrChipID_t tmu, GrTextureFilterMode_t minfilter_mode, GrTextureFilterMode_t magfilter_mode);
|
||||
void FX_CALL trap_grTexLodBiasValue (GrChipID_t tmu, float bias);
|
||||
void FX_CALL trap_grTexDownloadMipMap (GrChipID_t tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info);
|
||||
void FX_CALL trap_grTexDownloadMipMapLevel (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 evenOdd, void *data);
|
||||
FxBool FX_CALL trap_grTexDownloadMipMapLevelPartial (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 evenOdd, void *data, int start, int end);
|
||||
void FX_CALL trap_grTexDownloadTable (GrTexTable_t type, void *data);
|
||||
void FX_CALL trap_grTexDownloadTablePartial (GrTexTable_t type, void *data, int start, int end);
|
||||
void FX_CALL trap_grTexMipMapMode (GrChipID_t tmu, GrMipMapMode_t mode, FxBool lodBlend);
|
||||
void FX_CALL trap_grTexMultibase (GrChipID_t tmu, FxBool enable);
|
||||
void FX_CALL trap_grTexMultibaseAddress (GrChipID_t tmu, GrTexBaseRange_t range, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info);
|
||||
|
||||
/*
|
||||
** linear frame buffer functions
|
||||
*/
|
||||
FxBool FX_CALL trap_grLfbLock (GrLock_t type, GrBuffer_t buffer, GrLfbWriteMode_t writeMode, GrOriginLocation_t origin, FxBool pixelPipeline, GrLfbInfo_t *info);
|
||||
FxBool FX_CALL trap_grLfbUnlock (GrLock_t type, GrBuffer_t buffer);
|
||||
void FX_CALL trap_grLfbConstantAlpha (GrAlpha_t alpha);
|
||||
void FX_CALL trap_grLfbConstantDepth (FxU32 depth);
|
||||
void FX_CALL trap_grLfbWriteColorSwizzle (FxBool swizzleBytes, FxBool swapWords);
|
||||
void FX_CALL trap_grLfbWriteColorFormat (GrColorFormat_t colorFormat);
|
||||
FxBool FX_CALL trap_grLfbWriteRegion (GrBuffer_t dst_buffer, FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format, FxU32 src_width, FxU32 src_height, FxBool pixelPipeline, FxI32 src_stride, void *src_data);
|
||||
FxBool FX_CALL trap_grLfbReadRegion (GrBuffer_t src_buffer, FxU32 src_x, FxU32 src_y, FxU32 src_width, FxU32 src_height, FxU32 dst_stride, void *dst_data);
|
||||
|
||||
/*
|
||||
** glide management functions
|
||||
*/
|
||||
void FX_CALL trap_grGlideInit (void);
|
||||
void FX_CALL trap_grGlideShutdown (void);
|
||||
void FX_CALL trap_grGlideGetState (void *state);
|
||||
void FX_CALL trap_grGlideSetState (const void *state);
|
||||
void FX_CALL trap_grGlideGetVertexLayout (void *layout);
|
||||
void FX_CALL trap_grGlideSetVertexLayout (const void *layout);
|
||||
|
||||
/*
|
||||
** glide utility functions
|
||||
*/
|
||||
void FX_CALL trap_guGammaCorrectionRGB (FxFloat red, FxFloat green, FxFloat blue);
|
||||
float FX_CALL trap_guFogTableIndexToW (int i);
|
||||
void FX_CALL trap_guFogGenerateExp (GrFog_t *fogtable, float density);
|
||||
void FX_CALL trap_guFogGenerateExp2 (GrFog_t *fogtable, float density);
|
||||
void FX_CALL trap_guFogGenerateLinear (GrFog_t *fogtable, float nearZ, float farZ);
|
||||
|
||||
#ifndef FX_TRAP_GLIDE_internal
|
||||
/*
|
||||
** rendering functions
|
||||
*/
|
||||
#define grDrawPoint trap_grDrawPoint
|
||||
#define grDrawLine trap_grDrawLine
|
||||
#define grDrawTriangle trap_grDrawTriangle
|
||||
#define grVertexLayout trap_grVertexLayout
|
||||
#define grDrawVertexArray trap_grDrawVertexArray
|
||||
#define grDrawVertexArrayContiguous trap_grDrawVertexArrayContiguous
|
||||
|
||||
/*
|
||||
** Antialiasing Functions
|
||||
*/
|
||||
#define grAADrawTriangle trap_grAADrawTriangle
|
||||
|
||||
/*
|
||||
** buffer management
|
||||
*/
|
||||
#define grBufferClear trap_grBufferClear
|
||||
#define grBufferSwap trap_grBufferSwap
|
||||
#define grRenderBuffer trap_grRenderBuffer
|
||||
|
||||
/*
|
||||
** error management
|
||||
*/
|
||||
#define grErrorSetCallback trap_grErrorSetCallback
|
||||
|
||||
/*
|
||||
** SST routines
|
||||
*/
|
||||
#define grFinish trap_grFinish
|
||||
#define grFlush trap_grFlush
|
||||
#define grSstWinOpen trap_grSstWinOpen
|
||||
#define grSstWinClose trap_grSstWinClose
|
||||
#define grSelectContext trap_grSelectContext
|
||||
#define grSstOrigin trap_grSstOrigin
|
||||
#define grSstSelect trap_grSstSelect
|
||||
|
||||
/*
|
||||
** Glide configuration and special effect maintenance functions
|
||||
*/
|
||||
#define grAlphaBlendFunction trap_grAlphaBlendFunction
|
||||
#define grAlphaCombine trap_grAlphaCombine
|
||||
#define grAlphaControlsITRGBLighting trap_grAlphaControlsITRGBLighting
|
||||
#define grAlphaTestFunction trap_grAlphaTestFunction
|
||||
#define grAlphaTestReferenceValue trap_grAlphaTestReferenceValue
|
||||
#define grChromakeyMode trap_grChromakeyMode
|
||||
#define grChromakeyValue trap_grChromakeyValue
|
||||
#define grClipWindow trap_grClipWindow
|
||||
#define grColorCombine trap_grColorCombine
|
||||
#define grColorMask trap_grColorMask
|
||||
#define grCullMode trap_grCullMode
|
||||
#define grConstantColorValue trap_grConstantColorValue
|
||||
#define grDepthBiasLevel trap_grDepthBiasLevel
|
||||
#define grDepthBufferFunction trap_grDepthBufferFunction
|
||||
#define grDepthBufferMode trap_grDepthBufferMode
|
||||
#define grDepthMask trap_grDepthMask
|
||||
#define grDisableAllEffects trap_grDisableAllEffects
|
||||
#define grDitherMode trap_grDitherMode
|
||||
#define grFogColorValue trap_grFogColorValue
|
||||
#define grFogMode trap_grFogMode
|
||||
#define grFogTable trap_grFogTable
|
||||
#define grLoadGammaTable trap_grLoadGammaTable
|
||||
#define grSplash trap_grSplash
|
||||
#define grGet trap_grGet
|
||||
#define grGetString trap_grGetString
|
||||
#define grQueryResolutions trap_grQueryResolutions
|
||||
#define grReset trap_grReset
|
||||
#define grGetProcAddress trap_grGetProcAddress
|
||||
#define grEnable trap_grEnable
|
||||
#define grDisable trap_grDisable
|
||||
#define grCoordinateSpace trap_grCoordinateSpace
|
||||
#define grDepthRange trap_grDepthRange
|
||||
#define grStippleMode trap_grStippleMode
|
||||
#define grStipplePattern trap_grStipplePattern
|
||||
#define grViewport trap_grViewport
|
||||
|
||||
/*
|
||||
** texture mapping control functions
|
||||
*/
|
||||
#define grTexCalcMemRequired trap_grTexCalcMemRequired
|
||||
#define grTexTextureMemRequired trap_grTexTextureMemRequired
|
||||
#define grTexMinAddress trap_grTexMinAddress
|
||||
#define grTexMaxAddress trap_grTexMaxAddress
|
||||
#define grTexNCCTable trap_grTexNCCTable
|
||||
#define grTexSource trap_grTexSource
|
||||
#define grTexClampMode trap_grTexClampMode
|
||||
#define grTexCombine trap_grTexCombine
|
||||
#define grTexDetailControl trap_grTexDetailControl
|
||||
#define grTexFilterMode trap_grTexFilterMode
|
||||
#define grTexLodBiasValue trap_grTexLodBiasValue
|
||||
#define grTexDownloadMipMap trap_grTexDownloadMipMap
|
||||
#define grTexDownloadMipMapLevel trap_grTexDownloadMipMapLevel
|
||||
#define grTexDownloadMipMapLevelPartial trap_grTexDownloadMipMapLevelPartial
|
||||
#define grTexDownloadTable trap_grTexDownloadTable
|
||||
#define grTexDownloadTablePartial trap_grTexDownloadTablePartial
|
||||
#define grTexMipMapMode trap_grTexMipMapMode
|
||||
#define grTexMultibase trap_grTexMultibase
|
||||
#define grTexMultibaseAddress trap_grTexMultibaseAddress
|
||||
|
||||
/*
|
||||
** linear frame buffer functions
|
||||
*/
|
||||
#define grLfbLock trap_grLfbLock
|
||||
#define grLfbUnlock trap_grLfbUnlock
|
||||
#define grLfbConstantAlpha trap_grLfbConstantAlpha
|
||||
#define grLfbConstantDepth trap_grLfbConstantDepth
|
||||
#define grLfbWriteColorSwizzle trap_grLfbWriteColorSwizzle
|
||||
#define grLfbWriteColorFormat trap_grLfbWriteColorFormat
|
||||
#define grLfbWriteRegion trap_grLfbWriteRegion
|
||||
#define grLfbReadRegion trap_grLfbReadRegion
|
||||
|
||||
/*
|
||||
** glide management functions
|
||||
*/
|
||||
#define grGlideInit trap_grGlideInit
|
||||
#define grGlideShutdown trap_grGlideShutdown
|
||||
#define grGlideGetState trap_grGlideGetState
|
||||
#define grGlideSetState trap_grGlideSetState
|
||||
#define grGlideGetVertexLayout trap_grGlideGetVertexLayout
|
||||
#define grGlideSetVertexLayout trap_grGlideSetVertexLayout
|
||||
|
||||
/*
|
||||
** glide utility functions
|
||||
*/
|
||||
#define guGammaCorrectionRGB trap_guGammaCorrectionRGB
|
||||
#define guFogTableIndexToW trap_guFogTableIndexToW
|
||||
#define guFogGenerateExp trap_guFogGenerateExp
|
||||
#define guFogGenerateExp2 trap_guFogGenerateExp2
|
||||
#define guFogGenerateLinear trap_guFogGenerateLinear
|
||||
#endif /* FX_TRAP_GLIDE_internal */
|
||||
#endif /* FX_TRAP_GLIDE */
|
||||
|
||||
|
||||
|
||||
/* <texus.h> */
|
||||
#define TX_MAX_LEVEL 16
|
||||
typedef struct _TxMip {
|
||||
int format;
|
||||
int width;
|
||||
int height;
|
||||
int depth;
|
||||
int size;
|
||||
void *data[TX_MAX_LEVEL];
|
||||
FxU32 pal[256];
|
||||
} TxMip;
|
||||
|
||||
#define TX_DITHER_NONE 0x00000000
|
||||
#define TX_DITHER_4x4 0x00000001
|
||||
#define TX_DITHER_ERR 0x00000002
|
||||
|
||||
#define TX_COMPRESSION_STATISTICAL 0x00000000
|
||||
#define TX_COMPRESSION_HEURISTIC 0x00000010
|
||||
/* <texus.h> */
|
||||
|
||||
|
||||
|
||||
struct tdfx_glide {
|
||||
/*
|
||||
** glide extensions
|
||||
*/
|
||||
void (FX_CALL *grSetNumPendingBuffers) (FxI32 NumPendingBuffers);
|
||||
char * (FX_CALL *grGetRegistryOrEnvironmentStringExt) (char *theEntry);
|
||||
void (FX_CALL *grGetGammaTableExt) (FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue);
|
||||
void (FX_CALL *grChromaRangeModeExt) (GrChromakeyMode_t mode);
|
||||
void (FX_CALL *grChromaRangeExt) (GrColor_t color, GrColor_t range, GrChromaRangeMode_t match_mode);
|
||||
void (FX_CALL *grTexChromaModeExt) (GrChipID_t tmu, GrChromakeyMode_t mode);
|
||||
void (FX_CALL *grTexChromaRangeExt) (GrChipID_t tmu, GrColor_t min, GrColor_t max, GrTexChromakeyMode_t mode);
|
||||
|
||||
/* pointcast */
|
||||
void (FX_CALL *grTexDownloadTableExt) (GrChipID_t tmu, GrTexTable_t type, void *data);
|
||||
void (FX_CALL *grTexDownloadTablePartialExt) (GrChipID_t tmu, GrTexTable_t type, void *data, int start, int end);
|
||||
void (FX_CALL *grTexNCCTableExt) (GrChipID_t tmu, GrNCCTable_t table);
|
||||
|
||||
/* tbext */
|
||||
void (FX_CALL *grTextureBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask);
|
||||
void (FX_CALL *grTextureAuxBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask);
|
||||
void (FX_CALL *grAuxBufferExt) (GrBuffer_t buffer);
|
||||
|
||||
/* napalm */
|
||||
GrContext_t (FX_CALL *grSstWinOpenExt) (FxU32 hWnd, GrScreenResolution_t resolution, GrScreenRefresh_t refresh, GrColorFormat_t format, GrOriginLocation_t origin, GrPixelFormat_t pixelformat, int nColBuffers, int nAuxBuffers);
|
||||
void (FX_CALL *grStencilFuncExt) (GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask);
|
||||
void (FX_CALL *grStencilMaskExt) (GrStencil_t value);
|
||||
void (FX_CALL *grStencilOpExt) (GrStencilOp_t stencil_fail, GrStencilOp_t depth_fail, GrStencilOp_t depth_pass);
|
||||
void (FX_CALL *grLfbConstantStencilExt) (GrStencil_t value);
|
||||
void (FX_CALL *grBufferClearExt) (GrColor_t color, GrAlpha_t alpha, FxU32 depth, GrStencil_t stencil);
|
||||
void (FX_CALL *grColorCombineExt) (GrCCUColor_t a, GrCombineMode_t a_mode, GrCCUColor_t b, GrCombineMode_t b_mode, GrCCUColor_t c, FxBool c_invert, GrCCUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
|
||||
void (FX_CALL *grAlphaCombineExt) (GrACUColor_t a, GrCombineMode_t a_mode, GrACUColor_t b, GrCombineMode_t b_mode, GrACUColor_t c, FxBool c_invert, GrACUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
|
||||
void (FX_CALL *grTexColorCombineExt) (GrChipID_t tmu, GrTCCUColor_t a, GrCombineMode_t a_mode, GrTCCUColor_t b, GrCombineMode_t b_mode, GrTCCUColor_t c, FxBool c_invert, GrTCCUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
|
||||
void (FX_CALL *grTexAlphaCombineExt) (GrChipID_t tmu, GrTACUColor_t a, GrCombineMode_t a_mode, GrTACUColor_t b, GrCombineMode_t b_mode, GrTACUColor_t c, FxBool c_invert, GrTACUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
|
||||
void (FX_CALL *grConstantColorValueExt) (GrChipID_t tmu, GrColor_t value);
|
||||
void (FX_CALL *grColorMaskExt) (FxBool r, FxBool g, FxBool b, FxBool a);
|
||||
void (FX_CALL *grAlphaBlendFunctionExt) (GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df, GrAlphaBlendOp_t rgb_op, GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df, GrAlphaBlendOp_t alpha_op);
|
||||
void (FX_CALL *grTBufferWriteMaskExt) (FxU32 tmask);
|
||||
|
||||
/*
|
||||
** Texus2 functions
|
||||
*/
|
||||
void (FX_CALL *txImgQuantize) (char *dst, char *src, int w, int h, FxU32 format, FxU32 dither);
|
||||
void (FX_CALL *txMipQuantize) (TxMip *pxMip, TxMip *txMip, int fmt, FxU32 d, FxU32 comp);
|
||||
void (FX_CALL *txPalToNcc) (GuNccTable *ncc_table, const FxU32 *pal);
|
||||
};
|
||||
|
||||
void tdfx_hook_glide (struct tdfx_glide *Glide, int pointcast);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,269 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.0
|
||||
*
|
||||
* Copyright (C) 1999-2001 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.
|
||||
*/
|
||||
|
||||
/* Authors:
|
||||
* David Bucciarelli
|
||||
* Brian Paul
|
||||
* Daryll Strauss
|
||||
* Keith Whitwell
|
||||
* Daniel Borca
|
||||
* Hiroshi Morii
|
||||
*/
|
||||
|
||||
/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "conf.h"
|
||||
#endif
|
||||
|
||||
#if defined(FX)
|
||||
#include "fxglidew.h"
|
||||
#include "fxdrv.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
FxI32
|
||||
FX_grGetInteger_NoLock(FxU32 pname)
|
||||
{
|
||||
FxI32 result;
|
||||
|
||||
if (grGet(pname, 4, &result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "FX_grGetInteger_NoLock: wrong parameter (%lx)\n", pname);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
FxBool
|
||||
FX_grSstControl(FxU32 code)
|
||||
{
|
||||
/* The glide 3 sources call for grEnable/grDisable to be called in exchange
|
||||
* for grSstControl. */
|
||||
switch (code) {
|
||||
case GR_CONTROL_ACTIVATE:
|
||||
grEnable(GR_PASSTHRU);
|
||||
break;
|
||||
case GR_CONTROL_DEACTIVATE:
|
||||
grDisable(GR_PASSTHRU);
|
||||
break;
|
||||
}
|
||||
/* Appearently GR_CONTROL_RESIZE can be ignored. */
|
||||
return 1; /* OK? */
|
||||
}
|
||||
|
||||
|
||||
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_grSstPerfStats(GrSstPerfStats_t * st)
|
||||
{
|
||||
FxI32 n;
|
||||
grGet(GR_STATS_PIXELS_IN, 4, &n);
|
||||
st->pixelsIn = n;
|
||||
grGet(GR_STATS_PIXELS_CHROMA_FAIL, 4, &n);
|
||||
st->chromaFail = n;
|
||||
grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, 4, &n);
|
||||
st->zFuncFail = n;
|
||||
grGet(GR_STATS_PIXELS_AFUNC_FAIL, 4, &n);
|
||||
st->aFuncFail = n;
|
||||
grGet(GR_STATS_PIXELS_OUT, 4, &n);
|
||||
st->pixelsOut = n;
|
||||
}
|
||||
|
||||
void
|
||||
FX_setupGrVertexLayout(void)
|
||||
{
|
||||
BEGIN_BOARD_LOCK();
|
||||
grReset(GR_VERTEX_PARAMETER);
|
||||
|
||||
grCoordinateSpace(GR_WINDOW_COORDS);
|
||||
grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
|
||||
#if FX_PACKEDCOLOR
|
||||
grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE);
|
||||
#else /* !FX_PACKEDCOLOR */
|
||||
grVertexLayout(GR_PARAM_RGB, GR_VERTEX_RGB_OFFSET << 2, GR_PARAM_ENABLE);
|
||||
grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);
|
||||
#endif /* !FX_PACKEDCOLOR */
|
||||
grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
|
||||
grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
|
||||
grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2,
|
||||
GR_PARAM_ENABLE);
|
||||
grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,
|
||||
GR_PARAM_DISABLE);
|
||||
grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2,
|
||||
GR_PARAM_DISABLE);
|
||||
grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2,
|
||||
GR_PARAM_DISABLE);
|
||||
END_BOARD_LOCK();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Glide3 doesn't have the grSstQueryHardware function anymore.
|
||||
* Instead, we call grGet() and fill in the data structures ourselves.
|
||||
*/
|
||||
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;
|
||||
|
||||
for (i = 0; i < config->num_sst; i++) {
|
||||
FxI32 result;
|
||||
const char *extension;
|
||||
|
||||
grSstSelect(i);
|
||||
|
||||
extension = grGetString(GR_HARDWARE);
|
||||
if (strstr(extension, "Rush")) {
|
||||
config->SSTs[i].type = GR_SSTTYPE_SST96;
|
||||
} else if (strstr(extension, "Voodoo2")) {
|
||||
config->SSTs[i].type = GR_SSTTYPE_Voodoo2;
|
||||
} else if (strstr(extension, "Voodoo Banshee")) {
|
||||
config->SSTs[i].type = GR_SSTTYPE_Banshee;
|
||||
} else if (strstr(extension, "Voodoo3")) {
|
||||
config->SSTs[i].type = GR_SSTTYPE_Voodoo3;
|
||||
} else if (strstr(extension, "Voodoo4")) {
|
||||
config->SSTs[i].type = GR_SSTTYPE_Voodoo4;
|
||||
} else if (strstr(extension, "Voodoo5")) {
|
||||
config->SSTs[i].type = GR_SSTTYPE_Voodoo5;
|
||||
} else {
|
||||
config->SSTs[i].type = GR_SSTTYPE_VOODOO;
|
||||
}
|
||||
|
||||
grGet(GR_MEMORY_FB, 4, &result);
|
||||
config->SSTs[i].fbRam = result / (1024 * 1024);
|
||||
|
||||
grGet(GR_NUM_TMU, 4, &result);
|
||||
config->SSTs[i].nTexelfx = result;
|
||||
|
||||
grGet(GR_REVISION_FB, 4, &result);
|
||||
config->SSTs[i].fbiRev = result;
|
||||
|
||||
for (j = 0; j < config->SSTs[i].nTexelfx; j++) {
|
||||
grGet(GR_MEMORY_TMU, 4, &result);
|
||||
config->SSTs[i].tmuConfig[j].tmuRam = result / (1024 * 1024);
|
||||
grGet(GR_REVISION_TMU, 4, &result);
|
||||
config->SSTs[i].tmuConfig[j].tmuRev = result;
|
||||
}
|
||||
|
||||
extension = grGetString(GR_EXTENSION);
|
||||
config->SSTs[i].HavePalExt = (strstr(extension, " PALETTE6666 ") != NULL);
|
||||
config->SSTs[i].HavePixExt = (strstr(extension, " PIXEXT ") != NULL);
|
||||
config->SSTs[i].HaveTexFmt = (strstr(extension, " TEXFMT ") != NULL);
|
||||
config->SSTs[i].HaveCmbExt = (strstr(extension, " COMBINE ") != NULL);
|
||||
config->SSTs[i].HaveMirExt = (strstr(extension, " TEXMIRROR ") != NULL);
|
||||
config->SSTs[i].HaveTexUma = (strstr(extension, " TEXUMA ") != NULL);
|
||||
|
||||
/* number of Voodoo chips */
|
||||
grGet(GR_NUM_FB, 4, (void *) &numFB);
|
||||
config->SSTs[i].numChips = numFB;
|
||||
|
||||
}
|
||||
|
||||
tdfx_hook_glide(&config->Glide, getenv("MESA_FX_POINTCAST") != NULL);
|
||||
|
||||
END_BOARD_LOCK();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Need this to provide at least one external definition.
|
||||
*/
|
||||
|
||||
extern int gl_fx_dummy_function_glidew(void);
|
||||
int
|
||||
gl_fx_dummy_function_glidew(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* FX */
|
||||
|
|
@ -1,228 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.0
|
||||
*
|
||||
* Copyright (C) 1999-2001 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.
|
||||
*/
|
||||
|
||||
/* Authors:
|
||||
* David Bucciarelli
|
||||
* Brian Paul
|
||||
* Daryll Strauss
|
||||
* Keith Whitwell
|
||||
* Daniel Borca
|
||||
* Hiroshi Morii
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __FX_GLIDE_WARPER__
|
||||
#define __FX_GLIDE_WARPER__
|
||||
|
||||
|
||||
#include "fxg.h"
|
||||
|
||||
#ifndef FX_PACKEDCOLOR
|
||||
#define FX_PACKEDCOLOR 1
|
||||
#endif
|
||||
|
||||
#define MAX_NUM_SST 4
|
||||
|
||||
enum {
|
||||
GR_SSTTYPE_VOODOO = 0,
|
||||
GR_SSTTYPE_SST96 = 1,
|
||||
GR_SSTTYPE_AT3D = 2,
|
||||
GR_SSTTYPE_Voodoo2 = 3,
|
||||
GR_SSTTYPE_Banshee = 4,
|
||||
GR_SSTTYPE_Voodoo3 = 5,
|
||||
GR_SSTTYPE_Voodoo4 = 6,
|
||||
GR_SSTTYPE_Voodoo5 = 7
|
||||
};
|
||||
|
||||
#define GrState void
|
||||
|
||||
typedef int GrSstType;
|
||||
|
||||
typedef struct GrTMUConfig_St {
|
||||
int tmuRev; /* Rev of Texelfx chip */
|
||||
int tmuRam; /* 1, 2, or 4 MB */
|
||||
} GrTMUConfig_t;
|
||||
|
||||
typedef struct {
|
||||
int num_sst; /* # of HW units in the system */
|
||||
struct SstCard_St {
|
||||
GrSstType type; /* Which hardware is it? */
|
||||
int fbRam; /* 1, 2, or 4 MB */
|
||||
int fbiRev; /* Rev of Pixelfx chip */
|
||||
int nTexelfx; /* How many texelFX chips are there? */
|
||||
int numChips; /* Number of Voodoo chips */
|
||||
GrTMUConfig_t tmuConfig[GLIDE_NUM_TMU]; /* Configuration of the Texelfx chips */
|
||||
/* Glide3 extensions */
|
||||
FxBool HavePalExt; /* PALETTE6666 */
|
||||
FxBool HavePixExt; /* PIXEXT */
|
||||
FxBool HaveTexFmt; /* TEXFMT */
|
||||
FxBool HaveCmbExt; /* COMBINE */
|
||||
FxBool HaveMirExt; /* TEXMIRROR */
|
||||
FxBool HaveTexUma; /* TEXUMA */
|
||||
}
|
||||
SSTs[MAX_NUM_SST]; /* configuration for each board */
|
||||
struct tdfx_glide Glide;
|
||||
} GrHwConfiguration;
|
||||
|
||||
|
||||
|
||||
typedef FxU32 GrHint_t;
|
||||
#define GR_HINTTYPE_MIN 0
|
||||
#define GR_HINT_STWHINT 0
|
||||
|
||||
typedef FxU32 GrSTWHint_t;
|
||||
#define GR_STWHINT_W_DIFF_FBI FXBIT(0)
|
||||
#define GR_STWHINT_W_DIFF_TMU0 FXBIT(1)
|
||||
#define GR_STWHINT_ST_DIFF_TMU0 FXBIT(2)
|
||||
#define GR_STWHINT_W_DIFF_TMU1 FXBIT(3)
|
||||
#define GR_STWHINT_ST_DIFF_TMU1 FXBIT(4)
|
||||
#define GR_STWHINT_W_DIFF_TMU2 FXBIT(5)
|
||||
#define GR_STWHINT_ST_DIFF_TMU2 FXBIT(6)
|
||||
|
||||
#define GR_CONTROL_ACTIVATE 1
|
||||
#define GR_CONTROL_DEACTIVATE 0
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** move the vertex layout defintion to application
|
||||
*/
|
||||
typedef struct {
|
||||
float sow; /* s texture ordinate (s over w) */
|
||||
float tow; /* t texture ordinate (t over w) */
|
||||
float oow; /* 1/w (used mipmapping - really 0xfff/w) */
|
||||
} GrTmuVertex;
|
||||
|
||||
#if FX_PACKEDCOLOR
|
||||
typedef struct {
|
||||
float x, y; /* X and Y in screen space */
|
||||
float ooz; /* 65535/Z (used for Z-buffering) */
|
||||
float oow; /* 1/W (used for W-buffering, texturing) */
|
||||
unsigned char pargb[4]; /* B, G, R, A [0..255] */
|
||||
GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
|
||||
float fog; /* fog coordinate */
|
||||
unsigned char pspec[4]; /* B, G, R, A [0..255] */
|
||||
float psize; /* point size */
|
||||
long pad[16 - 14]; /* ensure 64b structure */
|
||||
} GrVertex;
|
||||
|
||||
#define GR_VERTEX_X_OFFSET 0
|
||||
#define GR_VERTEX_Y_OFFSET 1
|
||||
#define GR_VERTEX_OOZ_OFFSET 2
|
||||
#define GR_VERTEX_OOW_OFFSET 3
|
||||
#define GR_VERTEX_PARGB_OFFSET 4
|
||||
#define GR_VERTEX_SOW_TMU0_OFFSET 5
|
||||
#define GR_VERTEX_TOW_TMU0_OFFSET 6
|
||||
#define GR_VERTEX_OOW_TMU0_OFFSET 7
|
||||
#define GR_VERTEX_SOW_TMU1_OFFSET 8
|
||||
#define GR_VERTEX_TOW_TMU1_OFFSET 9
|
||||
#define GR_VERTEX_OOW_TMU1_OFFSET 10
|
||||
#define GR_VERTEX_FOG_OFFSET 11
|
||||
#define GR_VERTEX_PSPEC_OFFSET 12
|
||||
#else /* !FX_PACKEDCOLOR */
|
||||
typedef struct {
|
||||
float x, y; /* X and Y in screen space */
|
||||
float ooz; /* 65535/Z (used for Z-buffering) */
|
||||
float oow; /* 1/W (used for W-buffering, texturing) */
|
||||
float r, g, b, a; /* R, G, B, A [0..255] */
|
||||
GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
|
||||
float fog; /* fog coordinate */
|
||||
float r1, g1, b1; /* R, G, B [0..255] */
|
||||
float psize; /* point size */
|
||||
long pad[20 - 19]; /* ensure multiple of 16 */
|
||||
} GrVertex;
|
||||
|
||||
#define GR_VERTEX_X_OFFSET 0
|
||||
#define GR_VERTEX_Y_OFFSET 1
|
||||
#define GR_VERTEX_OOZ_OFFSET 2
|
||||
#define GR_VERTEX_OOW_OFFSET 3
|
||||
#define GR_VERTEX_RGB_OFFSET 4
|
||||
#define GR_VERTEX_A_OFFSET 7
|
||||
#define GR_VERTEX_SOW_TMU0_OFFSET 8
|
||||
#define GR_VERTEX_TOW_TMU0_OFFSET 9
|
||||
#define GR_VERTEX_OOW_TMU0_OFFSET 10
|
||||
#define GR_VERTEX_SOW_TMU1_OFFSET 11
|
||||
#define GR_VERTEX_TOW_TMU1_OFFSET 12
|
||||
#define GR_VERTEX_OOW_TMU1_OFFSET 13
|
||||
#define GR_VERTEX_FOG_OFFSET 14
|
||||
#define GR_VERTEX_SPEC_OFFSET 15
|
||||
#endif /* !FX_PACKEDCOLOR */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* For Lod/LodLog2 conversion.
|
||||
*/
|
||||
#define FX_largeLodLog2(info) (info).largeLodLog2
|
||||
#define FX_aspectRatioLog2(info) (info).aspectRatioLog2
|
||||
#define FX_smallLodLog2(info) (info).smallLodLog2
|
||||
#define FX_lodToValue(val) ((int)(GR_LOD_LOG2_256-val))
|
||||
#define FX_largeLodValue(info) ((int)(GR_LOD_LOG2_256-(info).largeLodLog2))
|
||||
#define FX_smallLodValue(info) ((int)(GR_LOD_LOG2_256-(info).smallLodLog2))
|
||||
#define FX_valueToLod(val) ((GrLOD_t)(GR_LOD_LOG2_256-val))
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Query
|
||||
*/
|
||||
extern int FX_grSstScreenWidth(void);
|
||||
extern int FX_grSstScreenHeight(void);
|
||||
extern void FX_grSstPerfStats(GrSstPerfStats_t *st);
|
||||
extern int FX_grSstQueryHardware(GrHwConfiguration *config);
|
||||
#define FX_grGetInteger FX_grGetInteger_NoLock
|
||||
extern FxI32 FX_grGetInteger_NoLock(FxU32 pname);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* GrHints
|
||||
*/
|
||||
#define FX_grHints FX_grHints_NoLock
|
||||
extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Needed for Glide3 only, to set up Glide2 compatible vertex layout.
|
||||
*/
|
||||
extern void FX_setupGrVertexLayout(void);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* grSstControl stuff
|
||||
*/
|
||||
extern FxBool FX_grSstControl(FxU32 code);
|
||||
|
||||
#define FX_grBufferClear(c, a, d) \
|
||||
do { \
|
||||
BEGIN_CLIP_LOOP(); \
|
||||
grBufferClear(c, a, d); \
|
||||
END_CLIP_LOOP(); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
#endif /* __FX_GLIDE_WARPER__ */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,850 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.0
|
||||
*
|
||||
* Copyright (C) 1999-2001 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.
|
||||
*/
|
||||
|
||||
/* Authors:
|
||||
* David Bucciarelli
|
||||
* Brian Paul
|
||||
* Daryll Strauss
|
||||
* Keith Whitwell
|
||||
* Daniel Borca
|
||||
* Hiroshi Morii
|
||||
*/
|
||||
|
||||
/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
|
||||
/* This code belongs to fxsetup.c, but I didn't want to clutter
|
||||
* the original code with Napalm specifics, in order to keep things
|
||||
* clear -- especially for backward compatibility. I should have
|
||||
* put it into another .c file, but I didn't want to export so many
|
||||
* things...
|
||||
* The point is, Napalm uses a different technique for texture env.
|
||||
* SST1 Single texturing:
|
||||
* setup standard grTexCombine
|
||||
* fiddle with grColorCombine/grAlphaCombine
|
||||
* SST1 Multi texturing:
|
||||
* fiddle with grTexCombine/grColorCombine/grAlphaCombine
|
||||
* Napalm Single texturing:
|
||||
* setup standard grColorCombineExt/grAlphaCombineExt
|
||||
* fiddle with grTexColorCombine/grTexAlphaCombine
|
||||
* Napalm Multi texturing:
|
||||
* setup standard grColorCombineExt/grAlphaCombineExt
|
||||
* fiddle with grTexColorCombine/grTexAlphaCombine
|
||||
*/
|
||||
|
||||
/*
|
||||
* These macros are used below when handling COMBINE_EXT.
|
||||
*/
|
||||
#define TEXENV_OPERAND_INVERTED(operand) \
|
||||
(((operand) == GL_ONE_MINUS_SRC_ALPHA) \
|
||||
|| ((operand) == GL_ONE_MINUS_SRC_COLOR))
|
||||
#define TEXENV_OPERAND_ALPHA(operand) \
|
||||
(((operand) == GL_SRC_ALPHA) || ((operand) == GL_ONE_MINUS_SRC_ALPHA))
|
||||
#define TEXENV_SETUP_ARG_A(param, source, operand, iteratedAlpha) \
|
||||
switch (source) { \
|
||||
case GL_TEXTURE: \
|
||||
param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \
|
||||
break; \
|
||||
case GL_CONSTANT_EXT: \
|
||||
param = GR_CMBX_TMU_CALPHA; \
|
||||
break; \
|
||||
case GL_PRIMARY_COLOR_EXT: \
|
||||
param = GR_CMBX_ITALPHA; \
|
||||
break; \
|
||||
case GL_PREVIOUS_EXT: \
|
||||
param = iteratedAlpha; \
|
||||
break; \
|
||||
default: \
|
||||
/* \
|
||||
* This is here just to keep from getting \
|
||||
* compiler warnings. \
|
||||
*/ \
|
||||
param = GR_CMBX_ZERO; \
|
||||
break; \
|
||||
}
|
||||
|
||||
#define TEXENV_SETUP_ARG_RGB(param, source, operand, iteratedColor, iteratedAlpha) \
|
||||
if (!TEXENV_OPERAND_ALPHA(operand)) { \
|
||||
switch (source) { \
|
||||
case GL_TEXTURE: \
|
||||
param = GR_CMBX_LOCAL_TEXTURE_RGB; \
|
||||
break; \
|
||||
case GL_CONSTANT_EXT: \
|
||||
param = GR_CMBX_TMU_CCOLOR; \
|
||||
break; \
|
||||
case GL_PRIMARY_COLOR_EXT: \
|
||||
param = GR_CMBX_ITRGB; \
|
||||
break; \
|
||||
case GL_PREVIOUS_EXT: \
|
||||
param = iteratedColor; \
|
||||
break; \
|
||||
default: \
|
||||
/* \
|
||||
* This is here just to keep from getting \
|
||||
* compiler warnings. \
|
||||
*/ \
|
||||
param = GR_CMBX_ZERO; \
|
||||
break; \
|
||||
} \
|
||||
} else { \
|
||||
switch (source) { \
|
||||
case GL_TEXTURE: \
|
||||
param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \
|
||||
break; \
|
||||
case GL_CONSTANT_EXT: \
|
||||
param = GR_CMBX_TMU_CALPHA; \
|
||||
break; \
|
||||
case GL_PRIMARY_COLOR_EXT: \
|
||||
param = GR_CMBX_ITALPHA; \
|
||||
break; \
|
||||
case GL_PREVIOUS_EXT: \
|
||||
param = iteratedAlpha; \
|
||||
break; \
|
||||
default: \
|
||||
/* \
|
||||
* This is here just to keep from getting \
|
||||
* compiler warnings. \
|
||||
*/ \
|
||||
param = GR_CMBX_ZERO; \
|
||||
break; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define TEXENV_SETUP_MODE_RGB(param, operand) \
|
||||
switch (operand) { \
|
||||
case GL_SRC_COLOR: \
|
||||
case GL_SRC_ALPHA: \
|
||||
param = GR_FUNC_MODE_X; \
|
||||
break; \
|
||||
case GL_ONE_MINUS_SRC_ALPHA: \
|
||||
case GL_ONE_MINUS_SRC_COLOR: \
|
||||
param = GR_FUNC_MODE_ONE_MINUS_X; \
|
||||
break; \
|
||||
default: \
|
||||
param = GR_FUNC_MODE_ZERO; \
|
||||
break; \
|
||||
}
|
||||
|
||||
#define TEXENV_SETUP_MODE_A(param, operand) \
|
||||
switch (operand) { \
|
||||
case GL_SRC_ALPHA: \
|
||||
param = GR_FUNC_MODE_X; \
|
||||
break; \
|
||||
case GL_ONE_MINUS_SRC_ALPHA: \
|
||||
param = GR_FUNC_MODE_ONE_MINUS_X; \
|
||||
break; \
|
||||
default: \
|
||||
param = GR_FUNC_MODE_ZERO; \
|
||||
break; \
|
||||
}
|
||||
|
||||
static void
|
||||
fxSetupTextureEnvNapalm_NoLock(GLcontext * ctx, GLuint textureset, GLuint tmu, GLboolean iterated)
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[textureset];
|
||||
struct tdfx_combine_alpha_ext alphaComb;
|
||||
struct tdfx_combine_color_ext colorComb;
|
||||
const GLfloat *envColor = texUnit->EnvColor;
|
||||
GrCombineLocal_t localc, locala; /* fragmentColor/Alpha */
|
||||
GLint ifmt;
|
||||
tfxTexInfo *ti;
|
||||
struct gl_texture_object *tObj = texUnit->_Current;
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxSetupTextureEnvNapalm_NoLock(unit %u, TMU %u, iterated %d)\n",
|
||||
textureset, tmu, iterated);
|
||||
}
|
||||
|
||||
ti = fxTMGetTexInfo(tObj);
|
||||
|
||||
ifmt = ti->baseLevelInternalFormat;
|
||||
|
||||
if (iterated) {
|
||||
/* we don't have upstream TMU */
|
||||
locala = GR_CMBX_ITALPHA;
|
||||
localc = GR_CMBX_ITRGB;
|
||||
} else {
|
||||
/* we have upstream TMU */
|
||||
locala = GR_CMBX_OTHER_TEXTURE_ALPHA;
|
||||
localc = GR_CMBX_OTHER_TEXTURE_RGB;
|
||||
}
|
||||
|
||||
alphaComb.InvertD = FXFALSE;
|
||||
alphaComb.Shift = 0;
|
||||
alphaComb.Invert = FXFALSE;
|
||||
colorComb.InvertD = FXFALSE;
|
||||
colorComb.Shift = 0;
|
||||
colorComb.Invert = FXFALSE;
|
||||
|
||||
switch (texUnit->EnvMode) {
|
||||
case GL_DECAL:
|
||||
alphaComb.SourceA = locala;
|
||||
alphaComb.ModeA = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceB = GR_CMBX_ZERO;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceC = GR_CMBX_ZERO;
|
||||
alphaComb.InvertC = FXTRUE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
|
||||
colorComb.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB;
|
||||
colorComb.ModeA = GR_FUNC_MODE_X;
|
||||
colorComb.SourceB = localc;
|
||||
colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X;
|
||||
colorComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
|
||||
colorComb.InvertC = FXFALSE;
|
||||
colorComb.SourceD = GR_CMBX_B;
|
||||
break;
|
||||
case GL_MODULATE:
|
||||
if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) {
|
||||
alphaComb.SourceA = locala;
|
||||
alphaComb.ModeA = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceB = GR_CMBX_ZERO;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceC = GR_CMBX_ZERO;
|
||||
alphaComb.InvertC = FXTRUE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
} else {
|
||||
alphaComb.SourceA = locala;
|
||||
alphaComb.ModeA = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceB = GR_CMBX_ZERO;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
|
||||
alphaComb.InvertC = FXFALSE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
}
|
||||
|
||||
if (ifmt == GL_ALPHA) {
|
||||
colorComb.SourceA = localc;
|
||||
colorComb.ModeA = GR_FUNC_MODE_X;
|
||||
colorComb.SourceB = GR_CMBX_ZERO;
|
||||
colorComb.ModeB = GR_FUNC_MODE_X;
|
||||
colorComb.SourceC = GR_CMBX_ZERO;
|
||||
colorComb.InvertC = FXTRUE;
|
||||
colorComb.SourceD = GR_CMBX_ZERO;
|
||||
} else {
|
||||
colorComb.SourceA = localc;
|
||||
colorComb.ModeA = GR_FUNC_MODE_X;
|
||||
colorComb.SourceB = GR_CMBX_ZERO;
|
||||
colorComb.ModeB = GR_FUNC_MODE_X;
|
||||
colorComb.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB;
|
||||
colorComb.InvertC = FXFALSE;
|
||||
colorComb.SourceD = GR_CMBX_ZERO;
|
||||
}
|
||||
break;
|
||||
case GL_BLEND:
|
||||
if (ifmt == GL_INTENSITY) {
|
||||
alphaComb.SourceA = GR_CMBX_TMU_CALPHA;
|
||||
alphaComb.ModeA = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceB = locala;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
|
||||
alphaComb.InvertC = FXFALSE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
} else {
|
||||
alphaComb.SourceA = locala;
|
||||
alphaComb.ModeA = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceB = GR_CMBX_ZERO;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
|
||||
alphaComb.InvertC = FXFALSE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
}
|
||||
|
||||
if (ifmt == GL_ALPHA) {
|
||||
colorComb.SourceA = localc;
|
||||
colorComb.ModeA = GR_FUNC_MODE_X;
|
||||
colorComb.SourceB = GR_CMBX_ZERO;
|
||||
colorComb.ModeB = GR_FUNC_MODE_X;
|
||||
colorComb.SourceC = GR_CMBX_ZERO;
|
||||
colorComb.InvertC = FXTRUE;
|
||||
colorComb.SourceD = GR_CMBX_ZERO;
|
||||
} else {
|
||||
colorComb.SourceA = GR_CMBX_TMU_CCOLOR;
|
||||
colorComb.ModeA = GR_FUNC_MODE_X;
|
||||
colorComb.SourceB = localc;
|
||||
colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X;
|
||||
colorComb.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB;
|
||||
colorComb.InvertC = FXFALSE;
|
||||
colorComb.SourceD = GR_CMBX_B;
|
||||
}
|
||||
|
||||
fxMesa->Glide.grConstantColorValueExt(tmu,
|
||||
(((GLuint)(envColor[0] * 255.0f)) ) |
|
||||
(((GLuint)(envColor[1] * 255.0f)) << 8) |
|
||||
(((GLuint)(envColor[2] * 255.0f)) << 16) |
|
||||
(((GLuint)(envColor[3] * 255.0f)) << 24));
|
||||
break;
|
||||
case GL_REPLACE:
|
||||
if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) {
|
||||
alphaComb.SourceA = locala;
|
||||
alphaComb.ModeA = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceB = GR_CMBX_ZERO;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceC = GR_CMBX_ZERO;
|
||||
alphaComb.InvertC = FXTRUE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
} else {
|
||||
alphaComb.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA;
|
||||
alphaComb.ModeA = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceB = GR_CMBX_ZERO;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceC = GR_CMBX_ZERO;
|
||||
alphaComb.InvertC = FXTRUE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
}
|
||||
|
||||
if (ifmt == GL_ALPHA) {
|
||||
colorComb.SourceA = localc;
|
||||
colorComb.ModeA = GR_FUNC_MODE_X;
|
||||
colorComb.SourceB = GR_CMBX_ZERO;
|
||||
colorComb.ModeB = GR_FUNC_MODE_X;
|
||||
colorComb.SourceC = GR_CMBX_ZERO;
|
||||
colorComb.InvertC = FXTRUE;
|
||||
colorComb.SourceD = GR_CMBX_ZERO;
|
||||
} else {
|
||||
colorComb.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB;
|
||||
colorComb.ModeA = GR_FUNC_MODE_X;
|
||||
colorComb.SourceB = GR_CMBX_ZERO;
|
||||
colorComb.ModeB = GR_FUNC_MODE_X;
|
||||
colorComb.SourceC = GR_CMBX_ZERO;
|
||||
colorComb.InvertC = FXTRUE;
|
||||
colorComb.SourceD = GR_CMBX_ZERO;
|
||||
}
|
||||
break;
|
||||
case GL_ADD:
|
||||
if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) {
|
||||
alphaComb.SourceA = locala;
|
||||
alphaComb.ModeA = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceB = GR_CMBX_ZERO;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceC = GR_CMBX_ZERO;
|
||||
alphaComb.InvertC = FXTRUE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
} else if (ifmt == GL_INTENSITY) {
|
||||
alphaComb.SourceA = locala;
|
||||
alphaComb.ModeA = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceB = GR_CMBX_LOCAL_TEXTURE_ALPHA;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceC = GR_CMBX_ZERO;
|
||||
alphaComb.InvertC = FXTRUE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
} else {
|
||||
alphaComb.SourceA = locala;
|
||||
alphaComb.ModeA = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceB = GR_CMBX_ZERO;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_X;
|
||||
alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
|
||||
alphaComb.InvertC = FXFALSE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
}
|
||||
|
||||
if (ifmt == GL_ALPHA) {
|
||||
colorComb.SourceA = localc;
|
||||
colorComb.ModeA = GR_FUNC_MODE_X;
|
||||
colorComb.SourceB = GR_CMBX_ZERO;
|
||||
colorComb.ModeB = GR_FUNC_MODE_X;
|
||||
colorComb.SourceC = GR_CMBX_ZERO;
|
||||
colorComb.InvertC = FXTRUE;
|
||||
colorComb.SourceD = GR_CMBX_ZERO;
|
||||
} else {
|
||||
colorComb.SourceA = localc;
|
||||
colorComb.ModeA = GR_FUNC_MODE_X;
|
||||
colorComb.SourceB = GR_CMBX_LOCAL_TEXTURE_RGB;
|
||||
colorComb.ModeB = GR_FUNC_MODE_X;
|
||||
colorComb.SourceC = GR_CMBX_ZERO;
|
||||
colorComb.InvertC = FXTRUE;
|
||||
colorComb.SourceD = GR_CMBX_ZERO;
|
||||
}
|
||||
break;
|
||||
/* COMBINE_EXT */
|
||||
case GL_COMBINE_EXT:
|
||||
/* XXX todo - INCOMPLETE!!! */
|
||||
if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) {
|
||||
#if 1
|
||||
fprintf(stderr, "COMBINE_EXT: %s + %s\n",
|
||||
_mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB),
|
||||
_mesa_lookup_enum_by_nr(texUnit->Combine.ModeA));
|
||||
#else
|
||||
fprintf(stderr, "Texture Unit %d\n", textureset);
|
||||
fprintf(stderr, " GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode));
|
||||
fprintf(stderr, " GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB));
|
||||
fprintf(stderr, " GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA));
|
||||
fprintf(stderr, " GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0]));
|
||||
fprintf(stderr, " GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1]));
|
||||
fprintf(stderr, " GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2]));
|
||||
fprintf(stderr, " GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0]));
|
||||
fprintf(stderr, " GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1]));
|
||||
fprintf(stderr, " GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2]));
|
||||
fprintf(stderr, " GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0]));
|
||||
fprintf(stderr, " GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1]));
|
||||
fprintf(stderr, " GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2]));
|
||||
fprintf(stderr, " GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0]));
|
||||
fprintf(stderr, " GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1]));
|
||||
fprintf(stderr, " GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2]));
|
||||
fprintf(stderr, " GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB);
|
||||
fprintf(stderr, " GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA);
|
||||
fprintf(stderr, " GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", envColor[0], envColor[1], envColor[2], envColor[3]);
|
||||
#endif
|
||||
}
|
||||
|
||||
alphaComb.Shift = texUnit->Combine.ScaleShiftA;
|
||||
colorComb.Shift = texUnit->Combine.ScaleShiftRGB;
|
||||
|
||||
switch (texUnit->Combine.ModeRGB) {
|
||||
case GL_MODULATE:
|
||||
/* Arg0 * Arg1 == (A + 0) * C + 0 */
|
||||
TEXENV_SETUP_ARG_RGB(colorComb.SourceA,
|
||||
texUnit->Combine.SourceRGB[0],
|
||||
texUnit->Combine.OperandRGB[0],
|
||||
localc, locala);
|
||||
TEXENV_SETUP_MODE_RGB(colorComb.ModeA,
|
||||
texUnit->Combine.OperandRGB[0]);
|
||||
colorComb.SourceB = GR_CMBX_ZERO;
|
||||
colorComb.ModeB = GR_FUNC_MODE_ZERO;
|
||||
TEXENV_SETUP_ARG_RGB(colorComb.SourceC,
|
||||
texUnit->Combine.SourceRGB[1],
|
||||
texUnit->Combine.OperandRGB[1],
|
||||
localc, locala);
|
||||
colorComb.InvertC = TEXENV_OPERAND_INVERTED(
|
||||
texUnit->Combine.OperandRGB[1]);
|
||||
colorComb.SourceD = GR_CMBX_ZERO;
|
||||
break;
|
||||
case GL_REPLACE:
|
||||
/* Arg0 == (A + 0) * 1 + 0 */
|
||||
TEXENV_SETUP_ARG_RGB(colorComb.SourceA,
|
||||
texUnit->Combine.SourceRGB[0],
|
||||
texUnit->Combine.OperandRGB[0],
|
||||
localc, locala);
|
||||
TEXENV_SETUP_MODE_RGB(colorComb.ModeA,
|
||||
texUnit->Combine.OperandRGB[0]);
|
||||
colorComb.SourceB = GR_CMBX_ZERO;
|
||||
colorComb.ModeB = GR_FUNC_MODE_ZERO;
|
||||
colorComb.SourceC = GR_CMBX_ZERO;
|
||||
colorComb.InvertC = FXTRUE;
|
||||
colorComb.SourceD = GR_CMBX_ZERO;
|
||||
break;
|
||||
case GL_ADD:
|
||||
/* Arg0 + Arg1 = (A + B) * 1 + 0 */
|
||||
TEXENV_SETUP_ARG_RGB(colorComb.SourceA,
|
||||
texUnit->Combine.SourceRGB[0],
|
||||
texUnit->Combine.OperandRGB[0],
|
||||
localc, locala);
|
||||
TEXENV_SETUP_MODE_RGB(colorComb.ModeA,
|
||||
texUnit->Combine.OperandRGB[0]);
|
||||
TEXENV_SETUP_ARG_RGB(colorComb.SourceB,
|
||||
texUnit->Combine.SourceRGB[1],
|
||||
texUnit->Combine.OperandRGB[1],
|
||||
localc, locala);
|
||||
TEXENV_SETUP_MODE_RGB(colorComb.ModeB,
|
||||
texUnit->Combine.OperandRGB[1]);
|
||||
colorComb.SourceC = GR_CMBX_ZERO;
|
||||
colorComb.InvertC = FXTRUE;
|
||||
colorComb.SourceD = GR_CMBX_ZERO;
|
||||
break;
|
||||
case GL_INTERPOLATE_EXT:
|
||||
/* Arg0 * Arg2 + Arg1 * (1 - Arg2) ==
|
||||
* (Arg0 - Arg1) * Arg2 + Arg1 == (A - B) * C + D
|
||||
*/
|
||||
TEXENV_SETUP_ARG_RGB(colorComb.SourceA,
|
||||
texUnit->Combine.SourceRGB[0],
|
||||
texUnit->Combine.OperandRGB[0],
|
||||
localc, locala);
|
||||
TEXENV_SETUP_MODE_RGB(colorComb.ModeA,
|
||||
texUnit->Combine.OperandRGB[0]);
|
||||
TEXENV_SETUP_ARG_RGB(colorComb.SourceB,
|
||||
texUnit->Combine.SourceRGB[1],
|
||||
texUnit->Combine.OperandRGB[1],
|
||||
localc, locala);
|
||||
if (TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandRGB[1])) {
|
||||
/* Hack alert!!! This case is wrong!!! */
|
||||
fprintf(stderr, "COMBINE_EXT_color: WRONG!!!\n");
|
||||
colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X;
|
||||
} else {
|
||||
colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X;
|
||||
}
|
||||
/*
|
||||
* The Source/Operand for the C value must
|
||||
* specify some kind of alpha value.
|
||||
*/
|
||||
TEXENV_SETUP_ARG_A(colorComb.SourceC,
|
||||
texUnit->Combine.SourceRGB[2],
|
||||
texUnit->Combine.OperandRGB[2],
|
||||
locala);
|
||||
colorComb.InvertC = FXFALSE;
|
||||
colorComb.SourceD = GR_CMBX_B;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "COMBINE_EXT_color: %s\n",
|
||||
_mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB));
|
||||
}
|
||||
|
||||
switch (texUnit->Combine.ModeA) {
|
||||
case GL_MODULATE:
|
||||
/* Arg0 * Arg1 == (A + 0) * C + 0 */
|
||||
TEXENV_SETUP_ARG_A(alphaComb.SourceA,
|
||||
texUnit->Combine.SourceA[0],
|
||||
texUnit->Combine.OperandA[0],
|
||||
locala);
|
||||
TEXENV_SETUP_MODE_A(alphaComb.ModeA,
|
||||
texUnit->Combine.OperandA[0]);
|
||||
alphaComb.SourceB = GR_CMBX_ZERO;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_ZERO;
|
||||
TEXENV_SETUP_ARG_A(alphaComb.SourceC,
|
||||
texUnit->Combine.SourceA[1],
|
||||
texUnit->Combine.OperandA[1],
|
||||
locala);
|
||||
alphaComb.InvertC = TEXENV_OPERAND_INVERTED(
|
||||
texUnit->Combine.OperandA[1]);
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
break;
|
||||
case GL_REPLACE:
|
||||
/* Arg0 == (A + 0) * 1 + 0 */
|
||||
TEXENV_SETUP_ARG_A(alphaComb.SourceA,
|
||||
texUnit->Combine.SourceA[0],
|
||||
texUnit->Combine.OperandA[0],
|
||||
locala);
|
||||
TEXENV_SETUP_MODE_A(alphaComb.ModeA,
|
||||
texUnit->Combine.OperandA[0]);
|
||||
alphaComb.SourceB = GR_CMBX_ZERO;
|
||||
alphaComb.ModeB = GR_FUNC_MODE_ZERO;
|
||||
alphaComb.SourceC = GR_CMBX_ZERO;
|
||||
alphaComb.InvertC = FXTRUE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
break;
|
||||
case GL_ADD:
|
||||
/* Arg0 + Arg1 = (A + B) * 1 + 0 */
|
||||
TEXENV_SETUP_ARG_A(alphaComb.SourceA,
|
||||
texUnit->Combine.SourceA[0],
|
||||
texUnit->Combine.OperandA[0],
|
||||
locala);
|
||||
TEXENV_SETUP_MODE_A(alphaComb.ModeA,
|
||||
texUnit->Combine.OperandA[0]);
|
||||
TEXENV_SETUP_ARG_A(alphaComb.SourceB,
|
||||
texUnit->Combine.SourceA[1],
|
||||
texUnit->Combine.OperandA[1],
|
||||
locala);
|
||||
TEXENV_SETUP_MODE_A(alphaComb.ModeB,
|
||||
texUnit->Combine.OperandA[1]);
|
||||
alphaComb.SourceC = GR_CMBX_ZERO;
|
||||
alphaComb.InvertC = FXTRUE;
|
||||
alphaComb.SourceD = GR_CMBX_ZERO;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "COMBINE_EXT_alpha: %s\n",
|
||||
_mesa_lookup_enum_by_nr(texUnit->Combine.ModeA));
|
||||
}
|
||||
|
||||
fxMesa->Glide.grConstantColorValueExt(tmu,
|
||||
(((GLuint)(envColor[0] * 255.0f)) ) |
|
||||
(((GLuint)(envColor[1] * 255.0f)) << 8) |
|
||||
(((GLuint)(envColor[2] * 255.0f)) << 16) |
|
||||
(((GLuint)(envColor[3] * 255.0f)) << 24));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxSetupTextureEnvNapalm_NoLock: %x Texture.EnvMode not yet supported\n",
|
||||
texUnit->EnvMode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* On Napalm we simply put the color combine unit into passthrough mode
|
||||
* and do everything we need with the texture combine units. */
|
||||
fxMesa->Glide.grColorCombineExt(GR_CMBX_TEXTURE_RGB,
|
||||
GR_FUNC_MODE_X,
|
||||
GR_CMBX_ZERO,
|
||||
GR_FUNC_MODE_X,
|
||||
GR_CMBX_ZERO,
|
||||
FXTRUE,
|
||||
GR_CMBX_ZERO,
|
||||
FXFALSE,
|
||||
0,
|
||||
FXFALSE);
|
||||
fxMesa->Glide.grAlphaCombineExt(GR_CMBX_TEXTURE_ALPHA,
|
||||
GR_FUNC_MODE_X,
|
||||
GR_CMBX_ZERO,
|
||||
GR_FUNC_MODE_X,
|
||||
GR_CMBX_ZERO,
|
||||
FXTRUE,
|
||||
GR_CMBX_ZERO,
|
||||
FXFALSE,
|
||||
0,
|
||||
FXFALSE);
|
||||
|
||||
fxMesa->Glide.grTexAlphaCombineExt(tmu,
|
||||
alphaComb.SourceA,
|
||||
alphaComb.ModeA,
|
||||
alphaComb.SourceB,
|
||||
alphaComb.ModeB,
|
||||
alphaComb.SourceC,
|
||||
alphaComb.InvertC,
|
||||
alphaComb.SourceD,
|
||||
alphaComb.InvertD,
|
||||
alphaComb.Shift,
|
||||
alphaComb.Invert);
|
||||
fxMesa->Glide.grTexColorCombineExt(tmu,
|
||||
colorComb.SourceA,
|
||||
colorComb.ModeA,
|
||||
colorComb.SourceB,
|
||||
colorComb.ModeB,
|
||||
colorComb.SourceC,
|
||||
colorComb.InvertC,
|
||||
colorComb.SourceD,
|
||||
colorComb.InvertD,
|
||||
colorComb.Shift,
|
||||
colorComb.Invert);
|
||||
}
|
||||
|
||||
|
||||
/************************* Single Texture Set ***************************/
|
||||
|
||||
static void
|
||||
fxSelectSingleTMUSrcNapalm_NoLock(fxMesaContext fxMesa, GLint tmu, FxBool LODblend)
|
||||
{
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxSelectSingleTMUSrcNapalm_NoLock(%d, %d)\n", tmu, LODblend);
|
||||
}
|
||||
|
||||
if (LODblend) {
|
||||
/* XXX todo - GR_CMBX_LOD_FRAC? */
|
||||
fxMesa->tmuSrc = FX_TMU_SPLIT;
|
||||
}
|
||||
else {
|
||||
if (tmu != FX_TMU1) {
|
||||
/* disable tex1 */
|
||||
if (fxMesa->haveTwoTMUs) {
|
||||
fxMesa->Glide.grTexAlphaCombineExt(FX_TMU1,
|
||||
GR_CMBX_ZERO,
|
||||
GR_FUNC_MODE_ZERO,
|
||||
GR_CMBX_ZERO,
|
||||
GR_FUNC_MODE_ZERO,
|
||||
GR_CMBX_ZERO,
|
||||
FXTRUE,
|
||||
GR_CMBX_ZERO,
|
||||
FXFALSE,
|
||||
0,
|
||||
FXFALSE);
|
||||
fxMesa->Glide.grTexColorCombineExt(FX_TMU1,
|
||||
GR_CMBX_ZERO,
|
||||
GR_FUNC_MODE_ZERO,
|
||||
GR_CMBX_ZERO,
|
||||
GR_FUNC_MODE_ZERO,
|
||||
GR_CMBX_ZERO,
|
||||
FXTRUE,
|
||||
GR_CMBX_ZERO,
|
||||
FXFALSE,
|
||||
0,
|
||||
FXFALSE);
|
||||
}
|
||||
|
||||
fxMesa->tmuSrc = FX_TMU0;
|
||||
}
|
||||
else {
|
||||
#if 1
|
||||
grTexCombine(GR_TMU0,
|
||||
GR_COMBINE_FUNCTION_BLEND,
|
||||
GR_COMBINE_FACTOR_ONE,
|
||||
GR_COMBINE_FUNCTION_BLEND,
|
||||
GR_COMBINE_FACTOR_ONE,
|
||||
FXFALSE,
|
||||
FXFALSE);
|
||||
#else
|
||||
/* [dBorca] why, oh why? doesn't work! stupid Glide? */
|
||||
fxMesa->Glide.grTexAlphaCombineExt(FX_TMU0,
|
||||
GR_CMBX_OTHER_TEXTURE_ALPHA,
|
||||
GR_FUNC_MODE_X,
|
||||
GR_CMBX_ZERO,
|
||||
GR_FUNC_MODE_X,
|
||||
GR_CMBX_ZERO,
|
||||
FXTRUE,
|
||||
GR_CMBX_ZERO,
|
||||
FXFALSE,
|
||||
0,
|
||||
FXFALSE);
|
||||
fxMesa->Glide.grTexColorCombineExt(FX_TMU0,
|
||||
GR_CMBX_OTHER_TEXTURE_RGB,
|
||||
GR_FUNC_MODE_X,
|
||||
GR_CMBX_ZERO,
|
||||
GR_FUNC_MODE_X,
|
||||
GR_CMBX_ZERO,
|
||||
FXTRUE,
|
||||
GR_CMBX_ZERO,
|
||||
FXFALSE,
|
||||
0,
|
||||
FXFALSE);
|
||||
#endif
|
||||
|
||||
fxMesa->tmuSrc = FX_TMU1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fxSetupTextureSingleTMUNapalm_NoLock(GLcontext * ctx, GLuint textureset)
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
GLuint unitsmode;
|
||||
tfxTexInfo *ti;
|
||||
struct gl_texture_object *tObj = ctx->Texture.Unit[textureset]._Current;
|
||||
int tmu;
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxSetupTextureSingleTMUNapalm_NoLock(%d)\n", textureset);
|
||||
}
|
||||
|
||||
ti = fxTMGetTexInfo(tObj);
|
||||
|
||||
fxTexValidate(ctx, tObj);
|
||||
|
||||
fxSetupSingleTMU_NoLock(fxMesa, tObj);
|
||||
|
||||
if (ti->whichTMU == FX_TMU_BOTH)
|
||||
tmu = FX_TMU0;
|
||||
else
|
||||
tmu = ti->whichTMU;
|
||||
if (fxMesa->tmuSrc != tmu)
|
||||
fxSelectSingleTMUSrcNapalm_NoLock(fxMesa, tmu, ti->LODblend);
|
||||
|
||||
if (textureset == 0 || !fxMesa->haveTwoTMUs)
|
||||
unitsmode = fxGetTexSetConfiguration(ctx, tObj, NULL);
|
||||
else
|
||||
unitsmode = fxGetTexSetConfiguration(ctx, NULL, tObj);
|
||||
|
||||
/* if(fxMesa->lastUnitsMode==unitsmode) */
|
||||
/* return; */
|
||||
|
||||
fxMesa->lastUnitsMode = unitsmode;
|
||||
|
||||
fxMesa->stw_hint_state = 0;
|
||||
FX_grHints_NoLock(GR_HINT_STWHINT, 0);
|
||||
|
||||
if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
|
||||
fprintf(stderr, "fxSetupTextureSingleTMUNapalm_NoLock: envmode is %s\n",
|
||||
_mesa_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode));
|
||||
|
||||
/* [dBorca] Hack alert:
|
||||
* what if we're in split mode? (LODBlend)
|
||||
* also should we update BOTH TMUs in FX_TMU_BOTH mode?
|
||||
*/
|
||||
fxSetupTextureEnvNapalm_NoLock(ctx, textureset, tmu, GL_TRUE);
|
||||
}
|
||||
|
||||
|
||||
/************************* Double Texture Set ***************************/
|
||||
|
||||
static void
|
||||
fxSetupTextureDoubleTMUNapalm_NoLock(GLcontext * ctx)
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
tfxTexInfo *ti0, *ti1;
|
||||
struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current;
|
||||
struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current;
|
||||
GLuint unitsmode;
|
||||
int tmu0 = 0, tmu1 = 1;
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxSetupTextureDoubleTMUNapalm_NoLock(...)\n");
|
||||
}
|
||||
|
||||
ti0 = fxTMGetTexInfo(tObj0);
|
||||
fxTexValidate(ctx, tObj0);
|
||||
|
||||
ti1 = fxTMGetTexInfo(tObj1);
|
||||
fxTexValidate(ctx, tObj1);
|
||||
|
||||
fxSetupDoubleTMU_NoLock(fxMesa, tObj0, tObj1);
|
||||
|
||||
unitsmode = fxGetTexSetConfiguration(ctx, tObj0, tObj1);
|
||||
|
||||
/* if(fxMesa->lastUnitsMode==unitsmode) */
|
||||
/* return; */
|
||||
|
||||
fxMesa->lastUnitsMode = unitsmode;
|
||||
|
||||
fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1;
|
||||
FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state);
|
||||
|
||||
if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
|
||||
fprintf(stderr, "fxSetupTextureDoubleTMUNapalm_NoLock: envmode is %s/%s\n",
|
||||
_mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
|
||||
_mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
|
||||
|
||||
|
||||
if ((ti0->whichTMU == FX_TMU1) || (ti1->whichTMU == FX_TMU0)) {
|
||||
tmu0 = 1;
|
||||
tmu1 = 0;
|
||||
}
|
||||
fxMesa->tmuSrc = FX_TMU_BOTH;
|
||||
|
||||
/* OpenGL vs Glide texture pipeline */
|
||||
fxSetupTextureEnvNapalm_NoLock(ctx, 0, 1, GL_TRUE);
|
||||
fxSetupTextureEnvNapalm_NoLock(ctx, 1, 0, GL_FALSE);
|
||||
}
|
||||
|
||||
/************************* No Texture ***************************/
|
||||
|
||||
static void
|
||||
fxSetupTextureNoneNapalm_NoLock(GLcontext * ctx)
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxSetupTextureNoneNapalm_NoLock(...)\n");
|
||||
}
|
||||
|
||||
/* the combiner formula is: (A + B) * C + D
|
||||
**
|
||||
** a = tc_otherselect
|
||||
** a_mode = tc_invert_other
|
||||
** b = tc_localselect
|
||||
** b_mode = tc_invert_local
|
||||
** c = (tc_mselect, tc_mselect_7)
|
||||
** d = (tc_add_clocal, tc_add_alocal)
|
||||
** shift = tc_outshift
|
||||
** invert = tc_invert_output
|
||||
*/
|
||||
|
||||
fxMesa->Glide.grColorCombineExt(GR_CMBX_ITRGB,
|
||||
GR_FUNC_MODE_X,
|
||||
GR_CMBX_ZERO,
|
||||
GR_FUNC_MODE_ZERO,
|
||||
GR_CMBX_ZERO,
|
||||
FXTRUE,
|
||||
GR_CMBX_ZERO,
|
||||
FXFALSE,
|
||||
0,
|
||||
FXFALSE);
|
||||
fxMesa->Glide.grAlphaCombineExt(GR_CMBX_ITALPHA,
|
||||
GR_FUNC_MODE_X,
|
||||
GR_CMBX_ZERO,
|
||||
GR_FUNC_MODE_ZERO,
|
||||
GR_CMBX_ZERO,
|
||||
FXTRUE,
|
||||
GR_CMBX_ZERO,
|
||||
FXFALSE,
|
||||
0,
|
||||
FXFALSE);
|
||||
|
||||
fxMesa->lastUnitsMode = FX_UM_NONE;
|
||||
}
|
||||
|
|
@ -1,874 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.0
|
||||
*
|
||||
* Copyright (C) 1999-2001 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.
|
||||
*/
|
||||
|
||||
/* Authors:
|
||||
* David Bucciarelli
|
||||
* Brian Paul
|
||||
* Daryll Strauss
|
||||
* Keith Whitwell
|
||||
* Daniel Borca
|
||||
* Hiroshi Morii
|
||||
*/
|
||||
|
||||
/* fxtexman.c - 3Dfx VooDoo texture memory functions */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "conf.h"
|
||||
#endif
|
||||
|
||||
#if defined(FX)
|
||||
|
||||
#include "hash.h"
|
||||
#include "fxdrv.h"
|
||||
|
||||
int texSwaps = 0;
|
||||
static FxU32 texBoundMask;
|
||||
|
||||
#define FX_2MB_SPLIT 0x200000
|
||||
|
||||
static struct gl_texture_object *fxTMFindOldestObject(fxMesaContext fxMesa,
|
||||
int tmu);
|
||||
|
||||
|
||||
#ifdef TEXSANITY
|
||||
static void
|
||||
fubar()
|
||||
{
|
||||
}
|
||||
|
||||
/* Sanity Check */
|
||||
static void
|
||||
sanity(fxMesaContext fxMesa)
|
||||
{
|
||||
MemRange *tmp, *prev, *pos;
|
||||
|
||||
prev = 0;
|
||||
tmp = fxMesa->tmFree[0];
|
||||
while (tmp) {
|
||||
if (!tmp->startAddr && !tmp->endAddr) {
|
||||
fprintf(stderr, "Textures fubar\n");
|
||||
fubar();
|
||||
}
|
||||
if (tmp->startAddr >= tmp->endAddr) {
|
||||
fprintf(stderr, "Node fubar\n");
|
||||
fubar();
|
||||
}
|
||||
if (prev && (prev->startAddr >= tmp->startAddr ||
|
||||
prev->endAddr > tmp->startAddr)) {
|
||||
fprintf(stderr, "Sorting fubar\n");
|
||||
fubar();
|
||||
}
|
||||
prev = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
prev = 0;
|
||||
tmp = fxMesa->tmFree[1];
|
||||
while (tmp) {
|
||||
if (!tmp->startAddr && !tmp->endAddr) {
|
||||
fprintf(stderr, "Textures fubar\n");
|
||||
fubar();
|
||||
}
|
||||
if (tmp->startAddr >= tmp->endAddr) {
|
||||
fprintf(stderr, "Node fubar\n");
|
||||
fubar();
|
||||
}
|
||||
if (prev && (prev->startAddr >= tmp->startAddr ||
|
||||
prev->endAddr > tmp->startAddr)) {
|
||||
fprintf(stderr, "Sorting fubar\n");
|
||||
fubar();
|
||||
}
|
||||
prev = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static MemRange *
|
||||
fxTMNewRangeNode(fxMesaContext fxMesa, FxU32 start, FxU32 end)
|
||||
{
|
||||
MemRange *result = 0;
|
||||
|
||||
if (fxMesa->tmPool) {
|
||||
result = fxMesa->tmPool;
|
||||
fxMesa->tmPool = fxMesa->tmPool->next;
|
||||
}
|
||||
else {
|
||||
if (!(result = MALLOC(sizeof(MemRange)))) {
|
||||
fprintf(stderr, "fxTMNewRangeNode: ERROR: out of memory!\n");
|
||||
fxCloseHardware();
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
result->startAddr = start;
|
||||
result->endAddr = end;
|
||||
return result;
|
||||
}
|
||||
|
||||
#if 1
|
||||
#define fxTMDeleteRangeNode(fxMesa, range) \
|
||||
do { \
|
||||
range->next = fxMesa->tmPool; \
|
||||
fxMesa->tmPool = range; \
|
||||
} while (0);
|
||||
#else
|
||||
static void
|
||||
fxTMDeleteRangeNode(fxMesaContext fxMesa, MemRange * range)
|
||||
{
|
||||
range->next = fxMesa->tmPool;
|
||||
fxMesa->tmPool = range;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
fxTMUInit(fxMesaContext fxMesa, int tmu)
|
||||
{
|
||||
MemRange *tmn, *last;
|
||||
FxU32 start, end, blockstart, blockend, chunk;
|
||||
|
||||
start = grTexMinAddress(tmu);
|
||||
end = grTexMaxAddress(tmu);
|
||||
|
||||
chunk = (fxMesa->type >= GR_SSTTYPE_Banshee) ? (end - start) : FX_2MB_SPLIT;
|
||||
|
||||
if (fxMesa->verbose) {
|
||||
fprintf(stderr, "Voodoo TMU%d configuration:\n", tmu);
|
||||
}
|
||||
|
||||
fxMesa->freeTexMem[tmu] = end - start;
|
||||
fxMesa->tmFree[tmu] = NULL;
|
||||
|
||||
last = 0;
|
||||
blockstart = start;
|
||||
while (blockstart < end) {
|
||||
if (blockstart + chunk > end)
|
||||
blockend = end;
|
||||
else
|
||||
blockend = blockstart + chunk;
|
||||
|
||||
if (fxMesa->verbose)
|
||||
fprintf(stderr, "Voodoo %08u-%08u\n",
|
||||
(unsigned int) blockstart, (unsigned int) blockend);
|
||||
|
||||
tmn = fxTMNewRangeNode(fxMesa, blockstart, blockend);
|
||||
tmn->next = NULL;
|
||||
|
||||
|
||||
if (last)
|
||||
last->next = tmn;
|
||||
else
|
||||
fxMesa->tmFree[tmu] = tmn;
|
||||
last = tmn;
|
||||
|
||||
blockstart += chunk;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
fxTMFindStartAddr(fxMesaContext fxMesa, GLint tmu, int size)
|
||||
{
|
||||
MemRange *prev, *tmp;
|
||||
int result;
|
||||
struct gl_texture_object *obj;
|
||||
|
||||
if (fxMesa->HaveTexUma) {
|
||||
tmu = FX_TMU0;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
prev = 0;
|
||||
tmp = fxMesa->tmFree[tmu];
|
||||
while (tmp) {
|
||||
if (tmp->endAddr - tmp->startAddr >= size) { /* Fits here */
|
||||
result = tmp->startAddr;
|
||||
tmp->startAddr += size;
|
||||
if (tmp->startAddr == tmp->endAddr) { /* Empty */
|
||||
if (prev) {
|
||||
prev->next = tmp->next;
|
||||
}
|
||||
else {
|
||||
fxMesa->tmFree[tmu] = tmp->next;
|
||||
}
|
||||
fxTMDeleteRangeNode(fxMesa, tmp);
|
||||
}
|
||||
fxMesa->freeTexMem[tmu] -= size;
|
||||
return result;
|
||||
}
|
||||
prev = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
/* No free space. Discard oldest */
|
||||
if (TDFX_DEBUG & VERBOSE_TEXTURE) {
|
||||
fprintf(stderr, "fxTMFindStartAddr: No free space. Discard oldest\n");
|
||||
}
|
||||
obj = fxTMFindOldestObject(fxMesa, tmu);
|
||||
if (!obj) {
|
||||
fprintf(stderr, "fxTMFindStartAddr: ERROR: No space for texture\n");
|
||||
return -1;
|
||||
}
|
||||
fxTMMoveOutTM(fxMesa, obj);
|
||||
texSwaps++;
|
||||
}
|
||||
}
|
||||
|
||||
int fxTMCheckStartAddr (fxMesaContext fxMesa, GLint tmu, tfxTexInfo *ti)
|
||||
{
|
||||
MemRange *tmp;
|
||||
int size;
|
||||
|
||||
if (fxMesa->HaveTexUma) {
|
||||
return FXTRUE;
|
||||
}
|
||||
|
||||
size = grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
|
||||
|
||||
tmp = fxMesa->tmFree[tmu];
|
||||
while (tmp) {
|
||||
if (tmp->endAddr - tmp->startAddr >= size) { /* Fits here */
|
||||
return FXTRUE;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
return FXFALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
fxTMRemoveRange(fxMesaContext fxMesa, GLint tmu, MemRange * range)
|
||||
{
|
||||
MemRange *tmp, *prev;
|
||||
|
||||
if (fxMesa->HaveTexUma) {
|
||||
tmu = FX_TMU0;
|
||||
}
|
||||
|
||||
if (range->startAddr == range->endAddr) {
|
||||
fxTMDeleteRangeNode(fxMesa, range);
|
||||
return;
|
||||
}
|
||||
fxMesa->freeTexMem[tmu] += range->endAddr - range->startAddr;
|
||||
prev = 0;
|
||||
tmp = fxMesa->tmFree[tmu];
|
||||
while (tmp) {
|
||||
if (range->startAddr > tmp->startAddr) {
|
||||
prev = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
/* When we create the regions, we make a split at the 2MB boundary.
|
||||
Now we have to make sure we don't join those 2MB boundary regions
|
||||
back together again. */
|
||||
range->next = tmp;
|
||||
if (tmp) {
|
||||
if (range->endAddr == tmp->startAddr
|
||||
&& tmp->startAddr & texBoundMask) {
|
||||
/* Combine */
|
||||
tmp->startAddr = range->startAddr;
|
||||
fxTMDeleteRangeNode(fxMesa, range);
|
||||
range = tmp;
|
||||
}
|
||||
}
|
||||
if (prev) {
|
||||
if (prev->endAddr == range->startAddr
|
||||
&& range->startAddr & texBoundMask) {
|
||||
/* Combine */
|
||||
prev->endAddr = range->endAddr;
|
||||
prev->next = range->next;
|
||||
fxTMDeleteRangeNode(fxMesa, range);
|
||||
}
|
||||
else
|
||||
prev->next = range;
|
||||
}
|
||||
else {
|
||||
fxMesa->tmFree[tmu] = range;
|
||||
}
|
||||
}
|
||||
|
||||
static struct gl_texture_object *
|
||||
fxTMFindOldestObject(fxMesaContext fxMesa, int tmu)
|
||||
{
|
||||
GLuint age, old, lasttime, bindnumber;
|
||||
GLfloat lowestPriority;
|
||||
struct gl_texture_object *obj, *lowestPriorityObj;
|
||||
struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects;
|
||||
GLuint id;
|
||||
|
||||
if (!_mesa_HashFirstEntry(textures))
|
||||
return 0;
|
||||
|
||||
obj = NULL;
|
||||
old = 0;
|
||||
|
||||
lowestPriorityObj = NULL;
|
||||
lowestPriority = 1.0F;
|
||||
|
||||
bindnumber = fxMesa->texBindNumber;
|
||||
|
||||
for (id = _mesa_HashFirstEntry(textures);
|
||||
id;
|
||||
id = _mesa_HashNextEntry(textures, id)) {
|
||||
struct gl_texture_object *tmp
|
||||
= (struct gl_texture_object *) _mesa_HashLookup(textures, id);
|
||||
tfxTexInfo *info = fxTMGetTexInfo(tmp);
|
||||
|
||||
if (info && info->isInTM &&
|
||||
((info->whichTMU == tmu) ||
|
||||
(info->whichTMU == FX_TMU_BOTH) ||
|
||||
(info->whichTMU == FX_TMU_SPLIT) ||
|
||||
fxMesa->HaveTexUma
|
||||
)
|
||||
) {
|
||||
lasttime = info->lastTimeUsed;
|
||||
|
||||
if (lasttime > bindnumber)
|
||||
age = bindnumber + (UINT_MAX - lasttime + 1); /* TO DO: check wrap around */
|
||||
else
|
||||
age = bindnumber - lasttime;
|
||||
|
||||
if (age >= old) {
|
||||
old = age;
|
||||
obj = tmp;
|
||||
}
|
||||
|
||||
/* examine priority */
|
||||
if (tmp->Priority < lowestPriority) {
|
||||
lowestPriority = tmp->Priority;
|
||||
lowestPriorityObj = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lowestPriorityObj != NULL) {
|
||||
if (TDFX_DEBUG & VERBOSE_TEXTURE) {
|
||||
fprintf(stderr, "fxTMFindOldestObject: %d pri=%f\n", lowestPriorityObj->Name, lowestPriority);
|
||||
}
|
||||
return lowestPriorityObj;
|
||||
}
|
||||
else {
|
||||
if (TDFX_DEBUG & VERBOSE_TEXTURE) {
|
||||
if (obj != NULL) {
|
||||
fprintf(stderr, "fxTMFindOldestObject: %d age=%d\n", obj->Name, old);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
static MemRange *
|
||||
fxTMAddObj(fxMesaContext fxMesa,
|
||||
struct gl_texture_object *tObj, GLint tmu, int texmemsize)
|
||||
{
|
||||
FxI32 startAddr;
|
||||
MemRange *range;
|
||||
|
||||
startAddr = fxTMFindStartAddr(fxMesa, tmu, texmemsize);
|
||||
if (startAddr < 0)
|
||||
return 0;
|
||||
range = fxTMNewRangeNode(fxMesa, startAddr, startAddr + texmemsize);
|
||||
return range;
|
||||
}
|
||||
|
||||
/* External Functions */
|
||||
|
||||
void
|
||||
fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj,
|
||||
GLint where)
|
||||
{
|
||||
tfxTexInfo *ti = fxTMGetTexInfo(tObj);
|
||||
int i, l;
|
||||
int texmemsize;
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxTMMoveInTM_NoLock(%d)\n", tObj->Name);
|
||||
}
|
||||
|
||||
fxMesa->stats.reqTexUpload++;
|
||||
|
||||
if (!ti->validated) {
|
||||
fprintf(stderr, "fxTMMoveInTM_NoLock: INTERNAL ERROR: not validated\n");
|
||||
fxCloseHardware();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (ti->isInTM) {
|
||||
if (ti->whichTMU == where)
|
||||
return;
|
||||
if (where == FX_TMU_SPLIT || ti->whichTMU == FX_TMU_SPLIT)
|
||||
fxTMMoveOutTM_NoLock(fxMesa, tObj);
|
||||
else {
|
||||
if (ti->whichTMU == FX_TMU_BOTH)
|
||||
return;
|
||||
where = FX_TMU_BOTH;
|
||||
}
|
||||
}
|
||||
|
||||
if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) {
|
||||
fprintf(stderr, "fxTMMoveInTM_NoLock: downloading %p (%d) in texture memory in %d\n",
|
||||
(void *)tObj, tObj->Name, where);
|
||||
}
|
||||
|
||||
ti->whichTMU = (FxU32) where;
|
||||
|
||||
switch (where) {
|
||||
case FX_TMU0:
|
||||
case FX_TMU1:
|
||||
texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
|
||||
ti->tm[where] = fxTMAddObj(fxMesa, tObj, where, texmemsize);
|
||||
fxMesa->stats.memTexUpload += texmemsize;
|
||||
|
||||
for (i = FX_largeLodValue(ti->info), l = ti->minLevel;
|
||||
i <= FX_smallLodValue(ti->info); i++, l++) {
|
||||
struct gl_texture_image *texImage = tObj->Image[0][l];
|
||||
grTexDownloadMipMapLevel(where,
|
||||
ti->tm[where]->startAddr,
|
||||
FX_valueToLod(i),
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_BOTH,
|
||||
texImage->Data);
|
||||
}
|
||||
break;
|
||||
case FX_TMU_SPLIT:
|
||||
texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_ODD, &(ti->info));
|
||||
ti->tm[FX_TMU0] = fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
|
||||
fxMesa->stats.memTexUpload += texmemsize;
|
||||
|
||||
texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_EVEN, &(ti->info));
|
||||
ti->tm[FX_TMU1] = fxTMAddObj(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++) {
|
||||
struct gl_texture_image *texImage = tObj->Image[0][l];
|
||||
|
||||
grTexDownloadMipMapLevel(GR_TMU0,
|
||||
ti->tm[FX_TMU0]->startAddr,
|
||||
FX_valueToLod(i),
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_ODD,
|
||||
texImage->Data);
|
||||
|
||||
grTexDownloadMipMapLevel(GR_TMU1,
|
||||
ti->tm[FX_TMU1]->startAddr,
|
||||
FX_valueToLod(i),
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_EVEN,
|
||||
texImage->Data);
|
||||
}
|
||||
break;
|
||||
case FX_TMU_BOTH:
|
||||
texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
|
||||
ti->tm[FX_TMU0] = fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
|
||||
fxMesa->stats.memTexUpload += texmemsize;
|
||||
|
||||
/*texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));*/
|
||||
ti->tm[FX_TMU1] = fxTMAddObj(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++) {
|
||||
struct gl_texture_image *texImage = tObj->Image[0][l];
|
||||
grTexDownloadMipMapLevel(GR_TMU0,
|
||||
ti->tm[FX_TMU0]->startAddr,
|
||||
FX_valueToLod(i),
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_BOTH,
|
||||
texImage->Data);
|
||||
|
||||
grTexDownloadMipMapLevel(GR_TMU1,
|
||||
ti->tm[FX_TMU1]->startAddr,
|
||||
FX_valueToLod(i),
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_BOTH,
|
||||
texImage->Data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "fxTMMoveInTM_NoLock: INTERNAL ERROR: wrong tmu (%d)\n", where);
|
||||
fxCloseHardware();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fxMesa->stats.texUpload++;
|
||||
|
||||
ti->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 = fxTMGetTexInfo(tObj);
|
||||
GrLOD_t lodlevel;
|
||||
GLint tmu;
|
||||
struct gl_texture_image *texImage = tObj->Image[0][level];
|
||||
tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_TEXTURE) {
|
||||
fprintf(stderr, "fxTMReloadMipMapLevel(%p (%d), %d)\n", (void *)tObj, tObj->Name, level);
|
||||
}
|
||||
|
||||
assert(mml);
|
||||
assert(mml->width > 0);
|
||||
assert(mml->height > 0);
|
||||
assert(mml->glideFormat > 0);
|
||||
assert(ti->isInTM);
|
||||
|
||||
if (!ti->validated) {
|
||||
fprintf(stderr, "fxTMReloadMipMapLevel: INTERNAL ERROR: not validated\n");
|
||||
fxCloseHardware();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
tmu = (int) ti->whichTMU;
|
||||
fxMesa->stats.reqTexUpload++;
|
||||
fxMesa->stats.texUpload++;
|
||||
|
||||
lodlevel = ti->info.largeLodLog2 - (level - ti->minLevel);
|
||||
|
||||
switch (tmu) {
|
||||
case FX_TMU0:
|
||||
case FX_TMU1:
|
||||
grTexDownloadMipMapLevel(tmu,
|
||||
ti->tm[tmu]->startAddr,
|
||||
lodlevel,
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_BOTH, texImage->Data);
|
||||
break;
|
||||
case FX_TMU_SPLIT:
|
||||
grTexDownloadMipMapLevel(GR_TMU0,
|
||||
ti->tm[GR_TMU0]->startAddr,
|
||||
lodlevel,
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_ODD, texImage->Data);
|
||||
|
||||
grTexDownloadMipMapLevel(GR_TMU1,
|
||||
ti->tm[GR_TMU1]->startAddr,
|
||||
lodlevel,
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_EVEN, texImage->Data);
|
||||
break;
|
||||
case FX_TMU_BOTH:
|
||||
grTexDownloadMipMapLevel(GR_TMU0,
|
||||
ti->tm[GR_TMU0]->startAddr,
|
||||
lodlevel,
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_BOTH, texImage->Data);
|
||||
|
||||
grTexDownloadMipMapLevel(GR_TMU1,
|
||||
ti->tm[GR_TMU1]->startAddr,
|
||||
lodlevel,
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_BOTH, texImage->Data);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "fxTMReloadMipMapLevel: INTERNAL ERROR: wrong tmu (%d)\n", tmu);
|
||||
fxCloseHardware();
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fxTMReloadSubMipMapLevel(fxMesaContext fxMesa,
|
||||
struct gl_texture_object *tObj,
|
||||
GLint level, GLint yoffset, GLint height)
|
||||
{
|
||||
tfxTexInfo *ti = fxTMGetTexInfo(tObj);
|
||||
GrLOD_t lodlevel;
|
||||
unsigned short *data;
|
||||
GLint tmu;
|
||||
struct gl_texture_image *texImage = tObj->Image[0][level];
|
||||
tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
|
||||
|
||||
assert(mml);
|
||||
|
||||
if (!ti->validated) {
|
||||
fprintf(stderr, "fxTMReloadSubMipMapLevel: INTERNAL ERROR: not validated\n");
|
||||
fxCloseHardware();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
tmu = (int) ti->whichTMU;
|
||||
fxTMMoveInTM(fxMesa, tObj, tmu);
|
||||
|
||||
fxTexGetInfo(mml->width, mml->height,
|
||||
&lodlevel, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
if ((ti->info.format == GR_TEXFMT_INTENSITY_8) ||
|
||||
(ti->info.format == GR_TEXFMT_P_8) ||
|
||||
(ti->info.format == GR_TEXFMT_ALPHA_8))
|
||||
data = (GLushort *) texImage->Data + ((yoffset * mml->width) >> 1);
|
||||
else
|
||||
data = (GLushort *) texImage->Data + yoffset * mml->width;
|
||||
|
||||
switch (tmu) {
|
||||
case FX_TMU0:
|
||||
case FX_TMU1:
|
||||
grTexDownloadMipMapLevelPartial(tmu,
|
||||
ti->tm[tmu]->startAddr,
|
||||
FX_valueToLod(FX_lodToValue(lodlevel)
|
||||
+ level),
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_BOTH, data,
|
||||
yoffset, yoffset + height - 1);
|
||||
break;
|
||||
case FX_TMU_SPLIT:
|
||||
grTexDownloadMipMapLevelPartial(GR_TMU0,
|
||||
ti->tm[FX_TMU0]->startAddr,
|
||||
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,
|
||||
ti->tm[FX_TMU1]->startAddr,
|
||||
FX_valueToLod(FX_lodToValue(lodlevel)
|
||||
+ level),
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_EVEN, data,
|
||||
yoffset, yoffset + height - 1);
|
||||
break;
|
||||
case FX_TMU_BOTH:
|
||||
grTexDownloadMipMapLevelPartial(GR_TMU0,
|
||||
ti->tm[FX_TMU0]->startAddr,
|
||||
FX_valueToLod(FX_lodToValue(lodlevel)
|
||||
+ level),
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_BOTH, data,
|
||||
yoffset, yoffset + height - 1);
|
||||
|
||||
grTexDownloadMipMapLevelPartial(GR_TMU1,
|
||||
ti->tm[FX_TMU1]->startAddr,
|
||||
FX_valueToLod(FX_lodToValue(lodlevel)
|
||||
+ level),
|
||||
FX_largeLodLog2(ti->info),
|
||||
FX_aspectRatioLog2(ti->info),
|
||||
ti->info.format,
|
||||
GR_MIPMAPLEVELMASK_BOTH, data,
|
||||
yoffset, yoffset + height - 1);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "fxTMReloadSubMipMapLevel: INTERNAL ERROR: wrong tmu (%d)\n", tmu);
|
||||
fxCloseHardware();
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fxTMMoveOutTM(fxMesaContext fxMesa, struct gl_texture_object *tObj)
|
||||
{
|
||||
tfxTexInfo *ti = fxTMGetTexInfo(tObj);
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_DRIVER) {
|
||||
fprintf(stderr, "fxTMMoveOutTM(%p (%d))\n", (void *)tObj, tObj->Name);
|
||||
}
|
||||
|
||||
if (!ti->isInTM)
|
||||
return;
|
||||
|
||||
switch (ti->whichTMU) {
|
||||
case FX_TMU0:
|
||||
case FX_TMU1:
|
||||
fxTMRemoveRange(fxMesa, (int) ti->whichTMU, ti->tm[ti->whichTMU]);
|
||||
break;
|
||||
case FX_TMU_SPLIT:
|
||||
case FX_TMU_BOTH:
|
||||
fxTMRemoveRange(fxMesa, FX_TMU0, ti->tm[FX_TMU0]);
|
||||
fxTMRemoveRange(fxMesa, FX_TMU1, ti->tm[FX_TMU1]);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "fxTMMoveOutTM: INTERNAL ERROR: bad TMU (%ld)\n", ti->whichTMU);
|
||||
fxCloseHardware();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
ti->isInTM = GL_FALSE;
|
||||
ti->whichTMU = FX_TMU_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
fxTMFreeTexture(fxMesaContext fxMesa, struct gl_texture_object *tObj)
|
||||
{
|
||||
tfxTexInfo *ti = fxTMGetTexInfo(tObj);
|
||||
int i;
|
||||
|
||||
if (TDFX_DEBUG & VERBOSE_TEXTURE) {
|
||||
fprintf(stderr, "fxTMFreeTexture(%p (%d))\n", (void *)tObj, tObj->Name);
|
||||
}
|
||||
|
||||
fxTMMoveOutTM(fxMesa, tObj);
|
||||
|
||||
for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
|
||||
struct gl_texture_image *texImage = tObj->Image[0][i];
|
||||
if (texImage) {
|
||||
if (texImage->DriverData) {
|
||||
FREE(texImage->DriverData);
|
||||
texImage->DriverData = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (ti->whichTMU) {
|
||||
case FX_TMU0:
|
||||
case FX_TMU1:
|
||||
fxTMDeleteRangeNode(fxMesa, ti->tm[ti->whichTMU]);
|
||||
break;
|
||||
case FX_TMU_SPLIT:
|
||||
case FX_TMU_BOTH:
|
||||
fxTMDeleteRangeNode(fxMesa, ti->tm[FX_TMU0]);
|
||||
fxTMDeleteRangeNode(fxMesa, ti->tm[FX_TMU1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fxTMInit(fxMesaContext fxMesa)
|
||||
{
|
||||
fxMesa->texBindNumber = 0;
|
||||
fxMesa->tmPool = 0;
|
||||
|
||||
if (fxMesa->HaveTexUma) {
|
||||
grEnable(GR_TEXTURE_UMA_EXT);
|
||||
}
|
||||
|
||||
fxTMUInit(fxMesa, FX_TMU0);
|
||||
|
||||
if (!fxMesa->HaveTexUma && fxMesa->haveTwoTMUs)
|
||||
fxTMUInit(fxMesa, FX_TMU1);
|
||||
|
||||
texBoundMask = (fxMesa->type >= GR_SSTTYPE_Banshee) ? -1 : (FX_2MB_SPLIT - 1);
|
||||
}
|
||||
|
||||
void
|
||||
fxTMClose(fxMesaContext fxMesa)
|
||||
{
|
||||
MemRange *tmp, *next;
|
||||
|
||||
tmp = fxMesa->tmPool;
|
||||
while (tmp) {
|
||||
next = tmp->next;
|
||||
FREE(tmp);
|
||||
tmp = next;
|
||||
}
|
||||
tmp = fxMesa->tmFree[FX_TMU0];
|
||||
while (tmp) {
|
||||
next = tmp->next;
|
||||
FREE(tmp);
|
||||
tmp = next;
|
||||
}
|
||||
if (fxMesa->haveTwoTMUs) {
|
||||
tmp = fxMesa->tmFree[FX_TMU1];
|
||||
while (tmp) {
|
||||
next = tmp->next;
|
||||
FREE(tmp);
|
||||
tmp = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fxTMRestoreTextures_NoLock(fxMesaContext ctx)
|
||||
{
|
||||
struct _mesa_HashTable *textures = ctx->glCtx->Shared->TexObjects;
|
||||
GLuint id;
|
||||
|
||||
for (id = _mesa_HashFirstEntry(textures);
|
||||
id;
|
||||
id = _mesa_HashNextEntry(textures, id)) {
|
||||
struct gl_texture_object *tObj
|
||||
= (struct gl_texture_object *) _mesa_HashLookup(textures, id);
|
||||
tfxTexInfo *ti = fxTMGetTexInfo(tObj);
|
||||
if (ti && ti->isInTM) {
|
||||
int i;
|
||||
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 */
|
||||
int where = ti->whichTMU;
|
||||
fxTMMoveOutTM_NoLock(ctx, tObj);
|
||||
fxTMMoveInTM_NoLock(ctx, tObj, where);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == MAX_TEXTURE_UNITS) /* Mark the texture as off the board */
|
||||
fxTMMoveOutTM_NoLock(ctx, tObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
/*
|
||||
* Need this to provide at least one external definition.
|
||||
*/
|
||||
|
||||
extern int gl_fx_dummy_function_texman(void);
|
||||
int
|
||||
gl_fx_dummy_function_texman(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* FX */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,838 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 5.1
|
||||
*
|
||||
* Copyright (C) 1999-2003 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
|
||||
* KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
* Daniel Borca <dborca@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "conf.h"
|
||||
#endif
|
||||
|
||||
#ifdef FX
|
||||
|
||||
#include "main/glheader.h"
|
||||
#include "main/mtypes.h"
|
||||
#include "main/imports.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/colormac.h"
|
||||
|
||||
#include "math/m_translate.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_context.h"
|
||||
|
||||
#include "fxdrv.h"
|
||||
|
||||
|
||||
static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT( ctx );
|
||||
GrVertex *dst = fxMesa->verts + edst;
|
||||
GrVertex *src = fxMesa->verts + esrc;
|
||||
|
||||
#if FX_PACKEDCOLOR
|
||||
*(GLuint *)&dst->pargb = *(GLuint *)&src->pargb;
|
||||
#else /* !FX_PACKEDCOLOR */
|
||||
COPY_FLOAT(dst->r, src->r);
|
||||
COPY_FLOAT(dst->g, src->g);
|
||||
COPY_FLOAT(dst->b, src->b);
|
||||
COPY_FLOAT(dst->a, src->a);
|
||||
#endif /* !FX_PACKEDCOLOR */
|
||||
}
|
||||
|
||||
static void copy_pv2( GLcontext *ctx, GLuint edst, GLuint esrc )
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT( ctx );
|
||||
GrVertex *dst = fxMesa->verts + edst;
|
||||
GrVertex *src = fxMesa->verts + esrc;
|
||||
|
||||
#if FX_PACKEDCOLOR
|
||||
*(GLuint *)&dst->pargb = *(GLuint *)&src->pargb;
|
||||
*(GLuint *)&dst->pspec = *(GLuint *)&src->pspec;
|
||||
#else /* !FX_PACKEDCOLOR */
|
||||
COPY_FLOAT(dst->r, src->r);
|
||||
COPY_FLOAT(dst->g, src->g);
|
||||
COPY_FLOAT(dst->b, src->b);
|
||||
COPY_FLOAT(dst->a, src->a);
|
||||
COPY_FLOAT(dst->r1, src->r1);
|
||||
COPY_FLOAT(dst->g1, src->g1);
|
||||
COPY_FLOAT(dst->b1, src->b1);
|
||||
#endif /* !FX_PACKEDCOLOR */
|
||||
}
|
||||
|
||||
static struct {
|
||||
void (*emit) (GLcontext *ctx, GLuint start, GLuint end, void *dest);
|
||||
tnl_copy_pv_func copy_pv;
|
||||
tnl_interp_func interp;
|
||||
GLboolean (*check_tex_sizes) (GLcontext *ctx);
|
||||
GLuint vertex_format;
|
||||
} setup_tab[MAX_SETUP];
|
||||
|
||||
|
||||
#define GET_COLOR(ptr, idx) ((ptr)->data[idx])
|
||||
|
||||
|
||||
static void interp_extras( GLcontext *ctx,
|
||||
GLfloat t,
|
||||
GLuint dst, GLuint out, GLuint in,
|
||||
GLboolean force_boundary )
|
||||
{
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
|
||||
if (VB->BackfaceColorPtr) {
|
||||
/* If stride is zero, BackfaceColorPtr is constant across the VB, so
|
||||
* there is no point interpolating between two values as they will
|
||||
* be identical. This case is handled in t_dd_tritmp.h
|
||||
*/
|
||||
if (VB->BackfaceColorPtr->stride) {
|
||||
assert(VB->BackfaceColorPtr->stride == 4 * sizeof(GLfloat));
|
||||
INTERP_4F( t,
|
||||
GET_COLOR(VB->BackfaceColorPtr, dst),
|
||||
GET_COLOR(VB->BackfaceColorPtr, out),
|
||||
GET_COLOR(VB->BackfaceColorPtr, in) );
|
||||
}
|
||||
|
||||
if (VB->BackfaceSecondaryColorPtr) {
|
||||
INTERP_3F( t,
|
||||
GET_COLOR(VB->BackfaceSecondaryColorPtr, dst),
|
||||
GET_COLOR(VB->BackfaceSecondaryColorPtr, out),
|
||||
GET_COLOR(VB->BackfaceSecondaryColorPtr, in) );
|
||||
}
|
||||
}
|
||||
|
||||
if (VB->EdgeFlag) {
|
||||
VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
|
||||
}
|
||||
|
||||
setup_tab[FX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in,
|
||||
force_boundary);
|
||||
}
|
||||
|
||||
static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
|
||||
{
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
|
||||
if (VB->BackfaceColorPtr) {
|
||||
COPY_4FV( GET_COLOR(VB->BackfaceColorPtr, dst),
|
||||
GET_COLOR(VB->BackfaceColorPtr, src) );
|
||||
|
||||
if (VB->BackfaceSecondaryColorPtr) {
|
||||
COPY_3FV( GET_COLOR(VB->BackfaceSecondaryColorPtr, dst),
|
||||
GET_COLOR(VB->BackfaceSecondaryColorPtr, src) );
|
||||
}
|
||||
}
|
||||
|
||||
setup_tab[FX_CONTEXT(ctx)->SetupIndex].copy_pv(ctx, dst, src);
|
||||
}
|
||||
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA)
|
||||
#define TAG(x) x##_wg
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0)
|
||||
#define TAG(x) x##_wgt0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
|
||||
#define TAG(x) x##_wgt0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX)
|
||||
#define TAG(x) x##_wgpt0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
|
||||
SETUP_PTEX)
|
||||
#define TAG(x) x##_wgpt0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ)
|
||||
#define TAG(x) x##_wga
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
|
||||
#define TAG(x) x##_wgt0a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
|
||||
#define TAG(x) x##_wgt0t1a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
|
||||
#define TAG(x) x##_wgpt0a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
|
||||
SETUP_PTEX|SETUP_PSIZ)
|
||||
#define TAG(x) x##_wgpt0t1a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC)
|
||||
#define TAG(x) x##_2wg
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
|
||||
#define TAG(x) x##_2wgt0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
|
||||
#define TAG(x) x##_2wgt0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX)
|
||||
#define TAG(x) x##_2wgpt0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
|
||||
SETUP_PTEX)
|
||||
#define TAG(x) x##_2wgpt0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
|
||||
#define TAG(x) x##_2wga
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
|
||||
#define TAG(x) x##_2wgt0a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
|
||||
#define TAG(x) x##_2wgt0t1a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
|
||||
#define TAG(x) x##_2wgpt0a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
|
||||
SETUP_PTEX|SETUP_PSIZ)
|
||||
#define TAG(x) x##_2wgpt0t1a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
/* fog { */
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_FOGC)
|
||||
#define TAG(x) x##_wgf
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
|
||||
#define TAG(x) x##_wgt0f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
|
||||
#define TAG(x) x##_wgt0t1f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
|
||||
#define TAG(x) x##_wgpt0f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
|
||||
SETUP_PTEX|SETUP_FOGC)
|
||||
#define TAG(x) x##_wgpt0t1f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_wgaf
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_wgt0af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_wgt0t1af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_wgpt0af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
|
||||
SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_wgpt0t1af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wgf
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wgt0f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wgt0t1f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wgpt0f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
|
||||
SETUP_PTEX|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wgpt0t1f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wgaf
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wgt0af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wgt0t1af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wgpt0af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
|
||||
SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wgpt0t1af
|
||||
#include "fxvbtmp.h"
|
||||
/* fog } */
|
||||
|
||||
|
||||
/* Snapping for voodoo-1
|
||||
*/
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA)
|
||||
#define TAG(x) x##_wsg
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0)
|
||||
#define TAG(x) x##_wsgt0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_TMU1)
|
||||
#define TAG(x) x##_wsgt0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_PTEX)
|
||||
#define TAG(x) x##_wsgpt0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PTEX)
|
||||
#define TAG(x) x##_wsgpt0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ)
|
||||
#define TAG(x) x##_wsga
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
|
||||
#define TAG(x) x##_wsgt0a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PSIZ)
|
||||
#define TAG(x) x##_wsgt0t1a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_PTEX|SETUP_PSIZ)
|
||||
#define TAG(x) x##_wsgpt0a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ)
|
||||
#define TAG(x) x##_wsgpt0t1a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC)
|
||||
#define TAG(x) x##_2wsg
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
|
||||
#define TAG(x) x##_2wsgt0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_TMU1)
|
||||
#define TAG(x) x##_2wsgt0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_PTEX)
|
||||
#define TAG(x) x##_2wsgpt0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PTEX)
|
||||
#define TAG(x) x##_2wsgpt0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
|
||||
#define TAG(x) x##_2wsga
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
|
||||
#define TAG(x) x##_2wsgt0a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PSIZ)
|
||||
#define TAG(x) x##_2wsgt0t1a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_PTEX|SETUP_PSIZ)
|
||||
#define TAG(x) x##_2wsgpt0a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ)
|
||||
#define TAG(x) x##_2wsgpt0t1a
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
/* fog { */
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_FOGC)
|
||||
#define TAG(x) x##_wsgf
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
|
||||
#define TAG(x) x##_wsgt0f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_FOGC)
|
||||
#define TAG(x) x##_wsgt0t1f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_PTEX|SETUP_FOGC)
|
||||
#define TAG(x) x##_wsgpt0f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PTEX|SETUP_FOGC)
|
||||
#define TAG(x) x##_wsgpt0t1f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_wsgaf
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_wsgt0af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_wsgt0t1af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_wsgpt0af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_wsgpt0t1af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wsgf
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wsgt0f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wsgt0t1f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_PTEX|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wsgpt0f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PTEX|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wsgpt0t1f
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wsgaf
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wsgt0af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wsgt0t1af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wsgpt0af
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
|
||||
SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
|
||||
#define TAG(x) x##_2wsgpt0t1af
|
||||
#include "fxvbtmp.h"
|
||||
/* fog } */
|
||||
|
||||
|
||||
/* Vertex repair (multipass rendering)
|
||||
*/
|
||||
#define IND (SETUP_RGBA)
|
||||
#define TAG(x) x##_g
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_TMU0)
|
||||
#define TAG(x) x##_t0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_TMU0|SETUP_TMU1)
|
||||
#define TAG(x) x##_t0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_RGBA|SETUP_TMU0)
|
||||
#define TAG(x) x##_gt0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
|
||||
#define TAG(x) x##_gt0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
|
||||
#define IND (SETUP_RGBA|SETUP_SPEC)
|
||||
#define TAG(x) x##_2g
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_TMU0|SETUP_SPEC)
|
||||
#define TAG(x) x##_2t0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_TMU0|SETUP_SPEC|SETUP_TMU1)
|
||||
#define TAG(x) x##_2t0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
|
||||
#define TAG(x) x##_2gt0
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
#define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
|
||||
#define TAG(x) x##_2gt0t1
|
||||
#include "fxvbtmp.h"
|
||||
|
||||
|
||||
|
||||
static void init_setup_tab( void )
|
||||
{
|
||||
init_wg();
|
||||
init_wgt0();
|
||||
init_wgt0t1();
|
||||
init_wgpt0();
|
||||
init_wgpt0t1();
|
||||
init_wga();
|
||||
init_wgt0a();
|
||||
init_wgt0t1a();
|
||||
init_wgpt0a();
|
||||
init_wgpt0t1a();
|
||||
init_2wg();
|
||||
init_2wgt0();
|
||||
init_2wgt0t1();
|
||||
init_2wgpt0();
|
||||
init_2wgpt0t1();
|
||||
init_2wga();
|
||||
init_2wgt0a();
|
||||
init_2wgt0t1a();
|
||||
init_2wgpt0a();
|
||||
init_2wgpt0t1a();
|
||||
init_wgf();
|
||||
init_wgt0f();
|
||||
init_wgt0t1f();
|
||||
init_wgpt0f();
|
||||
init_wgpt0t1f();
|
||||
init_wgaf();
|
||||
init_wgt0af();
|
||||
init_wgt0t1af();
|
||||
init_wgpt0af();
|
||||
init_wgpt0t1af();
|
||||
init_2wgf();
|
||||
init_2wgt0f();
|
||||
init_2wgt0t1f();
|
||||
init_2wgpt0f();
|
||||
init_2wgpt0t1f();
|
||||
init_2wgaf();
|
||||
init_2wgt0af();
|
||||
init_2wgt0t1af();
|
||||
init_2wgpt0af();
|
||||
init_2wgpt0t1af();
|
||||
|
||||
init_wsg();
|
||||
init_wsgt0();
|
||||
init_wsgt0t1();
|
||||
init_wsgpt0();
|
||||
init_wsgpt0t1();
|
||||
init_wsga();
|
||||
init_wsgt0a();
|
||||
init_wsgt0t1a();
|
||||
init_wsgpt0a();
|
||||
init_wsgpt0t1a();
|
||||
init_2wsg();
|
||||
init_2wsgt0();
|
||||
init_2wsgt0t1();
|
||||
init_2wsgpt0();
|
||||
init_2wsgpt0t1();
|
||||
init_2wsga();
|
||||
init_2wsgt0a();
|
||||
init_2wsgt0t1a();
|
||||
init_2wsgpt0a();
|
||||
init_2wsgpt0t1a();
|
||||
init_wsgf();
|
||||
init_wsgt0f();
|
||||
init_wsgt0t1f();
|
||||
init_wsgpt0f();
|
||||
init_wsgpt0t1f();
|
||||
init_wsgaf();
|
||||
init_wsgt0af();
|
||||
init_wsgt0t1af();
|
||||
init_wsgpt0af();
|
||||
init_wsgpt0t1af();
|
||||
init_2wsgf();
|
||||
init_2wsgt0f();
|
||||
init_2wsgt0t1f();
|
||||
init_2wsgpt0f();
|
||||
init_2wsgpt0t1f();
|
||||
init_2wsgaf();
|
||||
init_2wsgt0af();
|
||||
init_2wsgt0t1af();
|
||||
init_2wsgpt0af();
|
||||
init_2wsgpt0t1af();
|
||||
|
||||
init_g();
|
||||
init_t0();
|
||||
init_t0t1();
|
||||
init_gt0();
|
||||
init_gt0t1();
|
||||
init_2g();
|
||||
init_2t0();
|
||||
init_2t0t1();
|
||||
init_2gt0();
|
||||
init_2gt0t1();
|
||||
}
|
||||
|
||||
|
||||
void fxPrintSetupFlags(char *msg, GLuint flags )
|
||||
{
|
||||
fprintf(stderr, "%s(%x): %s%s%s%s%s%s%s%s\n",
|
||||
msg,
|
||||
(int)flags,
|
||||
(flags & SETUP_XYZW) ? " xyzw," : "",
|
||||
(flags & SETUP_SNAP) ? " snap," : "",
|
||||
(flags & SETUP_RGBA) ? " rgba," : "",
|
||||
(flags & SETUP_TMU0) ? " tex-0," : "",
|
||||
(flags & SETUP_TMU1) ? " tex-1," : "",
|
||||
(flags & SETUP_PSIZ) ? " psiz," : "",
|
||||
(flags & SETUP_SPEC) ? " spec," : "",
|
||||
(flags & SETUP_FOGC) ? " fog," : "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void fxCheckTexSizes( GLcontext *ctx )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
fxMesaContext fxMesa = FX_CONTEXT( ctx );
|
||||
|
||||
if (!setup_tab[fxMesa->SetupIndex].check_tex_sizes(ctx)) {
|
||||
GLuint ind = fxMesa->SetupIndex |= (SETUP_PTEX|SETUP_RGBA);
|
||||
|
||||
/* Tdfx handles projective textures nicely; just have to change
|
||||
* up to the new vertex format.
|
||||
*/
|
||||
if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) {
|
||||
|
||||
fxMesa->stw_hint_state = setup_tab[ind].vertex_format;
|
||||
FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state);
|
||||
|
||||
/* This is required as we have just changed the vertex
|
||||
* format, so the interp routines must also change.
|
||||
* In the unfilled and twosided cases we are using the
|
||||
* Extras ones anyway, so leave them in place.
|
||||
*/
|
||||
if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
|
||||
tnl->Driver.Render.Interp = setup_tab[fxMesa->SetupIndex].interp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint end,
|
||||
GLuint newinputs )
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT( ctx );
|
||||
GrVertex *v = (fxMesa->verts + start);
|
||||
|
||||
if (!newinputs)
|
||||
return;
|
||||
|
||||
if (newinputs & VERT_BIT_POS) {
|
||||
setup_tab[fxMesa->SetupIndex].emit( ctx, start, end, v );
|
||||
} else {
|
||||
GLuint ind = 0;
|
||||
|
||||
if (newinputs & VERT_BIT_COLOR0)
|
||||
ind |= SETUP_RGBA;
|
||||
|
||||
if (newinputs & VERT_BIT_COLOR1)
|
||||
ind |= SETUP_SPEC;
|
||||
|
||||
if (newinputs & VERT_BIT_FOG)
|
||||
ind |= SETUP_FOGC;
|
||||
|
||||
if (newinputs & VERT_BIT_TEX0)
|
||||
ind |= SETUP_TMU0;
|
||||
|
||||
if (newinputs & VERT_BIT_TEX1)
|
||||
ind |= SETUP_TMU0|SETUP_TMU1;
|
||||
|
||||
if (fxMesa->SetupIndex & SETUP_PTEX)
|
||||
ind = ~0;
|
||||
|
||||
ind &= fxMesa->SetupIndex;
|
||||
|
||||
if (ind) {
|
||||
setup_tab[ind].emit( ctx, start, end, v );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fxChooseVertexState( GLcontext *ctx )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
fxMesaContext fxMesa = FX_CONTEXT( ctx );
|
||||
GLuint ind = SETUP_XYZW|SETUP_RGBA;
|
||||
|
||||
if (fxMesa->snapVertices)
|
||||
ind |= SETUP_SNAP;
|
||||
|
||||
fxMesa->tmu_source[0] = 0;
|
||||
fxMesa->tmu_source[1] = 1;
|
||||
|
||||
if (ctx->Texture._EnabledUnits & 0x2) {
|
||||
if (ctx->Texture._EnabledUnits & 0x1) {
|
||||
ind |= SETUP_TMU1;
|
||||
}
|
||||
ind |= SETUP_TMU0;
|
||||
fxMesa->tmu_source[0] = 1;
|
||||
fxMesa->tmu_source[1] = 0;
|
||||
}
|
||||
else if (ctx->Texture._EnabledUnits & 0x1) {
|
||||
ind |= SETUP_TMU0;
|
||||
}
|
||||
|
||||
if (ctx->_TriangleCaps & DD_POINT_ATTEN) {
|
||||
ind |= SETUP_PSIZ;
|
||||
}
|
||||
|
||||
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
|
||||
ind |= SETUP_SPEC;
|
||||
}
|
||||
|
||||
if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) {
|
||||
ind |= SETUP_FOGC;
|
||||
}
|
||||
|
||||
fxMesa->SetupIndex = ind;
|
||||
|
||||
if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
|
||||
tnl->Driver.Render.Interp = interp_extras;
|
||||
tnl->Driver.Render.CopyPV = copy_pv_extras;
|
||||
} else {
|
||||
tnl->Driver.Render.Interp = setup_tab[ind].interp;
|
||||
tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
|
||||
}
|
||||
|
||||
if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) {
|
||||
fxMesa->stw_hint_state = setup_tab[ind].vertex_format;
|
||||
FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void fxAllocVB( GLcontext *ctx )
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
|
||||
static int firsttime = 1;
|
||||
if (firsttime) {
|
||||
init_setup_tab();
|
||||
firsttime = 0;
|
||||
}
|
||||
|
||||
fxMesa->verts = (GrVertex *)_mesa_align_malloc(size * sizeof(GrVertex), 32);
|
||||
fxMesa->SetupIndex = SETUP_XYZW|SETUP_RGBA;
|
||||
}
|
||||
|
||||
|
||||
void fxFreeVB( GLcontext *ctx )
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
if (fxMesa->verts) {
|
||||
_mesa_align_free(fxMesa->verts);
|
||||
fxMesa->verts = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
|
||||
/*
|
||||
* Need this to provide at least one external definition.
|
||||
*/
|
||||
|
||||
extern int gl_fx_dummy_function_vb(void);
|
||||
int
|
||||
gl_fx_dummy_function_vb(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* FX */
|
||||
|
|
@ -1,370 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.1
|
||||
*
|
||||
* Copyright (C) 1999-2002 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.
|
||||
*/
|
||||
|
||||
/* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
* Daniel Borca <dborca@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
|
||||
#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12]
|
||||
#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13]
|
||||
#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14]
|
||||
|
||||
static void TAG(emit)( GLcontext *ctx,
|
||||
GLuint start, GLuint end,
|
||||
void *dest )
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
GLuint tmu0_source = fxMesa->tmu_source[0];
|
||||
GLuint tmu1_source = fxMesa->tmu_source[1];
|
||||
GLfloat (*tc0)[4], (*tc1)[4];
|
||||
GLfloat (*col)[4], (*spec)[4];
|
||||
GLuint tc0_stride, tc1_stride, col_stride, spec_stride;
|
||||
GLuint tc0_size, tc1_size, col_size;
|
||||
GLfloat (*proj)[4] = VB->NdcPtr->data;
|
||||
GLuint proj_stride = VB->NdcPtr->stride;
|
||||
GLfloat (*psize)[4];
|
||||
GLuint psize_stride;
|
||||
GLfloat (*fog)[4];
|
||||
GLuint fog_stride;
|
||||
GrVertex *v = (GrVertex *)dest;
|
||||
GLfloat u0scale,v0scale,u1scale,v1scale;
|
||||
const GLubyte *mask = VB->ClipMask;
|
||||
const GLfloat *const s = ctx->Viewport._WindowMap.m;
|
||||
int i;
|
||||
|
||||
if (IND & SETUP_PSIZ) {
|
||||
psize = VB->PointSizePtr->data;
|
||||
psize_stride = VB->PointSizePtr->stride;
|
||||
}
|
||||
|
||||
if (IND & SETUP_TMU0) {
|
||||
tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->data;
|
||||
tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->stride;
|
||||
u0scale = fxMesa->s0scale;
|
||||
v0scale = fxMesa->t0scale;
|
||||
if (IND & SETUP_PTEX)
|
||||
tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->size;
|
||||
}
|
||||
|
||||
if (IND & SETUP_TMU1) {
|
||||
tc1 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->data;
|
||||
tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->stride;
|
||||
u1scale = fxMesa->s1scale; /* wrong if tmu1_source == 0, possible? */
|
||||
v1scale = fxMesa->t1scale;
|
||||
if (IND & SETUP_PTEX)
|
||||
tc1_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->size;
|
||||
}
|
||||
|
||||
if (IND & SETUP_RGBA) {
|
||||
col = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->data;
|
||||
col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride;
|
||||
col_size = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size;
|
||||
}
|
||||
|
||||
if (IND & SETUP_SPEC) {
|
||||
spec = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->data;
|
||||
spec_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->stride;
|
||||
}
|
||||
|
||||
if (IND & SETUP_FOGC) {
|
||||
fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data;
|
||||
fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride;
|
||||
}
|
||||
|
||||
if (start) {
|
||||
proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride);
|
||||
if (IND & SETUP_PSIZ)
|
||||
psize = (GLfloat (*)[4])((GLubyte *)psize + start * psize_stride);
|
||||
if (IND & SETUP_TMU0)
|
||||
tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
|
||||
if (IND & SETUP_TMU1)
|
||||
tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride);
|
||||
if (IND & SETUP_RGBA)
|
||||
STRIDE_4F(col, start * col_stride);
|
||||
if (IND & SETUP_SPEC)
|
||||
STRIDE_4F(spec, start * spec_stride);
|
||||
if (IND & SETUP_FOGC)
|
||||
fog = (GLfloat (*)[4])((GLubyte *)fog + start * fog_stride);
|
||||
}
|
||||
|
||||
for (i=start; i < end; i++, v++) {
|
||||
if (IND & SETUP_PSIZ) {
|
||||
v->psize = psize[0][0];
|
||||
psize = (GLfloat (*)[4])((GLubyte *)psize + psize_stride);
|
||||
}
|
||||
|
||||
if (IND & SETUP_XYZW) {
|
||||
if (mask[i] == 0) {
|
||||
/* unclipped */
|
||||
VIEWPORT_X(v->x, proj[0][0]);
|
||||
VIEWPORT_Y(v->y, proj[0][1]);
|
||||
VIEWPORT_Z(v->ooz, proj[0][2]);
|
||||
v->oow = proj[0][3];
|
||||
|
||||
if (IND & SETUP_SNAP) {
|
||||
#if defined(USE_IEEE)
|
||||
const float snapper = (3L << 18);
|
||||
v->x += snapper;
|
||||
v->x -= snapper;
|
||||
v->y += snapper;
|
||||
v->y -= snapper;
|
||||
#else
|
||||
v->x = ((int) (v->x * 16.0f)) * (1.0f / 16.0f);
|
||||
v->y = ((int) (v->y * 16.0f)) * (1.0f / 16.0f);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
/* clipped */
|
||||
v->oow = 1.0;
|
||||
}
|
||||
|
||||
proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
|
||||
}
|
||||
if (IND & SETUP_RGBA) {
|
||||
#if FX_PACKEDCOLOR
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[2], col[0][0]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[1], col[0][1]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[0], col[0][2]);
|
||||
if (col_size == 4) {
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[3], col[0][3]);
|
||||
} else {
|
||||
v->pargb[3] = 255;
|
||||
}
|
||||
#else /* !FX_PACKEDCOLOR */
|
||||
CNORM(v->r, col[0][0]);
|
||||
CNORM(v->g, col[0][1]);
|
||||
CNORM(v->b, col[0][2]);
|
||||
if (col_size == 4) {
|
||||
CNORM(v->a, col[0][3]);
|
||||
} else {
|
||||
v->a = 255.0f;
|
||||
}
|
||||
#endif /* !FX_PACKEDCOLOR */
|
||||
STRIDE_4F(col, col_stride);
|
||||
}
|
||||
if (IND & SETUP_SPEC) {
|
||||
#if FX_PACKEDCOLOR
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[2], spec[0][0]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[1], spec[0][1]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[0], spec[0][2]);
|
||||
#else /* !FX_PACKEDCOLOR */
|
||||
CNORM(v->r1, spec[0][0]);
|
||||
CNORM(v->g1, spec[0][1]);
|
||||
CNORM(v->b1, spec[0][2]);
|
||||
#endif /* !FX_PACKEDCOLOR */
|
||||
STRIDE_4F(spec, spec_stride);
|
||||
}
|
||||
if (IND & SETUP_FOGC) {
|
||||
v->fog = CLAMP(fog[0][0], 0.0f, 1.0f);
|
||||
fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride);
|
||||
}
|
||||
if (IND & SETUP_TMU0) {
|
||||
GLfloat w = v->oow;
|
||||
v->tmuvtx[0].sow = tc0[0][0] * u0scale * w;
|
||||
v->tmuvtx[0].tow = tc0[0][1] * v0scale * w;
|
||||
if (IND & SETUP_PTEX) {
|
||||
v->tmuvtx[0].oow = w;
|
||||
if (tc0_size == 4)
|
||||
v->tmuvtx[0].oow *= tc0[0][3];
|
||||
}
|
||||
tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
|
||||
}
|
||||
if (IND & SETUP_TMU1) {
|
||||
GLfloat w = v->oow;
|
||||
v->tmuvtx[1].sow = tc1[0][0] * u1scale * w;
|
||||
v->tmuvtx[1].tow = tc1[0][1] * v1scale * w;
|
||||
if (IND & SETUP_PTEX) {
|
||||
v->tmuvtx[1].oow = w;
|
||||
if (tc1_size == 4)
|
||||
v->tmuvtx[1].oow *= tc1[0][3];
|
||||
}
|
||||
tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if (IND & SETUP_XYZW) && (IND & SETUP_RGBA)
|
||||
|
||||
static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
|
||||
{
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
if (IND & SETUP_PTEX)
|
||||
return GL_TRUE;
|
||||
|
||||
if (IND & SETUP_TMU0) {
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
|
||||
if (IND & SETUP_TMU1) {
|
||||
if (VB->AttribPtr[_TNL_ATTRIB_TEX0] == 0)
|
||||
VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1];
|
||||
|
||||
if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4)
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (VB->AttribPtr[_TNL_ATTRIB_TEX0] &&
|
||||
VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4)
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void TAG(interp)( GLcontext *ctx,
|
||||
GLfloat t,
|
||||
GLuint edst, GLuint eout, GLuint ein,
|
||||
GLboolean force_boundary )
|
||||
{
|
||||
fxMesaContext fxMesa = FX_CONTEXT( ctx );
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
const GLfloat *dstclip = VB->ClipPtr->data[edst];
|
||||
const GLfloat oow = (dstclip[3] == 0.0F) ? 1.0F : (1.0F / dstclip[3]);
|
||||
const GLfloat *const s = ctx->Viewport._WindowMap.m;
|
||||
GrVertex *fxverts = fxMesa->verts;
|
||||
GrVertex *dst = (GrVertex *) (fxverts + edst);
|
||||
const GrVertex *out = (const GrVertex *) (fxverts + eout);
|
||||
const GrVertex *in = (const GrVertex *) (fxverts + ein);
|
||||
const GLfloat wout = oow / out->oow;
|
||||
const GLfloat win = oow / in->oow;
|
||||
|
||||
VIEWPORT_X(dst->x, dstclip[0] * oow);
|
||||
VIEWPORT_Y(dst->y, dstclip[1] * oow);
|
||||
VIEWPORT_Z(dst->ooz, dstclip[2] * oow);
|
||||
dst->oow = oow;
|
||||
|
||||
if (IND & SETUP_SNAP) {
|
||||
#if defined(USE_IEEE)
|
||||
const float snapper = (3L << 18);
|
||||
dst->x += snapper;
|
||||
dst->x -= snapper;
|
||||
dst->y += snapper;
|
||||
dst->y -= snapper;
|
||||
#else
|
||||
dst->x = ((int) (dst->x * 16.0f)) * (1.0f / 16.0f);
|
||||
dst->y = ((int) (dst->y * 16.0f)) * (1.0f / 16.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if FX_PACKEDCOLOR
|
||||
INTERP_UB( t, dst->pargb[0], out->pargb[0], in->pargb[0] );
|
||||
INTERP_UB( t, dst->pargb[1], out->pargb[1], in->pargb[1] );
|
||||
INTERP_UB( t, dst->pargb[2], out->pargb[2], in->pargb[2] );
|
||||
INTERP_UB( t, dst->pargb[3], out->pargb[3], in->pargb[3] );
|
||||
#else /* !FX_PACKEDCOLOR */
|
||||
INTERP_F( t, dst->r, out->r, in->r );
|
||||
INTERP_F( t, dst->g, out->g, in->g );
|
||||
INTERP_F( t, dst->b, out->b, in->b );
|
||||
INTERP_F( t, dst->a, out->a, in->a );
|
||||
#endif /* !FX_PACKEDCOLOR */
|
||||
|
||||
if (IND & SETUP_SPEC) {
|
||||
#if FX_PACKEDCOLOR
|
||||
INTERP_UB( t, dst->pspec[0], out->pspec[0], in->pspec[0] );
|
||||
INTERP_UB( t, dst->pspec[1], out->pspec[1], in->pspec[1] );
|
||||
INTERP_UB( t, dst->pspec[2], out->pspec[2], in->pspec[2] );
|
||||
#else /* !FX_PACKEDCOLOR */
|
||||
INTERP_F( t, dst->r1, out->r1, in->r1 );
|
||||
INTERP_F( t, dst->g1, out->g1, in->g1 );
|
||||
INTERP_F( t, dst->b1, out->b1, in->b1 );
|
||||
#endif /* !FX_PACKEDCOLOR */
|
||||
}
|
||||
|
||||
if (IND & SETUP_FOGC) {
|
||||
INTERP_F( t, dst->fog, out->fog, in->fog );
|
||||
}
|
||||
|
||||
if (IND & SETUP_TMU0) {
|
||||
INTERP_F( t,
|
||||
dst->tmuvtx[0].sow,
|
||||
out->tmuvtx[0].sow * wout,
|
||||
in->tmuvtx[0].sow * win );
|
||||
INTERP_F( t,
|
||||
dst->tmuvtx[0].tow,
|
||||
out->tmuvtx[0].tow * wout,
|
||||
in->tmuvtx[0].tow * win );
|
||||
if (IND & SETUP_PTEX) {
|
||||
INTERP_F( t,
|
||||
dst->tmuvtx[0].oow,
|
||||
out->tmuvtx[0].oow * wout,
|
||||
in->tmuvtx[0].oow * win );
|
||||
}
|
||||
}
|
||||
|
||||
if (IND & SETUP_TMU1) {
|
||||
INTERP_F( t,
|
||||
dst->tmuvtx[1].sow,
|
||||
out->tmuvtx[1].sow * wout,
|
||||
in->tmuvtx[1].sow * win );
|
||||
INTERP_F( t,
|
||||
dst->tmuvtx[1].tow,
|
||||
out->tmuvtx[1].tow * wout,
|
||||
in->tmuvtx[1].tow * win );
|
||||
if (IND & SETUP_PTEX) {
|
||||
INTERP_F( t,
|
||||
dst->tmuvtx[1].oow,
|
||||
out->tmuvtx[1].oow * wout,
|
||||
in->tmuvtx[1].oow * win );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void TAG(init)( void )
|
||||
{
|
||||
setup_tab[IND].emit = TAG(emit);
|
||||
|
||||
if (IND & SETUP_SPEC) {
|
||||
setup_tab[IND].copy_pv = copy_pv2;
|
||||
} else {
|
||||
setup_tab[IND].copy_pv = copy_pv;
|
||||
}
|
||||
|
||||
#if ((IND & SETUP_XYZW) && (IND & SETUP_RGBA))
|
||||
setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
|
||||
setup_tab[IND].interp = TAG(interp);
|
||||
|
||||
setup_tab[IND].vertex_format = 0;
|
||||
if (IND & SETUP_PTEX) {
|
||||
setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU0;
|
||||
}
|
||||
|
||||
#if (IND & SETUP_TMU1)
|
||||
setup_tab[IND].vertex_format |= GR_STWHINT_ST_DIFF_TMU1;
|
||||
if (IND & SETUP_PTEX) {
|
||||
setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#undef IND
|
||||
#undef TAG
|
||||
Loading…
Add table
Reference in a new issue