#define GL_LIB_NAME "libGL.so.1"
#endif
-#ifndef DEFAULT_DRIVER_DIR
-/* this is normally defined in Mesa/configs/default with DRI_DRIVER_SEARCH_PATH */
-#define DEFAULT_DRIVER_DIR "/usr/local/lib/dri"
-#endif
+static const __DRIextension **
+driGetDriverExtensions(void *handle, const char *driver_name);
/**
* Try to \c dlopen the named driver.
* order to find the driver.
*
* \param driverName - a name like "i965", "radeon", "nouveau", etc.
+ * \param out_driver_handle - Address to return the resulting dlopen() handle.
*
* \returns
- * A handle from \c dlopen, or \c NULL if driver file not found.
+ * The __DRIextension entrypoint table for the driver, or \c NULL if driver
+ * file not found.
*/
-_X_HIDDEN void *
-driOpenDriver(const char *driverName)
+_X_HIDDEN const __DRIextension **
+driOpenDriver(const char *driverName, void **out_driver_handle)
{
void *glhandle, *handle;
const char *libPaths, *p, *next;
if (glhandle)
dlclose(glhandle);
- return handle;
+ const __DRIextension **extensions = driGetDriverExtensions(handle,
+ driverName);
+ if (!extensions) {
+ dlclose(handle);
+ handle = NULL;
+ }
+
+ *out_driver_handle = handle;
+ return extensions;
}
-_X_HIDDEN const __DRIextension **
+static const __DRIextension **
driGetDriverExtensions(void *handle, const char *driver_name)
{
const __DRIextension **extensions = NULL;
const __DRIextension **(*get_extensions)(void);
- char *get_extensions_name = dri_get_extensions_name(driver_name);
+ char *get_extensions_name = loader_get_extensions_name(driver_name);
if (get_extensions_name) {
get_extensions = dlsym(handle, get_extensions_name);
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels),
__ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth),
__ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight),
-#if 0
__ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod),
-#endif
-__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
+ __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba),
__ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE,
bindToMipmapTexture),
return GL_FALSE;
break;
+ case __DRI_ATTRIB_SWAP_METHOD:
+ if (value == __DRI_ATTRIB_SWAP_EXCHANGE)
+ glxValue = GLX_SWAP_EXCHANGE_OML;
+ else if (value == __DRI_ATTRIB_SWAP_COPY)
+ glxValue = GLX_SWAP_COPY_OML;
+ else
+ glxValue = GLX_SWAP_UNDEFINED_OML;
+
+ if (!scalarEqual(config, attrib, glxValue))
+ return GL_FALSE;
+
+ break;
+
default:
if (!scalarEqual(config, attrib, value))
return GL_FALSE;
free(configs);
}
+static struct glx_config *
+driInferDrawableConfig(struct glx_screen *psc, GLXDrawable draw)
+{
+ unsigned int fbconfig = 0;
+
+ if (__glXGetDrawableAttribute(psc->dpy, draw, GLX_FBCONFIG_ID, &fbconfig)) {
+ return glx_config_find_fbconfig(psc->configs, fbconfig);
+ }
+
+ return NULL;
+}
+
_X_HIDDEN __GLXDRIdrawable *
driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
{
struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
__GLXDRIdrawable *pdraw;
struct glx_screen *psc;
+ struct glx_config *config = gc->config;
if (priv == NULL)
return NULL;
return pdraw;
}
- pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
- glxDrawable, gc->config);
+ if (config == NULL)
+ config = driInferDrawableConfig(gc->psc, glxDrawable);
+ if (config == NULL)
+ return NULL;
+
+ pdraw = psc->driScreen->createDrawable(psc, glxDrawable, glxDrawable,
+ config);
if (pdraw == NULL) {
ErrorMessageF("failed to create drawable\n");
dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
unsigned *major_ver, unsigned *minor_ver,
uint32_t *render_type, uint32_t *flags, unsigned *api,
- int *reset, unsigned *error)
+ int *reset, int *release, unsigned *error)
{
unsigned i;
bool got_profile = false;
*minor_ver = 0;
*render_type = GLX_RGBA_TYPE;
*reset = __DRI_CTX_RESET_NO_NOTIFICATION;
+ *release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
*flags = 0;
*api = __DRI_API_OPENGL;
return false;
}
break;
+ case GLX_CONTEXT_RELEASE_BEHAVIOR_ARB:
+ switch (attribs[i * 2 + 1]) {
+ case GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB:
+ *release = __DRI_CTX_RELEASE_BEHAVIOR_NONE;
+ break;
+ case GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB:
+ *release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
+ break;
+ default:
+ *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+ return false;
+ }
+ break;
default:
/* If an unknown attribute is received, fail.
*/