From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/opengl.c | 109 +++++++------------------------------- 1 file changed, 19 insertions(+), 90 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index dce066f608d..829045c2353 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -55,7 +55,7 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag); static const char *glExtensions; static const char *glxExtensions; static char wglExtensions[4096]; -static int glxVersion[2]; +static int glx_version[2]; static int glx_opcode;
struct glx_pixel_format @@ -130,8 +130,6 @@ static pthread_mutex_t context_mutex = PTHREAD_MUTEX_INITIALIZER;
static const BOOL is_win64 = sizeof(void *) > sizeof(int);
-static BOOL glxRequireVersion(int requiredVersion); - static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR *ppfd) { TRACE( "size %u version %u flags %u type %u color %u %u,%u,%u,%u " "accum %u depth %u stencil %u aux %u ", @@ -304,14 +302,14 @@ static BOOL X11DRV_WineGL_InitOpenglInfo(void) glExtensions = (const char *) pglGetString(GL_EXTENSIONS);
/* Get the common GLX version supported by GLX client and server ( major/minor) */ - pglXQueryVersion(gdi_display, &glxVersion[0], &glxVersion[1]); + pglXQueryVersion( gdi_display, &glx_version[0], &glx_version[1] );
glxExtensions = pglXQueryExtensionsString(gdi_display, screen); glx_direct = pglXIsDirect(gdi_display, ctx);
TRACE("GL version : %s.\n", gl_version); TRACE("GL renderer : %s.\n", gl_renderer); - TRACE("GLX version : %d.%d.\n", glxVersion[0], glxVersion[1]); + TRACE( "GLX version : %d.%d.\n", glx_version[0], glx_version[1] ); TRACE("Server GLX version : %s.\n", pglXQueryServerString(gdi_display, screen, GLX_VERSION)); TRACE("Server GLX vendor: : %s.\n", pglXQueryServerString(gdi_display, screen, GLX_VENDOR)); TRACE("Client GLX version : %s.\n", pglXGetClientString(gdi_display, GLX_VERSION)); @@ -458,71 +456,20 @@ UINT X11DRV_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, c
if (!X11DRV_WineGL_InitOpenglInfo()) return STATUS_NOT_SUPPORTED;
- if (XQueryExtension( gdi_display, "GLX", &glx_opcode, &event_base, &error_base )) + if (!XQueryExtension( gdi_display, "GLX", &glx_opcode, &event_base, &error_base ) || + glx_version[0] < 1 || (glx_version[0] == 1 && glx_version[1] < 3)) { - TRACE("GLX is up and running error_base = %d\n", error_base); - } else { - ERR( "GLX extension is missing, disabling OpenGL.\n" ); + ERR( "GLX 1.3 extension is missing, disabling OpenGL.\n" ); return STATUS_NOT_SUPPORTED; } gl_hwnd_context = XUniqueContext(); gl_pbuffer_context = XUniqueContext();
- /* In case of GLX you have direct and indirect rendering. Most of the time direct rendering is used - * as in general only that is hardware accelerated. In some cases like in case of remote X indirect - * rendering is used. - * - * The main problem for our OpenGL code is that we need certain GLX calls but their presence - * depends on the reported GLX client / server version and on the client / server extension list. - * Those don't have to be the same. - * - * In general the server GLX information lists the capabilities in case of indirect rendering. - * When direct rendering is used, the OpenGL client library is responsible for which GLX calls are - * available and in that case the client GLX informat can be used. - * OpenGL programs should use the 'intersection' of both sets of information which is advertised - * in the GLX version/extension list. When a program does this it works for certain for both - * direct and indirect rendering. - * - * The problem we are having in this area is that ATI's Linux drivers are broken. For some reason - * they haven't added some very important GLX extensions like GLX_SGIX_fbconfig to their client - * extension list which causes this extension not to be listed. (Wine requires this extension). - * ATI advertises a GLX client version of 1.3 which implies that this fbconfig extension among - * pbuffers is around. - * - * In order to provide users of Ati's proprietary drivers with OpenGL support, we need to detect - * the ATI drivers and from then on use GLX client information for them. - */ - - if(glxRequireVersion(3)) { - pglXChooseFBConfig = pglXGetProcAddressARB((const GLubyte *) "glXChooseFBConfig"); - pglXGetFBConfigAttrib = pglXGetProcAddressARB((const GLubyte *) "glXGetFBConfigAttrib"); - pglXGetVisualFromFBConfig = pglXGetProcAddressARB((const GLubyte *) "glXGetVisualFromFBConfig"); - pglXQueryDrawable = pglXGetProcAddressARB((const GLubyte *) "glXQueryDrawable"); - } else if (has_extension( glxExtensions, "GLX_SGIX_fbconfig")) { - pglXChooseFBConfig = pglXGetProcAddressARB((const GLubyte *) "glXChooseFBConfigSGIX"); - pglXGetFBConfigAttrib = pglXGetProcAddressARB((const GLubyte *) "glXGetFBConfigAttribSGIX"); - pglXGetVisualFromFBConfig = pglXGetProcAddressARB((const GLubyte *) "glXGetVisualFromFBConfigSGIX"); - - /* The mesa libGL client library seems to forward glXQueryDrawable to the Xserver, so only - * enable this function when the Xserver understand GLX 1.3 or newer - */ - pglXQueryDrawable = NULL; - } else if(strcmp("ATI", pglXGetClientString(gdi_display, GLX_VENDOR)) == 0) { - TRACE("Overriding ATI GLX capabilities!\n"); - pglXChooseFBConfig = pglXGetProcAddressARB((const GLubyte *) "glXChooseFBConfig"); - pglXGetFBConfigAttrib = pglXGetProcAddressARB((const GLubyte *) "glXGetFBConfigAttrib"); - pglXGetVisualFromFBConfig = pglXGetProcAddressARB((const GLubyte *) "glXGetVisualFromFBConfig"); - pglXQueryDrawable = pglXGetProcAddressARB((const GLubyte *) "glXQueryDrawable"); - - /* Use client GLX information in case of the ATI drivers. We override the - * capabilities over here and not somewhere else as ATI might better their - * life in the future. In case they release proper drivers this block of - * code won't be called. */ - glxExtensions = pglXGetClientString(gdi_display, GLX_EXTENSIONS); - } else { - ERR(" glx_version is %s and GLX_SGIX_fbconfig extension is unsupported. Expect problems.\n", - pglXQueryServerString(gdi_display, DefaultScreen(gdi_display), GLX_VERSION)); - } + pglXChooseFBConfig = pglXGetProcAddressARB( (const GLubyte *)"glXChooseFBConfig" ); + pglXGetFBConfigAttrib = pglXGetProcAddressARB( (const GLubyte *)"glXGetFBConfigAttrib" ); + pglXGetVisualFromFBConfig = pglXGetProcAddressARB( (const GLubyte + *)"glXGetVisualFromFBConfig" ); + pglXQueryDrawable = pglXGetProcAddressARB( (const GLubyte *)"glXQueryDrawable" );
if (has_extension( glxExtensions, "GLX_MESA_copy_sub_buffer")) { pglXCopySubBufferMESA = pglXGetProcAddressARB((const GLubyte *) "glXCopySubBufferMESA"); @@ -820,11 +767,8 @@ static inline void sync_context(struct x11drv_context *context) } if (refresh) { - if (glxRequireVersion(3)) - pglXMakeContextCurrent(gdi_display, context->drawables[0]->drawable, - context->drawables[1]->drawable, context->ctx); - else - pglXMakeCurrent(gdi_display, context->drawables[0]->drawable, context->ctx); + pglXMakeContextCurrent( gdi_display, context->drawables[0]->drawable, + context->drawables[1]->drawable, context->ctx ); release_gl_drawable( old[0] ); release_gl_drawable( old[1] ); } @@ -1676,17 +1620,6 @@ static const char *X11DRV_wglQueryRendererStringWINE( HDC dc, GLint renderer, GL return pglXQueryRendererStringMESA( gdi_display, DefaultScreen(gdi_display), renderer, attribute ); }
-/** - * glxRequireVersion (internal) - * - * Check if the supported GLX version matches requiredVersion. - */ -static BOOL glxRequireVersion(int requiredVersion) -{ - /* Both requiredVersion and glXVersion[1] contains the minor GLX version */ - return (requiredVersion <= glxVersion[1]); -} - static void register_extension(const char *ext) { if (wglExtensions[0]) @@ -1710,17 +1643,13 @@ static const char *x11drv_init_wgl_extensions( struct opengl_funcs *funcs ) register_extension("WGL_ATI_pixel_format_float"); }
- /* Support WGL_ARB_render_texture when there's support or pbuffer based emulation */ - if (has_extension( glxExtensions, "GLX_ARB_render_texture" ) || glxRequireVersion( 3 )) - { - /* The WGL version of GLX_NV_float_buffer requires render_texture */ - if (has_extension( glxExtensions, "GLX_NV_float_buffer")) - register_extension("WGL_NV_float_buffer"); + /* The WGL version of GLX_NV_float_buffer requires render_texture */ + if (has_extension( glxExtensions, "GLX_NV_float_buffer" )) + register_extension( "WGL_NV_float_buffer" );
- /* Again there's no GLX equivalent for this extension, so depend on the required GL extension */ - if (has_extension(glExtensions, "GL_NV_texture_rectangle")) - register_extension("WGL_NV_render_texture_rectangle"); - } + /* Again there's no GLX equivalent for this extension, so depend on the required GL extension */ + if (has_extension( glExtensions, "GL_NV_texture_rectangle" )) + register_extension( "WGL_NV_render_texture_rectangle" );
/* EXT Extensions */