1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-08 20:06:18 +00:00

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
*/
static void dibdrv_wglDeleteContext( struct wgl_context *context )
static BOOL dibdrv_wglDeleteContext( struct wgl_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" ],
"GLsizeiptrARB" => [ "long", "INT_PTR" ],
"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
@ -358,9 +370,29 @@ sub generate_null_func($$)
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($$$)
{
my ($format, $name, $func) = @_;
die "unknown func $name" unless defined $func->[0];
my $ret = sprintf "%-10s", ConvertType($func->[0]);
$ret .= " " . sprintf($format,$name) . "(";
for (my $i = 0; $i < @{$func->[1]}; $i++)
@ -445,29 +477,33 @@ if ($version eq "1.0") {
#
my %norm_functions;
my %ext_functions;
my %wgl_functions;
my %wgl_functions =
(
"wglCopyContext" => [ "BOOL", [ [ "struct wgl_context *", "src" ],
[ "struct wgl_context *", "dst" ],
[ "UINT", "mask" ] ] ],
"wglCreateContext" => [ "struct wgl_context *", [ [ "HDC", "hdc" ] ] ],
"wglDeleteContext" => [ "void", [ [ "struct wgl_context *", "context" ] ] ],
"wglDescribePixelFormat" => [ "INT", [ [ "HDC", "hdc" ],
[ "INT", "format" ],
[ "UINT", "size" ],
[ "PIXELFORMATDESCRIPTOR *", "descr" ] ] ],
"wglGetPixelFormat" => [ "INT", [ [ "HDC", "hdc" ] ] ],
"wglGetProcAddress" => [ "PROC", [ [ "LPCSTR", "name" ] ] ],
"wglMakeCurrent" => [ "BOOL", [ [ "HDC", "hdc" ],
[ "struct wgl_context *", "context" ] ] ],
"wglSetPixelFormat" => [ "BOOL", [ [ "HDC", "hdc" ],
[ "INT", "format" ],
[ "const PIXELFORMATDESCRIPTOR *", "descr" ] ] ],
"wglShareLists" => [ "BOOL", [ [ "struct wgl_context *", "org" ],
[ "struct wgl_context *", "dst" ] ] ],
"wglSwapBuffers" => [ "BOOL", [ [ "HDC", "hdc" ] ] ],
);
my %supported_wgl_functions =
(
"wglCopyContext" => 1,
"wglCreateContext" => 1,
"wglDeleteContext" => 1,
"wglDescribePixelFormat" => 1,
"wglGetPixelFormat" => 1,
"wglGetProcAddress" => 1,
"wglMakeCurrent" => 1,
"wglSetPixelFormat" => 1,
"wglShareLists" => 1,
"wglSwapBuffers" => 1,
);
my %remapped_wgl_functions =
(
"ChoosePixelFormat" => "wglChoosePixelFormat",
"DescribePixelFormat" => "wglDescribePixelFormat",
"GetPixelFormat" => "wglGetPixelFormat",
"GetEnhMetaFilePixelFormat" => 0,
"SetPixelFormat" => "wglSetPixelFormat",
"SwapBuffers" => "wglSwapBuffers",
"wglUseFontBitmaps" => 0,
"wglUseFontOutlines" => 0,
);
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
@ -643,6 +692,7 @@ print HEADER "struct opengl_funcs\n{\n";
print HEADER " struct\n {\n";
foreach (sort keys %wgl_functions)
{
next unless defined $supported_wgl_functions{$_};
printf HEADER " %s;\n", get_func_proto("(WINE_GLAPI *p_%s)", $_, $wgl_functions{$_});
}
print HEADER " } wgl;\n\n";
@ -690,6 +740,7 @@ print HEADER "#endif\n\n";
foreach (sort keys %arg_conv)
{
next unless $arg_conv{$_}[1];
printf HEADER "typedef %-22s %s;\n", $arg_conv{$_}[1], $_;
}
print HEADER "\n";
@ -716,46 +767,11 @@ close HEADER;
open(SPEC, ">$spec_file") or die "cannot create $spec_file";
foreach (sort keys %norm_functions) {
my $args=" ";
for (my $i = 0; $i < @{$norm_functions{$_}->[1]}; $i++) {
my $type = $norm_functions{$_}->[1]->[$i]->[0];
if ($type =~ /\*/) {
$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";
printf SPEC "%s\n", generate_spec_entry( $_, $norm_functions{$_} );
}
foreach (sort keys %wgl_functions) {
printf SPEC "%s\n", generate_spec_entry( $_, $wgl_functions{$_} );
}
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);
@ -783,6 +799,7 @@ foreach (sort keys %norm_functions) {
}
foreach (sort keys %wgl_functions) {
next unless defined $supported_wgl_functions{$_};
print NORM generate_null_func($_, $wgl_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";
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";
foreach (sort keys %norm_functions) { print NORM " null_$_,\n" unless $_ eq "glDebugEntry"; }
print NORM " },\n {\n";

View File

@ -344,7 +344,6 @@
@ 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)
@ -357,5 +356,5 @@
@ 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)
@ stdcall wglUseFontOutlinesA(long long long long float float 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 );
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 struct wgl_context * null_wglCreateContext( HDC hdc ) { return 0; }
static void null_wglDeleteContext( struct wgl_context * context ) { }
static INT null_wglDescribePixelFormat( HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR * descr ) { return 0; }
static INT null_wglGetPixelFormat( HDC hdc ) { return 0; }
static PROC null_wglGetProcAddress( LPCSTR name ) { return 0; }
static BOOL null_wglMakeCurrent( HDC hdc, struct wgl_context * context ) { return 0; }
static BOOL null_wglSetPixelFormat( HDC hdc, INT format, const PIXELFORMATDESCRIPTOR * descr ) { return 0; }
static BOOL null_wglShareLists( struct wgl_context * org, struct wgl_context * dst ) { 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 BOOL null_wglDeleteContext( struct wgl_context * oldContext ) { 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 PROC null_wglGetProcAddress( LPCSTR lpszProc ) { return 0; }
static BOOL null_wglMakeCurrent( HDC hDc, struct wgl_context * newContext ) { return 0; }
static BOOL null_wglSetPixelFormat( HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR* ppfd ) { 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 void null_glAccum( GLenum op, GLfloat value ) { }
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 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>
<proto>BOOL <name>wglSetPixelFormatWINE</name></proto>
<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>
</feature>
<feature api="wgl" name="WGL_VERSION_1_0" number="1.0">
<require>
<command name="wglDescribePixelFormat"/>
</require>
</feature>
<enums namespace="WGL" group="RendererWINE">
<enum value="0x8183" name="WGL_RENDERER_VENDOR_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
*/
static void android_wglDeleteContext( struct wgl_context *ctx )
static BOOL android_wglDeleteContext( struct wgl_context *ctx )
{
EnterCriticalSection( &drawable_section );
list_remove( &ctx->entry );
LeaveCriticalSection( &drawable_section );
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
*/
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);
@ -4443,7 +4443,7 @@ static void macdrv_wglDeleteContext(struct wgl_context *context)
LeaveCriticalSection(&context_section);
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
*/
static void glxdrv_wglDeleteContext(struct wgl_context *ctx)
static BOOL glxdrv_wglDeleteContext(struct wgl_context *ctx)
{
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->vis) XFree( ctx->vis );
HeapFree( GetProcessHeap(), 0, ctx );
return HeapFree( GetProcessHeap(), 0, ctx );
}
/***********************************************************************

View File

@ -7,7 +7,7 @@
#define WINE_GLAPI
#endif
#define WINE_WGL_DRIVER_VERSION 16
#define WINE_WGL_DRIVER_VERSION 17
struct wgl_context;
struct wgl_pbuffer;
@ -18,12 +18,12 @@ struct opengl_funcs
{
BOOL (WINE_GLAPI *p_wglCopyContext)(struct wgl_context *,struct wgl_context *,UINT);
struct wgl_context * (WINE_GLAPI *p_wglCreateContext)(HDC);
void (WINE_GLAPI *p_wglDeleteContext)(struct wgl_context *);
INT (WINE_GLAPI *p_wglDescribePixelFormat)(HDC,INT,UINT,PIXELFORMATDESCRIPTOR *);
INT (WINE_GLAPI *p_wglGetPixelFormat)(HDC);
BOOL (WINE_GLAPI *p_wglDeleteContext)(struct wgl_context *);
int (WINE_GLAPI *p_wglDescribePixelFormat)(HDC,int,UINT,PIXELFORMATDESCRIPTOR*);
int (WINE_GLAPI *p_wglGetPixelFormat)(HDC);
PROC (WINE_GLAPI *p_wglGetProcAddress)(LPCSTR);
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_wglSwapBuffers)(HDC);
} wgl;