/* $Id: fxglidew.c,v 1.21 2003/08/19 15:52:53 brianp Exp $ */ /* * 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 "glide.h" #include "fxglidew.h" #include "fxdrv.h" #include #include FxI32 FX_grGetInteger_NoLock(FxU32 pname) { FxI32 result; if (grGet(pname, 4, &result)) { return result; } if (MESA_VERBOSE & VERBOSE_DRIVER) { fprintf(stderr, "Wrong parameter in FX_grGetInteger!\n"); } 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_grAADrawLine(GrVertex * a, GrVertex * b) { /* ToDo */ BEGIN_CLIP_LOOP(); grDrawLine(a, b); END_CLIP_LOOP(); } void FX_grAADrawPoint(GrVertex * a) { BEGIN_CLIP_LOOP(); grDrawPoint(a); END_CLIP_LOOP(); } 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); grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE); grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE); 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, "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 { /* Voodoo1,2,rush */ /* ZZZ TO DO */ config->SSTs[i].type = GR_SSTTYPE_VOODOO; } grGet(GR_MEMORY_FB, 4, &result); config->SSTs[i].VoodooConfig.fbRam = result / (1024 * 1024); grGet(GR_NUM_TMU, 4, &result); config->SSTs[i].VoodooConfig.nTexelfx = result; grGet(GR_REVISION_FB, 4, &result); config->SSTs[i].VoodooConfig.fbiRev = result; for (j = 0; j < config->SSTs[i].VoodooConfig.nTexelfx; j++) { grGet(GR_MEMORY_TMU, 4, &result); config->SSTs[i].VoodooConfig.tmuConfig[j].tmuRam = result / (1024 * 1024); grGet(GR_REVISION_TMU, 4, &result); config->SSTs[i].VoodooConfig.tmuConfig[j].tmuRev = result; } extension = grGetString(GR_EXTENSION); if (strstr(extension, " PIXEXT ")) { config->SSTs[i].VoodooConfig.grSstWinOpenExt = grGetProcAddress("grSstWinOpenExt"); } /* [koolsmoky] */ grGet(GR_MAX_TEXTURE_SIZE, 4, &result); config->SSTs[i].VoodooConfig.maxTextureSize = result; /* need to get the number of SLI units for napalm */ grGet(GR_NUM_FB, 4, (void *) &numFB); config->SSTs[i].VoodooConfig.numChips = numFB; /* this can only be useful for Voodoo2: * sliDetect = ((config->SSTs[i].type == GR_SSTTYPE_Voodoo2) && (numFB > 1)); */ } END_BOARD_LOCK(); return 1; } /* It appears to me that this function is needed either way. */ GrContext_t FX_grSstWinOpen(struct SstCard_St *c, FxU32 hWnd, GrScreenResolution_t screen_resolution, GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrPixelFormat_t pixel_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers) { GrContext_t i; BEGIN_BOARD_LOCK(); if (c->VoodooConfig.grSstWinOpenExt) { i = c->VoodooConfig.grSstWinOpenExt(hWnd, screen_resolution, refresh_rate, color_format, origin_location, pixel_format, nColBuffers, nAuxBuffers); } else i = grSstWinOpen(hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers); /* fprintf(stderr, "grSstWinOpen( win %d res %d ref %d fmt %d\n" " org %d ncol %d naux %d )\n" " ==> %d\n", hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers, i); */ END_BOARD_LOCK(); return i; } #else /* * 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 */