*/
#define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
+/**
+ * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be
+ * suffixed by "_drivername", allowing multiple drivers to be built into one
+ * library, and also giving the driver the chance to return a variable driver
+ * extensions struct depending on the driver name being loaded or any other
+ * system state.
+ *
+ * The function prototype is:
+ *
+ * const __DRIextension **__driDriverGetExtensions_drivername(void);
+ */
+#define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"
+
/**
* Tokens for __DRIconfig attribs. A number of attributes defined by
* GLX or EGL standards are not in the table, as they must be provided
goto handle_error;
}
- extensions = driGetDriverExtensions(psc->driver);
+ extensions = driGetDriverExtensions(psc->driver, driverName);
if (extensions == NULL)
goto handle_error;
}
_X_HIDDEN const __DRIextension **
-driGetDriverExtensions(void *handle)
+driGetDriverExtensions(void *handle, const char *driver_name)
{
const __DRIextension **extensions = NULL;
+ const __DRIextension **(*get_extensions)(void);
+ char *get_extensions_name;
+
+ if (asprintf(&get_extensions_name, "%s_%s",
+ __DRI_DRIVER_GET_EXTENSIONS, driver_name) != -1) {
+ get_extensions = dlsym(handle, get_extensions_name);
+ if (get_extensions) {
+ free(get_extensions_name);
+ return get_extensions();
+ } else {
+ InfoMessageF("driver does not expose %s(): %s\n",
+ get_extensions_name, dlerror());
+ free(get_extensions_name);
+ }
+ }
extensions = dlsym(handle, __DRI_DRIVER_EXTENSIONS);
if (extensions == NULL) {
extern void *driOpenDriver(const char *driverName);
-extern const __DRIextension **driGetDriverExtensions(void *handle);
+extern const __DRIextension **
+driGetDriverExtensions(void *handle, const char *driver_name);
extern bool
dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
if (!handle)
return NULL;
- extensions = driGetDriverExtensions(handle);
+ extensions = driGetDriverExtensions(handle, driverName);
if (extensions) {
for (int i = 0; extensions[i]; i++) {
if (strcmp(extensions[i]->name, __DRI_CONFIG_OPTIONS) == 0)
if (psc->driver == NULL)
goto handle_error;
- extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
- if (extensions == NULL) {
- ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
+ extensions = driGetDriverExtensions(psc->driver, SWRAST_DRIVER_NAME);
+ if (extensions == NULL)
goto handle_error;
- }
for (i = 0; extensions[i]; i++) {
if (strcmp(extensions[i]->name, __DRI_CORE) == 0)