glxcmds.c revision edb5253dfa0751e451dca7c9a494be4609390545
1cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 2dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 5dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Permission is hereby granted, free of charge, to any person obtaining a 6dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * copy of this software and associated documentation files (the "Software"), 7dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * to deal in the Software without restriction, including without limitation 8dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * and/or sell copies of the Software, and to permit persons to whom the 10dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Software is furnished to do so, subject to the following conditions: 11dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 12dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * The above copyright notice including the dates of first publication and 13dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * either this permission notice or a reference to 14dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * http://oss.sgi.com/projects/FreeB/ 15dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall be included in all copies or substantial portions of the Software. 16dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 17dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SOFTWARE. 24dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * 25dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Except as contained in this notice, the name of Silicon Graphics, Inc. 26dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall not be used in advertising or otherwise to promote the sale, use or 27dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * other dealings in this Software without prior written authorization from 28dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Silicon Graphics, Inc. 29dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson */ 30cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 31cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 32cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \file glxcmds.c 33cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Client-side GLX interface. 34cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 35cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 36cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "glxclient.h" 37cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "glapi.h" 38cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "glxextensions.h" 39cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "glcontextmodes.h" 40df04ffbf025994abd59e26c8439e77bb340ef20bGeorge Sapountzis 41df04ffbf025994abd59e26c8439e77bb340ef20bGeorge Sapountzis#ifdef GLX_DIRECT_RENDERING 42cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include <sys/time.h> 43df04ffbf025994abd59e26c8439e77bb340ef20bGeorge Sapountzis#include <X11/extensions/xf86vmode.h> 44df04ffbf025994abd59e26c8439e77bb340ef20bGeorge Sapountzis#include "xf86dri.h" 452b4e009ed56b69b243f5cc88f490dcf8166cf729Ian Romanick#define GC_IS_DIRECT(gc) ((gc)->driContext != NULL) 462b4e009ed56b69b243f5cc88f490dcf8166cf729Ian Romanick#else 472b4e009ed56b69b243f5cc88f490dcf8166cf729Ian Romanick#define GC_IS_DIRECT(gc) (0) 48df04ffbf025994abd59e26c8439e77bb340ef20bGeorge Sapountzis#endif 49cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 509c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf#if defined(USE_XCB) 519c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf#include <X11/Xlib-xcb.h> 529c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf#include <xcb/xcb.h> 539c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf#include <xcb/glx.h> 549c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf#endif 559c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf 5626d2ce0a09f1aac628519cf3473fcabd3f149446Ian Romanickstatic const char __glXGLXClientVendorName[] = "Mesa Project and SGI"; 57cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic const char __glXGLXClientVersion[] = "1.4"; 58cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 59cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 60cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/****************************************************************************/ 614a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg 624a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg#ifdef GLX_DIRECT_RENDERING 634a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg 644a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsbergstatic Bool windowExistsFlag; 650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic int 660896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófwindowExistsErrorHandler(Display * dpy, XErrorEvent * xerr) 674a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg{ 6826b2bee79d77b7a7b854d7300a10dce69e93d5cdIan Romanick (void) dpy; 6926b2bee79d77b7a7b854d7300a10dce69e93d5cdIan Romanick 700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (xerr->error_code == BadWindow) { 710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf windowExistsFlag = GL_FALSE; 720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return 0; 744a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg} 754a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg 764a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg/** 774a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg * Find drawables in the local hash that have been destroyed on the 784a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg * server. 790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 804a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg * \param dpy Display to destroy drawables for 814a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg * \param screen Screen number to destroy drawables for 824a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg */ 830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 840896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófGarbageCollectDRIDrawables(Display * dpy, __GLXscreenConfigs * sc) 850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XID draw; 870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw; 880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XWindowAttributes xwa; 890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int (*oldXErrorHandler) (Display *, XErrorEvent *); 900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Set no-op error handler so Xlib doesn't bail out if the windows 920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * has alreay been destroyed on the server. */ 930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XSync(dpy, GL_FALSE); 940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler); 950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (__glxHashFirst(sc->drawHash, &draw, (void *) &pdraw) == 1) { 970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf do { 980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf windowExistsFlag = GL_TRUE; 990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */ 1000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!windowExistsFlag) { 1010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Destroy the local drawable data, if the drawable no 1020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf longer exists in the Xserver */ 1030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*pdraw->destroyDrawable) (pdraw); 1040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glxHashDelete(sc->drawHash, draw); 1050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } while (__glxHashNext(sc->drawHash, &draw, (void *) &pdraw) == 1); 1070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 1090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XSync(dpy, GL_FALSE); 1100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XSetErrorHandler(oldXErrorHandler); 1110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf} 1120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 113cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 114cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Get the __DRIdrawable for the drawable associated with a GLXContext 1150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 116cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param dpy The display associated with \c drawable. 117cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param drawable GLXDrawable whose __DRIdrawable part is to be retrieved. 1184a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg * \param scrn_num If non-NULL, the drawables screen is stored there 119cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \returns A pointer to the context's __DRIdrawable on success, or NULL if 120cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * the drawable is not associated with a direct-rendering context. 121cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 122e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg_X_HIDDEN __GLXDRIdrawable * 1230896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófGetGLXDRIDrawable(Display * dpy, GLXDrawable drawable, int *const scrn_num) 124cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 1250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *priv = __glXInitialize(dpy); 1260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw; 1270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const unsigned screen_count = ScreenCount(dpy); 1280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf unsigned i; 1290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc; 130cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (priv == NULL) 1320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 133e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 1340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (i = 0; i < screen_count; i++) { 1350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc = &priv->screenConfigs[i]; 1360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->drawHash == NULL) 1370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf continue; 1380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 1390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0) { 1400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (scrn_num != NULL) 1410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *scrn_num = i; 1420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return pdraw; 1430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 145cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 147cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1484a22ae8d446855d839cc199df8eb1b057045cb88Kristian Høgsberg 149cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 150cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 151cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 152cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 153cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Get the GLX per-screen data structure associated with a GLX context. 1540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 155cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param dpy Display for which the GLX per-screen information is to be 156cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * retrieved. 157cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param scrn Screen on \c dpy for which the GLX per-screen information is 158cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * to be retrieved. 159cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \returns A pointer to the GLX per-screen data if \c dpy and \c scrn 160cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * specify a valid GLX screen, or NULL otherwise. 1610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 162cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \todo Should this function validate that \c scrn is within the screen 163cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * number range for \c dpy? 164cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 165cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 166cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic __GLXscreenConfigs * 1670896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófGetGLXScreenConfigs(Display * dpy, int scrn) 168cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 1690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *const priv = __glXInitialize(dpy); 170cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (priv 1720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf && priv->screenConfigs != 1730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf NULL) ? &priv->screenConfigs[scrn] : NULL; 174cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 175cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 176cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 177cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic int 1780896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófGetGLXPrivScreenConfig(Display * dpy, int scrn, __GLXdisplayPrivate ** ppriv, 1790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs ** ppsc) 180cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 1810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Initialize the extension, if needed . This has the added value 1820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * of initializing/allocating the display private 1830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 184cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (dpy == NULL) { 1860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GLX_NO_EXTENSION; 1870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 188cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *ppriv = __glXInitialize(dpy); 1900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (*ppriv == NULL) { 1910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GLX_NO_EXTENSION; 1920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 193cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Check screen number to see if its valid */ 1950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((scrn < 0) || (scrn >= ScreenCount(dpy))) { 1960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GLX_BAD_SCREEN; 1970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 198cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Check to see if the GL is supported on this screen */ 2000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *ppsc = &((*ppriv)->screenConfigs[scrn]); 2010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((*ppsc)->configs == NULL) { 2020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* No support for GL on this screen regardless of visual */ 2030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GLX_BAD_VISUAL; 2040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return Success; 207cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 208cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 209cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 210cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 211cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Determine if a \c GLXFBConfig supplied by the application is valid. 212cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 213cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param dpy Application supplied \c Display pointer. 214cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param config Application supplied \c GLXFBConfig. 215cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 216cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \returns If the \c GLXFBConfig is valid, the a pointer to the matching 217cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \c __GLcontextModes structure is returned. Otherwise, \c NULL 218cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * is returned. 219cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 220cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic __GLcontextModes * 2210896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófValidateGLXFBConfig(Display * dpy, GLXFBConfig config) 2220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 2230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *const priv = __glXInitialize(dpy); 2240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const unsigned num_screens = ScreenCount(dpy); 2250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf unsigned i; 2260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __GLcontextModes *modes; 2270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (priv != NULL) { 2300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (i = 0; i < num_screens; i++) { 2310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (modes = priv->screenConfigs[i].configs; modes != NULL; 2320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf modes = modes->next) { 2330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (modes == (__GLcontextModes *) config) { 2340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (__GLcontextModes *) config; 2350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 23977c7f90ed44748f0e54e894deff1cac63da54cd6Kristian Høgsberg 2400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 241cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 242cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 243cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 244cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 245cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \todo It should be possible to move the allocate of \c client_state_private 246cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * later in the function for direct-rendering contexts. Direct-rendering 247cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * contexts don't need to track client state, so they don't need that memory 248cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * at all. 2490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 250cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \todo Eliminate \c __glXInitVertexArrayState. Replace it with a new 251cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * function called \c __glXAllocateClientState that allocates the memory and 252cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * does all the initialization (including the pixel pack / unpack). 253cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 2540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic GLXContext 2550896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófAllocateGLXContext(Display * dpy) 2560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 2570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc; 2580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int bufSize; 2590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 2600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXattribute *state; 2610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!dpy) 2630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 2640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 2660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode) { 2670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 2680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Allocate our context record */ 2710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc = (GLXContext) Xmalloc(sizeof(struct __GLXcontextRec)); 2720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!gc) { 2730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Out of memory */ 2740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 2750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf memset(gc, 0, sizeof(struct __GLXcontextRec)); 2770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf state = Xmalloc(sizeof(struct __GLXattributeRec)); 2790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (state == NULL) { 2800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Out of memory */ 2810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(gc); 2820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 2830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->client_state_private = state; 2850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf memset(gc->client_state_private, 0, sizeof(struct __GLXattributeRec)); 2860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf state->NoDrawArraysProtocol = (getenv("LIBGL_NO_DRAWARRAYS") != NULL); 2870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 289cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** Create a temporary buffer to hold GLX rendering commands. The size 290cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** of the buffer is selected so that the maximum number of GLX rendering 291cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** commands can fit in a single X packet and still have room in the X 292cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** packet for the GLXRenderReq header. 293cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 294cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf bufSize = (XMaxRequestSize(dpy) * 4) - sz_xGLXRenderReq; 2960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->buf = (GLubyte *) Xmalloc(bufSize); 2970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!gc->buf) { 2980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(gc->client_state_private); 2990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(gc); 3000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 3010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->bufSize = bufSize; 303cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Fill in the new context */ 3050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->renderMode = GL_RENDER; 306cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf state->storePack.alignment = 4; 3080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf state->storeUnpack.alignment = 4; 309cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->attributes.stackPointer = &gc->attributes.stack[0]; 311cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 313cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** PERFORMANCE NOTE: A mode dependent fill image can speed things up. 314cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** Other code uses the fastImageUnpack bit, but it is never set 315cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** to GL_TRUE. 316cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 3170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->fastImageUnpack = GL_FALSE; 3180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->fillImage = __glFillImage; 3190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->pc = gc->buf; 3200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->bufEnd = gc->buf + bufSize; 3210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->isDirect = GL_FALSE; 3220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (__glXDebug) { 3230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 3240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ** Set limit register so that there will be one command per packet 3250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 3260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->limit = gc->buf; 3270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 3290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->limit = gc->buf + bufSize - __GLX_BUFFER_LIMIT_SIZE; 3300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->createDpy = dpy; 3320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->majorOpcode = opcode; 3330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 335cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** Constrain the maximum drawing command size allowed to be 336cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** transfered using the X_GLXRender protocol request. First 337cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** constrain by a software limit, then constrain by the protocl 338cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** limit. 339cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 3400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (bufSize > __GLX_RENDER_CMD_SIZE_LIMIT) { 3410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf bufSize = __GLX_RENDER_CMD_SIZE_LIMIT; 3420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (bufSize > __GLX_MAX_RENDER_CMD_SIZE) { 3440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf bufSize = __GLX_MAX_RENDER_CMD_SIZE; 3450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->maxSmallRenderCommandSize = bufSize; 3470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return gc; 348cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 349cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 350cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 351cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 352cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Create a new context. Exactly one of \c vis and \c fbconfig should be 353cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * non-NULL. 3540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 355cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param use_glx_1_3 For FBConfigs, should GLX 1.3 protocol or 356cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * SGIX_fbconfig protocol be used? 357cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param renderType For FBConfigs, what is the rendering type? 358cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 359cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 360cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic GLXContext 361d46d30f997c1718217545947ca4d80ec7d18e684Ian RomanickCreateContext(Display * dpy, int generic_id, 3620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __GLcontextModes * const fbconfig, 3630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext shareList, 3642243029eeec9e31b92079ff0e8fafdc0315053d6Ian Romanick Bool allowDirect, 3657bcfb66000557a0ef32bdc6b31949a92f95a9ff6Ian Romanick unsigned code, int renderType, int screen) 366cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 3670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc; 3683731159ec6e1527655d91b3eb364d5c2d252ac60Kristian Høgsberg#ifdef GLX_DIRECT_RENDERING 3690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); 3703731159ec6e1527655d91b3eb364d5c2d252ac60Kristian Høgsberg#endif 371cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (dpy == NULL) 3730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 374cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 375d46d30f997c1718217545947ca4d80ec7d18e684Ian Romanick if (generic_id == None) 3760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 377cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc = AllocateGLXContext(dpy); 3790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!gc) 3800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 381cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 382cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef GLX_DIRECT_RENDERING 383bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick if (allowDirect && psc->driScreen) { 38452cf8db428909156b062f17a9e6251a38178dec3Ian Romanick gc->driContext = psc->driScreen->createContext(psc, fbconfig, gc, 38552cf8db428909156b062f17a9e6251a38178dec3Ian Romanick shareList, renderType); 386bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick if (gc->driContext != NULL) { 38752cf8db428909156b062f17a9e6251a38178dec3Ian Romanick gc->screen = screen; 388bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick gc->psc = psc; 38952cf8db428909156b062f17a9e6251a38178dec3Ian Romanick gc->mode = fbconfig; 390bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick gc->isDirect = GL_TRUE; 3910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 392bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick } 393cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 394cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 395bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick LockDisplay(dpy); 396bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick switch (code) { 397bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick case X_GLXCreateContext: { 398bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick xGLXCreateContextReq *req; 399bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick 400bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick /* Send the glXCreateContext request */ 401bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick GetReq(GLXCreateContext, req); 402bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->reqType = gc->majorOpcode; 403bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->glxCode = X_GLXCreateContext; 404bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->context = gc->xid = XAllocID(dpy); 405d46d30f997c1718217545947ca4d80ec7d18e684Ian Romanick req->visual = generic_id; 406c3db1d621e1f7c73006ed76855d31b1034bc3aefIan Romanick req->screen = screen; 407bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->shareList = shareList ? shareList->xid : None; 408bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->isDirect = GC_IS_DIRECT(gc); 409bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick break; 410bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick } 411cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 412bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick case X_GLXCreateNewContext: { 413bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick xGLXCreateNewContextReq *req; 414bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick 415bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick /* Send the glXCreateNewContext request */ 416bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick GetReq(GLXCreateNewContext, req); 417bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->reqType = gc->majorOpcode; 418bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->glxCode = X_GLXCreateNewContext; 419bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->context = gc->xid = XAllocID(dpy); 420d46d30f997c1718217545947ca4d80ec7d18e684Ian Romanick req->fbconfig = generic_id; 421c3db1d621e1f7c73006ed76855d31b1034bc3aefIan Romanick req->screen = screen; 422bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->renderType = renderType; 423bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->shareList = shareList ? shareList->xid : None; 424bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->isDirect = GC_IS_DIRECT(gc); 425bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick break; 4260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 4278bffadbc83d19ecd8be8f0107d51463e36477666Ian Romanick 428bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick case X_GLXvop_CreateContextWithConfigSGIX: { 429bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick xGLXVendorPrivateWithReplyReq *vpreq; 430bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick xGLXCreateContextWithConfigSGIXReq *req; 431bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick 432bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick /* Send the glXCreateNewContext request */ 433bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick GetReqExtra(GLXVendorPrivateWithReply, 434bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick sz_xGLXCreateContextWithConfigSGIXReq - 435bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick sz_xGLXVendorPrivateWithReplyReq, vpreq); 436bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req = (xGLXCreateContextWithConfigSGIXReq *) vpreq; 437bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->reqType = gc->majorOpcode; 438bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->glxCode = X_GLXVendorPrivateWithReply; 439bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->vendorCode = X_GLXvop_CreateContextWithConfigSGIX; 440bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->context = gc->xid = XAllocID(dpy); 441d46d30f997c1718217545947ca4d80ec7d18e684Ian Romanick req->fbconfig = generic_id; 442c3db1d621e1f7c73006ed76855d31b1034bc3aefIan Romanick req->screen = screen; 443bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->renderType = renderType; 444bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->shareList = shareList ? shareList->xid : None; 445bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick req->isDirect = GC_IS_DIRECT(gc); 446bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick break; 447bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick } 4488bffadbc83d19ecd8be8f0107d51463e36477666Ian Romanick 449bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick default: 450bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick /* What to do here? This case is the sign of an internal error. It 451bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick * should never be reachable. 452bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick */ 453bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick break; 4540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 455cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 456bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick UnlockDisplay(dpy); 457bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick SyncHandle(); 458cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 459bc7b2f0dc33753f6d6b55bd4058e82ddf0997967Ian Romanick gc->imported = GL_FALSE; 460521e4b9b7e3c79e7362f7cbd594a2e8cf74cdfe4Brian Paul gc->renderType = renderType; 461521e4b9b7e3c79e7362f7cbd594a2e8cf74cdfe4Brian Paul 4620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return gc; 463cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 464cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 4650896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC GLXContext 4660896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXCreateContext(Display * dpy, XVisualInfo * vis, 4670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext shareList, Bool allowDirect) 468cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 46952cf8db428909156b062f17a9e6251a38178dec3Ian Romanick const __GLcontextModes *mode = NULL; 47052cf8db428909156b062f17a9e6251a38178dec3Ian Romanick int renderType = 0; 47152cf8db428909156b062f17a9e6251a38178dec3Ian Romanick 47252cf8db428909156b062f17a9e6251a38178dec3Ian Romanick#ifdef GLX_DIRECT_RENDERING 47352cf8db428909156b062f17a9e6251a38178dec3Ian Romanick __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, vis->screen); 47452cf8db428909156b062f17a9e6251a38178dec3Ian Romanick 47552cf8db428909156b062f17a9e6251a38178dec3Ian Romanick mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid); 47652cf8db428909156b062f17a9e6251a38178dec3Ian Romanick if (mode == NULL) { 47752cf8db428909156b062f17a9e6251a38178dec3Ian Romanick xError error; 47852cf8db428909156b062f17a9e6251a38178dec3Ian Romanick 47952cf8db428909156b062f17a9e6251a38178dec3Ian Romanick error.errorCode = BadValue; 48052cf8db428909156b062f17a9e6251a38178dec3Ian Romanick error.resourceID = vis->visualid; 48152cf8db428909156b062f17a9e6251a38178dec3Ian Romanick error.sequenceNumber = dpy->request; 48252cf8db428909156b062f17a9e6251a38178dec3Ian Romanick error.type = X_Error; 48352cf8db428909156b062f17a9e6251a38178dec3Ian Romanick error.majorCode = __glXSetupForCommand(dpy); 48452cf8db428909156b062f17a9e6251a38178dec3Ian Romanick error.minorCode = X_GLXCreateContext; 48552cf8db428909156b062f17a9e6251a38178dec3Ian Romanick _XError(dpy, &error); 48652cf8db428909156b062f17a9e6251a38178dec3Ian Romanick return None; 48752cf8db428909156b062f17a9e6251a38178dec3Ian Romanick } 48852cf8db428909156b062f17a9e6251a38178dec3Ian Romanick 48952cf8db428909156b062f17a9e6251a38178dec3Ian Romanick renderType = mode->rgbMode ? GLX_RGBA_TYPE : GLX_COLOR_INDEX_TYPE; 49052cf8db428909156b062f17a9e6251a38178dec3Ian Romanick#endif 49152cf8db428909156b062f17a9e6251a38178dec3Ian Romanick 492d46d30f997c1718217545947ca4d80ec7d18e684Ian Romanick return CreateContext(dpy, vis->visualid, mode, shareList, allowDirect, 49352cf8db428909156b062f17a9e6251a38178dec3Ian Romanick X_GLXCreateContext, renderType, vis->screen); 494cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 495cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 4960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf_X_HIDDEN void 4970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXFreeContext(__GLXcontext * gc) 498cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 4990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc->vendor) 5000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XFree((char *) gc->vendor); 5010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc->renderer) 5020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XFree((char *) gc->renderer); 5030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc->version) 5040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XFree((char *) gc->version); 5050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc->extensions) 5060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XFree((char *) gc->extensions); 5070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glFreeAttributeState(gc); 5080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XFree((char *) gc->buf); 5090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree((char *) gc->client_state_private); 5100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XFree((char *) gc); 5110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 512cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 513cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 514cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 515cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Destroy the named context 516cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 5170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 5180896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófDestroyContext(Display * dpy, GLXContext gc) 519cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 5200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXDestroyContextReq *req; 5210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContextID xid; 5220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 5230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLboolean imported; 524cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 5250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 5260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode || !gc) { 5270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 5280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 529cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 5300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXLock(); 5310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xid = gc->xid; 5320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf imported = gc->imported; 5330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->xid = None; 534cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 5355e6a6a2719c695996490bde491dac267e52f78afBrian Paul if (gc->currentDpy) { 5365e6a6a2719c695996490bde491dac267e52f78afBrian Paul /* This context is bound to some thread. According to the man page, 5375e6a6a2719c695996490bde491dac267e52f78afBrian Paul * we should not actually delete the context until it's unbound. 5385e6a6a2719c695996490bde491dac267e52f78afBrian Paul * Note that we set gc->xid = None above. In MakeContextCurrent() 5395e6a6a2719c695996490bde491dac267e52f78afBrian Paul * we check for that and delete the context there. 5405e6a6a2719c695996490bde491dac267e52f78afBrian Paul */ 5415e6a6a2719c695996490bde491dac267e52f78afBrian Paul __glXUnlock(); 5425e6a6a2719c695996490bde491dac267e52f78afBrian Paul return; 5435e6a6a2719c695996490bde491dac267e52f78afBrian Paul } 5445e6a6a2719c695996490bde491dac267e52f78afBrian Paul 545cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef GLX_DIRECT_RENDERING 5460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Destroy the direct rendering context */ 5470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc->driContext) { 5480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*gc->driContext->destroyContext) (gc->driContext, gc->psc, dpy); 5490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->driContext = NULL; 5500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GarbageCollectDRIDrawables(dpy, gc->psc); 5510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 552cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 553cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 5540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXFreeVertexArrayState(gc); 555e2060348630b59a446bac7f734fdde40033093abKristof Ralovich 5560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc->currentDpy) { 5570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Have to free later cuz it's in use now */ 5580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXUnlock(); 5590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 5600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 5610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Destroy the handle if not current to anybody */ 5620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXUnlock(); 5630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXFreeContext(gc); 5640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 565cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 5660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!imported) { 5670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 5680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ** This dpy also created the server side part of the context. 5690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ** Send the glXDestroyContext request. 5700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 5710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 5720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReq(GLXDestroyContext, req); 5730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 5740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXDestroyContext; 5750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->context = xid; 5760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 5770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 5780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 579cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 580489ccef3982267b0d35c8548921f58d553c25a3aAdam Jackson 5810896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void 5820896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXDestroyContext(Display * dpy, GLXContext gc) 583cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 5840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf DestroyContext(dpy, gc); 585cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 586cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 587cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 588cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Return the major and minor version #s for the GLX extension 589cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 5900896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC Bool 5910896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXQueryVersion(Display * dpy, int *major, int *minor) 592cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 5930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *priv; 594cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 5950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Init the extension. This fetches the major and minor version. */ 5960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf priv = __glXInitialize(dpy); 5970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!priv) 5980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GL_FALSE; 599cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 6000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (major) 6010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *major = priv->majorVersion; 6020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (minor) 6030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *minor = priv->minorVersion; 6040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GL_TRUE; 605cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 606cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 607cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 608cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Query the existance of the GLX extension 609cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 6100896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC Bool 6110896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXQueryExtension(Display * dpy, int *errorBase, int *eventBase) 6120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 6130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int major_op, erb, evb; 6140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Bool rv; 6150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf rv = XQueryExtension(dpy, GLX_EXTENSION_NAME, &major_op, &evb, &erb); 6170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (rv) { 6180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (errorBase) 6190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *errorBase = erb; 6200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (eventBase) 6210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *eventBase = evb; 6220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 6230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return rv; 624cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 625cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 626cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 627cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Put a barrier in the token stream that forces the GL to finish its 628cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** work before X can proceed. 629cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 6300896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void 6310896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXWaitGL(void) 632cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 6330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXWaitGLReq *req; 6340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc = __glXGetCurrentContext(); 6350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Display *dpy = gc->currentDpy; 636cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 6370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!dpy) 6380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 639cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 6400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Flush any pending commands out */ 6410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXFlushRenderBuffer(gc, gc->pc); 642cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 643cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef GLX_DIRECT_RENDERING 6440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc->driContext) { 6450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int screen; 6460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw = 6470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen); 6480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (pdraw != NULL) { 6500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); 6510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf glFlush(); 6520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->driScreen->waitGL != NULL) 6530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*psc->driScreen->waitGL) (pdraw); 6540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 6550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 6560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 657cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 658cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 6590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Send the glXWaitGL request */ 6600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 6610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReq(GLXWaitGL, req); 6620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = gc->majorOpcode; 6630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXWaitGL; 6640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->contextTag = gc->currentContextTag; 6650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 6660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 667cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 668cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 669cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 670cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Put a barrier in the token stream that forces X to finish its 671cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** work before GL can proceed. 672cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 6730896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void 6740896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXWaitX(void) 675cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 6760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXWaitXReq *req; 6770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc = __glXGetCurrentContext(); 6780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Display *dpy = gc->currentDpy; 679cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 6800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!dpy) 6810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 682cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 6830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Flush any pending commands out */ 6840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXFlushRenderBuffer(gc, gc->pc); 685cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 686cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef GLX_DIRECT_RENDERING 6870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc->driContext) { 6880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int screen; 6890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw = 6900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen); 6910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (pdraw != NULL) { 6930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); 6940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->driScreen->waitX != NULL) 6950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*psc->driScreen->waitX) (pdraw); 6960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 6970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else 6980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XSync(dpy, False); 6990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 7000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 701cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 702cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 704cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** Send the glXWaitX request. 705cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 7060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 7070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReq(GLXWaitX, req); 7080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = gc->majorOpcode; 7090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXWaitX; 7100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->contextTag = gc->currentContextTag; 7110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 7120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 713cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 714cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7150896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void 7160896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXUseXFont(Font font, int first, int count, int listBase) 717cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 7180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXUseXFontReq *req; 7190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc = __glXGetCurrentContext(); 7200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Display *dpy = gc->currentDpy; 721cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!dpy) 7230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 724cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Flush any pending commands out */ 7260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (void) __glXFlushRenderBuffer(gc, gc->pc); 727cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 728cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef GLX_DIRECT_RENDERING 7290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc->driContext) { 730cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson DRI_glXUseXFont(font, first, count, listBase); 731cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return; 7320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 733cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 734cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Send the glXUseFont request */ 7360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 7370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReq(GLXUseXFont, req); 7380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = gc->majorOpcode; 7390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXUseXFont; 7400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->contextTag = gc->currentContextTag; 7410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->font = font; 7420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->first = first; 7430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->count = count; 7440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->listBase = listBase; 7450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 7460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 747cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 748cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 749cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/************************************************************************/ 750cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 751cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 752cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Copy the source context to the destination context using the 753cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** attribute "mask". 754cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 7550896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void 7560896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXCopyContext(Display * dpy, GLXContext source, 7570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext dest, unsigned long mask) 758cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 7590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXCopyContextReq *req; 7600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc = __glXGetCurrentContext(); 7610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContextTag tag; 7620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 763cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 7650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode) { 7660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 7670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 768cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 769cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef GLX_DIRECT_RENDERING 7700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc->driContext) { 7710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* NOT_DONE: This does not work yet */ 7720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 773cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 774cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 776cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** If the source is the current context, send its tag so that the context 777cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** can be flushed before the copy. 778cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 7790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (source == gc && dpy == gc->currentDpy) { 7800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf tag = gc->currentContextTag; 7810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 7820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 7830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf tag = 0; 7840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 7850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 7860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Send the glXCopyContext request */ 7870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 7880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReq(GLXCopyContext, req); 7890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 7900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXCopyContext; 7910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->source = source ? source->xid : None; 7920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->dest = dest ? dest->xid : None; 7930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->mask = mask; 7940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->contextTag = tag; 7950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 7960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 797cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 798cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 799cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 800cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 801cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Determine if a context uses direct rendering. 802cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 803cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param dpy Display where the context was created. 804cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param contextID ID of the context to be tested. 805cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 806cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \returns \c GL_TRUE if the context is direct rendering or not. 807cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 8080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic Bool 8090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXIsDirect(Display * dpy, GLXContextID contextID) 810cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 8119c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf#if !defined(USE_XCB) 8120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXIsDirectReq *req; 8130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXIsDirectReply reply; 8149c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf#endif 8150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 816cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 8170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 8180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode) { 8190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GL_FALSE; 8200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 821cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 8229c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf#ifdef USE_XCB 8230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xcb_connection_t *c = XGetXCBConnection(dpy); 8240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xcb_glx_is_direct_reply_t *reply = xcb_glx_is_direct_reply(c, 8250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xcb_glx_is_direct 8260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (c, contextID), 8270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf NULL); 8289c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf 8299c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf const Bool is_direct = reply->is_direct ? True : False; 8309c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf free(reply); 8319c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf 8329c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf return is_direct; 8339c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf#else 8340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Send the glXIsDirect request */ 8350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 8360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReq(GLXIsDirect, req); 8370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 8380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXIsDirect; 8390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->context = contextID; 8400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf _XReply(dpy, (xReply *) & reply, 0, False); 8410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 8420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 8430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 8440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return reply.isDirect; 8459c7aaa7afbda92587f28cc28c4c8315e7861d318RALOVICH, Kristóf#endif /* USE_XCB */ 846cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 847cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 848c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick/** 849c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick * \todo 850c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick * Shouldn't this function \b always return \c GL_FALSE when 851c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick * \c GLX_DIRECT_RENDERING is not defined? Do we really need to bother with 852c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick * the GLX protocol here at all? 853c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick */ 8540896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC Bool 8550896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXIsDirect(Display * dpy, GLXContext gc) 856cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 8570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!gc) { 8580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GL_FALSE; 8590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 8602b4e009ed56b69b243f5cc88f490dcf8166cf729Ian Romanick else if (GC_IS_DIRECT(gc)) { 8610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GL_TRUE; 8620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 8630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return __glXIsDirect(dpy, gc->xid); 864cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 865cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 8660896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC GLXPixmap 8670896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap) 868cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 8690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXCreateGLXPixmapReq *req; 8700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXPixmap xid; 8710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 872cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 8730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 8740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode) { 8750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return None; 8760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 877cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 8780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Send the glXCreateGLXPixmap request */ 8790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 8800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReq(GLXCreateGLXPixmap, req); 8810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 8820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXCreateGLXPixmap; 8830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->screen = vis->screen; 8840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->visual = vis->visualid; 8850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->pixmap = pixmap; 8860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxpixmap = xid = XAllocID(dpy); 8870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 8880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 889edb117879846155632aaeb66483a3085c7a78815Michel Dänzer 890edb117879846155632aaeb66483a3085c7a78815Michel Dänzer#ifdef GLX_DIRECT_RENDERING 8919053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer do { 8929053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer /* FIXME: Maybe delay __DRIdrawable creation until the drawable 8939053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer * is actually bound to a context... */ 8949053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer 8959053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer __GLXdisplayPrivate *const priv = __glXInitialize(dpy); 8969053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer __GLXDRIdrawable *pdraw; 8979053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer __GLXscreenConfigs *psc; 8989053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer __GLcontextModes *modes; 8999053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer 9009053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer psc = &priv->screenConfigs[vis->screen]; 9019053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer if (psc->driScreen == NULL) 9029053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer break; 9039053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid); 9049053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer pdraw = psc->driScreen->createDrawable(psc, pixmap, req->glxpixmap, modes); 9059053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer if (pdraw == NULL) { 9069053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer fprintf(stderr, "failed to create pixmap\n"); 9079053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer break; 9089053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer } 9099053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer 9109053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer if (__glxHashInsert(psc->drawHash, req->glxpixmap, pdraw)) { 9119053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer (*pdraw->destroyDrawable) (pdraw); 9129053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer return None; /* FIXME: Check what we're supposed to do here... */ 9139053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer } 9149053bb0d405db0b1a2a917317c7ec41e63b54f09Michel Dänzer } while (0); 915edb117879846155632aaeb66483a3085c7a78815Michel Dänzer#endif 916edb117879846155632aaeb66483a3085c7a78815Michel Dänzer 9170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return xid; 918cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 919cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 920cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 921cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Destroy the named pixmap 922cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 9230896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void 9240896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap) 9250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 9260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXDestroyGLXPixmapReq *req; 9270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 9280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 9290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 9300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode) { 9310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 9320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 9330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 9340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Send the glXDestroyGLXPixmap request */ 9350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 9360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReq(GLXDestroyGLXPixmap, req); 9370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 9380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXDestroyGLXPixmap; 9390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxpixmap = glxpixmap; 9400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 9410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 9429dfce365c7f35ddea6d81b7f595ddcd6d35382a5Michel Dänzer 9439dfce365c7f35ddea6d81b7f595ddcd6d35382a5Michel Dänzer#ifdef GLX_DIRECT_RENDERING 9440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf { 9450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int screen; 9460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *const priv = __glXInitialize(dpy); 9470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap, &screen); 9480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc = &priv->screenConfigs[screen]; 9490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 9500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (pdraw != NULL) { 9510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*pdraw->destroyDrawable) (pdraw); 9520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glxHashDelete(psc->drawHash, glxpixmap); 9530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 9540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 9559dfce365c7f35ddea6d81b7f595ddcd6d35382a5Michel Dänzer#endif 95677c7f90ed44748f0e54e894deff1cac63da54cd6Kristian Høgsberg} 95777c7f90ed44748f0e54e894deff1cac63da54cd6Kristian Høgsberg 9580896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void 9590896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXSwapBuffers(Display * dpy, GLXDrawable drawable) 96077c7f90ed44748f0e54e894deff1cac63da54cd6Kristian Høgsberg{ 9610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc; 9620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContextTag tag; 9630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 964b7f802eca2c78397ea7b8472b3a7e90a997fc140Brian Paul#ifdef USE_XCB 9650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xcb_connection_t *c; 966b7f802eca2c78397ea7b8472b3a7e90a997fc140Brian Paul#else 9670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXSwapBuffersReq *req; 968b7f802eca2c78397ea7b8472b3a7e90a997fc140Brian Paul#endif 969b7f802eca2c78397ea7b8472b3a7e90a997fc140Brian Paul 970cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef GLX_DIRECT_RENDERING 9710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); 972cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 9730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (pdraw != NULL) { 9740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf glFlush(); 975daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes (*pdraw->psc->driScreen->swapBuffers)(pdraw, 0, 0, 0); 9760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 9770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 978cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 979cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 9800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 9810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode) { 9820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 9830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 984cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 9850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 986cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** The calling thread may or may not have a current context. If it 987cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** does, send the context tag so the server can do a flush. 988cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 9890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc = __glXGetCurrentContext(); 9900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((gc != NULL) && (dpy == gc->currentDpy) && 9910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ((drawable == gc->currentDrawable) 9920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf || (drawable == gc->currentReadable))) { 9930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf tag = gc->currentContextTag; 9940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 9950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 9960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf tag = 0; 9970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 99877c7f90ed44748f0e54e894deff1cac63da54cd6Kristian Høgsberg 999ff3fa92eaa67579b3bd3480bc685cfc55ae1eff2RALOVICH, Kristóf#ifdef USE_XCB 10000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf c = XGetXCBConnection(dpy); 10010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xcb_glx_swap_buffers(c, tag, drawable); 10020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xcb_flush(c); 1003ff3fa92eaa67579b3bd3480bc685cfc55ae1eff2RALOVICH, Kristóf#else 10040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Send the glXSwapBuffers request */ 10050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 10060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReq(GLXSwapBuffers, req); 10070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 10080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXSwapBuffers; 10090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->drawable = drawable; 10100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->contextTag = tag; 10110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 10120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 10130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XFlush(dpy); 1014ff3fa92eaa67579b3bd3480bc685cfc55ae1eff2RALOVICH, Kristóf#endif /* USE_XCB */ 1015cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1016cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1017cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1018cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 1019cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Return configuration information for the given display, screen and 1020cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** visual combination. 1021cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 10220896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC int 10230896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXGetConfig(Display * dpy, XVisualInfo * vis, int attribute, 10240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int *value_return) 10250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 10260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *priv; 10270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc; 10280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLcontextModes *modes; 10290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int status; 10300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 10310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf status = GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc); 10320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (status == Success) { 10330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid); 10340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 10350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Lookup attribute after first finding a match on the visual */ 10360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (modes != NULL) { 10370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return _gl_get_context_mode_data(modes, attribute, value_return); 10380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 10390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 10400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf status = GLX_BAD_VISUAL; 10410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 10420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 10430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 1044cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** If we can't find the config for this visual, this visual is not 1045cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** supported by the OpenGL implementation on the server. 1046cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 10470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((status == GLX_BAD_VISUAL) && (attribute == GLX_USE_GL)) { 10480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *value_return = GL_FALSE; 10490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf status = Success; 10500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1051cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 10520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return status; 1053cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1054cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1055cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/************************************************************************/ 1056cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1057cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic void 10580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófinit_fbconfig_for_chooser(__GLcontextModes * config, 10590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLboolean fbconfig_style_tags) 10600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 10610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf memset(config, 0, sizeof(__GLcontextModes)); 10620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->visualID = (XID) GLX_DONT_CARE; 10630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->visualType = GLX_DONT_CARE; 10640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 10650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* glXChooseFBConfig specifies different defaults for these two than 10660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * glXChooseVisual. 10670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 10680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (fbconfig_style_tags) { 10690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->rgbMode = GL_TRUE; 10700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->doubleBufferMode = GLX_DONT_CARE; 10710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 10720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 10730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->visualRating = GLX_DONT_CARE; 10740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->transparentPixel = GLX_NONE; 10750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->transparentRed = GLX_DONT_CARE; 10760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->transparentGreen = GLX_DONT_CARE; 10770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->transparentBlue = GLX_DONT_CARE; 10780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->transparentAlpha = GLX_DONT_CARE; 10790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->transparentIndex = GLX_DONT_CARE; 10800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 10810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->drawableType = GLX_WINDOW_BIT; 10820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->renderType = 10830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; 10840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->xRenderable = GLX_DONT_CARE; 10850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->fbconfigID = (GLXFBConfigID) (GLX_DONT_CARE); 10860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 10870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->swapMethod = GLX_DONT_CARE; 10880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf} 10890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 10900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define MATCH_DONT_CARE( param ) \ 10910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf do { \ 109271a6fb15ceb6619d39029ff897daf2da4858b17eIan Romanick if ( ((int) a-> param != (int) GLX_DONT_CARE) \ 10930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf && (a-> param != b-> param) ) { \ 10940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return False; \ 10950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } \ 10960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } while ( 0 ) 10970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 10980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define MATCH_MINIMUM( param ) \ 10990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf do { \ 110071a6fb15ceb6619d39029ff897daf2da4858b17eIan Romanick if ( ((int) a-> param != (int) GLX_DONT_CARE) \ 11010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf && (a-> param > b-> param) ) { \ 11020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return False; \ 11030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } \ 11040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } while ( 0 ) 11050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 11060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define MATCH_EXACT( param ) \ 11070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf do { \ 11080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ( a-> param != b-> param) { \ 11090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return False; \ 11100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } \ 11110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } while ( 0 ) 1112cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1113edb5253dfa0751e451dca7c9a494be4609390545Kristian Høgsberg/* Test that all bits from a are contained in b */ 1114edb5253dfa0751e451dca7c9a494be4609390545Kristian Høgsberg#define MATCH_MASK(param) \ 1115edb5253dfa0751e451dca7c9a494be4609390545Kristian Høgsberg do { \ 1116edb5253dfa0751e451dca7c9a494be4609390545Kristian Høgsberg if ((a->param & ~b->param) != 0) \ 1117edb5253dfa0751e451dca7c9a494be4609390545Kristian Høgsberg return False; \ 1118edb5253dfa0751e451dca7c9a494be4609390545Kristian Høgsberg } while (0); 1119edb5253dfa0751e451dca7c9a494be4609390545Kristian Høgsberg 1120cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 1121cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Determine if two GLXFBConfigs are compatible. 1122cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 1123cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param a Application specified config to test. 1124cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param b Server specified config to test against \c a. 1125cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 1126cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic Bool 11270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóffbconfigs_compatible(const __GLcontextModes * const a, 11280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __GLcontextModes * const b) 11290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 11300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(doubleBufferMode); 11310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(visualType); 11320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(visualRating); 11330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(xRenderable); 11340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(fbconfigID); 11350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(swapMethod); 11360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 11370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(rgbBits); 11380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(numAuxBuffers); 11390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(redBits); 11400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(greenBits); 11410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(blueBits); 11420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(alphaBits); 11430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(depthBits); 11440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(stencilBits); 11450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(accumRedBits); 11460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(accumGreenBits); 11470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(accumBlueBits); 11480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(accumAlphaBits); 11490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(sampleBuffers); 11500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(maxPbufferWidth); 11510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(maxPbufferHeight); 11520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(maxPbufferPixels); 11530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_MINIMUM(samples); 11540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 11550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(stereoMode); 11560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_EXACT(level); 11570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 1158edb5253dfa0751e451dca7c9a494be4609390545Kristian Høgsberg MATCH_MASK(drawableType); 1159edb5253dfa0751e451dca7c9a494be4609390545Kristian Høgsberg MATCH_MASK(renderType); 11600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 11610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* There is a bug in a few of the XFree86 DDX drivers. They contain 11620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * visuals with a "transparent type" of 0 when they really mean GLX_NONE. 11630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * Technically speaking, it is a bug in the DDX driver, but there is 11640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * enough of an installed base to work around the problem here. In any 11650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * case, 0 is not a valid value of the transparent type, so we'll treat 0 11660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * from the app as GLX_DONT_CARE. We'll consider GLX_NONE from the app and 11670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 0 from the server to be a match to maintain backward compatibility with 11680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * the (broken) drivers. 11690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 11700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 117171a6fb15ceb6619d39029ff897daf2da4858b17eIan Romanick if (a->transparentPixel != (int) GLX_DONT_CARE && a->transparentPixel != 0) { 11720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (a->transparentPixel == GLX_NONE) { 11730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (b->transparentPixel != GLX_NONE && b->transparentPixel != 0) 11740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return False; 11750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 11760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 11770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_EXACT(transparentPixel); 11780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 11790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 11800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf switch (a->transparentPixel) { 11810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_TRANSPARENT_RGB: 11820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(transparentRed); 11830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(transparentGreen); 11840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(transparentBlue); 11850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(transparentAlpha); 11860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 11870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 11880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_TRANSPARENT_INDEX: 11890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf MATCH_DONT_CARE(transparentIndex); 11900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 11910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 11920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf default: 11930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 11940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 11950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 11960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 11970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return True; 1198cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1199cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1200cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1201cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* There's some trickly language in the GLX spec about how this is supposed 1202cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * to work. Basically, if a given component size is either not specified 1203cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * or the requested size is zero, it is supposed to act like PERFER_SMALLER. 1204cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Well, that's really hard to do with the code as-is. This behavior is 1205cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * closer to correct, but still not technically right. 1206cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 12070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define PREFER_LARGER_OR_ZERO(comp) \ 12080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf do { \ 12090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ( ((*a)-> comp) != ((*b)-> comp) ) { \ 12100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ( ((*a)-> comp) == 0 ) { \ 12110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return -1; \ 12120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } \ 12130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else if ( ((*b)-> comp) == 0 ) { \ 12140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return 1; \ 12150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } \ 12160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { \ 12170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return ((*b)-> comp) - ((*a)-> comp) ; \ 12180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } \ 12190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } \ 12200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } while( 0 ) 12210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 12220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define PREFER_LARGER(comp) \ 12230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf do { \ 12240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ( ((*a)-> comp) != ((*b)-> comp) ) { \ 12250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return ((*b)-> comp) - ((*a)-> comp) ; \ 12260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } \ 12270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } while( 0 ) 12280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 12290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf#define PREFER_SMALLER(comp) \ 12300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf do { \ 12310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ( ((*a)-> comp) != ((*b)-> comp) ) { \ 12320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return ((*a)-> comp) - ((*b)-> comp) ; \ 12330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } \ 12340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } while( 0 ) 1235cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1236cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 1237cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Compare two GLXFBConfigs. This function is intended to be used as the 1238cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * compare function passed in to qsort. 12390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 1240cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \returns If \c a is a "better" config, according to the specification of 1241cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * SGIX_fbconfig, a number less than zero is returned. If \c b is 1242cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * better, then a number greater than zero is return. If both are 1243cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * equal, zero is returned. 1244cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \sa qsort, glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX 1245cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 1246cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic int 12470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóffbconfig_compare(const __GLcontextModes * const *const a, 12480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __GLcontextModes * const *const b) 1249cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 12500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* The order of these comparisons must NOT change. It is defined by 12510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * the GLX 1.3 spec and ARB_multisample. 12520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 1253cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 12540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_SMALLER(visualSelectGroup); 1255cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 12560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* The sort order for the visualRating is GLX_NONE, GLX_SLOW, and 12570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * GLX_NON_CONFORMANT_CONFIG. It just so happens that this is the 12580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * numerical sort order of the enums (0x8000, 0x8001, and 0x800D). 12590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 12600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_SMALLER(visualRating); 1261cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 12620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* This isn't quite right. It is supposed to compare the sum of the 12630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * components the user specifically set minimums for. 12640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 12650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER_OR_ZERO(redBits); 12660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER_OR_ZERO(greenBits); 12670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER_OR_ZERO(blueBits); 12680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER_OR_ZERO(alphaBits); 1269cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 12700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_SMALLER(rgbBits); 1271cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 12720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (((*a)->doubleBufferMode != (*b)->doubleBufferMode)) { 12730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Prefer single-buffer. 12740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 12750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (!(*a)->doubleBufferMode) ? -1 : 1; 12760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1277cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 12780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_SMALLER(numAuxBuffers); 1279cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 12800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER_OR_ZERO(depthBits); 12810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_SMALLER(stencilBits); 1282cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 12830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* This isn't quite right. It is supposed to compare the sum of the 12840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * components the user specifically set minimums for. 12850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 12860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER_OR_ZERO(accumRedBits); 12870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER_OR_ZERO(accumGreenBits); 12880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER_OR_ZERO(accumBlueBits); 12890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER_OR_ZERO(accumAlphaBits); 1290cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 12910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_SMALLER(visualType); 1292cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 12930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* None of the multisample specs say where this comparison should happen, 12940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * so I put it near the end. 12950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 12960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_SMALLER(sampleBuffers); 12970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_SMALLER(samples); 1298cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 12990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* None of the pbuffer or fbconfig specs say that this comparison needs 13000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * to happen at all, but it seems like it should. 13010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 13020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER(maxPbufferWidth); 13030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER(maxPbufferHeight); 13040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf PREFER_LARGER(maxPbufferPixels); 1305cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 13060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return 0; 1307cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1308cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1309cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1310cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 1311cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Selects and sorts a subset of the supplied configs based on the attributes. 1312cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * This function forms to basis of \c glXChooseVisual, \c glXChooseFBConfig, 1313cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * and \c glXChooseFBConfigSGIX. 13140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 1315cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param configs Array of pointers to possible configs. The elements of 1316cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * this array that do not meet the criteria will be set to 1317cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * NULL. The remaining elements will be sorted according to 1318cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * the various visual / FBConfig selection rules. 1319cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param num_configs Number of elements in the \c configs array. 1320cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param attribList Attributes used select from \c configs. This array is 1321cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * terminated by a \c None tag. The array can either take 1322cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * the form expected by \c glXChooseVisual (where boolean 1323cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * tags do not have a value) or by \c glXChooseFBConfig 1324cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * (where every tag has a value). 1325cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param fbconfig_style_tags Selects whether \c attribList is in 1326cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \c glXChooseVisual style or 1327cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \c glXChooseFBConfig style. 1328cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \returns The number of valid elements left in \c configs. 13290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 1330cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX 1331cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 1332cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic int 13330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófchoose_visual(__GLcontextModes ** configs, int num_configs, 13340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const int *attribList, GLboolean fbconfig_style_tags) 13350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 13360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLcontextModes test_config; 13370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int base; 13380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int i; 13390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 13400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* This is a fairly direct implementation of the selection method 13410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * described by GLX_SGIX_fbconfig. Start by culling out all the 13420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * configs that are not compatible with the selected parameter 13430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * list. 13440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 13450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 13460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf init_fbconfig_for_chooser(&test_config, fbconfig_style_tags); 13470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXInitializeVisualConfigFromTags(&test_config, 512, 13480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (const INT32 *) attribList, 13490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GL_TRUE, fbconfig_style_tags); 13500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 13510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf base = 0; 13520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (i = 0; i < num_configs; i++) { 13530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (fbconfigs_compatible(&test_config, configs[i])) { 13540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf configs[base] = configs[i]; 13550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf base++; 13560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 13570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 13580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 13590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (base == 0) { 13600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return 0; 13610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 13620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 13630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (base < num_configs) { 13640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (void) memset(&configs[base], 0, sizeof(void *) * (num_configs - base)); 13650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 13660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 13670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* After the incompatible configs are removed, the resulting 13680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * list is sorted according to the rules set out in the various 13690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * specifications. 13700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 13710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 13720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf qsort(configs, base, sizeof(__GLcontextModes *), 13730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (int (*)(const void *, const void *)) fbconfig_compare); 13740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return base; 1375cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1376cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1377cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1378cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1379cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1380cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 1381cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Return the visual that best matches the template. Return None if no 1382cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** visual matches the template. 1383cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 13840896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC XVisualInfo * 13850896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXChooseVisual(Display * dpy, int screen, int *attribList) 1386cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 13870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XVisualInfo *visualList = NULL; 13880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *priv; 13890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc; 13900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLcontextModes test_config; 13910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLcontextModes *modes; 13920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __GLcontextModes *best_config = NULL; 1393cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 13940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 1395cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** Get a list of all visuals, return if list is empty 1396cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 13970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) { 13980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return None; 13990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1400cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 14010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 14020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 1403cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** Build a template from the defaults and the attribute list 1404cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** Free visual list and return if an unexpected token is encountered 1405cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 14060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf init_fbconfig_for_chooser(&test_config, GL_FALSE); 14070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXInitializeVisualConfigFromTags(&test_config, 512, 14080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (const INT32 *) attribList, 14090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GL_TRUE, GL_FALSE); 1410cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 14110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 1412cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** Eliminate visuals that don't meet minimum requirements 1413cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** Compute a score for those that do 1414cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** Remember which visual, if any, got the highest score 141546b81b0cc883df0ef7d998be36ae6cbf80257cd2Michel Dänzer ** If no visual is acceptable, return None 141646b81b0cc883df0ef7d998be36ae6cbf80257cd2Michel Dänzer ** Otherwise, create an XVisualInfo list with just the selected X visual 141746b81b0cc883df0ef7d998be36ae6cbf80257cd2Michel Dänzer ** and return this. 1418cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 14190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (modes = psc->visuals; modes != NULL; modes = modes->next) { 14200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (fbconfigs_compatible(&test_config, modes) 14210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf && ((best_config == NULL) 14220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf || 14230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (fbconfig_compare 14240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ((const __GLcontextModes * const *const) &modes, 14250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &best_config) < 0))) { 14260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XVisualInfo visualTemplate; 14270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XVisualInfo *newList; 14280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int i; 14290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 14300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf visualTemplate.screen = screen; 14310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf visualTemplate.visualid = modes->visualID; 14320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf newList = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask, 14330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &visualTemplate, &i); 14340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 14350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (newList) { 14360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(visualList); 14370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf visualList = newList; 14380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf best_config = modes; 14390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 14400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 14410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 144277c7f90ed44748f0e54e894deff1cac63da54cd6Kristian Høgsberg 14430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return visualList; 1444cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1445cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1446cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 14470896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC const char * 14480896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXQueryExtensionsString(Display * dpy, int screen) 1449cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 14500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc; 14510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *priv; 1452cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 14530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) { 14540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 14550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1456cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 14570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!psc->effectiveGLXexts) { 14580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!psc->serverGLXexts) { 14590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc->serverGLXexts = 14600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXQueryServerString(dpy, priv->majorOpcode, screen, 14610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_EXTENSIONS); 14620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1463cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 14640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXCalculateUsableExtensions(psc, 1465cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef GLX_DIRECT_RENDERING 14660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (psc->driScreen != NULL), 1467cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else 14680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GL_FALSE, 1469cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 14700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf priv->minorVersion); 14710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1472cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 14730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return psc->effectiveGLXexts; 1474cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1475cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 14760896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC const char * 14770896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXGetClientString(Display * dpy, int name) 1478cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 147926b2bee79d77b7a7b854d7300a10dce69e93d5cdIan Romanick (void) dpy; 148026b2bee79d77b7a7b854d7300a10dce69e93d5cdIan Romanick 14810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf switch (name) { 14820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_VENDOR: 14830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (__glXGLXClientVendorName); 14840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_VERSION: 14850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (__glXGLXClientVersion); 14860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_EXTENSIONS: 14870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (__glXGetClientExtensions()); 14880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf default: 14890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 14900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1491cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1492cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 14930896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC const char * 14940896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXQueryServerString(Display * dpy, int screen, int name) 1495cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 14960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc; 14970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *priv; 14980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const char **str; 1499cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1500cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 15010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) { 15020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 15030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1504cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 15050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf switch (name) { 15060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_VENDOR: 15070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf str = &priv->serverGLXvendor; 15080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 15090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_VERSION: 15100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf str = &priv->serverGLXversion; 15110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 15120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_EXTENSIONS: 15130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf str = &psc->serverGLXexts; 15140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 15150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf default: 15160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 15170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1518cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 15190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (*str == NULL) { 15200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *str = __glXQueryServerString(dpy, priv->majorOpcode, screen, name); 15210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 15220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 15230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return *str; 1524cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1525cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 15260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófvoid 15270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXClientInfo(Display * dpy, int opcode) 1528cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 15290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf char *ext_str = __glXGetClientGLExtensionString(); 15300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int size = strlen(ext_str) + 1; 153166db1b64e85a2225dff930d3bb9e1194bde75622RALOVICH, Kristóf 153266db1b64e85a2225dff930d3bb9e1194bde75622RALOVICH, Kristóf#ifdef USE_XCB 153366db1b64e85a2225dff930d3bb9e1194bde75622RALOVICH, Kristóf xcb_connection_t *c = XGetXCBConnection(dpy); 153466db1b64e85a2225dff930d3bb9e1194bde75622RALOVICH, Kristóf xcb_glx_client_info(c, 15350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_MAJOR_VERSION, GLX_MINOR_VERSION, size, ext_str); 153666db1b64e85a2225dff930d3bb9e1194bde75622RALOVICH, Kristóf#else 15370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXClientInfoReq *req; 15380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 15390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Send the glXClientInfo request */ 15400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 15410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReq(GLXClientInfo, req); 15420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 15430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXClientInfo; 15440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->major = GLX_MAJOR_VERSION; 15450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->minor = GLX_MINOR_VERSION; 15460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 15470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->length += (size + 3) >> 2; 15480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->numbytes = size; 15490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Data(dpy, ext_str, size); 15500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 15510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 15520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 155366db1b64e85a2225dff930d3bb9e1194bde75622RALOVICH, Kristóf#endif /* USE_XCB */ 155466db1b64e85a2225dff930d3bb9e1194bde75622RALOVICH, Kristóf 15550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(ext_str); 1556cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1557cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1558cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1559cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 1560cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** EXT_import_context 1561cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 1562cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 15630896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC Display * 15640896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXGetCurrentDisplay(void) 1565cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 15660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc = __glXGetCurrentContext(); 15670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (NULL == gc) 15680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 15690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return gc->currentDpy; 1570cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1571cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 15720896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC 15730896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófGLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (), 15740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf glXGetCurrentDisplay) 1575cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1576cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 1577cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Used internally by libGL to send \c xGLXQueryContextinfoExtReq requests 1578cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * to the X-server. 15790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 1580cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param dpy Display where \c ctx was created. 1581cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param ctx Context to query. 1582cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \returns \c Success on success. \c GLX_BAD_CONTEXT if \c ctx is invalid, 1583cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * or zero if the request failed due to internal problems (i.e., 1584cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * unable to allocate temporary memory, etc.) 15850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 1586cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \note 1587cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * This function dynamically determines whether to use the EXT_import_context 1588cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * version of the protocol or the GLX 1.3 version of the protocol. 1589cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 1590ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian Paulstatic int __glXQueryContextInfo(Display * dpy, GLXContext ctx) 15910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 15920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *priv = __glXInitialize(dpy); 15930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXQueryContextReply reply; 15940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 15950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLuint numValues; 15960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int retval; 15970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 15980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (ctx == NULL) { 15990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GLX_BAD_CONTEXT; 16000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 16010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 16020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode) { 16030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return 0; 16040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 16050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 16060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Send the glXQueryContextInfoEXT request */ 16070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 16080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 16090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { 16100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXQueryContextReq *req; 16110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 16120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReq(GLXQueryContext, req); 16130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 16140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 16150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXQueryContext; 16160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->context = (unsigned int) (ctx->xid); 16170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 16180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 16190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXVendorPrivateReq *vpreq; 16200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXQueryContextInfoEXTReq *req; 16210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 16220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReqExtra(GLXVendorPrivate, 16230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf sz_xGLXQueryContextInfoEXTReq - sz_xGLXVendorPrivateReq, 16240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf vpreq); 16250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req = (xGLXQueryContextInfoEXTReq *) vpreq; 16260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 16270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXVendorPrivateWithReply; 16280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->vendorCode = X_GLXvop_QueryContextInfoEXT; 16290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->context = (unsigned int) (ctx->xid); 16300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 16310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 16320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf _XReply(dpy, (xReply *) & reply, 0, False); 16330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 16340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf numValues = reply.n; 16350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (numValues == 0) 16360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf retval = Success; 16370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else if (numValues > __GLX_MAX_CONTEXT_PROPS) 16380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf retval = 0; 16390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 16400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int *propList, *pProp; 16410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int nPropListBytes; 16420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 16430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf nPropListBytes = numValues << 3; 16440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf propList = (int *) Xmalloc(nPropListBytes); 16450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (NULL == propList) { 16460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf retval = 0; 16470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 16480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 16491add5354d0fbfb2d9b6a4a3fd6a39225bcadc098Ian Romanick unsigned i; 16501add5354d0fbfb2d9b6a4a3fd6a39225bcadc098Ian Romanick 16510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf _XRead(dpy, (char *) propList, nPropListBytes); 16520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pProp = propList; 16530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (i = 0; i < numValues; i++) { 16540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf switch (*pProp++) { 16550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_SHARE_CONTEXT_EXT: 16560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ctx->share_xid = *pProp++; 16570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 16580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_VISUAL_ID_EXT: 16590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ctx->mode = 16600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf _gl_context_modes_find_visual(ctx->psc->visuals, *pProp++); 16610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 16620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_SCREEN: 16630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ctx->screen = *pProp++; 16640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 16650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_FBCONFIG_ID: 16660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ctx->mode = 16670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf _gl_context_modes_find_fbconfig(ctx->psc->configs, 16680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *pProp++); 16690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 16700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_RENDER_TYPE: 16710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ctx->renderType = *pProp++; 16720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 16730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf default: 16740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pProp++; 16750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf continue; 16760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 16770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 16780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree((char *) propList); 16790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf retval = Success; 16800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 16810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 16820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 16830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 16840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return retval; 1685cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1686cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1687489ccef3982267b0d35c8548921f58d553c25a3aAdam JacksonPUBLIC int 16880896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXQueryContext(Display * dpy, GLXContext ctx, int attribute, int *value) 1689cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 16900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int retVal; 1691cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 16920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* get the information from the server if we don't have it already */ 1693919ec22ecf72aa163e1b97d8c7381002131ed32cJeremy Huddleston#ifdef GLX_DIRECT_RENDERING 16940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!ctx->driContext && (ctx->mode == NULL)) { 1695919ec22ecf72aa163e1b97d8c7381002131ed32cJeremy Huddleston#else 16960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (ctx->mode == NULL) { 1697919ec22ecf72aa163e1b97d8c7381002131ed32cJeremy Huddleston#endif 16980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf retVal = __glXQueryContextInfo(dpy, ctx); 16990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (Success != retVal) 17000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return retVal; 17010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 17020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf switch (attribute) { 17030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_SHARE_CONTEXT_EXT: 17040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *value = (int) (ctx->share_xid); 17050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 17060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_VISUAL_ID_EXT: 17070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *value = ctx->mode ? ctx->mode->visualID : None; 17080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 17090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_SCREEN: 17100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *value = (int) (ctx->screen); 17110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 17120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_FBCONFIG_ID: 17130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *value = ctx->mode ? ctx->mode->fbconfigID : None; 17140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 17150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf case GLX_RENDER_TYPE: 17160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *value = (int) (ctx->renderType); 17170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf break; 17180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf default: 17190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GLX_BAD_ATTRIBUTE; 17200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 17210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return Success; 1722cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1723cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 17240896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC 17250896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófGLX_ALIAS(int, glXQueryContextInfoEXT, 17260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (Display * dpy, GLXContext ctx, int attribute, int *value), 17270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (dpy, ctx, attribute, value), glXQueryContext) 1728cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1729ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian PaulPUBLIC GLXContextID glXGetContextIDEXT(const GLXContext ctx) 1730cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 17310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return ctx->xid; 1732cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1733cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 17340896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC GLXContext 17350896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXImportContextEXT(Display * dpy, GLXContextID contextID) 1736cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 17370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext ctx; 1738cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 17390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (contextID == None) { 17400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 17410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 17420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (__glXIsDirect(dpy, contextID)) { 17430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 17440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1745cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 17462243029eeec9e31b92079ff0e8fafdc0315053d6Ian Romanick ctx = AllocateGLXContext(dpy); 17470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (NULL != ctx) { 17482243029eeec9e31b92079ff0e8fafdc0315053d6Ian Romanick ctx->xid = contextID; 17492243029eeec9e31b92079ff0e8fafdc0315053d6Ian Romanick ctx->imported = GL_TRUE; 17502243029eeec9e31b92079ff0e8fafdc0315053d6Ian Romanick 17510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (Success != __glXQueryContextInfo(dpy, ctx)) { 17522243029eeec9e31b92079ff0e8fafdc0315053d6Ian Romanick __glXFreeContext(ctx); 17532243029eeec9e31b92079ff0e8fafdc0315053d6Ian Romanick ctx = NULL; 17540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 17550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 17560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return ctx; 1757cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1758cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 17590896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void 17600896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXFreeContextEXT(Display * dpy, GLXContext ctx) 1761cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 17620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf DestroyContext(dpy, ctx); 1763cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1764cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1765cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1766cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1767cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 1768cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * GLX 1.3 functions - these are just stubs for now! 1769cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 1770cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 17710896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC GLXFBConfig * 17720896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXChooseFBConfig(Display * dpy, int screen, 17730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const int *attribList, int *nitems) 1774cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 17750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLcontextModes **config_list; 17760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int list_size; 1777cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1778cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 17790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config_list = (__GLcontextModes **) 17800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf glXGetFBConfigs(dpy, screen, &list_size); 1781cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 17820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((config_list != NULL) && (list_size > 0) && (attribList != NULL)) { 17830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf list_size = choose_visual(config_list, list_size, attribList, GL_TRUE); 17840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (list_size == 0) { 17850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XFree(config_list); 17860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config_list = NULL; 17870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 17880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1789cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 17900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *nitems = list_size; 17910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (GLXFBConfig *) config_list; 1792cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1793cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1794cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 17950896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC GLXContext 17960896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXCreateNewContext(Display * dpy, GLXFBConfig config, 17970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int renderType, GLXContext shareList, Bool allowDirect) 1798cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 17997bcfb66000557a0ef32bdc6b31949a92f95a9ff6Ian Romanick const __GLcontextModes *const fbconfig = 18007bcfb66000557a0ef32bdc6b31949a92f95a9ff6Ian Romanick (const __GLcontextModes *const) config; 18017bcfb66000557a0ef32bdc6b31949a92f95a9ff6Ian Romanick 1802d46d30f997c1718217545947ca4d80ec7d18e684Ian Romanick return CreateContext(dpy, fbconfig->fbconfigID, fbconfig, shareList, 18032243029eeec9e31b92079ff0e8fafdc0315053d6Ian Romanick allowDirect, X_GLXCreateNewContext, renderType, 18047bcfb66000557a0ef32bdc6b31949a92f95a9ff6Ian Romanick fbconfig->screen); 1805cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1806cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1807cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 18080896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC GLXDrawable 18090896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXGetCurrentReadDrawable(void) 1810cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 18110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc = __glXGetCurrentContext(); 18120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return gc->currentReadable; 1813cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1814cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1815cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 18160896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC GLXFBConfig * 18170896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXGetFBConfigs(Display * dpy, int screen, int *nelements) 1818cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 18190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *priv = __glXInitialize(dpy); 18200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLcontextModes **config = NULL; 18210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int i; 1822cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 18230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *nelements = 0; 18240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (priv && (priv->screenConfigs != NULL) 18250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf && (screen >= 0) && (screen <= ScreenCount(dpy)) 18260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf && (priv->screenConfigs[screen].configs != NULL) 182771a6fb15ceb6619d39029ff897daf2da4858b17eIan Romanick && (priv->screenConfigs[screen].configs->fbconfigID 182871a6fb15ceb6619d39029ff897daf2da4858b17eIan Romanick != (int) GLX_DONT_CARE)) { 18290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf unsigned num_configs = 0; 18300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLcontextModes *modes; 1831cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1832cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 18330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (modes = priv->screenConfigs[screen].configs; modes != NULL; 18340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf modes = modes->next) { 183571a6fb15ceb6619d39029ff897daf2da4858b17eIan Romanick if (modes->fbconfigID != (int) GLX_DONT_CARE) { 18360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf num_configs++; 18370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 18380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1839cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 18400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config = (__GLcontextModes **) Xmalloc(sizeof(__GLcontextModes *) 18410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * num_configs); 18420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (config != NULL) { 18430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *nelements = num_configs; 18440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf i = 0; 18450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (modes = priv->screenConfigs[screen].configs; modes != NULL; 18460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf modes = modes->next) { 184771a6fb15ceb6619d39029ff897daf2da4858b17eIan Romanick if (modes->fbconfigID != (int) GLX_DONT_CARE) { 18480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config[i] = modes; 18490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf i++; 18500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 18510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 18520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 18530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 18540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (GLXFBConfig *) config; 1855cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1856cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1857cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 18580896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC int 18590896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXGetFBConfigAttrib(Display * dpy, GLXFBConfig config, 18600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int attribute, int *value) 1861cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 18620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLcontextModes *const modes = ValidateGLXFBConfig(dpy, config); 1863cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 18640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (modes != NULL) 18650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ? _gl_get_context_mode_data(modes, attribute, value) 18660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf : GLXBadFBConfig; 1867cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1868cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1869cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 18700896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC XVisualInfo * 18710896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXGetVisualFromFBConfig(Display * dpy, GLXFBConfig config) 1872cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 18730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XVisualInfo visualTemplate; 18740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLcontextModes *fbconfig = (__GLcontextModes *) config; 18750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int count; 1876cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 18770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 1878cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson ** Get a list of all visuals, return if list is empty 1879cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 18800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf visualTemplate.visualid = fbconfig->visualID; 18810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return XGetVisualInfo(dpy, VisualIDMask, &visualTemplate, &count); 1882cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1883cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1884cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1885cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 1886cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** GLX_SGI_swap_control 1887cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 18880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic int 18890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXSwapIntervalSGI(int interval) 1890cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 1891cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson xGLXVendorPrivateReq *req; 1892cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson GLXContext gc = __glXGetCurrentContext(); 1893efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes __GLXscreenConfigs *psc; 18940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Display *dpy; 18950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD32 *interval_ptr; 1896cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson CARD8 opcode; 1897cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 18980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc == NULL) { 1899cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return GLX_BAD_CONTEXT; 1900cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 19010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 19020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (interval <= 0) { 1903cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return GLX_BAD_VALUE; 1904cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 1905cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1906efaf90b03e8b69e04909bce071f8ef6b65cc0e9dKristian Høgsberg#ifdef __DRI_SWAP_CONTROL 1907020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg if (gc->driContext) { 1908daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, 1909daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes gc->screen ); 19100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, 1911daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes gc->currentDrawable, 1912daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes NULL); 19130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->swapControl != NULL && pdraw != NULL) { 1914daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes psc->swapControl->setSwapInterval(pdraw->driDrawable, interval); 1915daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return 0; 19160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1917daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes else if (pdraw == NULL) { 1918daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return GLX_BAD_CONTEXT; 19190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1920cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 1921cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 1922efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); 1923efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes 192416f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee#ifdef GLX_DIRECT_RENDERING 1925efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes if (gc->driContext && psc->driScreen && psc->driScreen->setSwapInterval) { 1926efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, 1927efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes gc->currentDrawable, 1928efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes NULL); 1929efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes psc->driScreen->setSwapInterval(pdraw, interval); 1930efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes return 0; 1931efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes } 193216f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee#endif 1933efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes 1934cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson dpy = gc->currentDpy; 1935cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson opcode = __glXSetupForCommand(dpy); 1936cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson if (!opcode) { 1937cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return 0; 1938cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 1939cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1940cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /* Send the glXSwapIntervalSGI request */ 1941cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson LockDisplay(dpy); 19420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReqExtra(GLXVendorPrivate, sizeof(CARD32), req); 1943cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson req->reqType = opcode; 1944cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson req->glxCode = X_GLXVendorPrivate; 1945cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson req->vendorCode = X_GLXvop_SwapIntervalSGI; 1946cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson req->contextTag = gc->currentContextTag; 1947cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1948a70d56485a2d0f15ee5b660e8931eb8657535e2dIan Romanick interval_ptr = (CARD32 *) (req + 1); 1949cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson *interval_ptr = interval; 1950cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1951cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson UnlockDisplay(dpy); 1952cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson SyncHandle(); 1953cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson XFlush(dpy); 1954cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1955cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return 0; 1956cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1957cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1958cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1959cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 1960cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** GLX_MESA_swap_control 1961cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 19620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic int 19630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXSwapIntervalMESA(unsigned int interval) 1964cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 1965cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson GLXContext gc = __glXGetCurrentContext(); 1966cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 1967efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes#ifdef __DRI_SWAP_CONTROL 1968020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg if (gc != NULL && gc->driContext) { 19690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy, 19700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->screen); 19710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 19720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((psc != NULL) && (psc->driScreen != NULL)) { 19730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw = 19740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); 19750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->swapControl != NULL && pdraw != NULL) { 19760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc->swapControl->setSwapInterval(pdraw->driDrawable, interval); 19770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return 0; 19780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1979cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 1980cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 1981cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 1982cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 198316f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee#ifdef GLX_DIRECT_RENDERING 1984efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes if (gc != NULL && gc->driContext) { 1985efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes __GLXscreenConfigs *psc; 1986efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes 1987efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); 1988efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes if (psc->driScreen && psc->driScreen->setSwapInterval) { 1989efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, 1990efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes gc->currentDrawable, NULL); 1991efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes psc->driScreen->setSwapInterval(pdraw, interval); 1992efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes return 0; 1993efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes } 1994efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes } 199516f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee#endif 1996efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes 1997cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return GLX_BAD_CONTEXT; 1998cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 1999841a823d6ded26585aaecbc69a937b1ece8fccb2Brian Paul 20000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 20010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic int 20020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXGetSwapIntervalMESA(void) 2003cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2004efaf90b03e8b69e04909bce071f8ef6b65cc0e9dKristian Høgsberg#ifdef __DRI_SWAP_CONTROL 2005cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson GLXContext gc = __glXGetCurrentContext(); 2006cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2007020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg if (gc != NULL && gc->driContext) { 20080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy, 20090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc->screen); 20100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 20110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((psc != NULL) && (psc->driScreen != NULL)) { 20120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw = 20130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); 20140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->swapControl != NULL && pdraw != NULL) { 20150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return psc->swapControl->getSwapInterval(pdraw->driDrawable); 20160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2017cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 2018cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 2019cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 202067776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee 202167776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2022efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes if (gc != NULL && gc->driContext) { 2023efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes __GLXscreenConfigs *psc; 2024efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes 2025efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); 2026efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes if (psc->driScreen && psc->driScreen->getSwapInterval) { 2027efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, 2028efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes gc->currentDrawable, NULL); 2029efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes return psc->driScreen->getSwapInterval(pdraw); 2030efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes } 2031efc82e7c703f9160cfdbe6d97e166ca6f5e75d86Jesse Barnes } 203267776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2033cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2034cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return 0; 2035cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2036cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2037cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2038cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 2039cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** GLX_MESA_swap_frame_usage 2040cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 2041cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 20420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic GLint 20430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXBeginFrameTrackingMESA(Display * dpy, GLXDrawable drawable) 2044cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 20450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int status = GLX_BAD_CONTEXT; 2046a7a0a2beb54dcb78d7e0ab64cf2f5a6ede8191a4Kristian Høgsberg#ifdef __DRI_FRAME_TRACKING 204749c0825655bad3afde57faab84001641bd5340b8Brian Paul int screen = 0; 2048e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); 20490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); 2050cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2051a7a0a2beb54dcb78d7e0ab64cf2f5a6ede8191a4Kristian Høgsberg if (pdraw != NULL && psc->frameTracking != NULL) 20520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf status = psc->frameTracking->frameTracking(pdraw->driDrawable, GL_TRUE); 2053cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else 2054cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2055cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) drawable; 2056cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 2057cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return status; 2058cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2059cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 20600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 20610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic GLint 20620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXEndFrameTrackingMESA(Display * dpy, GLXDrawable drawable) 2063cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 20640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int status = GLX_BAD_CONTEXT; 2065a7a0a2beb54dcb78d7e0ab64cf2f5a6ede8191a4Kristian Høgsberg#ifdef __DRI_FRAME_TRACKING 206649c0825655bad3afde57faab84001641bd5340b8Brian Paul int screen = 0; 20670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); 2068e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg __GLXscreenConfigs *psc = GetGLXScreenConfigs(dpy, screen); 2069cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2070a7a0a2beb54dcb78d7e0ab64cf2f5a6ede8191a4Kristian Høgsberg if (pdraw != NULL && psc->frameTracking != NULL) 20710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf status = psc->frameTracking->frameTracking(pdraw->driDrawable, 20720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GL_FALSE); 2073cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else 2074cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2075cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) drawable; 2076cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 2077cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return status; 2078cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2079cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2080cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 20810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic GLint 20820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXGetFrameUsageMESA(Display * dpy, GLXDrawable drawable, GLfloat * usage) 2083cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 20840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int status = GLX_BAD_CONTEXT; 2085a7a0a2beb54dcb78d7e0ab64cf2f5a6ede8191a4Kristian Høgsberg#ifdef __DRI_FRAME_TRACKING 208649c0825655bad3afde57faab84001641bd5340b8Brian Paul int screen = 0; 20870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *const pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); 20880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); 2089cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2090a7a0a2beb54dcb78d7e0ab64cf2f5a6ede8191a4Kristian Høgsberg if (pdraw != NULL && psc->frameTracking != NULL) { 20910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int64_t sbc, missedFrames; 20920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf float lastMissedUsage; 2093cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 20940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable, 20950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &sbc, 20960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &missedFrames, 20970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &lastMissedUsage, 20980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf usage); 2099cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 2100cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else 2101cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2102cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) drawable; 2103cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) usage; 2104cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 2105cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return status; 2106cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2107cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2108cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 21090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic GLint 21100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXQueryFrameTrackingMESA(Display * dpy, GLXDrawable drawable, 21110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int64_t * sbc, int64_t * missedFrames, 21120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLfloat * lastMissedUsage) 2113cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 21140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int status = GLX_BAD_CONTEXT; 2115a7a0a2beb54dcb78d7e0ab64cf2f5a6ede8191a4Kristian Høgsberg#ifdef __DRI_FRAME_TRACKING 211649c0825655bad3afde57faab84001641bd5340b8Brian Paul int screen = 0; 21170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); 21180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); 2119cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2120a7a0a2beb54dcb78d7e0ab64cf2f5a6ede8191a4Kristian Høgsberg if (pdraw != NULL && psc->frameTracking != NULL) { 21210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf float usage; 2122cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2123e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable, 21240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf sbc, missedFrames, 21250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf lastMissedUsage, 21260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &usage); 2127cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 2128cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else 2129cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2130cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) drawable; 2131cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) sbc; 2132cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) missedFrames; 2133cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) lastMissedUsage; 2134cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 2135cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return status; 2136cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2137cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2138cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2139cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 2140cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** GLX_SGI_video_sync 2141cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 21420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic int 21430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXGetVideoSyncSGI(unsigned int *count) 2144cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2145daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes int64_t ust, msc, sbc; 2146daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes int ret; 2147daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes GLXContext gc = __glXGetCurrentContext(); 2148daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes __GLXscreenConfigs *psc; 214967776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2150daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes __GLXDRIdrawable *pdraw; 215167776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2152daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 215316f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee if (!gc) 2154daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return GLX_BAD_CONTEXT; 2155daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 215616f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee#ifdef GLX_DIRECT_RENDERING 215716f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee if (!gc->driContext) 215816f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee return GLX_BAD_CONTEXT; 215916f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee#endif 216016f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee 2161daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes psc = GetGLXScreenConfigs(gc->currentDpy, gc->screen); 216267776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2163daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); 216467776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2165daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 2166cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /* FIXME: Looking at the GLX_SGI_video_sync spec in the extension registry, 2167cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * FIXME: there should be a GLX encoding for this call. I can find no 2168cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * FIXME: documentation for the GLX encoding. 2169cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 2170106a6f29bbdc71982afd629bdf89369cefd1459eKristian Høgsberg#ifdef __DRI_MEDIA_STREAM_COUNTER 2171daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes if ( psc->msc && psc->driScreen ) { 2172daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes ret = (*psc->msc->getDrawableMSC)(psc->__driScreen, 2173daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes pdraw->driDrawable, &msc); 2174daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes *count = (unsigned) msc; 21750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2176daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return (ret == 0) ? 0 : GLX_BAD_CONTEXT; 2177cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 2178cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 217967776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee 218067776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2181daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes if (psc->driScreen && psc->driScreen->getDrawableMSC) { 2182daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes ret = psc->driScreen->getDrawableMSC(psc, pdraw, &ust, &msc, &sbc); 2183daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes *count = (unsigned) msc; 2184daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return (ret == True) ? 0 : GLX_BAD_CONTEXT; 2185daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes } 218667776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2187daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 2188cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return GLX_BAD_CONTEXT; 2189cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2190cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 21910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic int 21920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) 2193cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2194cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson GLXContext gc = __glXGetCurrentContext(); 2195daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes __GLXscreenConfigs *psc; 219667776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2197daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes __GLXDRIdrawable *pdraw; 219867776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2199daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes int64_t ust, msc, sbc; 2200daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes int ret; 2201cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 22020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (divisor <= 0 || remainder < 0) 22030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GLX_BAD_VALUE; 2204cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 220516f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee if (!gc) 2206daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return GLX_BAD_CONTEXT; 2207daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 220816f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee#ifdef GLX_DIRECT_RENDERING 220916f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee if (!gc->driContext) 221016f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee return GLX_BAD_CONTEXT; 221116f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee#endif 221216f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee 2213daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); 221467776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2215daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); 221667776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2217daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 2218daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes#ifdef __DRI_MEDIA_STREAM_COUNTER 2219daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes if (psc->msc != NULL && psc->driScreen ) { 2220daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, 0, 2221daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes divisor, remainder, &msc, &sbc); 2222daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes *count = (unsigned) msc; 2223daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return (ret == 0) ? 0 : GLX_BAD_CONTEXT; 2224cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 2225cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 222667776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee 222767776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2228daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes if (psc->driScreen && psc->driScreen->waitForMSC) { 2229daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes ret = psc->driScreen->waitForMSC(pdraw, 0, divisor, remainder, &ust, &msc, 2230daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes &sbc); 2231daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes *count = (unsigned) msc; 2232daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return (ret == True) ? 0 : GLX_BAD_CONTEXT; 2233daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes } 223467776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2235daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 2236cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return GLX_BAD_CONTEXT; 2237cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2238cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2239cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2240cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 2241cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** GLX_SGIX_fbconfig 2242cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Many of these functions are aliased to GLX 1.3 entry points in the 2243cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** GLX_functions table. 2244cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 2245cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 22460896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC 22470896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófGLX_ALIAS(int, glXGetFBConfigAttribSGIX, 22480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (Display * dpy, GLXFBConfigSGIX config, int attribute, int *value), 22490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (dpy, config, attribute, value), glXGetFBConfigAttrib) 2250cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2251ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian PaulPUBLIC GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX, 2252ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian Paul (Display * dpy, int screen, int *attrib_list, 2253ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian Paul int *nelements), (dpy, screen, attrib_list, nelements), 2254ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian Paul glXChooseFBConfig) 2255cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2256ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian PaulPUBLIC GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX, 2257ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian Paul (Display * dpy, GLXFBConfigSGIX config), 2258ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian Paul (dpy, config), glXGetVisualFromFBConfig) 2259cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2260ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian PaulPUBLIC GLXPixmap 2261ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian PaulglXCreateGLXPixmapWithConfigSGIX(Display * dpy, 2262ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian Paul GLXFBConfigSGIX config, 2263ef9cd84521cbbc622c3c37af04b8d10934903ae8Brian Paul Pixmap pixmap) 2264cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 22650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXVendorPrivateWithReplyReq *vpreq; 22660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXCreateGLXPixmapWithConfigSGIXReq *req; 22670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXPixmap xid = None; 22680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 22690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __GLcontextModes *const fbconfig = (__GLcontextModes *) config; 22700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc; 2271cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2272cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 22730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((dpy == NULL) || (config == NULL)) { 22740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return None; 22750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2276cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 22770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc = GetGLXScreenConfigs(dpy, fbconfig->screen); 22780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((psc != NULL) 22790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) { 22800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 22810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode) { 22820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return None; 22830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2284cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 22850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Send the glXCreateGLXPixmapWithConfigSGIX request */ 22860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 22870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReqExtra(GLXVendorPrivateWithReply, 22880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf sz_xGLXCreateGLXPixmapWithConfigSGIXReq - 22890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf sz_xGLXVendorPrivateWithReplyReq, vpreq); 22900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) vpreq; 22910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 22920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXVendorPrivateWithReply; 22930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX; 22940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->screen = fbconfig->screen; 22950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->fbconfig = fbconfig->fbconfigID; 22960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->pixmap = pixmap; 22970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxpixmap = xid = XAllocID(dpy); 22980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 22990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 23000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2301cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 23020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return xid; 2303cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2304cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 23050896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC GLXContext 23060896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXCreateContextWithConfigSGIX(Display * dpy, 23070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXFBConfigSGIX config, int renderType, 23080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext shareList, Bool allowDirect) 2309cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 23100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc = NULL; 23110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __GLcontextModes *const fbconfig = (__GLcontextModes *) config; 23120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc; 2313cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2314cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 23150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((dpy == NULL) || (config == NULL)) { 23160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return None; 23170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2318cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 23190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc = GetGLXScreenConfigs(dpy, fbconfig->screen); 23200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((psc != NULL) 23210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) { 2322d46d30f997c1718217545947ca4d80ec7d18e684Ian Romanick gc = CreateContext(dpy, fbconfig->fbconfigID, fbconfig, shareList, 23232243029eeec9e31b92079ff0e8fafdc0315053d6Ian Romanick allowDirect, 23247bcfb66000557a0ef32bdc6b31949a92f95a9ff6Ian Romanick X_GLXvop_CreateContextWithConfigSGIX, renderType, 23257bcfb66000557a0ef32bdc6b31949a92f95a9ff6Ian Romanick fbconfig->screen); 23260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2327cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 23280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return gc; 2329cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2330cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2331cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 23320896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC GLXFBConfigSGIX 23330896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * vis) 2334cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 23350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate *priv; 233649c0825655bad3afde57faab84001641bd5340b8Brian Paul __GLXscreenConfigs *psc = NULL; 2337cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 23380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc) != Success) 23390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit) 234071a6fb15ceb6619d39029ff897daf2da4858b17eIan Romanick && (psc->configs->fbconfigID != (int) GLX_DONT_CARE)) { 23410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (GLXFBConfigSGIX) _gl_context_modes_find_visual(psc->configs, 23420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf vis->visualid); 23430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2344cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 23450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 2346cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2347cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2348cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2349cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 2350cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** GLX_SGIX_swap_group 2351cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 23520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 23530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXJoinSwapGroupSGIX(Display * dpy, GLXDrawable drawable, 23540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXDrawable member) 2355cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2356cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2357cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) drawable; 2358cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) member; 2359cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2360cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2361cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2362cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 2363cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** GLX_SGIX_swap_barrier 2364cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 23650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 23660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXBindSwapBarrierSGIX(Display * dpy, GLXDrawable drawable, int barrier) 2367cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2368cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2369cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) drawable; 2370cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) barrier; 2371cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2372cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 23730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic Bool 23740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXQueryMaxSwapBarriersSGIX(Display * dpy, int screen, int *max) 2375cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2376cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2377cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) screen; 2378cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) max; 2379cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return False; 2380cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2381cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2382cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2383cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 2384cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** GLX_OML_sync_control 2385cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 23860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic Bool 23870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXGetSyncValuesOML(Display * dpy, GLXDrawable drawable, 23880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int64_t * ust, int64_t * msc, int64_t * sbc) 2389cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2390daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes __GLXdisplayPrivate * const priv = __glXInitialize(dpy); 2391daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes int i, ret; 239267776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2393daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes __GLXDRIdrawable *pdraw; 239467776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2395daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes __GLXscreenConfigs *psc; 23960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2397daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes if (!priv) 2398daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return False; 23990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 240067776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2401daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes pdraw = GetGLXDRIDrawable(dpy, drawable, &i); 240267776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2403daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes psc = &priv->screenConfigs[i]; 2404daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 2405daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER) 2406251bf298bfddd06c6d6cd4b03ba9aadfc02e2895kleinerm if (pdraw && psc->sbc && psc->msc) 2407daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return ( (pdraw && psc->sbc && psc->msc) 2408daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes && ((*psc->msc->getMSC)(psc->driScreen, msc) == 0) 2409daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes && ((*psc->sbc->getSBC)(pdraw->driDrawable, sbc) == 0) 2410daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes && (__glXGetUST(ust) == 0) ); 2411cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 241267776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee 241367776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2414daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes if (pdraw && psc && psc->driScreen && psc->driScreen->getDrawableMSC) { 2415daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes ret = psc->driScreen->getDrawableMSC(psc, pdraw, ust, msc, sbc); 2416daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return ret; 2417daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes } 241867776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2419daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 2420cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return False; 2421cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2422cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2423286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg#ifdef GLX_DIRECT_RENDERING 24243d28a2690f3752990be50a25447747e237d7bee9Kristian Høgsberg_X_HIDDEN GLboolean 24250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__driGetMscRateOML(__DRIdrawable * draw, 24260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int32_t * numerator, int32_t * denominator, void *private) 2427286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg{ 2428286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg#ifdef XF86VIDMODE 24290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc; 24300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XF86VidModeModeLine mode_line; 24310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int dot_clock; 24320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int i; 24330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *glxDraw = private; 24340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 243526b2bee79d77b7a7b854d7300a10dce69e93d5cdIan Romanick (void) draw; 243626b2bee79d77b7a7b854d7300a10dce69e93d5cdIan Romanick 24370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc = glxDraw->psc; 24380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (XF86VidModeQueryVersion(psc->dpy, &i, &i) && 24390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XF86VidModeGetModeLine(psc->dpy, psc->scr, &dot_clock, &mode_line)) { 24400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf unsigned n = dot_clock * 1000; 24410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf unsigned d = mode_line.vtotal * mode_line.htotal; 24420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2443286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg# define V_INTERLACE 0x010 2444286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg# define V_DBLSCAN 0x020 2445286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg 24460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (mode_line.flags & V_INTERLACE) 24470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf n *= 2; 24480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else if (mode_line.flags & V_DBLSCAN) 24490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf d *= 2; 24500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 24510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* The OML_sync_control spec requires that if the refresh rate is a 24520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * whole number, that the returned numerator be equal to the refresh 24530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * rate and the denominator be 1. 24540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 24550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 24560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (n % d == 0) { 24570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf n /= d; 24580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf d = 1; 24590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 24600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 24610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 }; 24620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 24630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* This is a poor man's way to reduce a fraction. It's far from 24640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * perfect, but it will work well enough for this situation. 24650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 24660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 24670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (i = 0; f[i] != 0; i++) { 24680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf while (n % f[i] == 0 && d % f[i] == 0) { 24690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf d /= f[i]; 24700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf n /= f[i]; 24710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 24720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 24730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 24740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 24750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *numerator = n; 24760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *denominator = d; 24770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 24780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return True; 24790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 24800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else 24810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return False; 2482286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg#else 248326b2bee79d77b7a7b854d7300a10dce69e93d5cdIan Romanick (void) draw; 248426b2bee79d77b7a7b854d7300a10dce69e93d5cdIan Romanick (void) numerator; 248526b2bee79d77b7a7b854d7300a10dce69e93d5cdIan Romanick (void) denominator; 248626b2bee79d77b7a7b854d7300a10dce69e93d5cdIan Romanick (void) private; 248726b2bee79d77b7a7b854d7300a10dce69e93d5cdIan Romanick 24880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return False; 2489286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg#endif 2490286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg} 2491286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg#endif 2492cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2493cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 2494cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Determine the refresh rate of the specified drawable and display. 24950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 2496cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param dpy Display whose refresh rate is to be determined. 2497cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param drawable Drawable whose refresh rate is to be determined. 2498cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param numerator Numerator of the refresh rate. 2499cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param demoninator Denominator of the refresh rate. 2500cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \return If the refresh rate for the specified display and drawable could 2501cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * be calculated, True is returned. Otherwise False is returned. 25020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 2503cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \note This function is implemented entirely client-side. A lot of other 2504cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * functionality is required to export GLX_OML_sync_control, so on 2505cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * XFree86 this function can be called for direct-rendering contexts 2506cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * when GLX_OML_sync_control appears in the client extension string. 2507cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 2508cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 25090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf_X_HIDDEN GLboolean 25100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXGetMscRateOML(Display * dpy, GLXDrawable drawable, 25110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int32_t * numerator, int32_t * denominator) 2512cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2513cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE ) 25140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *draw = GetGLXDRIDrawable(dpy, drawable, NULL); 2515cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 25160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (draw == NULL) 25170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return False; 2518cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 25190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return __driGetMscRateOML(draw->driDrawable, numerator, denominator, draw); 2520cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else 2521286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg (void) dpy; 2522286ce2719395485ffafb38097fa2551b066acd96Kristian Høgsberg (void) drawable; 2523cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) numerator; 2524cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) denominator; 2525cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 2526cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return False; 2527cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2528cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2529cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 25300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic int64_t 25310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable, 25320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int64_t target_msc, int64_t divisor, int64_t remainder) 2533cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2534daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes GLXContext gc = __glXGetCurrentContext(); 2535cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson int screen; 253667776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2537e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); 253867776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 25390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); 2540cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 254167776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee if (!gc) /* no GLX for this */ 2542daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return -1; 2543daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 254416f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee#ifdef GLX_DIRECT_RENDERING 254567776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee if (!pdraw || !gc->driContext) 254616f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee return -1; 254716f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee#endif 254816f568a1830ea17da82683f97e016cdc0aae0c65Vinson Lee 2549cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE 2550cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * error", but it also says "It [glXSwapBuffersMscOML] will return a value 2551cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * of -1 if the function failed because of errors detected in the input 2552cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * parameters" 2553cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 25540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (divisor < 0 || remainder < 0 || target_msc < 0) 2555cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return -1; 25560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (divisor > 0 && remainder >= divisor) 2557cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return -1; 2558cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 25598f4f2a0c3625de2bb2b8e955afc23b3ce8c95f93Jesse Barnes if (target_msc == 0 && divisor == 0 && remainder == 0) 25608f4f2a0c3625de2bb2b8e955afc23b3ce8c95f93Jesse Barnes remainder = 1; 25618f4f2a0c3625de2bb2b8e955afc23b3ce8c95f93Jesse Barnes 2562daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes#ifdef __DRI_SWAP_BUFFER_COUNTER 2563daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes if (psc->counters != NULL) 2564daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc, 2565daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes divisor, remainder); 2566daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes#endif 2567106a6f29bbdc71982afd629bdf89369cefd1459eKristian Høgsberg 2568daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes#ifdef GLX_DIRECT_RENDERING 2569daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes if (psc->driScreen && psc->driScreen->swapBuffers) 2570daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return (*psc->driScreen->swapBuffers)(pdraw, target_msc, divisor, 2571daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes remainder); 2572cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 2573daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 2574daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return -1; 2575cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2576cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2577cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 25780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic Bool 25790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXWaitForMscOML(Display * dpy, GLXDrawable drawable, 25800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int64_t target_msc, int64_t divisor, 25810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int64_t remainder, int64_t * ust, 25820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int64_t * msc, int64_t * sbc) 2583cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2584daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes int screen; 258567776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2586e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); 258767776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2588daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); 25890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int ret; 2590cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2591daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 2592cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE 2593cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * error", but the return type in the spec is Bool. 2594cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 25950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (divisor < 0 || remainder < 0 || target_msc < 0) 2596cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return False; 25970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (divisor > 0 && remainder >= divisor) 2598cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return False; 2599cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2600daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes#ifdef __DRI_MEDIA_STREAM_COUNTER 2601106a6f29bbdc71982afd629bdf89369cefd1459eKristian Høgsberg if (pdraw != NULL && psc->msc != NULL) { 26020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ret = (*psc->msc->waitForMSC) (pdraw->driDrawable, target_msc, 26030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf divisor, remainder, msc, sbc); 2604cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2605cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /* __glXGetUST returns zero on success and non-zero on failure. 2606cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * This function returns True on success and False on failure. 2607cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 26080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return ((ret == 0) && (__glXGetUST(ust) == 0)); 2609cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 2610cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 261167776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee 261267776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2613daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes if (pdraw && psc->driScreen && psc->driScreen->waitForMSC) { 2614daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes ret = psc->driScreen->waitForMSC(pdraw, target_msc, divisor, remainder, 2615daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes ust, msc, sbc); 2616daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return ret; 2617daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes } 261867776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 2619daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 2620cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return False; 2621cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2622cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2623cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 26240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic Bool 26250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXWaitForSbcOML(Display * dpy, GLXDrawable drawable, 26260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int64_t target_sbc, int64_t * ust, 26270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int64_t * msc, int64_t * sbc) 2628cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2629cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson int screen; 263067776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2631e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); 263267776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 26330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); 26340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int ret; 2635cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2636cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /* The OML_sync_control spec says this should "generate a GLX_BAD_VALUE 2637cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * error", but the return type in the spec is Bool. 2638cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 26390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (target_sbc < 0) 2640cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return False; 2641daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes#ifdef __DRI_SWAP_BUFFER_COUNTER 2642106a6f29bbdc71982afd629bdf89369cefd1459eKristian Høgsberg if (pdraw != NULL && psc->sbc != NULL) { 26430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ret = 26440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*psc->sbc->waitForSBC) (pdraw->driDrawable, target_sbc, msc, sbc); 2645cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2646cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /* __glXGetUST returns zero on success and non-zero on failure. 2647cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * This function returns True on success and False on failure. 2648cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 26490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return ((ret == 0) && (__glXGetUST(ust) == 0)); 2650cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 2651cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 265267776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee 265367776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#ifdef GLX_DIRECT_RENDERING 2654251bf298bfddd06c6d6cd4b03ba9aadfc02e2895kleinerm if (pdraw && psc->driScreen && psc->driScreen->waitForSBC) { 2655daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes ret = psc->driScreen->waitForSBC(pdraw, target_sbc, ust, msc, sbc); 2656daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return ret; 2657daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes } 265867776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee#endif 265967776f66c93abb44ee4d1432ba59458ce4fb28f7Vinson Lee 2660cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return False; 2661cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2662cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2663cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2664cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 2665cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * GLX_MESA_allocate_memory 2666cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 2667cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*@{*/ 2668cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 26690896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void * 26700896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXAllocateMemoryMESA(Display * dpy, int scrn, 26710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf size_t size, float readFreq, 26720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf float writeFreq, float priority) 2673cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 267478a6aa57a0155d72280dd91c05513c847bf76f3bKristian Høgsberg#ifdef __DRI_ALLOCATE 26750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn); 2676cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 267778a6aa57a0155d72280dd91c05513c847bf76f3bKristian Høgsberg if (psc && psc->allocate) 26780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (*psc->allocate->allocateMemory) (psc->__driScreen, size, 26790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf readFreq, writeFreq, priority); 268078a6aa57a0155d72280dd91c05513c847bf76f3bKristian Høgsberg 2681cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else 2682cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2683cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) scrn; 2684cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) size; 2685cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) readFreq; 2686cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) writeFreq; 2687cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) priority; 268832305e3a9f9408922c34f06174aaa0d34cf72459Jeremy Huddleston#endif /* __DRI_ALLOCATE */ 2689cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2690cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return NULL; 2691cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2692cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2693cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 26940896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void 26950896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXFreeMemoryMESA(Display * dpy, int scrn, void *pointer) 2696cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 269778a6aa57a0155d72280dd91c05513c847bf76f3bKristian Høgsberg#ifdef __DRI_ALLOCATE 26980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn); 2699cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 270078a6aa57a0155d72280dd91c05513c847bf76f3bKristian Høgsberg if (psc && psc->allocate) 27010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*psc->allocate->freeMemory) (psc->__driScreen, pointer); 270278a6aa57a0155d72280dd91c05513c847bf76f3bKristian Høgsberg 2703cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else 2704cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2705cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) scrn; 2706cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) pointer; 270732305e3a9f9408922c34f06174aaa0d34cf72459Jeremy Huddleston#endif /* __DRI_ALLOCATE */ 2708cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2709cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2710cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 27110896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC GLuint 27120896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXGetMemoryOffsetMESA(Display * dpy, int scrn, const void *pointer) 2713cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 271478a6aa57a0155d72280dd91c05513c847bf76f3bKristian Høgsberg#ifdef __DRI_ALLOCATE 27150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn); 2716cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 271778a6aa57a0155d72280dd91c05513c847bf76f3bKristian Høgsberg if (psc && psc->allocate) 27180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (*psc->allocate->memoryOffset) (psc->__driScreen, pointer); 271978a6aa57a0155d72280dd91c05513c847bf76f3bKristian Høgsberg 2720cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else 2721cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2722cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) scrn; 2723cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) pointer; 2724cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif /* GLX_DIRECT_RENDERING */ 2725cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2726cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return ~0L; 2727cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 27280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2729cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*@}*/ 2730cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2731cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2732cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 2733cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Mesa extension stubs. These will help reduce portability problems. 2734cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 2735cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*@{*/ 2736cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2737cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 2738cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Release all buffers associated with the specified GLX drawable. 2739cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 2740cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \todo 2741cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * This function was intended for stand-alone Mesa. The issue there is that 2742cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * the library doesn't get any notification when a window is closed. In 2743cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * DRI there is a similar but slightly different issue. When GLX 1.3 is 2744cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * supported, there are 3 different functions to destroy a drawable. It 2745cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * should be possible to create GLX protocol (or have it determine which 2746cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * protocol to use based on the type of the drawable) to have one function 2747cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * do the work of 3. For the direct-rendering case, this function could 2748cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * just call the driver's \c __DRIdrawableRec::destroyDrawable function. 2749cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * This would reduce the frequency with which \c __driGarbageCollectDrawables 2750cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * would need to be used. This really should be done as part of the new DRI 2751cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * interface work. 2752cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 2753cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \sa http://oss.sgi.com/projects/ogl-sample/registry/MESA/release_buffers.txt 2754cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * __driGarbageCollectDrawables 2755cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * glXDestroyGLXPixmap 2756cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * glXDestroyPbuffer glXDestroyPixmap glXDestroyWindow 2757cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * glXDestroyGLXPbufferSGIX glXDestroyGLXVideoSourceSGIX 2758cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 27590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic Bool 27600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXReleaseBuffersMESA(Display * dpy, GLXDrawable d) 2761cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2762cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2763cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) d; 2764cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return False; 2765cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2766cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2767cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 27680896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC GLXPixmap 27690896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXCreateGLXPixmapMESA(Display * dpy, XVisualInfo * visual, 27700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Pixmap pixmap, Colormap cmap) 2771cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2772cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) dpy; 2773cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) visual; 2774cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) pixmap; 2775cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson (void) cmap; 2776cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return 0; 2777cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 27780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2779fc5b57b71375ef6c117482be036b442c2cb8ab23Ian Romanick/*@}*/ 2780cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2781fc5b57b71375ef6c117482be036b442c2cb8ab23Ian Romanick 2782fc5b57b71375ef6c117482be036b442c2cb8ab23Ian Romanick/** 2783fc5b57b71375ef6c117482be036b442c2cb8ab23Ian Romanick * GLX_MESA_copy_sub_buffer 2784fc5b57b71375ef6c117482be036b442c2cb8ab23Ian Romanick */ 2785f2ad1b60c0da11283b399008f491792790cea294Brian Paul#define X_GLXvop_CopySubBufferMESA 5154 /* temporary */ 27860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 27870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXCopySubBufferMESA(Display * dpy, GLXDrawable drawable, 27880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int x, int y, int width, int height) 2789cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 27900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXVendorPrivateReq *req; 27910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc; 27920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContextTag tag; 27930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD32 *drawable_ptr; 27940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf INT32 *x_ptr, *y_ptr, *w_ptr, *h_ptr; 27950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 2796f2ad1b60c0da11283b399008f491792790cea294Brian Paul 2797ac3e838fa748c8c8a6ffc04d1ab13da71f75f103Kristian Høgsberg#ifdef __DRI_COPY_SUB_BUFFER 27980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int screen; 27990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); 28000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (pdraw != NULL) { 28010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); 28020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->driScreen->copySubBuffer != NULL) { 28030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf glFlush(); 28040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*psc->driScreen->copySubBuffer) (pdraw, x, y, width, height); 28050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 28060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 28070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 28080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2809f2ad1b60c0da11283b399008f491792790cea294Brian Paul#endif 2810f2ad1b60c0da11283b399008f491792790cea294Brian Paul 28110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 28120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode) 28130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 2814cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 28150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 2816f2ad1b60c0da11283b399008f491792790cea294Brian Paul ** The calling thread may or may not have a current context. If it 2817f2ad1b60c0da11283b399008f491792790cea294Brian Paul ** does, send the context tag so the server can do a flush. 2818f2ad1b60c0da11283b399008f491792790cea294Brian Paul */ 28190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf gc = __glXGetCurrentContext(); 28200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((gc != NULL) && (dpy == gc->currentDpy) && 28210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ((drawable == gc->currentDrawable) || 28220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (drawable == gc->currentReadable))) { 28230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf tag = gc->currentContextTag; 28240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 28250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 28260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf tag = 0; 28270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 28280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 28290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 28300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32) * 4, req); 28310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 28320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXVendorPrivate; 28330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->vendorCode = X_GLXvop_CopySubBufferMESA; 28340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->contextTag = tag; 28350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 28360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drawable_ptr = (CARD32 *) (req + 1); 28370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf x_ptr = (INT32 *) (drawable_ptr + 1); 28380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf y_ptr = (INT32 *) (drawable_ptr + 2); 28390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf w_ptr = (INT32 *) (drawable_ptr + 3); 28400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf h_ptr = (INT32 *) (drawable_ptr + 4); 28410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 28420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *drawable_ptr = drawable; 28430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *x_ptr = x; 28440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *y_ptr = y; 28450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *w_ptr = width; 28460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *h_ptr = height; 28470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 28480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 28490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 2850f2ad1b60c0da11283b399008f491792790cea294Brian Paul} 2851cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2852cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2853fc5b57b71375ef6c117482be036b442c2cb8ab23Ian Romanick/** 2854fc5b57b71375ef6c117482be036b442c2cb8ab23Ian Romanick * GLX_EXT_texture_from_pixmap 2855fc5b57b71375ef6c117482be036b442c2cb8ab23Ian Romanick */ 2856fc5b57b71375ef6c117482be036b442c2cb8ab23Ian Romanick/*@{*/ 28570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 28580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXBindTexImageEXT(Display * dpy, 28590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXDrawable drawable, int buffer, const int *attrib_list) 28600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 28610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXVendorPrivateReq *req; 28620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc = __glXGetCurrentContext(); 28630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD32 *drawable_ptr; 28640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf INT32 *buffer_ptr; 28650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD32 *num_attrib_ptr; 28660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD32 *attrib_ptr; 28670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 28680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf unsigned int i; 28690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 28700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc == NULL) 28710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 28720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 28730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf i = 0; 28740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (attrib_list) { 28750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf while (attrib_list[i * 2] != None) 28760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf i++; 28770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 28780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 287942725d6f545087d094b1479d1ebcbd45ec6ac15cBrian Paul#ifdef GLX_DIRECT_RENDERING 28800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gc->driContext) { 28810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); 28820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 28830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (pdraw != NULL) { 28840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (pdraw->psc->texBuffer->base.version >= 2 && 28850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdraw->psc->texBuffer->setTexBuffer2 != NULL) { 28860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*pdraw->psc->texBuffer->setTexBuffer2) (gc->__driContext, 28870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdraw->textureTarget, 28880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdraw->textureFormat, 28890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdraw->driDrawable); 28900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 28910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 28920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*pdraw->psc->texBuffer->setTexBuffer) (gc->__driContext, 28930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdraw->textureTarget, 28940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdraw->driDrawable); 28950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 28960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 28970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 28980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 289942725d6f545087d094b1479d1ebcbd45ec6ac15cBrian Paul#endif 290042725d6f545087d094b1479d1ebcbd45ec6ac15cBrian Paul 29010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 29020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode) 29030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 29040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 29050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 29060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReqExtra(GLXVendorPrivate, 12 + 8 * i, req); 29070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 29080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXVendorPrivate; 29090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->vendorCode = X_GLXvop_BindTexImageEXT; 29100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->contextTag = gc->currentContextTag; 29110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 29120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drawable_ptr = (CARD32 *) (req + 1); 29130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf buffer_ptr = (INT32 *) (drawable_ptr + 1); 29140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf num_attrib_ptr = (CARD32 *) (buffer_ptr + 1); 29150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf attrib_ptr = (CARD32 *) (num_attrib_ptr + 1); 29160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 29170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *drawable_ptr = drawable; 29180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *buffer_ptr = buffer; 29190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *num_attrib_ptr = (CARD32) i; 29200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 29210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf i = 0; 29220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (attrib_list) { 29230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf while (attrib_list[i * 2] != None) { 29240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 0]; 29250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 1]; 29260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf i++; 29270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 29280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 29290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 29300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 29310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 29320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf} 29330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 29340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 29350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer) 29360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 29370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xGLXVendorPrivateReq *req; 29380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc = __glXGetCurrentContext(); 29390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD32 *drawable_ptr; 29400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf INT32 *buffer_ptr; 29410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf CARD8 opcode; 29420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 29432b4e009ed56b69b243f5cc88f490dcf8166cf729Ian Romanick if ((gc == NULL) || GC_IS_DIRECT(gc)) 29440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 294542725d6f545087d094b1479d1ebcbd45ec6ac15cBrian Paul 29460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf opcode = __glXSetupForCommand(dpy); 29470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!opcode) 29480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 294942725d6f545087d094b1479d1ebcbd45ec6ac15cBrian Paul 29500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf LockDisplay(dpy); 29510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32), req); 29520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->reqType = opcode; 29530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->glxCode = X_GLXVendorPrivate; 29540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->vendorCode = X_GLXvop_ReleaseTexImageEXT; 29550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf req->contextTag = gc->currentContextTag; 295642725d6f545087d094b1479d1ebcbd45ec6ac15cBrian Paul 29570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drawable_ptr = (CARD32 *) (req + 1); 29580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf buffer_ptr = (INT32 *) (drawable_ptr + 1); 295942725d6f545087d094b1479d1ebcbd45ec6ac15cBrian Paul 29600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *drawable_ptr = drawable; 29610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *buffer_ptr = buffer; 296242725d6f545087d094b1479d1ebcbd45ec6ac15cBrian Paul 29630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf UnlockDisplay(dpy); 29640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf SyncHandle(); 296542725d6f545087d094b1479d1ebcbd45ec6ac15cBrian Paul} 29660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2967fc5b57b71375ef6c117482be036b442c2cb8ab23Ian Romanick/*@}*/ 2968cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2969cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 2970cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \c strdup is actually not a standard ANSI C or POSIX routine. 2971cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Irix will not define it if ANSI mode is in effect. 29720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 2973cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \sa strdup 2974cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 29753d28a2690f3752990be50a25447747e237d7bee9Kristian Høgsberg_X_HIDDEN char * 2976cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson__glXstrdup(const char *str) 2977cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 2978cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson char *copy; 2979cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson copy = (char *) Xmalloc(strlen(str) + 1); 2980cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson if (!copy) 2981cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return NULL; 2982cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson strcpy(copy, str); 2983cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return copy; 2984cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 2985cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2986cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 2987cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** glXGetProcAddress support 2988cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/ 2989cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 29900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstruct name_address_pair 29910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 2992cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson const char *Name; 2993cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson GLvoid *Address; 2994cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}; 2995cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2996cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define GLX_FUNCTION(f) { # f, (GLvoid *) f } 2997cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define GLX_FUNCTION2(n,f) { # n, (GLvoid *) f } 2998cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 2999cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic const struct name_address_pair GLX_functions[] = { 3000cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_VERSION_1_0 ***/ 30010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXChooseVisual), 30020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXCopyContext), 30030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXCreateContext), 30040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXCreateGLXPixmap), 30050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXDestroyContext), 30060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXDestroyGLXPixmap), 30070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetConfig), 30080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetCurrentContext), 30090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetCurrentDrawable), 30100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXIsDirect), 30110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXMakeCurrent), 30120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXQueryExtension), 30130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXQueryVersion), 30140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXSwapBuffers), 30150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXUseXFont), 30160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXWaitGL), 30170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXWaitX), 3018cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3019cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_VERSION_1_1 ***/ 30200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetClientString), 30210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXQueryExtensionsString), 30220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXQueryServerString), 3023cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3024cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_VERSION_1_2 ***/ 30250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetCurrentDisplay), 3026cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3027cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_VERSION_1_3 ***/ 30280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXChooseFBConfig), 30290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXCreateNewContext), 30300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXCreatePbuffer), 30310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXCreatePixmap), 30320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXCreateWindow), 30330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXDestroyPbuffer), 30340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXDestroyPixmap), 30350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXDestroyWindow), 30360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetCurrentReadDrawable), 30370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetFBConfigAttrib), 30380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetFBConfigs), 30390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetSelectedEvent), 30400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetVisualFromFBConfig), 30410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXMakeContextCurrent), 30420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXQueryContext), 30430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXQueryDrawable), 30440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXSelectEvent), 3045cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3046cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_SGI_swap_control ***/ 30470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXSwapIntervalSGI, __glXSwapIntervalSGI), 3048cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3049cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_SGI_video_sync ***/ 30500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXGetVideoSyncSGI, __glXGetVideoSyncSGI), 30510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXWaitVideoSyncSGI, __glXWaitVideoSyncSGI), 3052cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3053cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_SGI_make_current_read ***/ 30540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXMakeCurrentReadSGI, glXMakeContextCurrent), 30550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXGetCurrentReadDrawableSGI, glXGetCurrentReadDrawable), 3056cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3057cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_EXT_import_context ***/ 30580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXFreeContextEXT), 30590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetContextIDEXT), 30600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXGetCurrentDisplayEXT, glXGetCurrentDisplay), 30610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXImportContextEXT), 30620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXQueryContextInfoEXT, glXQueryContext), 3063cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3064cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_SGIX_fbconfig ***/ 30650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXGetFBConfigAttribSGIX, glXGetFBConfigAttrib), 30660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXChooseFBConfigSGIX, glXChooseFBConfig), 30670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXCreateGLXPixmapWithConfigSGIX), 30680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXCreateContextWithConfigSGIX), 30690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXGetVisualFromFBConfigSGIX, glXGetVisualFromFBConfig), 30700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetFBConfigFromVisualSGIX), 3071cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3072cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_SGIX_pbuffer ***/ 30730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXCreateGLXPbufferSGIX), 30740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXDestroyGLXPbufferSGIX), 30750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXQueryGLXPbufferSGIX), 30760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXSelectEventSGIX), 30770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetSelectedEventSGIX), 3078cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3079cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_SGIX_swap_group ***/ 30800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXJoinSwapGroupSGIX, __glXJoinSwapGroupSGIX), 3081cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3082cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_SGIX_swap_barrier ***/ 30830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXBindSwapBarrierSGIX, __glXBindSwapBarrierSGIX), 30840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXQueryMaxSwapBarriersSGIX, __glXQueryMaxSwapBarriersSGIX), 3085cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3086cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_MESA_allocate_memory ***/ 30870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXAllocateMemoryMESA), 30880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXFreeMemoryMESA), 30890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetMemoryOffsetMESA), 3090cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3091cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_MESA_copy_sub_buffer ***/ 30920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXCopySubBufferMESA, __glXCopySubBufferMESA), 3093cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3094cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_MESA_pixmap_colormap ***/ 30950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXCreateGLXPixmapMESA), 3096cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3097cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_MESA_release_buffers ***/ 30980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXReleaseBuffersMESA, __glXReleaseBuffersMESA), 3099cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3100cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_MESA_swap_control ***/ 31010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXSwapIntervalMESA, __glXSwapIntervalMESA), 31020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXGetSwapIntervalMESA, __glXGetSwapIntervalMESA), 3103cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3104cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_MESA_swap_frame_usage ***/ 31050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXBeginFrameTrackingMESA, __glXBeginFrameTrackingMESA), 31060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXEndFrameTrackingMESA, __glXEndFrameTrackingMESA), 31070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXGetFrameUsageMESA, __glXGetFrameUsageMESA), 31080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXQueryFrameTrackingMESA, __glXQueryFrameTrackingMESA), 3109cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3110cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_ARB_get_proc_address ***/ 31110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetProcAddressARB), 3112cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3113cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX 1.4 ***/ 31140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXGetProcAddress, glXGetProcAddressARB), 3115cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3116cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** GLX_OML_sync_control ***/ 31170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXWaitForSbcOML, __glXWaitForSbcOML), 31180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXWaitForMscOML, __glXWaitForMscOML), 31190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXSwapBuffersMscOML, __glXSwapBuffersMscOML), 31200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXGetMscRateOML, __glXGetMscRateOML), 31210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXGetSyncValuesOML, __glXGetSyncValuesOML), 3122cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 312342725d6f545087d094b1479d1ebcbd45ec6ac15cBrian Paul /*** GLX_EXT_texture_from_pixmap ***/ 31240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXBindTexImageEXT, __glXBindTexImageEXT), 31250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION2(glXReleaseTexImageEXT, __glXReleaseTexImageEXT), 312642725d6f545087d094b1479d1ebcbd45ec6ac15cBrian Paul 3127cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef GLX_DIRECT_RENDERING 3128cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /*** DRI configuration ***/ 31290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetScreenDriver), 31300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_FUNCTION(glXGetDriverConfig), 3131cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif 3132cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 31330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf {NULL, NULL} /* end of list */ 3134cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}; 3135cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 313677c7f90ed44748f0e54e894deff1cac63da54cd6Kristian Høgsberg 3137cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic const GLvoid * 3138cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonget_glx_proc_address(const char *funcName) 3139cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 3140cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson GLuint i; 3141cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3142cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /* try static functions */ 3143cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson for (i = 0; GLX_functions[i].Name; i++) { 3144cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson if (strcmp(GLX_functions[i].Name, funcName) == 0) 31450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return GLX_functions[i].Address; 3146cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 3147cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3148cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return NULL; 3149cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 3150cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3151cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3152cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 3153cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Get the address of a named GL function. This is the pre-GLX 1.4 name for 3154cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \c glXGetProcAddress. 3155cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 3156cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param procName Name of a GL or GLX function. 3157cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \returns A pointer to the named function 3158cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 3159cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \sa glXGetProcAddress 3160cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 31610896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void (*glXGetProcAddressARB(const GLubyte * procName)) (void) 3162cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 31630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf typedef void (*gl_function) (void); 3164cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson gl_function f; 3165cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3166cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3167cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson /* Search the table of GLX and internal functions first. If that 3168cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * fails and the supplied name could be a valid core GL name, try 3169cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * searching the core GL function table. This check is done to prevent 3170cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * DRI based drivers from searching the core GL function table for 3171cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * internal API functions. 3172cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 3173cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3174cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson f = (gl_function) get_glx_proc_address((const char *) procName); 31750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if ((f == NULL) && (procName[0] == 'g') && (procName[1] == 'l') 31760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf && (procName[2] != 'X')) { 3177cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson f = (gl_function) _glapi_get_proc_address((const char *) procName); 3178cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 3179cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3180cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return f; 3181cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 3182cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3183cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 3184cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Get the address of a named GL function. This is the GLX 1.4 name for 3185cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \c glXGetProcAddressARB. 3186cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 3187cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param procName Name of a GL or GLX function. 3188cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \returns A pointer to the named function 3189cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 3190cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \sa glXGetProcAddressARB 3191cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 31920896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC void (*glXGetProcAddress(const GLubyte * procName)) (void) 3193cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED) 31940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __attribute__ ((alias("glXGetProcAddressARB"))); 3195cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else 3196cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 3197cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return glXGetProcAddressARB(procName); 3198cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 3199cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif /* __GNUC__ */ 3200cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3201cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3202cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef GLX_DIRECT_RENDERING 3203cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/** 3204cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Get the unadjusted system time (UST). Currently, the UST is measured in 3205cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * microseconds since Epoc. The actual resolution of the UST may vary from 3206cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * system to system, and the units may vary from release to release. 3207cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Drivers should not call this function directly. They should instead use 3208cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \c glXGetProcAddress to obtain a pointer to the function. 3209cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 3210cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \param ust Location to store the 64-bit UST 3211cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \returns Zero on success or a negative errno value on failure. 32120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * 3213cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \sa glXGetProcAddress, PFNGLXGETUSTPROC 3214cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 3215cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * \since Internal API version 20030317. 3216cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 32170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf_X_HIDDEN int 32180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXGetUST(int64_t * ust) 32190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 32200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf struct timeval tv; 32210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 32220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (ust == NULL) { 32230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return -EFAULT; 32240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 32250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 32260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (gettimeofday(&tv, NULL) == 0) { 32270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec; 32280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return 0; 32290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 32300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 32310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return -errno; 32320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3233cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 3234cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif /* GLX_DIRECT_RENDERING */ 3235