📄 savage_xmesa.c
字号:
imesa->drawX = dPriv->x; imesa->drawY = dPriv->y; savageCalcViewport( imesa->glCtx );}void savageXMesaSetBackClipRects( savageContextPtr imesa ){ __DRIdrawablePrivate *dPriv = imesa->driDrawable; if (dPriv->numBackClipRects == 0) { 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 ) { if (0) fprintf(stderr, "savageXMesaWindowMoved\n\n"); switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) { case BUFFER_BIT_FRONT_LEFT: savageXMesaSetFrontClipRects( imesa ); break; case BUFFER_BIT_BACK_LEFT: savageXMesaSetBackClipRects( imesa ); break; default: break; }}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 *dPriv = imesa->driDrawable; __DRIscreenPrivate *sPriv = imesa->driScreen; drm_savage_sarea_t *sarea = imesa->sarea; int me = imesa->hHWContext; int stamp = dPriv->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, dPriv); /* 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 (dPriv->lastStamp != stamp) { driUpdateFramebufferSize(imesa->glCtx, dPriv); savageXMesaWindowMoved( imesa ); }}static const struct __DriverAPIRec savageAPI = { savageInitDriver, savageDestroyScreen, savageCreateContext, savageDestroyContext, savageCreateBuffer, savageDestroyBuffer, savageSwapBuffers, savageMakeCurrent, savageUnbindContext};static __GLcontextModes *savageFillInModes( unsigned pixel_bits, unsigned depth_bits, unsigned stencil_bits, GLboolean have_back_buffer ){ __GLcontextModes * modes; __GLcontextModes * m; unsigned num_modes; unsigned depth_buffer_factor; unsigned back_buffer_factor; GLenum fb_format; GLenum fb_type; /* 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; num_modes = depth_buffer_factor * back_buffer_factor * 4; 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; } modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) ); m = modes; if ( ! driFillInModes( & m, fb_format, fb_type, depth_bits_array, stencil_bits_array, depth_buffer_factor, back_buffer_modes, back_buffer_factor, GLX_TRUE_COLOR ) ) { fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__ ); return NULL; } if ( ! driFillInModes( & m, fb_format, fb_type, depth_bits_array, stencil_bits_array, depth_buffer_factor, back_buffer_modes, back_buffer_factor, GLX_DIRECT_COLOR ) ) { fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__ ); return NULL; } /* Mark the visual as slow if there are "fake" stencil bits. */ for ( m = modes ; m != NULL ; m = m->next ) { if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) { m->visualRating = GLX_SLOW_CONFIG; } } return modes;}/** * This is the bootstrap function for the driver. libGL supplies all of the * requisite information about the system, and the driver initializes itself. * This routine also fills in the linked list pointed to by \c driver_modes * with the \c __GLcontextModes that the driver can support for windows or * pbuffers. * * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on * failure. */PUBLICvoid * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, const __GLcontextModes * modes, const __DRIversion * ddx_version, const __DRIversion * dri_version, const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer, drmAddress pSAREA, int fd, int internal_api_version, const __DRIinterfaceMethods * interface, __GLcontextModes ** driver_modes ) { __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 }; dri_interface = interface; if ( ! driCheckDriDdxDrmVersions2( "Savage", dri_version, & dri_expected, ddx_version, & ddx_expected, drm_version, & drm_expected ) ) { return NULL; } psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &savageAPI); if ( psp != NULL ) { SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv; *driver_modes = savageFillInModes( dri_priv->cpp*8, (dri_priv->cpp == 2) ? 16 : 24, (dri_priv->cpp == 2) ? 0 : 8, (dri_priv->backOffset != dri_priv->depthOffset) ); /* 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 ); } return (void *) psp;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -