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

📄 r200_context.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
    * setting allow larger textures.    */   ctx = rmesa->glCtx;   ctx->Const.MaxTextureUnits = driQueryOptioni (&rmesa->optionCache,						 "texture_units");   ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;   ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;   i = driQueryOptioni( &rmesa->optionCache, "allow_large_textures");   driCalculateMaxTextureLevels( rmesa->texture_heaps,				 rmesa->nr_heaps,				 & ctx->Const,				 4,				 11, /* max 2D texture size is 2048x2048 */#if ENABLE_HW_3D_TEXTURE				 8,  /* max 3D texture size is 256^3 */#else				 0,  /* 3D textures unsupported */#endif				 11, /* max cube texture size is 2048x2048 */				 11, /* max texture rectangle size is 2048x2048 */				 12,				 GL_FALSE,				 i );   ctx->Const.MaxTextureMaxAnisotropy = 16.0;   /* No wide AA points.    */   ctx->Const.MinPointSize = 1.0;   ctx->Const.MinPointSizeAA = 1.0;   ctx->Const.MaxPointSizeAA = 1.0;   ctx->Const.PointSizeGranularity = 0.0625;   if (rmesa->r200Screen->drmSupportsPointSprites)      ctx->Const.MaxPointSize = 2047.0;   else      ctx->Const.MaxPointSize = 1.0;   /* mesa initialization problem - _mesa_init_point was already called */   ctx->Point.MaxSize = ctx->Const.MaxPointSize;   ctx->Const.MinLineWidth = 1.0;   ctx->Const.MinLineWidthAA = 1.0;   ctx->Const.MaxLineWidth = 10.0;   ctx->Const.MaxLineWidthAA = 10.0;   ctx->Const.LineWidthGranularity = 0.0625;   ctx->Const.VertexProgram.MaxNativeInstructions = R200_VSF_MAX_INST;   ctx->Const.VertexProgram.MaxNativeAttribs = 12;   ctx->Const.VertexProgram.MaxNativeTemps = R200_VSF_MAX_TEMPS;   ctx->Const.VertexProgram.MaxNativeParameters = R200_VSF_MAX_PARAM;   ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;   /* Initialize the software rasterizer and helper modules.    */   _swrast_CreateContext( ctx );   _vbo_CreateContext( ctx );   _tnl_CreateContext( ctx );   _swsetup_CreateContext( ctx );   _ae_create_context( ctx );   /* Install the customized pipeline:    */   _tnl_destroy_pipeline( ctx );   _tnl_install_pipeline( ctx, r200_pipeline );   /* Try and keep materials and vertices separate:    *//*    _tnl_isolate_materials( ctx, GL_TRUE ); */   /* Configure swrast and TNL to match hardware characteristics:    */   _swrast_allow_pixel_fog( ctx, GL_FALSE );   _swrast_allow_vertex_fog( ctx, GL_TRUE );   _tnl_allow_pixel_fog( ctx, GL_FALSE );   _tnl_allow_vertex_fog( ctx, GL_TRUE );   for ( i = 0 ; i < R200_MAX_TEXTURE_UNITS ; i++ ) {      _math_matrix_ctr( &rmesa->TexGenMatrix[i] );      _math_matrix_set_identity( &rmesa->TexGenMatrix[i] );   }   _math_matrix_ctr( &rmesa->tmpmat );   _math_matrix_set_identity( &rmesa->tmpmat );   driInitExtensions( ctx, card_extensions, GL_TRUE );   if (!(rmesa->r200Screen->chip_flags & R200_CHIPSET_YCBCR_BROKEN)) {     /* yuv textures don't work with some chips - R200 / rv280 okay so far	others get the bit ordering right but don't actually do YUV-RGB conversion */      _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" );   }   if (rmesa->glCtx->Mesa_DXTn) {      _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );      _mesa_enable_extension( ctx, "GL_S3_s3tc" );   }   else if (driQueryOptionb (&rmesa->optionCache, "force_s3tc_enable")) {      _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );   }   if (rmesa->r200Screen->drmSupportsCubeMapsR200)      _mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" );   if (rmesa->r200Screen->drmSupportsBlendColor) {       driInitExtensions( ctx, blend_extensions, GL_FALSE );   }   if(rmesa->r200Screen->drmSupportsVertexProgram)      driInitSingleExtension( ctx, ARB_vp_extension );   if(driQueryOptionb(&rmesa->optionCache, "nv_vertex_program"))      driInitSingleExtension( ctx, NV_vp_extension );   if ((ctx->Const.MaxTextureUnits == 6) && rmesa->r200Screen->drmSupportsFragShader)      driInitSingleExtension( ctx, ATI_fs_extension );   if (rmesa->r200Screen->drmSupportsPointSprites)      driInitExtensions( ctx, point_extensions, GL_FALSE );#if 0   r200InitDriverFuncs( ctx );   r200InitIoctlFuncs( ctx );   r200InitStateFuncs( ctx );   r200InitTextureFuncs( ctx );#endif   /* plug in a few more device driver functions */   /* XXX these should really go right after _mesa_init_driver_functions() */   r200InitPixelFuncs( ctx );   r200InitSpanFuncs( ctx );   r200InitTnlFuncs( ctx );   r200InitState( rmesa );   r200InitSwtcl( ctx );   fthrottle_mode = driQueryOptioni(&rmesa->optionCache, "fthrottle_mode");   rmesa->iw.irq_seq = -1;   rmesa->irqsEmitted = 0;   rmesa->do_irqs = (fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&		     rmesa->r200Screen->irq);   rmesa->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);   if (!rmesa->do_irqs)      fprintf(stderr,	      "IRQ's not enabled, falling back to %s: %d %d\n",	      rmesa->do_usleeps ? "usleeps" : "busy waits",	      fthrottle_mode,	      rmesa->r200Screen->irq);   rmesa->prefer_gart_client_texturing =       (getenv("R200_GART_CLIENT_TEXTURES") != 0);   (*sPriv->systemTime->getUST)( & rmesa->swap_ust );#if DO_DEBUG   R200_DEBUG  = driParseDebugString( getenv( "R200_DEBUG" ),				      debug_control );   R200_DEBUG |= driParseDebugString( getenv( "RADEON_DEBUG" ),				      debug_control );#endif   tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");   if (driQueryOptionb(&rmesa->optionCache, "no_rast")) {      fprintf(stderr, "disabling 3D acceleration\n");      FALLBACK(rmesa, R200_FALLBACK_DISABLE, 1);   }   else if (tcl_mode == DRI_CONF_TCL_SW || getenv("R200_NO_TCL") ||	    !(rmesa->r200Screen->chip_flags & RADEON_CHIPSET_TCL)) {      if (rmesa->r200Screen->chip_flags & RADEON_CHIPSET_TCL) {	 rmesa->r200Screen->chip_flags &= ~RADEON_CHIPSET_TCL;	 fprintf(stderr, "Disabling HW TCL support\n");      }      TCL_FALLBACK(rmesa->glCtx, R200_TCL_FALLBACK_TCL_DISABLE, 1);   }   return GL_TRUE;}/* Destroy the device specific context. *//* Destroy the Mesa and driver specific context data. */void r200DestroyContext( __DRIcontextPrivate *driContextPriv ){   GET_CURRENT_CONTEXT(ctx);   r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;   r200ContextPtr current = ctx ? R200_CONTEXT(ctx) : NULL;   /* check if we're deleting the currently bound context */   if (rmesa == current) {      R200_FIREVERTICES( rmesa );      _mesa_make_current(NULL, NULL, NULL);   }   /* Free r200 context resources */   assert(rmesa); /* should never be null */   if ( rmesa ) {      GLboolean   release_texture_heaps;      release_texture_heaps = (rmesa->glCtx->Shared->RefCount == 1);      _swsetup_DestroyContext( rmesa->glCtx );      _tnl_DestroyContext( rmesa->glCtx );      _vbo_DestroyContext( rmesa->glCtx );      _swrast_DestroyContext( rmesa->glCtx );      r200DestroySwtcl( rmesa->glCtx );      r200ReleaseArrays( rmesa->glCtx, ~0 );      if (rmesa->dma.current.buf) {	 r200ReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );	 r200FlushCmdBuf( rmesa, __FUNCTION__ );      }      if (rmesa->state.scissor.pClipRects) {	 FREE(rmesa->state.scissor.pClipRects);	 rmesa->state.scissor.pClipRects = NULL;      }      if ( release_texture_heaps ) {         /* This share group is about to go away, free our private          * texture object data.          */         int i;         for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {	    driDestroyTextureHeap( rmesa->texture_heaps[ i ] );	    rmesa->texture_heaps[ i ] = NULL;         }	 assert( is_empty_list( & rmesa->swapped ) );      }      /* free the Mesa context */      rmesa->glCtx->DriverCtx = NULL;      _mesa_destroy_context( rmesa->glCtx );      /* free the option cache */      driDestroyOptionCache (&rmesa->optionCache);      FREE( rmesa );   }}voidr200SwapBuffers( __DRIdrawablePrivate *dPriv ){   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {      r200ContextPtr rmesa;      GLcontext *ctx;      rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;      ctx = rmesa->glCtx;      if (ctx->Visual.doubleBufferMode) {         _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */         if ( rmesa->doPageFlip ) {            r200PageFlip( dPriv );         }         else {	     r200CopyBuffer( dPriv, NULL );         }      }   }   else {      /* XXX this shouldn't be an error but we can't handle it for now */      _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);   }}voidr200CopySubBuffer( __DRIdrawablePrivate *dPriv,		   int x, int y, int w, int h ){   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {      r200ContextPtr rmesa;      GLcontext *ctx;      rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;      ctx = rmesa->glCtx;      if (ctx->Visual.doubleBufferMode) {	 drm_clip_rect_t rect;	 rect.x1 = x + dPriv->x;	 rect.y1 = (dPriv->h - y - h) + dPriv->y;	 rect.x2 = rect.x1 + w;	 rect.y2 = rect.y1 + h;         _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */	 r200CopyBuffer( dPriv, &rect );      }   }   else {      /* XXX this shouldn't be an error but we can't handle it for now */      _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);   }}/* Force the context `c' to be the current context and associate with it * buffer `b'. */GLbooleanr200MakeCurrent( __DRIcontextPrivate *driContextPriv,                   __DRIdrawablePrivate *driDrawPriv,                   __DRIdrawablePrivate *driReadPriv ){   if ( driContextPriv ) {      r200ContextPtr newCtx = 	 (r200ContextPtr) driContextPriv->driverPrivate;      if (R200_DEBUG & DEBUG_DRI)	 fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)newCtx->glCtx);      newCtx->dri.readable = driReadPriv;      if ( newCtx->dri.drawable != driDrawPriv ||           newCtx->lastStamp != driDrawPriv->lastStamp ) {	 if (driDrawPriv->swap_interval == (unsigned)-1) {	    driDrawPriv->vblFlags = (newCtx->r200Screen->irq != 0)	       ? driGetDefaultVBlankFlags(&newCtx->optionCache)	       : VBLANK_FLAG_NO_IRQ;	    driDrawableInitVBlank( driDrawPriv );	 }	 newCtx->dri.drawable = driDrawPriv;	 r200SetCliprects(newCtx);	 r200UpdateViewportOffset( newCtx->glCtx );      }      _mesa_make_current( newCtx->glCtx,			  (GLframebuffer *) driDrawPriv->driverPrivate,			  (GLframebuffer *) driReadPriv->driverPrivate );      _mesa_update_state( newCtx->glCtx );      r200ValidateState( newCtx->glCtx );   } else {      if (R200_DEBUG & DEBUG_DRI)	 fprintf(stderr, "%s ctx is null\n", __FUNCTION__);      _mesa_make_current( NULL, NULL, NULL );   }   if (R200_DEBUG & DEBUG_DRI)      fprintf(stderr, "End %s\n", __FUNCTION__);   return GL_TRUE;}/* Force the context `c' to be unbound from its buffer. */GLbooleanr200UnbindContext( __DRIcontextPrivate *driContextPriv ){   r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;   if (R200_DEBUG & DEBUG_DRI)      fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)rmesa->glCtx);   return GL_TRUE;}

⌨️ 快捷键说明

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