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

📄 savage_xmesa.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
   imesa->float_depth = driQueryOptionb(&imesa->optionCache, "float_depth") &&       savageScreen->chipset >= S3_SAVAGE4;   imesa->no_rast = driQueryOptionb(&imesa->optionCache, "no_rast");#if 0   ctx->Const.MinLineWidth = 1.0;   ctx->Const.MinLineWidthAA = 1.0;   ctx->Const.MaxLineWidth = 3.0;   ctx->Const.MaxLineWidthAA = 3.0;   ctx->Const.LineWidthGranularity = 1.0;#endif      /* Dri stuff    */   imesa->hHWContext = driContextPriv->hHWContext;   imesa->driFd = sPriv->fd;   imesa->driHwLock = &sPriv->pSAREA->lock;      imesa->savageScreen = savageScreen;   imesa->driScreen = sPriv;   imesa->sarea = saPriv;   imesa->glBuffer = NULL;      /* DMA buffer */   for(i=0;i<5;i++)   {       imesa->apertureBase[i] = (GLubyte *)savageScreen->aperture.map + 	   0x01000000 * i;   }      imesa->aperturePitch = savageScreen->aperturePitch;   /* change texHeap initialize to support two kind of texture heap*/   /* here is some parts of initialization, others in InitDriver() */       (void) memset( imesa->textureHeaps, 0, sizeof( imesa->textureHeaps ) );   make_empty_list( & imesa->swapped );   textureSize[SAVAGE_CARD_HEAP] = savageScreen->textureSize[SAVAGE_CARD_HEAP];   textureSize[SAVAGE_AGP_HEAP] = savageScreen->textureSize[SAVAGE_AGP_HEAP];   imesa->lastTexHeap = savageScreen->texVirtual[SAVAGE_AGP_HEAP] ? 2 : 1;   switch(driQueryOptioni (&imesa->optionCache, "texture_heaps")) {   case DRI_CONF_TEXTURE_HEAPS_CARD: /* only use card memory, if available */       if (textureSize[SAVAGE_CARD_HEAP])	   imesa->lastTexHeap = 1;       break;   case DRI_CONF_TEXTURE_HEAPS_GART: /* only use gart memory, if available */       if (imesa->lastTexHeap == 2 && textureSize[SAVAGE_AGP_HEAP])	   textureSize[SAVAGE_CARD_HEAP] = 0;       break;   /*default: Nothing to do, use all available memory. */   }      for (i = 0; i < imesa->lastTexHeap; i++) {       imesa->textureHeaps[i] = driCreateTextureHeap(	   i, imesa,	   textureSize[i],	   11,					/* 2^11 = 2k alignment */	   SAVAGE_NR_TEX_REGIONS,	   (drmTextureRegionPtr)imesa->sarea->texList[i],	    &imesa->sarea->texAge[i],	    &imesa->swapped,	    sizeof( savageTexObj ),	    (destroy_texture_object_t *) savageDestroyTexObj );       /* If textureSize[i] == 0 textureHeaps[i] is NULL. This can happen	* if there is not enough card memory for a card texture heap. */       if (imesa->textureHeaps[i])	   driSetTextureSwapCounterLocation( imesa->textureHeaps[i],					     & imesa->c_textureSwaps );   }   imesa->texture_depth = driQueryOptioni (&imesa->optionCache,					   "texture_depth");   if (imesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)       imesa->texture_depth = ( savageScreen->cpp == 4 ) ?	   DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;   if (savageScreen->chipset >= S3_SAVAGE4)       ctx->Const.MaxTextureUnits = 2;   else       ctx->Const.MaxTextureUnits = 1;   if (driQueryOptioni(&imesa->optionCache, "texture_units") <       ctx->Const.MaxTextureUnits)       ctx->Const.MaxTextureUnits =	   driQueryOptioni(&imesa->optionCache, "texture_units");   ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;   ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;   driCalculateMaxTextureLevels( imesa->textureHeaps,				 imesa->lastTexHeap,				 & ctx->Const,				 4,				 11, /* max 2D texture size is 2048x2048 */				 0,  /* 3D textures unsupported. */				 0,  /* cube textures unsupported. */				 0,  /* texture rectangles unsupported. */				 12,				 GL_FALSE,				 0 );   if (ctx->Const.MaxTextureLevels <= 6) { /*spec requires at least 64x64*/       __driUtilMessage("Not enough texture memory. "			"Falling back to indirect rendering.");       Xfree(imesa);       return GL_FALSE;   }   imesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;   imesa->depth_scale = (imesa->savageScreen->zpp == 2) ?       (1.0F/0xffff):(1.0F/0xffffff);   imesa->bufferSize = savageScreen->bufferSize;   imesa->dmaVtxBuf.total = 0;   imesa->dmaVtxBuf.used = 0;   imesa->dmaVtxBuf.flushed = 0;   imesa->clientVtxBuf.total = imesa->bufferSize / 4;   imesa->clientVtxBuf.used = 0;   imesa->clientVtxBuf.flushed = 0;   imesa->clientVtxBuf.buf = (u_int32_t *)malloc(imesa->bufferSize);   imesa->vtxBuf = &imesa->clientVtxBuf;   imesa->firstElt = -1;   /* Uninitialized vertex format. Force setting the vertex state in    * savageRenderStart.    */   imesa->vertex_size = 0;   /* Utah stuff    */   imesa->new_state = ~0;   imesa->new_gl_state = ~0;   imesa->RenderIndex = ~0;   imesa->dirty = ~0;   imesa->lostContext = GL_TRUE;   imesa->CurrentTexObj[0] = 0;   imesa->CurrentTexObj[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, savage_pipeline );   imesa->enable_fastpath = driQueryOptionb(&imesa->optionCache,					    "enable_fastpath");   /* DRM versions before 2.1.3 would only render triangle lists. ELTS    * support was added in 2.2.0. */   if (imesa->enable_fastpath && sPriv->drm_version.minor < 2) {      fprintf (stderr,	       "*** Disabling fast path because your DRM version is buggy "	       "or doesn't\n*** support ELTS. You need at least Savage DRM "	       "version 2.2.\n");      imesa->enable_fastpath = GL_FALSE;   }   if (!savageScreen->bufs || savageScreen->chipset == S3_SUPERSAVAGE)       imesa->enable_vdma = GL_FALSE;   else       imesa->enable_vdma = driQueryOptionb(&imesa->optionCache, "enable_vdma");   imesa->sync_frames = driQueryOptionb(&imesa->optionCache, "sync_frames");   /* Configure swrast to match hardware characteristics:    */   _tnl_allow_pixel_fog( ctx, GL_FALSE );   _tnl_allow_vertex_fog( ctx, GL_TRUE );   _swrast_allow_pixel_fog( ctx, GL_FALSE );   _swrast_allow_vertex_fog( ctx, GL_TRUE );   ctx->DriverCtx = (void *) imesa;   imesa->glCtx = ctx;#ifndef SAVAGE_DEBUG   SAVAGE_DEBUG = driParseDebugString( getenv( "SAVAGE_DEBUG" ),				       debug_control );#endif   driInitExtensions( ctx, card_extensions, GL_TRUE );   if (savageScreen->chipset >= S3_SAVAGE4)       driInitExtensions( ctx, s4_extensions, GL_FALSE );   if (ctx->Mesa_DXTn ||       driQueryOptionb (&imesa->optionCache, "force_s3tc_enable")) {       _mesa_enable_extension( ctx, "GL_S3_s3tc" );       if (savageScreen->chipset >= S3_SAVAGE4)	   /* This extension needs DXT3 and DTX5 support in hardware.	    * Not available on Savage3D/MX/IX. */	   _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );   }   savageDDInitStateFuncs( ctx );   savageDDInitSpanFuncs( ctx );   savageDDInitDriverFuncs( ctx );   savageDDInitIoctlFuncs( ctx );   savageInitTriFuncs( ctx );   savageDDInitState( imesa );   driContextPriv->driverPrivate = (void *) imesa;   return GL_TRUE;}static voidsavageDestroyContext(__DRIcontextPrivate *driContextPriv){   savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;   GLuint i;   assert (imesa); /* should never be NULL */   if (imesa) {      savageFlushVertices(imesa);      savageReleaseIndexedVerts(imesa);      savageFlushCmdBuf(imesa, GL_TRUE); /* release DMA buffer */      WAIT_IDLE_EMPTY(imesa);      for (i = 0; i < imesa->lastTexHeap; i++)	 driDestroyTextureHeap(imesa->textureHeaps[i]);      free(imesa->cmdBuf.base);      free(imesa->clientVtxBuf.buf);      _swsetup_DestroyContext(imesa->glCtx );      _tnl_DestroyContext( imesa->glCtx );      _vbo_DestroyContext( imesa->glCtx );      _swrast_DestroyContext( imesa->glCtx );      /* free the Mesa context */      imesa->glCtx->DriverCtx = NULL;      _mesa_destroy_context(imesa->glCtx);      /* no longer use vertex_dma_buf*/      Xfree(imesa);   }}static GLbooleansavageCreateBuffer( __DRIscreenPrivate *driScrnPriv,		    __DRIdrawablePrivate *driDrawPriv,		    const __GLcontextModes *mesaVis,		    GLboolean isPixmap){   savageScreenPrivate *screen = (savageScreenPrivate *) driScrnPriv->private;   if (isPixmap) {      return GL_FALSE; /* not implemented */   }   else {      GLboolean swStencil = mesaVis->stencilBits > 0 && mesaVis->depthBits != 24;      struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);      /*       * XXX: this value needs to be set according to the config file       * setting.  But we don't get that until we create a rendering       * context!!!!       */      GLboolean float_depth = GL_FALSE;      {         driRenderbuffer *frontRb            = driNewRenderbuffer(GL_RGBA,                                 (GLubyte *) screen->aperture.map                                 + 0x01000000 * TARGET_FRONT,                                 screen->cpp,                                 screen->frontOffset, screen->aperturePitch,                                 driDrawPriv);         savageSetSpanFunctions(frontRb, mesaVis, float_depth);         assert(frontRb->Base.Data);         _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);      }      if (mesaVis->doubleBufferMode) {         driRenderbuffer *backRb            = driNewRenderbuffer(GL_RGBA,                                 (GLubyte *) screen->aperture.map                                 + 0x01000000 * TARGET_BACK,                                 screen->cpp,                                 screen->backOffset, screen->aperturePitch,                                 driDrawPriv);         savageSetSpanFunctions(backRb, mesaVis, float_depth);         assert(backRb->Base.Data);         _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);      }      if (mesaVis->depthBits == 16) {         driRenderbuffer *depthRb            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,                                 (GLubyte *) screen->aperture.map                                 + 0x01000000 * TARGET_DEPTH,                                 screen->zpp,                                 screen->depthOffset, screen->aperturePitch,                                 driDrawPriv);         savageSetSpanFunctions(depthRb, mesaVis, float_depth);         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);      }      else if (mesaVis->depthBits == 24) {         driRenderbuffer *depthRb            = driNewRenderbuffer(GL_DEPTH_COMPONENT24,                                 (GLubyte *) screen->aperture.map                                 + 0x01000000 * TARGET_DEPTH,                                 screen->zpp,                                 screen->depthOffset, screen->aperturePitch,                                 driDrawPriv);         savageSetSpanFunctions(depthRb, mesaVis, float_depth);         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);      }      if (mesaVis->stencilBits > 0 && !swStencil) {         driRenderbuffer *stencilRb            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT,                                 (GLubyte *) screen->aperture.map                                 + 0x01000000 * TARGET_DEPTH,                                 screen->zpp,                                 screen->depthOffset, screen->aperturePitch,                                 driDrawPriv);         savageSetSpanFunctions(stencilRb, mesaVis, float_depth);         _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);      }      _mesa_add_soft_renderbuffers(fb,                                   GL_FALSE, /* color */                                   GL_FALSE, /* depth */                                   swStencil,                                   mesaVis->accumRedBits > 0,                                   GL_FALSE, /* alpha */                                   GL_FALSE /* aux */);      driDrawPriv->driverPrivate = (void *) fb;      return (driDrawPriv->driverPrivate != NULL);   }}

⌨️ 快捷键说明

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