Don't use the 'NULL' GModule to resolve GL symbols

Previously, _cogl_get_proc_address had a fallback to resolve the
symbol using g_module_open(NULL) to get the symbol from anywhere in
the address space. The EGL backend ends up using this on some drivers
because eglGetProcAddress isn't meant to return a pointer for core
functions. This causes problems if something in the process is linking
against a different GL library, for example Cairo may be linking
against libGL itself. In this case it may end up resolving symbols
from the GL library even if GLES is being used.

This patch removes the fallback. The EGL version now has its own
fallback instead which passes the existing libgl_module from the
renderer to g_module_symbol so that it should only get symbols from
that library or its dependency chain. The GLX and WGL winsys only call
glXGetProcAddress and wglGetProcAddress. The stub winsys does however
continue using the global symbol lookup.

The internal _cogl_get_proc_address function has been renamed to
_cogl_renderer_get_proc_address because it needs a connected renderer
to work so it could be considered to be a renderer method. The pointer
to the renderer is passed down to the winsys backends so that it can
use the data attached to the renderer to get the module pointers.

https://bugzilla.gnome.org/show_bug.cgi?id=655412

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts
2011-07-27 12:30:02 +01:00
parent 76c88958b7
commit d259a87602
15 changed files with 80 additions and 99 deletions

View File

@ -46,6 +46,7 @@
#include "cogl-texture-driver.h"
#include "cogl-attribute-private.h"
#include "cogl-framebuffer-private.h"
#include "cogl-renderer-private.h"
#ifndef GL_PACK_INVERT_MESA
#define GL_PACK_INVERT_MESA 0x8758
@ -92,13 +93,9 @@ cogl_gl_error_to_string (GLenum error_code)
CoglFuncPtr
cogl_get_proc_address (const char* name)
{
const CoglWinsysVtable *winsys;
_COGL_GET_CONTEXT (ctx, NULL);
winsys = _cogl_context_get_winsys (ctx);
return _cogl_get_proc_address (winsys, name);
return _cogl_renderer_get_proc_address (ctx->display->renderer, name);
}
gboolean