diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 6a6d4e7c65a..4b5fe9c836b 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -821,57 +821,6 @@ static const struct glx_context_vtable dri2_context_vtable = { .wait_x = dri2_wait_x, }; -static void -dri2BindExtensions(struct dri2_screen *psc, struct glx_display * priv, - const char *driverName) -{ - const unsigned mask = driGetAPIMask(psc->driScreen); - - __glXEnableDirectExtension(&psc->base, "GLX_EXT_swap_control"); - __glXEnableDirectExtension(&psc->base, "GLX_SGI_swap_control"); - __glXEnableDirectExtension(&psc->base, "GLX_MESA_swap_control"); - __glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read"); - - /* - * GLX_INTEL_swap_event is broken on the server side, where it's - * currently unconditionally enabled. This completely breaks - * systems running on drivers which don't support that extension. - * There's no way to test for its presence on this side, so instead - * of disabling it unconditionally, just disable it for drivers - * which are known to not support it. - * - * This was fixed in xserver 1.15.0 (190b03215), so now we only - * disable the broken driver. - */ - if (strcmp(driverName, "vmwgfx") != 0) { - __glXEnableDirectExtension(&psc->base, "GLX_INTEL_swap_event"); - } - - __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context"); - __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile"); - __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_no_error"); - __glXEnableDirectExtension(&psc->base, "GLX_EXT_no_config_context"); - - if ((mask & ((1 << __DRI_API_GLES) | - (1 << __DRI_API_GLES2) | - (1 << __DRI_API_GLES3))) != 0) { - __glXEnableDirectExtension(&psc->base, - "GLX_EXT_create_context_es_profile"); - __glXEnableDirectExtension(&psc->base, - "GLX_EXT_create_context_es2_profile"); - } - - if (dri_get_screen_param(psc->driScreen, PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) - __glXEnableDirectExtension(&psc->base, - "GLX_ARB_create_context_robustness"); - - __glXEnableDirectExtension(&psc->base, "GLX_EXT_texture_from_pixmap"); - __glXEnableDirectExtension(&psc->base, "GLX_ARB_context_flush_control"); - __glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer"); - - __glXEnableDirectExtension(&psc->base, "GLX_MESA_gl_interop"); -} - static char * dri2_get_driver_name(struct glx_screen *glx_screen) { @@ -961,8 +910,6 @@ dri2CreateScreen(int screen, struct glx_display * priv, bool driver_name_is_infe goto handle_error; } - dri2BindExtensions(psc, priv, driverName); - configs = driConvertConfigs(psc->base.configs, driver_configs); visuals = driConvertConfigs(psc->base.visuals, driver_configs); @@ -1033,7 +980,6 @@ dri2CreateScreen(int screen, struct glx_display * priv, bool driver_name_is_infe /* DRI2 supports SubBuffer through DRI2CopyRegion, so it's always * available.*/ psp->copySubBuffer = dri2CopySubBuffer; - __glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer"); free(deviceName); diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index 7ff3f0ac255..fb2e29e252b 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -656,56 +656,6 @@ static const struct glx_context_vtable dri3_context_vtable = { .wait_x = dri3_wait_x, }; -/** dri3_bind_extensions - * - * Enable all of the extensions supported on DRI3 - */ -static void -dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv, - const char *driverName) -{ - unsigned mask; - - __glXEnableDirectExtension(&psc->base, "GLX_EXT_swap_control"); - __glXEnableDirectExtension(&psc->base, "GLX_EXT_swap_control_tear"); - __glXEnableDirectExtension(&psc->base, "GLX_SGI_swap_control"); - __glXEnableDirectExtension(&psc->base, "GLX_MESA_swap_control"); - __glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read"); - __glXEnableDirectExtension(&psc->base, "GLX_INTEL_swap_event"); - - mask = driGetAPIMask(psc->driScreenRenderGPU); - - __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context"); - __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile"); - __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_no_error"); - __glXEnableDirectExtension(&psc->base, "GLX_EXT_no_config_context"); - - if ((mask & ((1 << __DRI_API_GLES) | - (1 << __DRI_API_GLES2) | - (1 << __DRI_API_GLES3))) != 0) { - __glXEnableDirectExtension(&psc->base, - "GLX_EXT_create_context_es_profile"); - __glXEnableDirectExtension(&psc->base, - "GLX_EXT_create_context_es2_profile"); - } - - /* when on a different gpu than the server, the server pixmaps - * can have a tiling mode we can't read. Thus we can't create - * a texture from them. - */ - if (psc->fd_render_gpu == psc->fd_display_gpu) - __glXEnableDirectExtension(&psc->base, "GLX_EXT_texture_from_pixmap"); - - if (dri_get_screen_param(psc->driScreenRenderGPU, PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) - __glXEnableDirectExtension(&psc->base, - "GLX_ARB_create_context_robustness"); - - __glXEnableDirectExtension(&psc->base, "GLX_ARB_context_flush_control"); - __glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer"); - - __glXEnableDirectExtension(&psc->base, "GLX_MESA_gl_interop"); -} - static char * dri3_get_driver_name(struct glx_screen *glx_screen) { @@ -823,8 +773,6 @@ dri3_create_screen(int screen, struct glx_display * priv, bool driver_name_is_in if (psc->fd_render_gpu == psc->fd_display_gpu) psc->driScreenDisplayGPU = psc->driScreenRenderGPU; - dri3_bind_extensions(psc, priv, driverName); - configs = driConvertConfigs(psc->base.configs, driver_configs); visuals = driConvertConfigs(psc->base.visuals, driver_configs); @@ -867,10 +815,8 @@ dri3_create_screen(int screen, struct glx_display * priv, bool driver_name_is_in __glXEnableDirectExtension(&psc->base, "GLX_SGI_video_sync"); psp->copySubBuffer = dri3_copy_sub_buffer; - __glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer"); psp->getBufferAge = dri3_get_buffer_age; - __glXEnableDirectExtension(&psc->base, "GLX_EXT_buffer_age"); if (dri2GalliumConfigQuerys(psc->driScreenRenderGPU, "glx_extension_override", &tmp) == 0) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 49e01706b1f..2ac591333fe 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -772,42 +772,6 @@ static const struct glx_screen_vtable drisw_screen_vtable = { .get_driver_name = drisw_get_driver_name, }; -static void -driswBindExtensions(struct drisw_screen *psc) -{ - __glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read"); - __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context"); - __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile"); - __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_no_error"); - __glXEnableDirectExtension(&psc->base, "GLX_EXT_no_config_context"); - - /* DRISW version >= 2 implies support for OpenGL ES. */ - __glXEnableDirectExtension(&psc->base, - "GLX_EXT_create_context_es_profile"); - __glXEnableDirectExtension(&psc->base, - "GLX_EXT_create_context_es2_profile"); - - if (dri_get_screen_param(psc->driScreen, PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) - __glXEnableDirectExtension(&psc->base, - "GLX_ARB_create_context_robustness"); - - __glXEnableDirectExtension(&psc->base, "GLX_EXT_texture_from_pixmap"); - __glXEnableDirectExtension(&psc->base, "GLX_ARB_context_flush_control"); - __glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer"); - - if (psc->base.display->driver == GLX_DRIVER_ZINK_YES) { - __glXEnableDirectExtension(&psc->base, "GLX_EXT_buffer_age"); - __glXEnableDirectExtension(&psc->base, "GLX_EXT_swap_control"); - __glXEnableDirectExtension(&psc->base, "GLX_SGI_swap_control"); - __glXEnableDirectExtension(&psc->base, "GLX_MESA_swap_control"); - // This needs to check whether RELAXED is available - // __glXEnableDirectExtension(&psc->base, "GLX_EXT_swap_control_tear"); - } else { - __glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer"); - } - __glXEnableDirectExtension(&psc->base, "GLX_MESA_gl_interop"); -} - static int check_xshm(Display *dpy) { @@ -909,8 +873,6 @@ driswCreateScreen(int screen, struct glx_display *priv, enum glx_driver glx_driv goto handle_error; } - driswBindExtensions(psc); - configs = driConvertConfigs(psc->base.configs, driver_configs); visuals = driConvertConfigs(psc->base.visuals, driver_configs); diff --git a/src/glx/glxext.c b/src/glx/glxext.c index d27ecfea811..3ba2580207e 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -40,6 +40,7 @@ #include #include #include +#include "dri_util.h" #define __GLX_MIN_CONFIG_PROPS 18 #define __GLX_EXT_CONFIG_PROPS 32 @@ -745,6 +746,69 @@ glx_screen_cleanup(struct glx_screen *psc) free(psc->driverName); } +static void +bind_extensions(struct glx_screen *psc, const char *driverName) +{ + unsigned mask; + + if (psc->display->driver != GLX_DRIVER_SW) { + __glXEnableDirectExtension(psc, "GLX_EXT_buffer_age"); + __glXEnableDirectExtension(psc, "GLX_EXT_swap_control"); + __glXEnableDirectExtension(psc, "GLX_SGI_swap_control"); + __glXEnableDirectExtension(psc, "GLX_MESA_swap_control"); + // for zink this needs to check whether RELAXED is available + if (psc->display->driver == GLX_DRIVER_DRI3) + __glXEnableDirectExtension(psc, "GLX_EXT_swap_control_tear"); + } + if (psc->display->driver != GLX_DRIVER_ZINK_YES) + __glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer"); + __glXEnableDirectExtension(psc, "GLX_SGI_make_current_read"); + + if (psc->can_EXT_texture_from_pixmap) + __glXEnableDirectExtension(psc, "GLX_EXT_texture_from_pixmap"); + + /* + * GLX_INTEL_swap_event is broken on the server side, where it's + * currently unconditionally enabled. This completely breaks + * systems running on drivers which don't support that extension. + * There's no way to test for its presence on this side, so instead + * of disabling it unconditionally, just disable it for drivers + * which are known to not support it. + * + * This was fixed in xserver 1.15.0 (190b03215), so now we only + * disable the broken driver. + */ + if (!driverName || strcmp(driverName, "vmwgfx") != 0) { + __glXEnableDirectExtension(psc, "GLX_INTEL_swap_event"); + } + + mask = driGetAPIMask(psc->frontend_screen); + + __glXEnableDirectExtension(psc, "GLX_ARB_create_context"); + __glXEnableDirectExtension(psc, "GLX_ARB_create_context_profile"); + __glXEnableDirectExtension(psc, "GLX_ARB_create_context_no_error"); + __glXEnableDirectExtension(psc, "GLX_EXT_no_config_context"); + + if ((mask & ((1 << __DRI_API_GLES) | + (1 << __DRI_API_GLES2) | + (1 << __DRI_API_GLES3))) != 0) { + __glXEnableDirectExtension(psc, + "GLX_EXT_create_context_es_profile"); + __glXEnableDirectExtension(psc, + "GLX_EXT_create_context_es2_profile"); + } + + if (dri_get_screen_param(psc->frontend_screen, PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) + __glXEnableDirectExtension(psc, + "GLX_ARB_create_context_robustness"); + + __glXEnableDirectExtension(psc, "GLX_ARB_context_flush_control"); + __glXEnableDirectExtension(psc, "GLX_MESA_query_renderer"); + + __glXEnableDirectExtension(psc, "GLX_MESA_gl_interop"); +} + + /* ** Allocate the memory for the per screen configs for each screen. ** If that works then fetch the per screen configs data. @@ -821,6 +885,8 @@ AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv, enum glx_dr if(indirect) /* Load extensions required only for indirect glx */ glxSendClientInfo(priv, i); + else if (priv->driver != GLX_DRIVER_WINDOWS) + bind_extensions(psc, psc->driverName); } if (zink && !screen_count) return GL_FALSE;