Commit 8a6987af authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

opengl32: Move function / extension registry mapping to unix_thunks.c.

Keeping the extension function pointers array on the PE side.
parent b6f80f9f
...@@ -901,15 +901,11 @@ foreach (sort keys %ext_functions) ...@@ -901,15 +901,11 @@ foreach (sort keys %ext_functions)
printf OUT "extern %s WINAPI %s(%s) DECLSPEC_HIDDEN;\n", $func_ret, $_, $decl_args; printf OUT "extern %s WINAPI %s(%s) DECLSPEC_HIDDEN;\n", $func_ret, $_, $decl_args;
} }
# Then the table giving the string <-> function correspondence */ print OUT "const void *extension_procs[] =\n";
my $count = keys %ext_functions;
print OUT "\nconst int extension_registry_size = $count;\n";
print OUT "const OpenGL_extension extension_registry[$count] =\n";
print OUT "{\n"; print OUT "{\n";
foreach (sort keys %ext_functions) foreach (sort keys %ext_functions)
{ {
my $func = $ext_functions{$_}; printf OUT " %s,\n", $_;
printf OUT " { \"%s\", \"%s\", %s },\n", $_, join(" ", sort @{$func->[2]}), $_;
} }
print OUT "};\n"; print OUT "};\n";
...@@ -1034,4 +1030,16 @@ foreach (sort keys %ext_functions) ...@@ -1034,4 +1030,16 @@ foreach (sort keys %ext_functions)
print OUT " },\n"; print OUT " },\n";
print OUT "};\n"; print OUT "};\n";
# Then the table giving the string <-> function correspondence */
my $count = keys %ext_functions;
print OUT "\nconst int extension_registry_size = $count;\n";
print OUT "const struct registry_entry extension_registry[$count] =\n";
print OUT "{\n";
foreach (sort keys %ext_functions)
{
my $func = $ext_functions{$_};
printf OUT " { \"%s\", \"%s\" },\n", $_, join(" ", sort @{$func->[2]});
}
print OUT "};\n";
close OUT; close OUT;
...@@ -30,14 +30,15 @@ ...@@ -30,14 +30,15 @@
#include "wine/wgl.h" #include "wine/wgl.h"
#include "wine/wgl_driver.h" #include "wine/wgl_driver.h"
typedef struct { struct registry_entry
const char *name; /* name of the extension */ {
const char *extension; /* name of the GL/WGL extension */ const char *name; /* name of the extension */
void *func; /* pointer to the Wine function for this extension */ const char *extension; /* name of the GL/WGL extension */
} OpenGL_extension; };
extern const OpenGL_extension extension_registry[] DECLSPEC_HIDDEN; extern const struct registry_entry extension_registry[] DECLSPEC_HIDDEN;
extern const int extension_registry_size DECLSPEC_HIDDEN; extern const int extension_registry_size DECLSPEC_HIDDEN;
extern const void *extension_procs[] DECLSPEC_HIDDEN;
extern struct opengl_funcs null_opengl_funcs DECLSPEC_HIDDEN; extern struct opengl_funcs null_opengl_funcs DECLSPEC_HIDDEN;
static inline struct opengl_funcs *get_dc_funcs( HDC hdc ) static inline struct opengl_funcs *get_dc_funcs( HDC hdc )
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -334,9 +334,10 @@ int WINAPI wglGetLayerPaletteEntries(HDC hdc, ...@@ -334,9 +334,10 @@ int WINAPI wglGetLayerPaletteEntries(HDC hdc,
return 0; return 0;
} }
static int compar(const void *elt_a, const void *elt_b) { static int registry_entry_cmp( const void *a, const void *b )
return strcmp(((const OpenGL_extension *) elt_a)->name, {
((const OpenGL_extension *) elt_b)->name); const struct registry_entry *entry_a = a, *entry_b = b;
return strcmp( entry_a->name, entry_b->name );
} }
static char *heap_strdup( const char *str ) static char *heap_strdup( const char *str )
...@@ -369,10 +370,9 @@ static BOOL is_extension_supported( const char *extension ) ...@@ -369,10 +370,9 @@ static BOOL is_extension_supported( const char *extension )
*/ */
PROC WINAPI wglGetProcAddress( LPCSTR name ) PROC WINAPI wglGetProcAddress( LPCSTR name )
{ {
const struct registry_entry entry = {.name = name}, *found;
struct opengl_funcs *funcs = NtCurrentTeb()->glTable; struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
void **func_ptr; const void **func_ptr, *proc;
OpenGL_extension ext;
const OpenGL_extension *ext_ret;
if (!name) return NULL; if (!name) return NULL;
...@@ -385,20 +385,19 @@ PROC WINAPI wglGetProcAddress( LPCSTR name ) ...@@ -385,20 +385,19 @@ PROC WINAPI wglGetProcAddress( LPCSTR name )
return NULL; return NULL;
} }
ext.name = name; if (!(found = bsearch( &entry, extension_registry, extension_registry_size,
ext_ret = bsearch(&ext, extension_registry, extension_registry_size, sizeof(ext), compar); sizeof(entry), registry_entry_cmp )))
if (!ext_ret)
{ {
WARN("Function %s unknown\n", name); WARN("Function %s unknown\n", name);
return NULL; return NULL;
} }
func_ptr = (void **)&funcs->ext + (ext_ret - extension_registry); func_ptr = (const void **)&funcs->ext + (found - extension_registry);
if (!*func_ptr) if (!*func_ptr)
{ {
void *driver_func = funcs->wgl.p_wglGetProcAddress( name ); void *driver_func = funcs->wgl.p_wglGetProcAddress( name );
if (!is_extension_supported(ext_ret->extension)) if (!is_extension_supported(found->extension))
{ {
unsigned int i; unsigned int i;
static const struct { const char *name, *alt; } alternatives[] = static const struct { const char *name, *alt; } alternatives[] =
...@@ -410,11 +409,11 @@ PROC WINAPI wglGetProcAddress( LPCSTR name ) ...@@ -410,11 +409,11 @@ PROC WINAPI wglGetProcAddress( LPCSTR name )
for (i = 0; i < ARRAY_SIZE(alternatives); i++) for (i = 0; i < ARRAY_SIZE(alternatives); i++)
{ {
if (strcmp( name, alternatives[i].name )) continue; if (strcmp( name, alternatives[i].name )) continue;
WARN("Extension %s required for %s not supported, trying %s\n", WARN( "Extension %s required for %s not supported, trying %s\n", found->extension,
ext_ret->extension, name, alternatives[i].alt ); name, alternatives[i].alt );
return wglGetProcAddress( alternatives[i].alt ); return wglGetProcAddress( alternatives[i].alt );
} }
WARN("Extension %s required for %s not supported\n", ext_ret->extension, name); WARN( "Extension %s required for %s not supported\n", found->extension, name );
return NULL; return NULL;
} }
...@@ -426,8 +425,9 @@ PROC WINAPI wglGetProcAddress( LPCSTR name ) ...@@ -426,8 +425,9 @@ PROC WINAPI wglGetProcAddress( LPCSTR name )
*func_ptr = driver_func; *func_ptr = driver_func;
} }
TRACE("returning %s -> %p\n", name, ext_ret->func); proc = extension_procs[found - extension_registry];
return ext_ret->func; TRACE( "returning %s -> %p\n", name, proc );
return proc;
} }
/*********************************************************************** /***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment