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

📄 radeon_context.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_context.c,v 1.9 2003/09/24 02:43:12 dawes Exp $ *//**************************************************************************Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and                     VA Linux Systems Inc., Fremont, California.All Rights Reserved.Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:The above copyright notice and this permission notice (including thenext paragraph) shall be included in all copies or substantialportions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BELIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIONOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIONWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.**************************************************************************//* * Authors: *   Kevin E. Martin <martin@valinux.com> *   Gareth Hughes <gareth@valinux.com> *   Keith Whitwell <keith@tungstengraphics.com> */#include "main/glheader.h"#include "main/api_arrayelt.h"#include "main/context.h"#include "main/simple_list.h"#include "main/imports.h"#include "main/matrix.h"#include "main/extensions.h"#include "main/framebuffer.h"#include "main/state.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 "radeon_context.h"#include "radeon_ioctl.h"#include "radeon_state.h"#include "radeon_span.h"#include "radeon_tex.h"#include "radeon_swtcl.h"#include "radeon_tcl.h"#include "radeon_maos.h"#define need_GL_ARB_multisample#define need_GL_ARB_texture_compression#define need_GL_ARB_vertex_buffer_object#define need_GL_EXT_blend_minmax#define need_GL_EXT_fog_coord#define need_GL_EXT_secondary_color#include "extension_helper.h"#define DRIVER_DATE	"20061018"#include "vblank.h"#include "utils.h"#include "xmlpool.h" /* for symbolic values of enum-type options */#ifndef RADEON_DEBUGint RADEON_DEBUG = (0);#endif/* Return various strings for glGetString(). */static const GLubyte *radeonGetString( GLcontext *ctx, GLenum name ){   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);   static char buffer[128];   unsigned   offset;   GLuint agp_mode = (rmesa->radeonScreen->card_type==RADEON_CARD_PCI) ? 0 :      rmesa->radeonScreen->AGPMode;   switch ( name ) {   case GL_VENDOR:      return (GLubyte *)"Tungsten Graphics, Inc.";   case GL_RENDERER:      offset = driGetRendererString( buffer, "Radeon", DRIVER_DATE,				     agp_mode );      sprintf( & buffer[ offset ], " %sTCL",	       !(rmesa->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)	       ? "" : "NO-" );      return (GLubyte *)buffer;   default:      return NULL;   }}/* Extension strings exported by the R100 driver. */const struct dri_extension card_extensions[] ={    { "GL_ARB_multisample",                GL_ARB_multisample_functions },    { "GL_ARB_multitexture",               NULL },    { "GL_ARB_texture_border_clamp",       NULL },    { "GL_ARB_texture_compression",        GL_ARB_texture_compression_functions },    { "GL_ARB_texture_env_add",            NULL },    { "GL_ARB_texture_env_combine",        NULL },    { "GL_ARB_texture_env_crossbar",       NULL },    { "GL_ARB_texture_env_dot3",           NULL },    { "GL_ARB_texture_mirrored_repeat",    NULL },    { "GL_ARB_vertex_buffer_object",       GL_ARB_vertex_buffer_object_functions },    { "GL_EXT_blend_logic_op",             NULL },    { "GL_EXT_blend_subtract",             GL_EXT_blend_minmax_functions },    { "GL_EXT_fog_coord",                  GL_EXT_fog_coord_functions },    { "GL_EXT_secondary_color",            GL_EXT_secondary_color_functions },    { "GL_EXT_stencil_wrap",               NULL },    { "GL_EXT_texture_edge_clamp",         NULL },    { "GL_EXT_texture_env_combine",        NULL },    { "GL_EXT_texture_env_dot3",           NULL },    { "GL_EXT_texture_filter_anisotropic", NULL },    { "GL_EXT_texture_lod_bias",           NULL },    { "GL_EXT_texture_mirror_clamp",       NULL },    { "GL_ATI_texture_env_combine3",       NULL },    { "GL_ATI_texture_mirror_once",        NULL },    { "GL_MESA_ycbcr_texture",             NULL },    { "GL_NV_blend_square",                NULL },    { "GL_SGIS_generate_mipmap",           NULL },    { NULL,                                NULL }};extern const struct tnl_pipeline_stage _radeon_render_stage;extern const struct tnl_pipeline_stage _radeon_tcl_stage;static const struct tnl_pipeline_stage *radeon_pipeline[] = {   /* Try and go straight to t&l    */   &_radeon_tcl_stage,     /* Catch any t&l fallbacks    */   &_tnl_vertex_transform_stage,   &_tnl_normal_transform_stage,   &_tnl_lighting_stage,   &_tnl_fog_coordinate_stage,   &_tnl_texgen_stage,   &_tnl_texture_transform_stage,   &_radeon_render_stage,   &_tnl_render_stage,		/* FALLBACK:  */   NULL,};/* Initialize the driver's misc functions. */static void radeonInitDriverFuncs( struct dd_function_table *functions ){    functions->GetString	= radeonGetString;}static const struct dri_debug_control debug_control[] ={    { "fall",  DEBUG_FALLBACKS },    { "tex",   DEBUG_TEXTURE },    { "ioctl", DEBUG_IOCTL },    { "prim",  DEBUG_PRIMS },    { "vert",  DEBUG_VERTS },    { "state", DEBUG_STATE },    { "code",  DEBUG_CODEGEN },    { "vfmt",  DEBUG_VFMT },    { "vtxf",  DEBUG_VFMT },    { "verb",  DEBUG_VERBOSE },    { "dri",   DEBUG_DRI },    { "dma",   DEBUG_DMA },    { "san",   DEBUG_SANITY },    { "sync",  DEBUG_SYNC },    { NULL,    0 }};/* Create the device specific context. */GLbooleanradeonCreateContext( const __GLcontextModes *glVisual,                     __DRIcontextPrivate *driContextPriv,                     void *sharedContextPrivate){   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;   radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);   struct dd_function_table functions;   radeonContextPtr rmesa;   GLcontext *ctx, *shareCtx;   int i;   int tcl_mode, fthrottle_mode;   assert(glVisual);   assert(driContextPriv);   assert(screen);   /* Allocate the Radeon context */   rmesa = (radeonContextPtr) CALLOC( sizeof(*rmesa) );   if ( !rmesa )      return GL_FALSE;   /* init exp fog table data */   radeonInitStaticFogData();      /* Parse configuration files.    * Do this here so that initialMaxAnisotropy is set before we create    * the default textures.    */   driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,			screen->driScreen->myNum, "radeon");   rmesa->initialMaxAnisotropy = driQueryOptionf(&rmesa->optionCache,                                                 "def_max_anisotropy");   if ( driQueryOptionb( &rmesa->optionCache, "hyperz" ) ) {      if ( sPriv->drm_version.minor < 13 )	 fprintf( stderr, "DRM version 1.%d too old to support HyperZ, "			  "disabling.\n", sPriv->drm_version.minor );      else	 rmesa->using_hyperz = GL_TRUE;   }   if ( sPriv->drm_version.minor >= 15 )      rmesa->texmicrotile = GL_TRUE;   /* Init default driver functions then plug in our Radeon-specific functions    * (the texture functions are especially important)    */   _mesa_init_driver_functions( &functions );   radeonInitDriverFuncs( &functions );   radeonInitTextureFuncs( &functions );   /* Allocate the Mesa context */   if (sharedContextPrivate)      shareCtx = ((radeonContextPtr) sharedContextPrivate)->glCtx;   else      shareCtx = NULL;   rmesa->glCtx = _mesa_create_context(glVisual, shareCtx,                                       &functions, (void *) rmesa);   if (!rmesa->glCtx) {      FREE(rmesa);      return GL_FALSE;   }   driContextPriv->driverPrivate = rmesa;   /* Init radeon context data */   rmesa->dri.context = driContextPriv;   rmesa->dri.screen = sPriv;   rmesa->dri.drawable = NULL;   rmesa->dri.readable = NULL;   rmesa->dri.hwContext = driContextPriv->hHWContext;   rmesa->dri.hwLock = &sPriv->pSAREA->lock;   rmesa->dri.fd = sPriv->fd;   rmesa->dri.drmMinor = sPriv->drm_version.minor;   rmesa->radeonScreen = screen;   rmesa->sarea = (drm_radeon_sarea_t *)((GLubyte *)sPriv->pSAREA +				       screen->sarea_priv_offset);   rmesa->dma.buf0_address = rmesa->radeonScreen->buffers->list[0].address;   (void) memset( rmesa->texture_heaps, 0, sizeof( rmesa->texture_heaps ) );   make_empty_list( & rmesa->swapped );   rmesa->nr_heaps = screen->numTexHeaps;   for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {      rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa,	    screen->texSize[i],	    12,	    RADEON_NR_TEX_REGIONS,	    (drmTextureRegionPtr)rmesa->sarea->tex_list[i],	    & rmesa->sarea->tex_age[i],	    & rmesa->swapped,	    sizeof( radeonTexObj ),	    (destroy_texture_object_t *) radeonDestroyTexObj );      driSetTextureSwapCounterLocation( rmesa->texture_heaps[i],					& rmesa->c_textureSwaps );   }   rmesa->texture_depth = driQueryOptioni (&rmesa->optionCache,					   "texture_depth");   if (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)      rmesa->texture_depth = ( screen->cpp == 4 ) ?	 DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;   rmesa->swtcl.RenderIndex = ~0;   rmesa->hw.all_dirty = GL_TRUE;   /* Set the maximum texture size small enough that we can guarentee that    * all texture units can bind a maximal texture and have all of them in    * texturable memory at once. Depending on the allow_large_textures driconf    * setting allow larger textures.    */   ctx = rmesa->glCtx;   ctx->Const.MaxTextureUnits = driQueryOptioni (&rmesa->optionCache,						 "texture_units");   ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;

⌨️ 快捷键说明

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