⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tdfx_context.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
/* -*- mode: c; c-basic-offset: 3 -*- * * Copyright 2000 VA Linux Systems Inc., Fremont, California. * * 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 (including the next * paragraph) 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 * VA LINUX SYSTEMS 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. *//** * \file tdfx_context.c * Context management functions for 3Dfx hardware. * * \author Gareth Hughes <gareth@valinux.com> (original rewrite 29 Sep - 1 Oct 2000) * \author Brian Paul <brianp@valinux.com> * \author Daniel Borca <dborca@users.sourceforge.net> (new fixes 19 Jul 2004) */#include <dlfcn.h>#include "tdfx_context.h"#include "tdfx_dd.h"#include "tdfx_state.h"#include "tdfx_vb.h"#include "tdfx_tex.h"#include "tdfx_tris.h"#include "tdfx_render.h"#include "tdfx_span.h"#include "tdfx_texman.h"#include "extensions.h"#include "hash.h"#include "texobj.h"#include "swrast/swrast.h"#include "swrast_setup/swrast_setup.h"#include "vbo/vbo.h"#include "tnl/tnl.h"#include "tnl/t_pipeline.h"#include "drivers/common/driverfuncs.h"#include "utils.h"#define need_GL_ARB_multisample/* #define need_GL_ARB_point_parameters */#define need_GL_ARB_occlusion_query#define need_GL_ARB_texture_compression#define need_GL_ARB_vertex_buffer_object/* #define need_GL_ARB_vertex_program */#define need_GL_EXT_blend_equation_separate#define need_GL_EXT_blend_func_separate#define need_GL_EXT_blend_minmax#define need_GL_EXT_fog_coord#define need_GL_EXT_multi_draw_arrays#define need_GL_EXT_paletted_texture/* #define need_GL_EXT_secondary_color */#define need_GL_IBM_multimode_draw_arrays/* #define need_GL_MESA_program_debug *//* #define need_GL_NV_vertex_program */#include "extension_helper.h"/** * Common extension strings exported by all cards */const struct dri_extension card_extensions[] ={    { "GL_ARB_multisample",                GL_ARB_multisample_functions },    { "GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions },    { "GL_ARB_texture_mirrored_repeat",    NULL },    { "GL_ARB_vertex_buffer_object",       GL_ARB_vertex_buffer_object_functions },    { "GL_EXT_blend_func_separate",        GL_EXT_blend_func_separate_functions },    { "GL_EXT_fog_coord",                  GL_EXT_fog_coord_functions },    { "GL_EXT_multi_draw_arrays",          GL_EXT_multi_draw_arrays_functions },    { "GL_EXT_paletted_texture",           GL_EXT_paletted_texture_functions },    { "GL_EXT_shared_texture_palette",     NULL },    { "GL_EXT_stencil_wrap",               NULL },    { "GL_EXT_texture_env_add",            NULL },    { "GL_EXT_texture_lod_bias",           NULL },    { "GL_IBM_multimode_draw_arrays",      GL_IBM_multimode_draw_arrays_functions },#ifdef need_GL_ARB_point_parameters    { "GL_ARB_point_parameters",           GL_ARB_point_parameters_functions },    { "GL_ARB_point_sprite",               NULL },#endif#ifdef need_GL_EXT_secondary_color    { "GL_EXT_secondary_color",            GL_EXT_secondary_color_functions },#endif#ifdef need_GL_ARB_vertex_program    { "GL_ARB_vertex_program",             GL_ARB_vertex_program_functions }#endif#ifdef need_GL_NV_vertex_program    { "GL_NV_vertex_program",              GL_NV_vertex_program_functions }    { "GL_NV_vertex_program1_1",           NULL },#endif#ifdef need_GL_MESA_program_debug    { "GL_MESA_program_debug",             GL_MESA_program_debug_functions },#endif    { NULL,                                NULL }};/** * Extension strings exported only by Naplam (e.g., Voodoo4 & Voodoo5) cards. */const struct dri_extension napalm_extensions[] ={    { "GL_ARB_texture_compression",        GL_ARB_texture_compression_functions },    { "GL_ARB_texture_env_combine",        NULL },    { "GL_EXT_blend_equation_separate",    GL_EXT_blend_equation_separate_functions },    { "GL_EXT_blend_subtract",             GL_EXT_blend_minmax_functions },    { "GL_EXT_texture_compression_s3tc",   NULL },    { "GL_EXT_texture_env_combine",        NULL },    { "GL_3DFX_texture_compression_FXT1",  NULL },    { "GL_NV_blend_square",                NULL },    { "GL_S3_s3tc",                        NULL },    { NULL,                                NULL }};/* * Enable/Disable the extensions for this context. */static void tdfxDDInitExtensions( GLcontext *ctx ){   tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);   driInitExtensions( ctx, card_extensions, GL_FALSE );   if ( fxMesa->haveTwoTMUs ) {      _mesa_enable_extension( ctx, "GL_ARB_multitexture" );   }   if ( TDFX_IS_NAPALM( fxMesa ) ) {      driInitExtensions( ctx, napalm_extensions, GL_FALSE );   } else {      _mesa_enable_extension( ctx, "GL_SGIS_generate_mipmap" );   }}static const struct tnl_pipeline_stage *tdfx_pipeline[] = {   &_tnl_vertex_transform_stage,    &_tnl_normal_transform_stage,    &_tnl_lighting_stage,   &_tnl_fog_coordinate_stage,    &_tnl_texgen_stage,    &_tnl_texture_transform_stage,    &_tnl_point_attenuation_stage,   &_tnl_render_stage,		   0,};static const struct dri_debug_control debug_control[] ={    { "dri",   DEBUG_VERBOSE_DRI },    { "sync",  DEBUG_ALWAYS_SYNC },    { "api",   DEBUG_VERBOSE_API },    { "fall",  DEBUG_VERBOSE_FALL },    { NULL,    0 }};GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,			     __DRIcontextPrivate *driContextPriv,                             void *sharedContextPrivate ){   tdfxContextPtr fxMesa;   GLcontext *ctx, *shareCtx;   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;   tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private;   TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) ((char *) sPriv->pSAREA +					      sizeof(drm_sarea_t));   struct dd_function_table functions;   /* Allocate tdfx context */   fxMesa = (tdfxContextPtr) CALLOC( sizeof(tdfxContextRec) );   if (!fxMesa)      return GL_FALSE;   /* Init default driver functions then plug in our tdfx-specific functions    * (the texture functions are especially important)    */   _mesa_init_driver_functions(&functions);   tdfxDDInitDriverFuncs(mesaVis, &functions);   tdfxInitTextureFuncs(&functions);   tdfxInitRenderFuncs(&functions);   /* Allocate the Mesa context */   if (sharedContextPrivate)      shareCtx = ((tdfxContextPtr) sharedContextPrivate)->glCtx;   else       shareCtx = NULL;   fxMesa->glCtx = _mesa_create_context(mesaVis, shareCtx,                                        &functions, (void *) fxMesa);   if (!fxMesa->glCtx) {      FREE(fxMesa);      return GL_FALSE;   }   driContextPriv->driverPrivate = fxMesa;   /* Mirror some important DRI state    */   fxMesa->hHWContext = driContextPriv->hHWContext;   fxMesa->driHwLock = &sPriv->pSAREA->lock;   fxMesa->driFd = sPriv->fd;   fxMesa->driScreen = sPriv;   fxMesa->driContext = driContextPriv;   fxMesa->fxScreen = fxScreen;   fxMesa->sarea = saPriv;   /*JJJ - really?*/   fxMesa->haveHwAlpha = ( mesaVis->alphaBits &&                           ((mesaVis->greenBits == 8) ||                            (mesaVis->depthBits == 0)) );   fxMesa->haveHwStencil = ( TDFX_IS_NAPALM( fxMesa ) &&			     mesaVis->stencilBits &&			     mesaVis->depthBits == 24 );   fxMesa->screen_width = fxScreen->width;   fxMesa->screen_height = fxScreen->height;   fxMesa->new_gl_state = ~0;   fxMesa->new_state = ~0;   fxMesa->dirty = ~0;   /* Parse configuration files */   driParseConfigFiles (&fxMesa->optionCache, &fxScreen->optionCache,                        fxMesa->driScreen->myNum, "tdfx");   /* NOTE: This must be here before any Glide calls! */   if (!tdfxInitGlide( fxMesa )) {      FREE(fxMesa);      return GL_FALSE;   }   fxMesa->Glide.grDRIOpen( (char*) sPriv->pFB, fxScreen->regs.map, fxScreen->deviceID,	      fxScreen->width, fxScreen->height, fxScreen->mem, fxScreen->cpp,	      fxScreen->stride, fxScreen->fifoOffset, fxScreen->fifoSize,	      fxScreen->fbOffset, fxScreen->backOffset, fxScreen->depthOffset,	      fxScreen->textureOffset, fxScreen->textureSize, &saPriv->fifoPtr,	      &saPriv->fifoRead );   if ( getenv( "FX_GLIDE_SWAPINTERVAL" ) ) {      fxMesa->Glide.SwapInterval = atoi( getenv( "FX_GLIDE_SWAPINTERVAL" ) );   } else {      fxMesa->Glide.SwapInterval = 0;   }   if ( getenv( "FX_MAX_PENDING_SWAPS" ) ) {      fxMesa->Glide.MaxPendingSwaps = atoi( getenv( "FX_MAX_PENDING_SWAPS" ) );   } else {      fxMesa->Glide.MaxPendingSwaps = 2;   }   fxMesa->Glide.Initialized = GL_FALSE;   fxMesa->Glide.Board = 0;   if (getenv("FX_EMULATE_SINGLE_TMU")) {      fxMesa->haveTwoTMUs = GL_FALSE;   }   else {      if ( TDFX_IS_BANSHEE( fxMesa ) ) {         fxMesa->haveTwoTMUs = GL_FALSE;      } else {         fxMesa->haveTwoTMUs = GL_TRUE;      }   }   fxMesa->stats.swapBuffer = 0;   fxMesa->stats.reqTexUpload = 0;   fxMesa->stats.texUpload = 0;   fxMesa->stats.memTexUpload = 0;   fxMesa->tmuSrc = TDFX_TMU_NONE;   ctx = fxMesa->glCtx;   if ( TDFX_IS_NAPALM( fxMesa ) ) {      ctx->Const.MaxTextureLevels = 12;   } else {      ctx->Const.MaxTextureLevels = 9;   }   ctx->Const.MaxTextureUnits = TDFX_IS_BANSHEE( fxMesa ) ? 1 : 2;   ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;   ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;   /* No wide points.    */   ctx->Const.MinPointSize = 1.0;   ctx->Const.MinPointSizeAA = 1.0;   ctx->Const.MaxPointSize = 1.0;   ctx->Const.MaxPointSizeAA = 1.0;   /* Disable wide lines as we can't antialias them correctly in    * hardware.    */   ctx->Const.MinLineWidth = 1.0;   ctx->Const.MinLineWidthAA = 1.0;   ctx->Const.MaxLineWidth = 1.0;   ctx->Const.MaxLineWidthAA = 1.0;   ctx->Const.LineWidthGranularity = 1.0;   /* Initialize the software rasterizer and helper modules.    */   _swrast_CreateContext( ctx );   _vbo_CreateContext( ctx );   _tnl_CreateContext( ctx );   _swsetup_CreateContext( ctx );   /* Install the customized pipeline:    */   _tnl_destroy_pipeline( ctx );   _tnl_install_pipeline( ctx, tdfx_pipeline );   /* Configure swrast and T&L to match hardware characteristics:    */   _swrast_allow_pixel_fog( ctx, GL_TRUE );   _swrast_allow_vertex_fog( ctx, GL_FALSE );   _tnl_allow_pixel_fog( ctx, GL_TRUE );   _tnl_allow_vertex_fog( ctx, GL_FALSE );   tdfxDDInitExtensions( ctx );   /* XXX these should really go right after _mesa_init_driver_functions() */   tdfxDDInitSpanFuncs( ctx ); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -