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)
printf OUT "extern %s WINAPI %s(%s) DECLSPEC_HIDDEN;\n", $func_ret, $_, $decl_args;
}
# 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 OpenGL_extension extension_registry[$count] =\n";
print OUT "const void *extension_procs[] =\n";
print OUT "{\n";
foreach (sort keys %ext_functions)
{
my $func = $ext_functions{$_};
printf OUT " { \"%s\", \"%s\", %s },\n", $_, join(" ", sort @{$func->[2]}), $_;
printf OUT " %s,\n", $_;
}
print OUT "};\n";
......@@ -1034,4 +1030,16 @@ foreach (sort keys %ext_functions)
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;
......@@ -30,14 +30,15 @@
#include "wine/wgl.h"
#include "wine/wgl_driver.h"
typedef struct {
const char *name; /* name of the extension */
const char *extension; /* name of the GL/WGL extension */
void *func; /* pointer to the Wine function for this extension */
} OpenGL_extension;
struct registry_entry
{
const char *name; /* name of the extension */
const char *extension; /* name of the GL/WGL 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 void *extension_procs[] DECLSPEC_HIDDEN;
extern struct opengl_funcs null_opengl_funcs DECLSPEC_HIDDEN;
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,
return 0;
}
static int compar(const void *elt_a, const void *elt_b) {
return strcmp(((const OpenGL_extension *) elt_a)->name,
((const OpenGL_extension *) elt_b)->name);
static int registry_entry_cmp( const void *a, const void *b )
{
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 )
......@@ -369,10 +370,9 @@ static BOOL is_extension_supported( const char *extension )
*/
PROC WINAPI wglGetProcAddress( LPCSTR name )
{
const struct registry_entry entry = {.name = name}, *found;
struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
void **func_ptr;
OpenGL_extension ext;
const OpenGL_extension *ext_ret;
const void **func_ptr, *proc;
if (!name) return NULL;
......@@ -385,20 +385,19 @@ PROC WINAPI wglGetProcAddress( LPCSTR name )
return NULL;
}
ext.name = name;
ext_ret = bsearch(&ext, extension_registry, extension_registry_size, sizeof(ext), compar);
if (!ext_ret)
if (!(found = bsearch( &entry, extension_registry, extension_registry_size,
sizeof(entry), registry_entry_cmp )))
{
WARN("Function %s unknown\n", name);
return NULL;
}
func_ptr = (void **)&funcs->ext + (ext_ret - extension_registry);
func_ptr = (const void **)&funcs->ext + (found - extension_registry);
if (!*func_ptr)
{
void *driver_func = funcs->wgl.p_wglGetProcAddress( name );
if (!is_extension_supported(ext_ret->extension))
if (!is_extension_supported(found->extension))
{
unsigned int i;
static const struct { const char *name, *alt; } alternatives[] =
......@@ -410,11 +409,11 @@ PROC WINAPI wglGetProcAddress( LPCSTR name )
for (i = 0; i < ARRAY_SIZE(alternatives); i++)
{
if (strcmp( name, alternatives[i].name )) continue;
WARN("Extension %s required for %s not supported, trying %s\n",
ext_ret->extension, name, alternatives[i].alt );
WARN( "Extension %s required for %s not supported, trying %s\n", found->extension,
name, 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;
}
......@@ -426,8 +425,9 @@ PROC WINAPI wglGetProcAddress( LPCSTR name )
*func_ptr = driver_func;
}
TRACE("returning %s -> %p\n", name, ext_ret->func);
return ext_ret->func;
proc = extension_procs[found - extension_registry];
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