On Mon, Sep 30, 2013 at 1:44 PM, Eric Anholt <e...@anholt.net> wrote: > The previous interface relied on a static struct, which meant tha the > driver didn't get a chance to edit the struct before the struct got used. > For megadrivers, I want to return a variable struct based on what driver > is getting loaded. > --- > include/GL/internal/dri_interface.h | 13 +++++++++++++ > src/glx/dri2_glx.c | 2 +- > src/glx/dri_common.c | 18 +++++++++++++++++- > src/glx/dri_common.h | 3 ++- > src/glx/dri_glx.c | 2 +- > src/glx/drisw_glx.c | 6 ++---- > 6 files changed, 36 insertions(+), 8 deletions(-) > > diff --git a/include/GL/internal/dri_interface.h > b/include/GL/internal/dri_interface.h > index 5c53d6e..93b6c0b 100644 > --- a/include/GL/internal/dri_interface.h > +++ b/include/GL/internal/dri_interface.h > @@ -488,6 +488,19 @@ struct __DRIuseInvalidateExtensionRec { > #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(const char *name); > + */ > +#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 > * by the loader. For example, FBConfig ID or visual ID, drawable type. > diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c > index 123c87c..7e22906 100644 > --- a/src/glx/dri2_glx.c > +++ b/src/glx/dri2_glx.c > @@ -1183,7 +1183,7 @@ dri2CreateScreen(int screen, struct glx_display * priv) > goto handle_error; > } > > - extensions = driGetDriverExtensions(psc->driver); > + extensions = driGetDriverExtensions(psc->driver, driverName); > if (extensions == NULL) > goto handle_error; > > diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c > index f1d1164..16f820f 100644 > --- a/src/glx/dri_common.c > +++ b/src/glx/dri_common.c > @@ -188,9 +188,25 @@ driOpenDriver(const char *driverName) > } > > _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; > + > + asprintf(&get_extensions_name, "%s_%s", > + __DRI_DRIVER_GET_EXTENSIONS, driver_name);
My gcc complains about this: dri_common.c: In function 'driGetDriverExtensions': dri_common.c:197:12: warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result] asprintf(&get_extensions_name, "%s_%s", ^ Kind of silly, but whatever. _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev