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

📄 r200_context.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
/*Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.The Weather Channel (TM) funded Tungsten Graphics to develop theinitial release of the Radeon 8500 driver under the XFree86 license.This notice must be preserved.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: *   Keith Whitwell <keith@tungstengraphics.com> */#include "glheader.h"#include "api_arrayelt.h"#include "context.h"#include "simple_list.h"#include "imports.h"#include "matrix.h"#include "extensions.h"#include "framebuffer.h"#include "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 "r200_context.h"#include "r200_ioctl.h"#include "r200_state.h"#include "r200_span.h"#include "r200_pixel.h"#include "r200_tex.h"#include "r200_swtcl.h"#include "r200_tcl.h"#include "r200_maos.h"#include "r200_vertprog.h"#define need_GL_ARB_multisample#define need_GL_ARB_texture_compression#define need_GL_ARB_vertex_buffer_object#define need_GL_ARB_vertex_program#define need_GL_ATI_fragment_shader#define need_GL_EXT_blend_minmax#define need_GL_EXT_fog_coord#define need_GL_EXT_multi_draw_arrays#define need_GL_EXT_secondary_color#define need_GL_EXT_blend_equation_separate#define need_GL_EXT_blend_func_separate#define need_GL_NV_vertex_program#define need_GL_ARB_point_parameters#include "extension_helper.h"#define DRIVER_DATE	"20060602"#include "vblank.h"#include "utils.h"#include "xmlpool.h" /* for symbolic values of enum-type options */#ifndef R200_DEBUGint R200_DEBUG = (0);#endif/* Return various strings for glGetString(). */static const GLubyte *r200GetString( GLcontext *ctx, GLenum name ){   r200ContextPtr rmesa = R200_CONTEXT(ctx);   static char buffer[128];   unsigned   offset;   GLuint agp_mode = (rmesa->r200Screen->card_type == RADEON_CARD_PCI)? 0 :      rmesa->r200Screen->AGPMode;   switch ( name ) {   case GL_VENDOR:      return (GLubyte *)"Tungsten Graphics, Inc.";   case GL_RENDERER:      offset = driGetRendererString( buffer, "R200", DRIVER_DATE,				     agp_mode );      sprintf( & buffer[ offset ], " %sTCL",	       !(rmesa->TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)	       ? "" : "NO-" );      return (GLubyte *)buffer;   default:      return NULL;   }}/* Extension strings exported by the R200 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_dot3",           NULL },    { "GL_ARB_texture_env_crossbar",       NULL },    { "GL_ARB_texture_mirrored_repeat",    NULL },    { "GL_ARB_vertex_buffer_object",       GL_ARB_vertex_buffer_object_functions },    { "GL_EXT_blend_minmax",               GL_EXT_blend_minmax_functions },    { "GL_EXT_blend_subtract",             NULL },    { "GL_EXT_fog_coord",                  GL_EXT_fog_coord_functions },    { "GL_EXT_multi_draw_arrays",          GL_EXT_multi_draw_arrays_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_EXT_texture_rectangle",          NULL },    { "GL_ATI_texture_env_combine3",       NULL },    { "GL_ATI_texture_mirror_once",        NULL },    { "GL_MESA_pack_invert",               NULL },    { "GL_NV_blend_square",                NULL },    { "GL_SGIS_generate_mipmap",           NULL },    { NULL,                                NULL }};const struct dri_extension blend_extensions[] = {    { "GL_EXT_blend_equation_separate",    GL_EXT_blend_equation_separate_functions },    { "GL_EXT_blend_func_separate",        GL_EXT_blend_func_separate_functions },    { NULL,                                NULL }};const struct dri_extension ARB_vp_extension[] = {    { "GL_ARB_vertex_program",             GL_ARB_vertex_program_functions }};const struct dri_extension NV_vp_extension[] = {    { "GL_NV_vertex_program",              GL_NV_vertex_program_functions }};const struct dri_extension ATI_fs_extension[] = {    { "GL_ATI_fragment_shader",            GL_ATI_fragment_shader_functions }};const struct dri_extension point_extensions[] = {    { "GL_ARB_point_sprite",               NULL },    { "GL_ARB_point_parameters",           GL_ARB_point_parameters_functions },    { NULL,                                NULL }};extern const struct tnl_pipeline_stage _r200_render_stage;extern const struct tnl_pipeline_stage _r200_tcl_stage;static const struct tnl_pipeline_stage *r200_pipeline[] = {   /* Try and go straight to t&l    */   &_r200_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,   &_tnl_point_attenuation_stage,   &_tnl_vertex_program_stage,   /* Try again to go to tcl?     *     - no good for asymmetric-twoside (do with multipass)    *     - no good for asymmetric-unfilled (do with multipass)    *     - good for material    *     - good for texgen    *     - need to manipulate a bit of state    *    * - worth it/not worth it?    */			   /* Else do them here.    *//*    &_r200_render_stage,  */ /* FIXME: bugs with ut2003 */   &_tnl_render_stage,		/* FALLBACK:  */   NULL,};/* Initialize the driver's misc functions. */static void r200InitDriverFuncs( struct dd_function_table *functions ){    functions->GetBufferSize		= NULL; /* OBSOLETE */    functions->GetString		= r200GetString;}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 },    { "pix",   DEBUG_PIXEL },    { "mem",   DEBUG_MEMORY },    { NULL,    0 }};/* Create the device specific rendering context. */GLboolean r200CreateContext( const __GLcontextModes *glVisual,			     __DRIcontextPrivate *driContextPriv,			     void *sharedContextPrivate){   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;   radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);   struct dd_function_table functions;   r200ContextPtr rmesa;   GLcontext *ctx, *shareCtx;   int i;   int tcl_mode, fthrottle_mode;   assert(glVisual);   assert(driContextPriv);   assert(screen);   /* Allocate the R200 context */   rmesa = (r200ContextPtr) CALLOC( sizeof(*rmesa) );   if ( !rmesa )      return GL_FALSE;         /* init exp fog table data */   r200InitStaticFogData();   /* 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, "r200");   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 R200-specific functions    * (the texture functions are especially important)    */   _mesa_init_driver_functions(&functions);   r200InitDriverFuncs(&functions);   r200InitIoctlFuncs(&functions);   r200InitStateFuncs(&functions);   r200InitTextureFuncs(&functions);   r200InitShaderFuncs(&functions);    /* Allocate and initialize the Mesa context */   if (sharedContextPrivate)      shareCtx = ((r200ContextPtr) 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 r200 context data */   rmesa->dri.context = driContextPriv;   rmesa->dri.screen = sPriv;   rmesa->dri.drawable = NULL; /* Set by XMesaMakeCurrent */   rmesa->dri.hwContext = driContextPriv->hHWContext;   rmesa->dri.hwLock = &sPriv->pSAREA->lock;   rmesa->dri.fd = sPriv->fd;   rmesa->dri.drmMinor = sPriv->drm_version.minor;   rmesa->r200Screen = screen;   rmesa->sarea = (drm_radeon_sarea_t *)((GLubyte *)sPriv->pSAREA +				       screen->sarea_priv_offset);   rmesa->dma.buf0_address = rmesa->r200Screen->buffers->list[0].address;   (void) memset( rmesa->texture_heaps, 0, sizeof( rmesa->texture_heaps ) );   make_empty_list( & rmesa->swapped );   rmesa->nr_heaps = 1 /* screen->numTexHeaps */ ;   assert(rmesa->nr_heaps < RADEON_NR_TEX_HEAPS);   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( r200TexObj ),	    (destroy_texture_object_t *) r200DestroyTexObj );   }   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 = 1;   /* 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

⌨️ 快捷键说明

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