📄 glxcmds.c
字号:
if (psc->msc != NULL && psc->driScreen ) { __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); int ret; int64_t msc; int64_t sbc; ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, 0, divisor, remainder, &msc, &sbc); *count = (unsigned) msc; return (ret == 0) ? 0 : GLX_BAD_CONTEXT; } }#else (void) count;#endif return GLX_BAD_CONTEXT;}/*** GLX_SGIX_fbconfig** Many of these functions are aliased to GLX 1.3 entry points in the ** GLX_functions table.*/PUBLIC GLX_ALIAS(int, glXGetFBConfigAttribSGIX, (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value), (dpy, config, attribute, value), glXGetFBConfigAttrib)PUBLIC GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX, (Display *dpy, int screen, int *attrib_list, int *nelements), (dpy, screen, attrib_list, nelements), glXChooseFBConfig)PUBLIC GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX, (Display * dpy, GLXFBConfigSGIX config), (dpy, config), glXGetVisualFromFBConfig)PUBLIC GLXPixmap glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap){ xGLXVendorPrivateWithReplyReq *vpreq; xGLXCreateGLXPixmapWithConfigSGIXReq *req; GLXPixmap xid = None; CARD8 opcode; const __GLcontextModes * const fbconfig = (__GLcontextModes *) config; __GLXscreenConfigs * psc; if ( (dpy == NULL) || (config == NULL) ) { return None; } psc = GetGLXScreenConfigs( dpy, fbconfig->screen ); if ( (psc != NULL) && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit ) ) { opcode = __glXSetupForCommand(dpy); if (!opcode) { return None; } /* Send the glXCreateGLXPixmapWithConfigSGIX request */ LockDisplay(dpy); GetReqExtra(GLXVendorPrivateWithReply, sz_xGLXCreateGLXPixmapWithConfigSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq); req = (xGLXCreateGLXPixmapWithConfigSGIXReq *)vpreq; req->reqType = opcode; req->glxCode = X_GLXVendorPrivateWithReply; req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX; req->screen = fbconfig->screen; req->fbconfig = fbconfig->fbconfigID; req->pixmap = pixmap; req->glxpixmap = xid = XAllocID(dpy); UnlockDisplay(dpy); SyncHandle(); } return xid;}PUBLIC GLXContext glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int renderType, GLXContext shareList, Bool allowDirect){ GLXContext gc = NULL; const __GLcontextModes * const fbconfig = (__GLcontextModes *) config; __GLXscreenConfigs * psc; if ( (dpy == NULL) || (config == NULL) ) { return None; } psc = GetGLXScreenConfigs( dpy, fbconfig->screen ); if ( (psc != NULL) && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit ) ) { gc = CreateContext( dpy, NULL, (__GLcontextModes *) config, shareList, allowDirect, None, False, renderType ); } return gc;}PUBLIC GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis){ __GLXdisplayPrivate *priv; __GLXscreenConfigs *psc; if ( (GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc ) != Success) && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit ) && (psc->configs->fbconfigID != GLX_DONT_CARE) ) { return (GLXFBConfigSGIX) _gl_context_modes_find_visual( psc->configs, vis->visualid ); } return NULL;}/*** GLX_SGIX_swap_group*/static void __glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member){ (void) dpy; (void) drawable; (void) member;}/*** GLX_SGIX_swap_barrier*/static void __glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier){ (void) dpy; (void) drawable; (void) barrier;}static Bool __glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max){ (void) dpy; (void) screen; (void) max; return False;}/*** GLX_OML_sync_control*/static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc){#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER) __GLXdisplayPrivate * const priv = __glXInitialize(dpy); if ( priv != NULL ) { int i; __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &i); __GLXscreenConfigs * const psc = &priv->screenConfigs[i]; assert( (pdraw == NULL) || (i != -1) ); return ( (pdraw && psc->sbc && psc->msc) && ((*psc->msc->getMSC)(psc->driScreen, msc) == 0) && ((*psc->sbc->getSBC)(pdraw->driDrawable, sbc) == 0) && (__glXGetUST(ust) == 0) ); }#else (void) dpy; (void) drawable; (void) ust; (void) msc; (void) sbc;#endif return False;}#ifdef GLX_DIRECT_RENDERING_X_HIDDEN GLboolean__driGetMscRateOML(__DRIdrawable *draw, int32_t *numerator, int32_t *denominator, void *private){#ifdef XF86VIDMODE __GLXscreenConfigs *psc; XF86VidModeModeLine mode_line; int dot_clock; int i; __GLXDRIdrawable *glxDraw = private; psc = glxDraw->psc; if (XF86VidModeQueryVersion(psc->dpy, &i, &i) && XF86VidModeGetModeLine(psc->dpy, psc->scr, &dot_clock, &mode_line) ) { unsigned n = dot_clock * 1000; unsigned d = mode_line.vtotal * mode_line.htotal; # define V_INTERLACE 0x010# define V_DBLSCAN 0x020 if (mode_line.flags & V_INTERLACE) n *= 2; else if (mode_line.flags & V_DBLSCAN) d *= 2; /* The OML_sync_control spec requires that if the refresh rate is a * whole number, that the returned numerator be equal to the refresh * rate and the denominator be 1. */ if (n % d == 0) { n /= d; d = 1; } else { static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 }; /* This is a poor man's way to reduce a fraction. It's far from * perfect, but it will work well enough for this situation. */ for (i = 0; f[i] != 0; i++) { while (n % f[i] == 0 && d % f[i] == 0) { d /= f[i]; n /= f[i]; } } } *numerator = n; *denominator = d; return True; } else return False;#else return False;#endif}#endif/** * Determine the refresh rate of the specified drawable and display. * * \param dpy Display whose refresh rate is to be determined. * \param drawable Drawable whose refresh rate is to be determined. * \param numerator Numerator of the refresh rate. * \param demoninator Denominator of the refresh rate. * \return If the refresh rate for the specified display and drawable could * be calculated, True is returned. Otherwise False is returned. * * \note This function is implemented entirely client-side. A lot of other * functionality is required to export GLX_OML_sync_control, so on * XFree86 this function can be called for direct-rendering contexts * when GLX_OML_sync_control appears in the client extension string. */_X_HIDDEN GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, int32_t * numerator, int32_t * denominator){#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE ) __GLXDRIdrawable *draw = GetGLXDRIDrawable(dpy, drawable, NULL); if (draw == NULL) return False; return __driGetMscRateOML(draw->driDrawable, numerator, denominator, draw);#else (void) dpy; (void) drawable; (void) numerator; (void) denominator;#endif return False;}static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder){#ifdef __DRI_SWAP_BUFFER_COUNTER int screen; __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE * error", but it also says "It [glXSwapBuffersMscOML] will return a value * of -1 if the function failed because of errors detected in the input * parameters" */ if ( divisor < 0 || remainder < 0 || target_msc < 0 ) return -1; if ( divisor > 0 && remainder >= divisor ) return -1; if (pdraw != NULL && psc->counters != NULL) return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc, divisor, remainder);#else (void) dpy; (void) drawable; (void) target_msc; (void) divisor; (void) remainder;#endif return 0;}static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc){#ifdef __DRI_MEDIA_STREAM_COUNTER int screen; __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); int ret; /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE * error", but the return type in the spec is Bool. */ if ( divisor < 0 || remainder < 0 || target_msc < 0 ) return False; if ( divisor > 0 && remainder >= divisor ) return False; if (pdraw != NULL && psc->msc != NULL) { ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, target_msc, divisor, remainder, msc, sbc); /* __glXGetUST returns zero on success and non-zero on failure. * This function returns True on success and False on failure. */ return ( (ret == 0) && (__glXGetUST( ust ) == 0) ); }#else (void) dpy; (void) drawable; (void) target_msc; (void) divisor; (void) remainder; (void) ust; (void) msc; (void) sbc;#endif return False;}static Bool __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc ){#ifdef __DRI_SWAP_BUFFER_COUNTER int screen; __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); int ret; /* The OML_sync_control spec says this should "generate a GLX_BAD_VALUE * error", but the return type in the spec is Bool. */ if ( target_sbc < 0 ) return False; if (pdraw != NULL && psc->sbc != NULL) { ret = (*psc->sbc->waitForSBC)(pdraw->driDrawable, target_sbc, msc, sbc); /* __glXGetUST returns zero on success and non-zero on failure. * This function returns True on success and False on failure. */ return( (ret == 0) && (__glXGetUST( ust ) == 0) ); }#else (void) dpy; (void) drawable; (void) target_sbc; (void) ust; (void) msc; (void) sbc;#endif return False;}/** * GLX_MESA_allocate_memory *//*@{*/PUBLIC void *glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size, float readFreq, float writeFreq, float priority){#ifdef __DRI_ALLOCATE __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn ); if (psc && psc->allocate) return (*psc->allocate->allocateMemory)(psc->__driScreen, size, readFreq, writeFreq, priority);#else (void) dpy; (void) scrn; (void) size; (void) readFreq; (void) writeFreq; (void) priority;#endif /* GLX_DIRECT_RENDERING */ return NULL;}PUBLIC void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer){#ifdef __DRI_ALLOCATE __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn ); if (psc && psc->allocate) (*psc->allocate->freeMemory)(psc->__driScreen, pointer);#else (void) dpy; (void) scrn; (void) pointer;#endif /* GLX_DIRECT_RENDERING */}PUBLIC GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn, const void *pointer ){#ifdef __DRI_ALLOCATE __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn ); if (psc && psc->allocate) return (*psc->allocate->memoryOffset)(psc->__driScreen, pointer);#else (void) dpy; (void) scrn; (void) pointer;#endif /* GLX_DIRECT_RENDERING */ return ~0L;}/*@}*//** * Mesa extension stubs. These will help reduce portability problems. *//*@{*//** * Release all buffers associated with the specified GLX drawable. * * \todo * This function was intended for stand-alone Mesa. The issue there is that * the library doesn't get any notification when a window is closed. In * DRI there is a similar but slightly different issue. When GLX 1.3 is * supported, there are 3 different functions to destroy a drawable. It * should be possible to create GLX protocol (or have it determine which * protocol to use based on the type of the drawable) to have one function * do the work of 3. For the direct-rendering case, this function could * just call the driver's \c __DRIdrawableRec::destroyDrawable function. * This would reduce the frequency with which \c __driGarbageCollectDrawables * would need to be used. This really should be done as part of the new DRI * interface work. * * \sa http://oss.sgi.com/projects/ogl-sample/registry/MESA/release_buffers.txt * __driGarbageCollectDrawables * glXDestroyGLXPixmap * glXDestroyPbuffer glXDestroyPixmap glXDestroyWindow * glXDestroyGLXPbufferSGIX glXDestroyGLXVideoSourceSGIX */static Bool __glXReleaseBuffersMESA( Display *dpy, GLXDrawable
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -