opengl32: Get WGL function definitions from the XML files.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2017-10-10 10:06:10 +02:00
parent 62c4ffb4d6
commit 17dffaac7d
9 changed files with 122 additions and 88 deletions

View file

@ -214,10 +214,10 @@ static struct wgl_context *dibdrv_wglCreateContext( HDC hdc )
/*********************************************************************** /***********************************************************************
* dibdrv_wglDeleteContext * dibdrv_wglDeleteContext
*/ */
static void dibdrv_wglDeleteContext( struct wgl_context *context ) static BOOL dibdrv_wglDeleteContext( struct wgl_context *context )
{ {
pOSMesaDestroyContext( context->context ); pOSMesaDestroyContext( context->context );
HeapFree( GetProcessHeap(), 0, context ); return HeapFree( GetProcessHeap(), 0, context );
} }
/*********************************************************************** /***********************************************************************

View file

@ -180,7 +180,19 @@ my %arg_conv =
"GLintptrARB" => [ "long", "INT_PTR" ], "GLintptrARB" => [ "long", "INT_PTR" ],
"GLsizeiptrARB" => [ "long", "INT_PTR" ], "GLsizeiptrARB" => [ "long", "INT_PTR" ],
"GLhalfNV" => [ "long", "unsigned short" ], "GLhalfNV" => [ "long", "unsigned short" ],
"GLvdpauSurfaceNV" => [ "long", "INT_PTR" ]); "GLvdpauSurfaceNV" => [ "long", "INT_PTR" ],
"HDC" => [ "long" ],
"HGLRC" => [ "long" ],
"HENHMETAFILE" => [ "long" ],
"LPGLYPHMETRICSFLOAT" => [ "ptr" ],
"LPCSTR" => [ "str" ],
"int" => [ "long" ],
"INT" => [ "long" ],
"BOOL" => [ "long" ],
"DWORD" => [ "long" ],
"FLOAT" => [ "float" ],
"UINT" => [ "long" ],
);
# #
# Used to convert some types # Used to convert some types
@ -358,9 +370,29 @@ sub generate_null_func($$)
return $ret; return $ret;
} }
sub generate_spec_entry($$)
{
my ($name, $func) = @_;
my $args=" ";
foreach my $arg (@{$func->[1]})
{
my $type = $arg->[0];
if ($type =~ /\*/) {
$args .= "ptr ";
} elsif (defined($arg_conv{$type})) {
$args .= "$@$arg_conv{$type}[0] ";
} else {
die "No conversion for func $name type $type\n";
}
}
$args = substr($args,1,-1);
return "@ stdcall $_($args)";
}
sub get_func_proto($$$) sub get_func_proto($$$)
{ {
my ($format, $name, $func) = @_; my ($format, $name, $func) = @_;
die "unknown func $name" unless defined $func->[0];
my $ret = sprintf "%-10s", ConvertType($func->[0]); my $ret = sprintf "%-10s", ConvertType($func->[0]);
$ret .= " " . sprintf($format,$name) . "("; $ret .= " " . sprintf($format,$name) . "(";
for (my $i = 0; $i < @{$func->[1]}; $i++) for (my $i = 0; $i < @{$func->[1]}; $i++)
@ -445,29 +477,33 @@ if ($version eq "1.0") {
# #
my %norm_functions; my %norm_functions;
my %ext_functions; my %ext_functions;
my %wgl_functions;
my %wgl_functions = my %supported_wgl_functions =
( (
"wglCopyContext" => [ "BOOL", [ [ "struct wgl_context *", "src" ], "wglCopyContext" => 1,
[ "struct wgl_context *", "dst" ], "wglCreateContext" => 1,
[ "UINT", "mask" ] ] ], "wglDeleteContext" => 1,
"wglCreateContext" => [ "struct wgl_context *", [ [ "HDC", "hdc" ] ] ], "wglDescribePixelFormat" => 1,
"wglDeleteContext" => [ "void", [ [ "struct wgl_context *", "context" ] ] ], "wglGetPixelFormat" => 1,
"wglDescribePixelFormat" => [ "INT", [ [ "HDC", "hdc" ], "wglGetProcAddress" => 1,
[ "INT", "format" ], "wglMakeCurrent" => 1,
[ "UINT", "size" ], "wglSetPixelFormat" => 1,
[ "PIXELFORMATDESCRIPTOR *", "descr" ] ] ], "wglShareLists" => 1,
"wglGetPixelFormat" => [ "INT", [ [ "HDC", "hdc" ] ] ], "wglSwapBuffers" => 1,
"wglGetProcAddress" => [ "PROC", [ [ "LPCSTR", "name" ] ] ], );
"wglMakeCurrent" => [ "BOOL", [ [ "HDC", "hdc" ],
[ "struct wgl_context *", "context" ] ] ], my %remapped_wgl_functions =
"wglSetPixelFormat" => [ "BOOL", [ [ "HDC", "hdc" ], (
[ "INT", "format" ], "ChoosePixelFormat" => "wglChoosePixelFormat",
[ "const PIXELFORMATDESCRIPTOR *", "descr" ] ] ], "DescribePixelFormat" => "wglDescribePixelFormat",
"wglShareLists" => [ "BOOL", [ [ "struct wgl_context *", "org" ], "GetPixelFormat" => "wglGetPixelFormat",
[ "struct wgl_context *", "dst" ] ] ], "GetEnhMetaFilePixelFormat" => 0,
"wglSwapBuffers" => [ "BOOL", [ [ "HDC", "hdc" ] ] ], "SetPixelFormat" => "wglSetPixelFormat",
); "SwapBuffers" => "wglSwapBuffers",
"wglUseFontBitmaps" => 0,
"wglUseFontOutlines" => 0,
);
my %supported_wgl_extensions = my %supported_wgl_extensions =
( (
@ -578,6 +614,19 @@ sub parse_file($$)
} }
} }
} }
elsif ($v->{api} eq "wgl")
{
for my $req (@{$v->{require}}) {
for (keys %{$req->{command}}) {
if (defined $remapped_wgl_functions{$_}) {
$wgl_functions{$remapped_wgl_functions{$_}} = $functions{$_} if $remapped_wgl_functions{$_};
}
else {
$wgl_functions{$_} = $functions{$_};
}
}
}
}
} }
# generate extension functions # generate extension functions
@ -643,6 +692,7 @@ print HEADER "struct opengl_funcs\n{\n";
print HEADER " struct\n {\n"; print HEADER " struct\n {\n";
foreach (sort keys %wgl_functions) foreach (sort keys %wgl_functions)
{ {
next unless defined $supported_wgl_functions{$_};
printf HEADER " %s;\n", get_func_proto("(WINE_GLAPI *p_%s)", $_, $wgl_functions{$_}); printf HEADER " %s;\n", get_func_proto("(WINE_GLAPI *p_%s)", $_, $wgl_functions{$_});
} }
print HEADER " } wgl;\n\n"; print HEADER " } wgl;\n\n";
@ -690,6 +740,7 @@ print HEADER "#endif\n\n";
foreach (sort keys %arg_conv) foreach (sort keys %arg_conv)
{ {
next unless $arg_conv{$_}[1];
printf HEADER "typedef %-22s %s;\n", $arg_conv{$_}[1], $_; printf HEADER "typedef %-22s %s;\n", $arg_conv{$_}[1], $_;
} }
print HEADER "\n"; print HEADER "\n";
@ -716,46 +767,11 @@ close HEADER;
open(SPEC, ">$spec_file") or die "cannot create $spec_file"; open(SPEC, ">$spec_file") or die "cannot create $spec_file";
foreach (sort keys %norm_functions) { foreach (sort keys %norm_functions) {
my $args=" "; printf SPEC "%s\n", generate_spec_entry( $_, $norm_functions{$_} );
for (my $i = 0; $i < @{$norm_functions{$_}->[1]}; $i++) { }
my $type = $norm_functions{$_}->[1]->[$i]->[0]; foreach (sort keys %wgl_functions) {
if ($type =~ /\*/) { printf SPEC "%s\n", generate_spec_entry( $_, $wgl_functions{$_} );
$args .= "ptr ";
} elsif (defined($arg_conv{$type})) {
$args .= "$@$arg_conv{$type}[0] ";
} else {
die "No conversion for GL type $type...\n";
}
}
$args = substr($args,1,-1);
print SPEC "@ stdcall $_($args)\n";
} }
print SPEC "@ stdcall wglChoosePixelFormat(long ptr)
@ stdcall wglCopyContext(long long long)
@ stdcall wglCreateContext(long)
@ stdcall wglCreateLayerContext(long long)
@ stdcall wglDeleteContext(long)
@ stdcall wglDescribeLayerPlane(long long long long ptr)
@ stdcall wglDescribePixelFormat(long long long ptr)
@ stdcall wglGetCurrentContext()
@ stdcall wglGetCurrentDC()
@ stub wglGetDefaultProcAddress
@ stdcall wglGetLayerPaletteEntries(long long long long ptr)
@ stdcall wglGetPixelFormat(long)
@ stdcall wglGetProcAddress(str)
@ stdcall wglMakeCurrent(long long)
@ stdcall wglRealizeLayerPalette(long long long)
@ stdcall wglSetLayerPaletteEntries(long long long long ptr)
@ stdcall wglSetPixelFormat(long long ptr)
@ stdcall wglShareLists(long long)
@ stdcall wglSwapBuffers(long)
@ stdcall wglSwapLayerBuffers(long long)
@ stdcall wglUseFontBitmapsA(long long long long)
@ stdcall wglUseFontBitmapsW(long long long long)
@ stdcall wglUseFontOutlinesA(long long long long long long long ptr)
@ stdcall wglUseFontOutlinesW(long long long long long long long ptr)
";
close(SPEC); close(SPEC);
@ -783,6 +799,7 @@ foreach (sort keys %norm_functions) {
} }
foreach (sort keys %wgl_functions) { foreach (sort keys %wgl_functions) {
next unless defined $supported_wgl_functions{$_};
print NORM generate_null_func($_, $wgl_functions{$_}); print NORM generate_null_func($_, $wgl_functions{$_});
} }
foreach (sort keys %norm_functions) { foreach (sort keys %norm_functions) {
@ -793,7 +810,11 @@ foreach (sort keys %ext_functions) {
} }
print NORM "\nstruct opengl_funcs null_opengl_funcs =\n{\n {\n"; print NORM "\nstruct opengl_funcs null_opengl_funcs =\n{\n {\n";
foreach (sort keys %wgl_functions) { print NORM " null_$_,\n"; } foreach (sort keys %wgl_functions)
{
next unless defined $supported_wgl_functions{$_};
print NORM " null_$_,\n";
}
print NORM " },\n {\n"; print NORM " },\n {\n";
foreach (sort keys %norm_functions) { print NORM " null_$_,\n" unless $_ eq "glDebugEntry"; } foreach (sort keys %norm_functions) { print NORM " null_$_,\n" unless $_ eq "glDebugEntry"; }
print NORM " },\n {\n"; print NORM " },\n {\n";

View file

@ -344,7 +344,6 @@
@ stdcall wglDescribePixelFormat(long long long ptr) @ stdcall wglDescribePixelFormat(long long long ptr)
@ stdcall wglGetCurrentContext() @ stdcall wglGetCurrentContext()
@ stdcall wglGetCurrentDC() @ stdcall wglGetCurrentDC()
@ stub wglGetDefaultProcAddress
@ stdcall wglGetLayerPaletteEntries(long long long long ptr) @ stdcall wglGetLayerPaletteEntries(long long long long ptr)
@ stdcall wglGetPixelFormat(long) @ stdcall wglGetPixelFormat(long)
@ stdcall wglGetProcAddress(str) @ stdcall wglGetProcAddress(str)
@ -357,5 +356,5 @@
@ stdcall wglSwapLayerBuffers(long long) @ stdcall wglSwapLayerBuffers(long long)
@ stdcall wglUseFontBitmapsA(long long long long) @ stdcall wglUseFontBitmapsA(long long long long)
@ stdcall wglUseFontBitmapsW(long long long long) @ stdcall wglUseFontBitmapsW(long long long long)
@ stdcall wglUseFontOutlinesA(long long long long long long long ptr) @ stdcall wglUseFontOutlinesA(long long long long float float long ptr)
@ stdcall wglUseFontOutlinesW(long long long long long long long ptr) @ stdcall wglUseFontOutlinesW(long long long long float float long ptr)

View file

@ -2014,15 +2014,15 @@ void WINAPI glViewport( GLint x, GLint y, GLsizei width, GLsizei height ) {
TRACE("(%d, %d, %d, %d)\n", x, y, width, height ); TRACE("(%d, %d, %d, %d)\n", x, y, width, height );
funcs->gl.p_glViewport( x, y, width, height ); funcs->gl.p_glViewport( x, y, width, height );
} }
static BOOL null_wglCopyContext( struct wgl_context * src, struct wgl_context * dst, UINT mask ) { return 0; } static BOOL null_wglCopyContext( struct wgl_context * hglrcSrc, struct wgl_context * hglrcDst, UINT mask ) { return 0; }
static struct wgl_context * null_wglCreateContext( HDC hdc ) { return 0; } static struct wgl_context * null_wglCreateContext( HDC hDc ) { return 0; }
static void null_wglDeleteContext( struct wgl_context * context ) { } static BOOL null_wglDeleteContext( struct wgl_context * oldContext ) { return 0; }
static INT null_wglDescribePixelFormat( HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR * descr ) { return 0; } static int null_wglDescribePixelFormat( HDC hdc, int ipfd, UINT cjpfd, PIXELFORMATDESCRIPTOR* ppfd ) { return 0; }
static INT null_wglGetPixelFormat( HDC hdc ) { return 0; } static int null_wglGetPixelFormat( HDC hdc ) { return 0; }
static PROC null_wglGetProcAddress( LPCSTR name ) { return 0; } static PROC null_wglGetProcAddress( LPCSTR lpszProc ) { return 0; }
static BOOL null_wglMakeCurrent( HDC hdc, struct wgl_context * context ) { return 0; } static BOOL null_wglMakeCurrent( HDC hDc, struct wgl_context * newContext ) { return 0; }
static BOOL null_wglSetPixelFormat( HDC hdc, INT format, const PIXELFORMATDESCRIPTOR * descr ) { return 0; } static BOOL null_wglSetPixelFormat( HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR* ppfd ) { return 0; }
static BOOL null_wglShareLists( struct wgl_context * org, struct wgl_context * dst ) { return 0; } static BOOL null_wglShareLists( struct wgl_context * hrcSrvShare, struct wgl_context * hrcSrvSource ) { return 0; }
static BOOL null_wglSwapBuffers( HDC hdc ) { return 0; } static BOOL null_wglSwapBuffers( HDC hdc ) { return 0; }
static void null_glAccum( GLenum op, GLfloat value ) { } static void null_glAccum( GLenum op, GLfloat value ) { }
static void null_glAlphaFunc( GLenum func, GLfloat ref ) { } static void null_glAlphaFunc( GLenum func, GLfloat ref ) { }

View file

@ -275,6 +275,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
</commands> </commands>
<commands namespace="WGL"> <commands namespace="WGL">
<command>
<proto>int <name>wglDescribePixelFormat</name></proto>
<param><ptype>HDC</ptype> <name>hdc</name></param>
<param>int <name>ipfd</name></param>
<param><ptype>UINT</ptype> <name>cjpfd</name></param>
<!-- pixel format is wrongly specified 'const' in wgl.xml -->
<param><ptype>PIXELFORMATDESCRIPTOR</ptype> *<name>ppfd</name></param>
</command>
<command> <command>
<proto>BOOL <name>wglSetPixelFormatWINE</name></proto> <proto>BOOL <name>wglSetPixelFormatWINE</name></proto>
<param><ptype>HDC</ptype> <name>hdc</name></param> <param><ptype>HDC</ptype> <name>hdc</name></param>
@ -310,6 +318,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
</require> </require>
</feature> </feature>
<feature api="wgl" name="WGL_VERSION_1_0" number="1.0">
<require>
<command name="wglDescribePixelFormat"/>
</require>
</feature>
<enums namespace="WGL" group="RendererWINE"> <enums namespace="WGL" group="RendererWINE">
<enum value="0x8183" name="WGL_RENDERER_VENDOR_ID_WINE"/> <enum value="0x8183" name="WGL_RENDERER_VENDOR_ID_WINE"/>
<enum value="0x8184" name="WGL_RENDERER_DEVICE_ID_WINE"/> <enum value="0x8184" name="WGL_RENDERER_DEVICE_ID_WINE"/>

View file

@ -439,13 +439,13 @@ static struct wgl_context *android_wglCreateContext( HDC hdc )
/*********************************************************************** /***********************************************************************
* android_wglDeleteContext * android_wglDeleteContext
*/ */
static void android_wglDeleteContext( struct wgl_context *ctx ) static BOOL android_wglDeleteContext( struct wgl_context *ctx )
{ {
EnterCriticalSection( &drawable_section ); EnterCriticalSection( &drawable_section );
list_remove( &ctx->entry ); list_remove( &ctx->entry );
LeaveCriticalSection( &drawable_section ); LeaveCriticalSection( &drawable_section );
p_eglDestroyContext( display, ctx->context ); p_eglDestroyContext( display, ctx->context );
HeapFree( GetProcessHeap(), 0, ctx ); return HeapFree( GetProcessHeap(), 0, ctx );
} }
/*********************************************************************** /***********************************************************************

View file

@ -4434,7 +4434,7 @@ static struct wgl_context *macdrv_wglCreateContext(HDC hdc)
/*********************************************************************** /***********************************************************************
* macdrv_wglDeleteContext * macdrv_wglDeleteContext
*/ */
static void macdrv_wglDeleteContext(struct wgl_context *context) static BOOL macdrv_wglDeleteContext(struct wgl_context *context)
{ {
TRACE("deleting context %p/%p/%p\n", context, context->context, context->cglcontext); TRACE("deleting context %p/%p/%p\n", context, context->context, context->cglcontext);
@ -4443,7 +4443,7 @@ static void macdrv_wglDeleteContext(struct wgl_context *context)
LeaveCriticalSection(&context_section); LeaveCriticalSection(&context_section);
macdrv_dispose_opengl_context(context->context); macdrv_dispose_opengl_context(context->context);
HeapFree(GetProcessHeap(), 0, context); return HeapFree(GetProcessHeap(), 0, context);
} }
/*********************************************************************** /***********************************************************************

View file

@ -1841,7 +1841,7 @@ static struct wgl_context *glxdrv_wglCreateContext( HDC hdc )
/*********************************************************************** /***********************************************************************
* glxdrv_wglDeleteContext * glxdrv_wglDeleteContext
*/ */
static void glxdrv_wglDeleteContext(struct wgl_context *ctx) static BOOL glxdrv_wglDeleteContext(struct wgl_context *ctx)
{ {
struct wgl_pbuffer *pb; struct wgl_pbuffer *pb;
@ -1860,7 +1860,7 @@ static void glxdrv_wglDeleteContext(struct wgl_context *ctx)
if (ctx->ctx) pglXDestroyContext( gdi_display, ctx->ctx ); if (ctx->ctx) pglXDestroyContext( gdi_display, ctx->ctx );
if (ctx->vis) XFree( ctx->vis ); if (ctx->vis) XFree( ctx->vis );
HeapFree( GetProcessHeap(), 0, ctx ); return HeapFree( GetProcessHeap(), 0, ctx );
} }
/*********************************************************************** /***********************************************************************

View file

@ -7,7 +7,7 @@
#define WINE_GLAPI #define WINE_GLAPI
#endif #endif
#define WINE_WGL_DRIVER_VERSION 16 #define WINE_WGL_DRIVER_VERSION 17
struct wgl_context; struct wgl_context;
struct wgl_pbuffer; struct wgl_pbuffer;
@ -18,12 +18,12 @@ struct opengl_funcs
{ {
BOOL (WINE_GLAPI *p_wglCopyContext)(struct wgl_context *,struct wgl_context *,UINT); BOOL (WINE_GLAPI *p_wglCopyContext)(struct wgl_context *,struct wgl_context *,UINT);
struct wgl_context * (WINE_GLAPI *p_wglCreateContext)(HDC); struct wgl_context * (WINE_GLAPI *p_wglCreateContext)(HDC);
void (WINE_GLAPI *p_wglDeleteContext)(struct wgl_context *); BOOL (WINE_GLAPI *p_wglDeleteContext)(struct wgl_context *);
INT (WINE_GLAPI *p_wglDescribePixelFormat)(HDC,INT,UINT,PIXELFORMATDESCRIPTOR *); int (WINE_GLAPI *p_wglDescribePixelFormat)(HDC,int,UINT,PIXELFORMATDESCRIPTOR*);
INT (WINE_GLAPI *p_wglGetPixelFormat)(HDC); int (WINE_GLAPI *p_wglGetPixelFormat)(HDC);
PROC (WINE_GLAPI *p_wglGetProcAddress)(LPCSTR); PROC (WINE_GLAPI *p_wglGetProcAddress)(LPCSTR);
BOOL (WINE_GLAPI *p_wglMakeCurrent)(HDC,struct wgl_context *); BOOL (WINE_GLAPI *p_wglMakeCurrent)(HDC,struct wgl_context *);
BOOL (WINE_GLAPI *p_wglSetPixelFormat)(HDC,INT,const PIXELFORMATDESCRIPTOR *); BOOL (WINE_GLAPI *p_wglSetPixelFormat)(HDC,int,const PIXELFORMATDESCRIPTOR*);
BOOL (WINE_GLAPI *p_wglShareLists)(struct wgl_context *,struct wgl_context *); BOOL (WINE_GLAPI *p_wglShareLists)(struct wgl_context *,struct wgl_context *);
BOOL (WINE_GLAPI *p_wglSwapBuffers)(HDC); BOOL (WINE_GLAPI *p_wglSwapBuffers)(HDC);
} wgl; } wgl;