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

📄 savage_xmesa.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
static voidsavageDestroyBuffer(__DRIdrawablePrivate *driDrawPriv){   _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)));}#if 0void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv){   /* XXX should do swap according to the buffer, not the context! */   savageContextPtr imesa = savageCtx;    FLUSH_VB( imesa->glCtx, "swap buffers" );   savageSwapBuffers(imesa);}#endifvoid savageXMesaSetClipRects(savageContextPtr imesa){   __DRIdrawablePrivate *dPriv = imesa->driDrawable;   if ((dPriv->numBackClipRects == 0)       || (imesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)) {      imesa->numClipRects = dPriv->numClipRects;      imesa->pClipRects = dPriv->pClipRects;      imesa->drawX = dPriv->x;      imesa->drawY = dPriv->y;   } else {      imesa->numClipRects = dPriv->numBackClipRects;      imesa->pClipRects = dPriv->pBackClipRects;      imesa->drawX = dPriv->backX;      imesa->drawY = dPriv->backY;   }   savageCalcViewport( imesa->glCtx );}static void savageXMesaWindowMoved( savageContextPtr imesa ) {   __DRIdrawablePrivate *const drawable = imesa->driDrawable;   __DRIdrawablePrivate *const readable = imesa->driReadable;   if (0)      fprintf(stderr, "savageXMesaWindowMoved\n\n");   savageXMesaSetClipRects(imesa);   driUpdateFramebufferSize(imesa->glCtx, drawable);   if (drawable != readable) {      driUpdateFramebufferSize(imesa->glCtx, readable);   }}static GLbooleansavageUnbindContext(__DRIcontextPrivate *driContextPriv){   savageContextPtr savage = (savageContextPtr) driContextPriv->driverPrivate;   if (savage)      savage->dirty = ~0;   return GL_TRUE;}#if 0static GLbooleansavageOpenFullScreen(__DRIcontextPrivate *driContextPriv){              if (driContextPriv) {      savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;      imesa->IsFullScreen = GL_TRUE;      imesa->backup_frontOffset = imesa->savageScreen->frontOffset;      imesa->backup_backOffset = imesa->savageScreen->backOffset;      imesa->backup_frontBitmapDesc = imesa->savageScreen->frontBitmapDesc;      imesa->savageScreen->frontBitmapDesc = imesa->savageScreen->backBitmapDesc;            imesa->toggle = TARGET_BACK;   }    return GL_TRUE;}static GLbooleansavageCloseFullScreen(__DRIcontextPrivate *driContextPriv){        if (driContextPriv) {      savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;      WAIT_IDLE_EMPTY(imesa);      imesa->IsFullScreen = GL_FALSE;         imesa->savageScreen->frontOffset = imesa->backup_frontOffset;      imesa->savageScreen->backOffset = imesa->backup_backOffset;      imesa->savageScreen->frontBitmapDesc = imesa->backup_frontBitmapDesc;   }    return GL_TRUE;}#endifstatic GLbooleansavageMakeCurrent(__DRIcontextPrivate *driContextPriv,		  __DRIdrawablePrivate *driDrawPriv,		  __DRIdrawablePrivate *driReadPriv){   if (driContextPriv) {      savageContextPtr imesa         = (savageContextPtr) driContextPriv->driverPrivate;      struct gl_framebuffer *drawBuffer         = (GLframebuffer *) driDrawPriv->driverPrivate;      struct gl_framebuffer *readBuffer         = (GLframebuffer *) driReadPriv->driverPrivate;      driRenderbuffer *frontRb = (driRenderbuffer *)         drawBuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;      driRenderbuffer *backRb = (driRenderbuffer *)         drawBuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer;      assert(frontRb->Base.Data);      if (imesa->glCtx->Visual.doubleBufferMode) {         assert(backRb->Base.Data);      }      imesa->driReadable = driReadPriv;      imesa->driDrawable = driDrawPriv;      imesa->dirty = ~0;            _mesa_make_current(imesa->glCtx, drawBuffer, readBuffer);            savageXMesaWindowMoved( imesa );   }   else    {      _mesa_make_current(NULL, NULL, NULL);   }   return GL_TRUE;}void savageGetLock( savageContextPtr imesa, GLuint flags ) {   __DRIdrawablePrivate *const drawable = imesa->driDrawable;   __DRIdrawablePrivate *const readable = imesa->driReadable;   __DRIscreenPrivate *sPriv = imesa->driScreen;   drm_savage_sarea_t *sarea = imesa->sarea;   int me = imesa->hHWContext;   int stamp = drawable->lastStamp;    int heap;   unsigned int timestamp = 0;     /* We know there has been contention.    */   drmGetLock(imesa->driFd, imesa->hHWContext, flags);	   /* Note contention for throttling hint    */   imesa->any_contend = 1;   /* If the window moved, may need to set a new cliprect now.    *    * NOTE: This releases and regains the hw lock, so all state    * checking must be done *after* this call:    */   DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable);   if (drawable != readable) {      DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable);   }   /* If we lost context, need to dump all registers to hardware.    * Note that we don't care about 2d contexts, even if they perform    * accelerated commands, so the DRI locking in the X server is even    * more broken than usual.    */   if (sarea->ctxOwner != me) {      imesa->dirty |= (SAVAGE_UPLOAD_LOCAL |		       SAVAGE_UPLOAD_GLOBAL |		       SAVAGE_UPLOAD_FOGTBL |		       SAVAGE_UPLOAD_TEX0 |		       SAVAGE_UPLOAD_TEX1 |		       SAVAGE_UPLOAD_TEXGLOBAL);      imesa->lostContext = GL_TRUE;      sarea->ctxOwner = me;   }   for (heap = 0; heap < imesa->lastTexHeap; ++heap) {      /* If a heap was changed, update its timestamp. Do this before       * DRI_AGE_TEXTURES updates the local_age. */      if (imesa->textureHeaps[heap] &&	  imesa->textureHeaps[heap]->global_age[0] >	  imesa->textureHeaps[heap]->local_age) {	 if (timestamp == 0)	    timestamp = savageEmitEventLocked(imesa, 0);	 imesa->textureHeaps[heap]->timestamp = timestamp;      }      DRI_AGE_TEXTURES( imesa->textureHeaps[heap] );   }   if (drawable->lastStamp != stamp) {      driUpdateFramebufferSize(imesa->glCtx, drawable);      savageXMesaWindowMoved( imesa );   }}static const  __DRIconfig **savageFillInModes( __DRIscreenPrivate *psp,		   unsigned pixel_bits, unsigned depth_bits,		   unsigned stencil_bits, GLboolean have_back_buffer ){    __DRIconfig **configs;    __GLcontextModes * m;    unsigned depth_buffer_factor;    unsigned back_buffer_factor;    GLenum fb_format;    GLenum fb_type;    int i;    /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy     * enough to add support.  Basically, if a context is created with an     * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping     * will never be used.     *     * FK: What about drivers that don't use page flipping? Could they     * just expose GLX_SWAP_COPY_OML?     */    static const GLenum back_buffer_modes[] = {	GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */    };    u_int8_t depth_bits_array[2];    u_int8_t stencil_bits_array[2];    depth_bits_array[0] = depth_bits;    depth_bits_array[1] = depth_bits;        /* Just like with the accumulation buffer, always provide some modes     * with a stencil buffer.  It will be a sw fallback, but some apps won't     * care about that.     */    stencil_bits_array[0] = 0;    stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;    depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;    back_buffer_factor  = (have_back_buffer) ? 2 : 1;    if ( pixel_bits == 16 ) {        fb_format = GL_RGB;        fb_type = GL_UNSIGNED_SHORT_5_6_5;    }    else {        fb_format = GL_BGR;        fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;    }    configs = driCreateConfigs(fb_format, fb_type,			       depth_bits_array, stencil_bits_array,			       depth_buffer_factor,			       back_buffer_modes, back_buffer_factor);    if (configs == NULL) {	fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",		 __func__, __LINE__ );	return NULL;    }    /* Mark the visual as slow if there are "fake" stencil bits.     */    for (i = 0; configs[i]; i++) {	m = &configs[i]->modes;	if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {	    m->visualRating = GLX_SLOW_CONFIG;	}    }    return (const __DRIconfig **) configs;}/** * This is the driver specific part of the createNewScreen entry point. *  * \todo maybe fold this into intelInitDriver * * \return the __GLcontextModes supported by this driver */static const __DRIconfig **savageInitScreen(__DRIscreenPrivate *psp){   static const __DRIversion ddx_expected = { 2, 0, 0 };   static const __DRIversion dri_expected = { 4, 0, 0 };   static const __DRIversion drm_expected = { 2, 1, 0 };   SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv;   if ( ! driCheckDriDdxDrmVersions2( "Savage",				      &psp->dri_version, & dri_expected,				      &psp->ddx_version, & ddx_expected,				      &psp->drm_version, & drm_expected ) )      return NULL;   /* Calling driInitExtensions here, with a NULL context pointer,    * does not actually enable the extensions.  It just makes sure    * that all the dispatch offsets for all the extensions that    * *might* be enables are known.  This is needed because the    * dispatch offsets need to be known when _mesa_context_create is    * called, but we can't enable the extensions until we have a    * context pointer.    *    * Hello chicken.  Hello egg.  How are you two today?    */   driInitExtensions( NULL, card_extensions, GL_FALSE );   if (!savageInitDriver(psp))       return NULL;   return savageFillInModes( psp,			     dri_priv->cpp*8,			     (dri_priv->cpp == 2) ? 16 : 24,			     (dri_priv->cpp == 2) ? 0  : 8,			     (dri_priv->backOffset != dri_priv->depthOffset) );}const struct __DriverAPIRec driDriverAPI = {   savageInitScreen,    savageDestroyScreen,   savageCreateContext,   savageDestroyContext,   savageCreateBuffer,   savageDestroyBuffer,   savageSwapBuffers,   savageMakeCurrent,   savageUnbindContext};

⌨️ 快捷键说明

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