dri_util.c revision 1ab545494a6750527cb8b945c286f23a6524826a
1680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell/** 2680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * \file dri_util.c 3680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * DRI utility functions. 4680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * 5680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * This module acts as glue between GLX and the actual hardware driver. A DRI 6680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * driver doesn't really \e have to use any of this - it's optional. But, some 7680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * useful stuff is done here that otherwise would have to be duplicated in most 8680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * drivers. 9680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * 10680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * Basically, these utility functions take care of some of the dirty details of 11680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * screen initialization, context creation, context binding, DRM setup, etc. 12680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * 13680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * These functions are compiled into each DRI driver so libGL.so knows nothing 14680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * about them. 15680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell */ 16680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 17680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 187192c37294964b3f6e1551469f161593ec8f851dGeorge Sapountzis#include <xf86drm.h> 197c46033130b1b4d6098647d85c2710367572e079Ian Romanick#include "dri_util.h" 20c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis#include "utils.h" 2145e2b51c853471b79004a954ce3092a253b20b77Jesse Barnes#include "xmlpool.h" 22ae6e112c69cf42fb81ef4ed5bdeb3b280647f141Eric Anholt#include "../glsl/glsl_parser_extras.h" 2345e2b51c853471b79004a954ce3092a253b20b77Jesse Barnes 2445e2b51c853471b79004a954ce3092a253b20b77Jesse BarnesPUBLIC const char __dri2ConfigOptions[] = 2545e2b51c853471b79004a954ce3092a253b20b77Jesse Barnes DRI_CONF_BEGIN 2645e2b51c853471b79004a954ce3092a253b20b77Jesse Barnes DRI_CONF_SECTION_PERFORMANCE 2745e2b51c853471b79004a954ce3092a253b20b77Jesse Barnes DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1) 2845e2b51c853471b79004a954ce3092a253b20b77Jesse Barnes DRI_CONF_SECTION_END 2945e2b51c853471b79004a954ce3092a253b20b77Jesse Barnes DRI_CONF_END; 3045e2b51c853471b79004a954ce3092a253b20b77Jesse Barnes 3145e2b51c853471b79004a954ce3092a253b20b77Jesse Barnesstatic const uint __dri2NConfigOptions = 1; 32680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 33680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell/*****************************************************************/ 34c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis/** \name Screen handling functions */ 35c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis/*****************************************************************/ 36c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis/*@{*/ 37c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 38c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzisstatic void 39c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge SapountzissetupLoaderExtensions(__DRIscreen *psp, 40c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis const __DRIextension **extensions) 41c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis{ 42c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis int i; 43c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 44c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis for (i = 0; extensions[i]; i++) { 45c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis if (strcmp(extensions[i]->name, __DRI_DRI2_LOADER) == 0) 46c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis psp->dri2.loader = (__DRIdri2LoaderExtension *) extensions[i]; 47c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis if (strcmp(extensions[i]->name, __DRI_IMAGE_LOOKUP) == 0) 48c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis psp->dri2.image = (__DRIimageLookupExtension *) extensions[i]; 49c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis if (strcmp(extensions[i]->name, __DRI_USE_INVALIDATE) == 0) 50c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis psp->dri2.useInvalidate = (__DRIuseInvalidateExtension *) extensions[i]; 51c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis } 52c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis} 53c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 54c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzisstatic __DRIscreen * 55c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzisdri2CreateNewScreen(int scrn, int fd, 56c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis const __DRIextension **extensions, 57c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis const __DRIconfig ***driver_configs, void *data) 58c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis{ 59c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis static const __DRIextension *emptyExtensionList[] = { NULL }; 60c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis __DRIscreen *psp; 61c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis drmVersionPtr version; 62c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 63c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis psp = calloc(1, sizeof(*psp)); 64c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis if (!psp) 65c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis return NULL; 66c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 67c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis setupLoaderExtensions(psp, extensions); 68c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 69c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis version = drmGetVersion(fd); 70c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis if (version) { 71c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis psp->drm_version.major = version->version_major; 72c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis psp->drm_version.minor = version->version_minor; 73c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis psp->drm_version.patch = version->version_patchlevel; 74c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis drmFreeVersion(version); 75c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis } 76c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 77cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis psp->loaderPrivate = data; 78cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis 79c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis psp->extensions = emptyExtensionList; 80c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis psp->fd = fd; 81c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis psp->myNum = scrn; 82c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 83c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis psp->api_mask = (1 << __DRI_API_OPENGL); 84cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis 85c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis *driver_configs = driDriverAPI.InitScreen(psp); 86c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis if (*driver_configs == NULL) { 87c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis free(psp); 88c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis return NULL; 89c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis } 90c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 91cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions, __dri2NConfigOptions); 92cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum, "dri2"); 93c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 94c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis return psp; 95c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis} 96c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 97c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis/** 98c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis * Destroy the per-screen private information. 99c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis * 100c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis * \internal 101c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis * This function calls __DriverAPIRec::DestroyScreen on \p screenPrivate, calls 102c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis * drmClose(), and finally frees \p screenPrivate. 103c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis */ 104c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzisstatic void driDestroyScreen(__DRIscreen *psp) 105c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis{ 106c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis if (psp) { 107c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis /* No interaction with the X-server is possible at this point. This 108c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis * routine is called after XCloseDisplay, so there is no protocol 109c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis * stream open to the X-server anymore. 110c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis */ 111c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 112c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis _mesa_destroy_shader_compiler(); 113c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 114cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis driDriverAPI.DestroyScreen(psp); 115c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 116c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis driDestroyOptionCache(&psp->optionCache); 117c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis driDestroyOptionInfo(&psp->optionInfo); 118c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 119c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis free(psp); 120c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis } 121c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis} 122c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 123c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzisstatic const __DRIextension **driGetExtensions(__DRIscreen *psp) 124c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis{ 125c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis return psp->extensions; 126c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis} 127c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 128c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis/*@}*/ 129c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 130c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis 131c98d15c9f5cf7e8d2a8f8e9e56ed08786b91c86bGeorge Sapountzis/*****************************************************************/ 1329292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis/** \name Context handling functions */ 1339292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis/*****************************************************************/ 1349292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis/*@{*/ 1359292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 1369292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzisstatic __DRIcontext * 1379292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzisdri2CreateNewContextForAPI(__DRIscreen *screen, int api, 1389292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis const __DRIconfig *config, 1399292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis __DRIcontext *shared, void *data) 1409292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis{ 1419292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis __DRIcontext *context; 1429292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis const struct gl_config *modes = (config != NULL) ? &config->modes : NULL; 1439292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL; 1449292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis gl_api mesa_api; 1459292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 1469292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis if (!(screen->api_mask & (1 << api))) 1479292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis return NULL; 1489292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 1499292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis switch (api) { 1509292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis case __DRI_API_OPENGL: 1519292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis mesa_api = API_OPENGL; 1529292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis break; 1539292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis case __DRI_API_GLES: 1549292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis mesa_api = API_OPENGLES; 1559292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis break; 1569292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis case __DRI_API_GLES2: 1579292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis mesa_api = API_OPENGLES2; 1589292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis break; 1599292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis default: 1609292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis return NULL; 1619292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis } 1629292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 1639292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis context = malloc(sizeof *context); 1649292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis if (!context) 1659292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis return NULL; 1669292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 167cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis context->loaderPrivate = data; 168cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis 1699292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis context->driScreenPriv = screen; 1709292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis context->driDrawablePriv = NULL; 171cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis context->driReadablePriv = NULL; 1729292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 173cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis if (!driDriverAPI.CreateContext(mesa_api, modes, context, shareCtx) ) { 1749292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis free(context); 1759292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis return NULL; 1769292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis } 1779292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 1789292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis return context; 1799292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis} 1809292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 1819292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 1829292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzisstatic __DRIcontext * 1839292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzisdri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config, 1849292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis __DRIcontext *shared, void *data) 1859292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis{ 186cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis return dri2CreateNewContextForAPI(screen, __DRI_API_OPENGL, 187cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis config, shared, data); 1889292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis} 1899292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 1909292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis/** 1919292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis * Destroy the per-context private information. 1929292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis * 1939292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis * \internal 1949292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis * This function calls __DriverAPIRec::DestroyContext on \p contextPrivate, calls 1959292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis * drmDestroyContext(), and finally frees \p contextPrivate. 1969292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis */ 1979292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzisstatic void 1989292ab7190b7f5805e1670be63022716035d067eGeorge SapountzisdriDestroyContext(__DRIcontext *pcp) 1999292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis{ 2009292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis if (pcp) { 2019292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis driDriverAPI.DestroyContext(pcp); 2029292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis free(pcp); 2039292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis } 2049292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis} 2059292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 2069292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzisstatic int 2079292ab7190b7f5805e1670be63022716035d067eGeorge SapountzisdriCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask) 2089292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis{ 2099292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis (void) dest; 2109292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis (void) src; 2119292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis (void) mask; 2129292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis return GL_FALSE; 2139292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis} 2149292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 2159292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis/*@}*/ 2169292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 2179292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis 2189292ab7190b7f5805e1670be63022716035d067eGeorge Sapountzis/*****************************************************************/ 219680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell/** \name Context (un)binding functions */ 220680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell/*****************************************************************/ 221680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell/*@{*/ 222680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 2232314021d603afa40321fb7b50881bc85d406c921George Sapountzisstatic void dri_get_drawable(__DRIdrawable *pdp); 2242314021d603afa40321fb7b50881bc85d406c921George Sapountzisstatic void dri_put_drawable(__DRIdrawable *pdp); 2252314021d603afa40321fb7b50881bc85d406c921George Sapountzis 2262314021d603afa40321fb7b50881bc85d406c921George Sapountzis/** 2272314021d603afa40321fb7b50881bc85d406c921George Sapountzis * This function takes both a read buffer and a draw buffer. This is needed 2282314021d603afa40321fb7b50881bc85d406c921George Sapountzis * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent 2292314021d603afa40321fb7b50881bc85d406c921George Sapountzis * function. 2302314021d603afa40321fb7b50881bc85d406c921George Sapountzis */ 2312314021d603afa40321fb7b50881bc85d406c921George Sapountzisstatic int driBindContext(__DRIcontext *pcp, 2322314021d603afa40321fb7b50881bc85d406c921George Sapountzis __DRIdrawable *pdp, 2332314021d603afa40321fb7b50881bc85d406c921George Sapountzis __DRIdrawable *prp) 2342314021d603afa40321fb7b50881bc85d406c921George Sapountzis{ 2352314021d603afa40321fb7b50881bc85d406c921George Sapountzis /* 2362314021d603afa40321fb7b50881bc85d406c921George Sapountzis ** Assume error checking is done properly in glXMakeCurrent before 2372314021d603afa40321fb7b50881bc85d406c921George Sapountzis ** calling driUnbindContext. 2382314021d603afa40321fb7b50881bc85d406c921George Sapountzis */ 2392314021d603afa40321fb7b50881bc85d406c921George Sapountzis 2402314021d603afa40321fb7b50881bc85d406c921George Sapountzis if (!pcp) 2412314021d603afa40321fb7b50881bc85d406c921George Sapountzis return GL_FALSE; 2422314021d603afa40321fb7b50881bc85d406c921George Sapountzis 2432314021d603afa40321fb7b50881bc85d406c921George Sapountzis /* Bind the drawable to the context */ 2442314021d603afa40321fb7b50881bc85d406c921George Sapountzis pcp->driDrawablePriv = pdp; 2452314021d603afa40321fb7b50881bc85d406c921George Sapountzis pcp->driReadablePriv = prp; 2462314021d603afa40321fb7b50881bc85d406c921George Sapountzis if (pdp) { 2472314021d603afa40321fb7b50881bc85d406c921George Sapountzis pdp->driContextPriv = pcp; 2482314021d603afa40321fb7b50881bc85d406c921George Sapountzis dri_get_drawable(pdp); 2492314021d603afa40321fb7b50881bc85d406c921George Sapountzis } 2502314021d603afa40321fb7b50881bc85d406c921George Sapountzis if (prp && pdp != prp) { 2512314021d603afa40321fb7b50881bc85d406c921George Sapountzis dri_get_drawable(prp); 2522314021d603afa40321fb7b50881bc85d406c921George Sapountzis } 2532314021d603afa40321fb7b50881bc85d406c921George Sapountzis 2542314021d603afa40321fb7b50881bc85d406c921George Sapountzis return driDriverAPI.MakeCurrent(pcp, pdp, prp); 2552314021d603afa40321fb7b50881bc85d406c921George Sapountzis} 2562314021d603afa40321fb7b50881bc85d406c921George Sapountzis 257680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell/** 258680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * Unbind context. 259680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * 260aceccda56b08338e217991e54607f1c9f18fc3e6Kristian Høgsberg * \param scrn the screen. 261680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * \param gc context. 262680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * 263680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * \return \c GL_TRUE on success, or \c GL_FALSE on failure. 264680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * 265680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * \internal 266680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * This function calls __DriverAPIRec::UnbindContext, and then decrements 267d61f07318c8678901b948fdaa8ccdf37aa3203e9Kristian Høgsberg * __DRIdrawableRec::refcount which must be non-zero for a successful 268680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * return. 269680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * 270680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * While casting the opaque private pointers associated with the parameters 271680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell * into their respective real types it also assures they are not \c NULL. 272680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell */ 273e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsbergstatic int driUnbindContext(__DRIcontext *pcp) 274680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell{ 275418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen __DRIdrawable *pdp; 276418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen __DRIdrawable *prp; 277680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 278680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell /* 279680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell ** Assume error checking is done properly in glXMakeCurrent before 280c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick ** calling driUnbindContext. 281680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell */ 282680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 283e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg if (pcp == NULL) 284cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis return GL_FALSE; 285680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 286418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen pdp = pcp->driDrawablePriv; 287418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen prp = pcp->driReadablePriv; 288680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 289418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen /* already unbound */ 290418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen if (!pdp && !prp) 291cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis return GL_TRUE; 292cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis 293875a757ddd103722cfe9a2b21035024aa5a23d32George Sapountzis driDriverAPI.UnbindContext(pcp); 294680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 295cab77711b3e8d398393677bcefcd413f50503a64Vinson Lee assert(pdp); 296418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen if (pdp->refcount == 0) { 297418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen /* ERROR!!! */ 298418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen return GL_FALSE; 299418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen } 300418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen 301418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen dri_put_drawable(pdp); 302418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen 303418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen if (prp != pdp) { 304cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis if (prp->refcount == 0) { 305418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen /* ERROR!!! */ 306418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen return GL_FALSE; 307418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen } 308418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen 309cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis dri_put_drawable(prp); 310418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen } 311418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen 312418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen /* XXX this is disabled so that if we call SwapBuffers on an unbound 313418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen * window we can determine the last context bound to the window and 314418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen * use that context's lock. (BrianP, 2-Dec-2000) 315418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen */ 316cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis pcp->driDrawablePriv = NULL; 317cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis pcp->driReadablePriv = NULL; 318418cdc66ec10c1f3005320ab46404b907c30e37dPauli Nieminen 319680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell return GL_TRUE; 320680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell} 321680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 3222314021d603afa40321fb7b50881bc85d406c921George Sapountzis/*@}*/ 323680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 324680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 3252fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzisstatic void dri_get_drawable(__DRIdrawable *pdp) 3262fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis{ 3272fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis pdp->refcount++; 3282fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis} 3292fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis 3302fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzisstatic void dri_put_drawable(__DRIdrawable *pdp) 3312fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis{ 3322fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis if (pdp) { 3332fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis pdp->refcount--; 3342fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis if (pdp->refcount) 3352fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis return; 3362fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis 337cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis driDriverAPI.DestroyBuffer(pdp); 3382fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis free(pdp); 3392fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis } 3402fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis} 3412fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis 342e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsbergstatic __DRIdrawable * 343f5ba7662bdaf7f8d62cbc1c0c0a59dabb242e78bKristian Høgsbergdri2CreateNewDrawable(__DRIscreen *screen, 344f5ba7662bdaf7f8d62cbc1c0c0a59dabb242e78bKristian Høgsberg const __DRIconfig *config, 345cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis void *data) 346680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell{ 347f5ba7662bdaf7f8d62cbc1c0c0a59dabb242e78bKristian Høgsberg __DRIdrawable *pdraw; 348680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 349f5ba7662bdaf7f8d62cbc1c0c0a59dabb242e78bKristian Høgsberg pdraw = malloc(sizeof *pdraw); 350f5ba7662bdaf7f8d62cbc1c0c0a59dabb242e78bKristian Høgsberg if (!pdraw) 351680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell return NULL; 352680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 353cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis pdraw->loaderPrivate = data; 354cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis 355cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis pdraw->driScreenPriv = screen; 356f5ba7662bdaf7f8d62cbc1c0c0a59dabb242e78bKristian Høgsberg pdraw->driContextPriv = NULL; 357cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis pdraw->refcount = 0; 358f5ba7662bdaf7f8d62cbc1c0c0a59dabb242e78bKristian Høgsberg pdraw->lastStamp = 0; 359f5ba7662bdaf7f8d62cbc1c0c0a59dabb242e78bKristian Høgsberg pdraw->w = 0; 360f5ba7662bdaf7f8d62cbc1c0c0a59dabb242e78bKristian Høgsberg pdraw->h = 0; 361f5ba7662bdaf7f8d62cbc1c0c0a59dabb242e78bKristian Høgsberg 362cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis dri_get_drawable(pdraw); 363cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis 364cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis if (!driDriverAPI.CreateBuffer(screen, pdraw, &config->modes, GL_FALSE)) { 365f5ba7662bdaf7f8d62cbc1c0c0a59dabb242e78bKristian Høgsberg free(pdraw); 366680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell return NULL; 367680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell } 368680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 369e9beaf65fdaf82a7845cbe176f353ddb6b8466c7Kristian Høgsberg pdraw->dri2.stamp = pdraw->lastStamp + 1; 37061d26bc82e7c4100acfb551cbb0ba9d84bbc4ba5Francisco Jerez 371e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg return pdraw; 372680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell} 373680ec7f85158eae58fd5ab56da8c66a645883cb0Keith Whitwell 3742fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzisstatic void 3752fbba6bb906a4389de64cc6e961b531d8cd5c495George SapountzisdriDestroyDrawable(__DRIdrawable *pdp) 3762fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis{ 3772fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis dri_put_drawable(pdp); 3782fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis} 3792fbba6bb906a4389de64cc6e961b531d8cd5c495George Sapountzis 3801b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzkestatic __DRIbuffer * 3811b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzkedri2AllocateBuffer(__DRIscreen *screen, 3821b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzke unsigned int attachment, unsigned int format, 3831b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzke int width, int height) 3841b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzke{ 385875a757ddd103722cfe9a2b21035024aa5a23d32George Sapountzis return driDriverAPI.AllocateBuffer(screen, attachment, format, 386875a757ddd103722cfe9a2b21035024aa5a23d32George Sapountzis width, height); 3871b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzke} 3881b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzke 3891b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzkestatic void 3901b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzkedri2ReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer) 3911b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzke{ 392cd86a5d2f862f183f85ef8c7d51f69e028d04447George Sapountzis driDriverAPI.ReleaseBuffer(screen, buffer); 3931b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzke} 3941b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzke 3951b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzke 396234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnesstatic int 397234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnesdri2ConfigQueryb(__DRIscreen *screen, const char *var, GLboolean *val) 398234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes{ 399234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes if (!driCheckOption(&screen->optionCache, var, DRI_BOOL)) 400234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes return -1; 401234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes 402234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes *val = driQueryOptionb(&screen->optionCache, var); 403234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes 404234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes return 0; 405234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes} 406234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes 407234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnesstatic int 408234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnesdri2ConfigQueryi(__DRIscreen *screen, const char *var, GLint *val) 409234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes{ 410234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes if (!driCheckOption(&screen->optionCache, var, DRI_INT) && 411234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes !driCheckOption(&screen->optionCache, var, DRI_ENUM)) 412234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes return -1; 413234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes 414234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes *val = driQueryOptioni(&screen->optionCache, var); 415234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes 416234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes return 0; 417234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes} 418234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes 419234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnesstatic int 420234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnesdri2ConfigQueryf(__DRIscreen *screen, const char *var, GLfloat *val) 421234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes{ 422234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes if (!driCheckOption(&screen->optionCache, var, DRI_FLOAT)) 423234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes return -1; 424234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes 425234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes *val = driQueryOptionf(&screen->optionCache, var); 426234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes 427234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes return 0; 428234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes} 429234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes 430a7a9a91d7b28e5b5faed509d00f0f951e3136b1bKristian Høgsbergstatic unsigned int 431a7a9a91d7b28e5b5faed509d00f0f951e3136b1bKristian Høgsbergdri2GetAPIMask(__DRIscreen *screen) 432a7a9a91d7b28e5b5faed509d00f0f951e3136b1bKristian Høgsberg{ 433a7a9a91d7b28e5b5faed509d00f0f951e3136b1bKristian Høgsberg return screen->api_mask; 434a7a9a91d7b28e5b5faed509d00f0f951e3136b1bKristian Høgsberg} 435a7a9a91d7b28e5b5faed509d00f0f951e3136b1bKristian Høgsberg 436e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 437f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg/** Core interface */ 438e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsbergconst __DRIcoreExtension driCoreExtension = { 439e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg { __DRI_CORE, __DRI_CORE_VERSION }, 440f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg NULL, 441e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg driDestroyScreen, 442e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg driGetExtensions, 443e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg driGetConfigAttrib, 444e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg driIndexConfigAttrib, 445f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg NULL, 446e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg driDestroyDrawable, 4476260618b29983fd961718fd6e3961bdd32163cb5Kristian Høgsberg NULL, 448f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg NULL, 449e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg driCopyContext, 450e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg driDestroyContext, 451e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg driBindContext, 452e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg driUnbindContext 453e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg}; 454e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 45539a0e4e7de379a182c1544fa24d5cb2a7687ec72Kristian Høgsberg/** DRI2 interface */ 456f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsbergconst __DRIdri2Extension driDRI2Extension = { 4571ab545494a6750527cb8b945c286f23a6524826aIan Romanick /* Force the version to 2 because the underlying drivers don't (can't!) 4581ab545494a6750527cb8b945c286f23a6524826aIan Romanick * support the extra requirements of CreateContextAttribs. 4591ab545494a6750527cb8b945c286f23a6524826aIan Romanick */ 4601ab545494a6750527cb8b945c286f23a6524826aIan Romanick { __DRI_DRI2, 2 }, 461f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg dri2CreateNewScreen, 462f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg dri2CreateNewDrawable, 463f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg dri2CreateNewContext, 464a7a9a91d7b28e5b5faed509d00f0f951e3136b1bKristian Høgsberg dri2GetAPIMask, 4651b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzke dri2CreateNewContextForAPI, 4661b8ef9416bf3a4d2d47fcf9935063af57da2975dBenjamin Franzke dri2AllocateBuffer, 4671ab545494a6750527cb8b945c286f23a6524826aIan Romanick dri2ReleaseBuffer, 4681ab545494a6750527cb8b945c286f23a6524826aIan Romanick NULL 469f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg}; 470f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg 471234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnesconst __DRI2configQueryExtension dri2ConfigQueryExtension = { 472234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes { __DRI2_CONFIG_QUERY, __DRI2_CONFIG_QUERY_VERSION }, 473234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes dri2ConfigQueryb, 474234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes dri2ConfigQueryi, 475234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes dri2ConfigQueryf, 476234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes}; 477234286c0f8b7d30ed49223c648d4c73c1a517ab3Jesse Barnes 47861d26bc82e7c4100acfb551cbb0ba9d84bbc4ba5Francisco Jerezvoid 47961d26bc82e7c4100acfb551cbb0ba9d84bbc4ba5Francisco Jerezdri2InvalidateDrawable(__DRIdrawable *drawable) 48061d26bc82e7c4100acfb551cbb0ba9d84bbc4ba5Francisco Jerez{ 48161d26bc82e7c4100acfb551cbb0ba9d84bbc4ba5Francisco Jerez drawable->dri2.stamp++; 48261d26bc82e7c4100acfb551cbb0ba9d84bbc4ba5Francisco Jerez} 48361d26bc82e7c4100acfb551cbb0ba9d84bbc4ba5Francisco Jerez 484c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg/** 485c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg * Check that the gl_framebuffer associated with dPriv is the right size. 486c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg * Resize the gl_framebuffer if needed. 487c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg * It's expected that the dPriv->driverPrivate member points to a 488c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg * gl_framebuffer object. 489c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg */ 490c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsbergvoid 491c467db4cc765965bd347cf5b91aec39b831273ecKristian HøgsbergdriUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv) 492c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg{ 493c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg struct gl_framebuffer *fb = (struct gl_framebuffer *) dPriv->driverPrivate; 494c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg if (fb && (dPriv->w != fb->Width || dPriv->h != fb->Height)) { 495c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg ctx->Driver.ResizeBuffers(ctx, fb, dPriv->w, dPriv->h); 496c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg /* if the driver needs the hw lock for ResizeBuffers, the drawable 497c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg might have changed again by now */ 498c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg assert(fb->Width == dPriv->w); 499c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg assert(fb->Height == dPriv->h); 500c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg } 501c467db4cc765965bd347cf5b91aec39b831273ecKristian Høgsberg} 502