Commit f6a0597d authored by Alexandre Julliard's avatar Alexandre Julliard

opengl32: Pass the TEB pointer in the Unix call parameters.

NtCurrentTeb() is more expensive on the Unix side.
parent 288da7c8
......@@ -345,7 +345,7 @@ sub generate_unix_thunk($$$)
$ret .= "NTSTATUS $prefix\_$name( void *args )\n";
$ret .= "{\n";
$ret .= " struct $name\_params *params = args;\n" unless !$call_args && is_void_func( $func );
$ret .= " struct $name\_params *params = args;\n";
# special case for functions that take an HDC as first parameter
if (@{$func->[1]} && get_arg_type( ${$func->[1]}[0] ) eq "HDC")
{
......@@ -355,7 +355,7 @@ sub generate_unix_thunk($$$)
}
else
{
$ret .= " const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;\n";
$ret .= " const struct opengl_funcs *funcs = params->teb->glTable;\n";
}
$ret .= " ";
$ret .= "params->ret = " unless is_void_func( $func );
......@@ -378,12 +378,13 @@ sub generate_win_thunk($$)
$ret .= "$func_ret WINAPI $name($decl_args)\n";
$ret .= "{\n";
$ret .= " struct $name\_params args";
$params .= " .teb = NtCurrentTeb()";
foreach my $arg (@{$func->[1]})
{
my $pname = get_arg_name( $arg );
$params .= " .$pname = $pname," unless $arg->textContent() =~ /\[/;
$params .= ", .$pname = $pname" unless $arg->textContent() =~ /\[/;
}
$ret .= ($params ? " = {$params }" : is_void_func( $func ) ? "" : " = {0}");
$ret .= " = {$params }";
$ret .= ";\n";
$ret .= " NTSTATUS status;\n";
foreach my $arg (@{$func->[1]})
......@@ -411,16 +412,6 @@ sub get_wow64_arg_type($)
return $ptype;
}
sub needs_wow64_thunk($$)
{
my ($name, $func) = @_;
foreach my $arg (@{$func->[1]})
{
return 1 if get_wow64_arg_type( $arg ) =~ /PTR32/;
}
return get_wow64_arg_type( $func->[0] ) =~ /PTR32/;
}
sub generate_wow64_thunk($$$)
{
my ($name, $func, $prefix) = @_;
......@@ -432,6 +423,7 @@ sub generate_wow64_thunk($$$)
$ret .= "static NTSTATUS wow64_$prefix\_$name( void *args )\n";
$ret .= "{\n";
$ret .= " struct\n {\n";
$ret .= " PTR32 teb;\n";
foreach my $arg (@{$func->[1]})
{
my $ptype = get_wow64_arg_type( $arg );
......@@ -448,6 +440,7 @@ sub generate_wow64_thunk($$$)
$ret .= " } *params32 = args;\n";
$ret .= " struct $name\_params params =\n";
$ret .= " {\n";
$ret .= " .teb = get_teb64(params32->teb),\n";
foreach my $arg (@{$func->[1]})
{
next if $arg->textContent() =~ /(\*.*\*|\[|(sizei|int)ptr.*\*)/;
......@@ -564,6 +557,7 @@ sub generate_func_params($$)
my ($name, $func) = @_;
my $ret = "";
$ret .= sprintf "struct %s_params\n{\n", $name;
$ret .= " TEB *teb;\n";
foreach my $arg (@{$func->[1]})
{
$ret .= sprintf " %s;\n", $arg->textContent();
......@@ -1213,23 +1207,25 @@ print OUT "\n";
print OUT "#ifdef _WIN64\n\n";
print OUT "typedef ULONG PTR32;\n\n";
print OUT "extern NTSTATUS wow64_process_detach( void *args ) DECLSPEC_HIDDEN;\n";
print OUT "extern NTSTATUS wow64_thread_attach( void *args ) DECLSPEC_HIDDEN;\n";
print OUT "extern NTSTATUS wow64_process_detach( void *args ) DECLSPEC_HIDDEN;\n\n";
foreach (sort keys %wgl_functions)
{
next if defined $manual_win_functions{$_};
next if !needs_wow64_thunk($_, $wgl_functions{$_}) || defined $manual_wow64_thunks{$_};
next if defined $manual_wow64_thunks{$_};
print OUT generate_wow64_thunk($_, $wgl_functions{$_}, "wgl");
}
foreach (sort keys %norm_functions)
{
next if defined $manual_win_functions{$_};
next if !needs_wow64_thunk($_, $norm_functions{$_}) || defined $manual_wow64_thunks{$_};
next if defined $manual_wow64_thunks{$_};
print OUT generate_wow64_thunk($_, $norm_functions{$_}, "gl");
}
foreach (sort keys %ext_functions)
{
next if defined $manual_win_functions{$_};
next if !needs_wow64_thunk($_, $ext_functions{$_}) || defined $manual_wow64_thunks{$_};
next if defined $manual_wow64_thunks{$_};
print OUT generate_wow64_thunk($_, $ext_functions{$_}, "ext");
}
......@@ -1254,43 +1250,22 @@ foreach (sort keys %ext_functions)
print OUT "\nconst unixlib_entry_t __wine_unix_call_wow64_funcs[] =\n";
print OUT "{\n";
print OUT " &thread_attach,\n";
print OUT " &wow64_process_detach,\n";
print OUT " wow64_thread_attach,\n";
print OUT " wow64_process_detach,\n";
foreach (sort keys %wgl_functions)
{
next if defined $manual_win_functions{$_};
if (needs_wow64_thunk($_, $wgl_functions{$_}) || defined $manual_wow64_thunks{$_})
{
printf OUT " &wow64_wgl_%s,\n", $_;
}
else
{
printf OUT " &wgl_%s,\n", $_;
}
printf OUT " wow64_wgl_%s,\n", $_;
}
foreach (sort keys %norm_functions)
{
next if defined $manual_win_functions{$_};
if (needs_wow64_thunk($_, $norm_functions{$_}) || defined $manual_wow64_thunks{$_})
{
printf OUT " &wow64_gl_%s,\n", $_;
}
else
{
printf OUT " &gl_%s,\n", $_;
}
printf OUT " wow64_gl_%s,\n", $_;
}
foreach (sort keys %ext_functions)
{
next if defined $manual_win_functions{$_};
if (needs_wow64_thunk($_, $ext_functions{$_}) || defined $manual_wow64_thunks{$_})
{
printf OUT " &wow64_ext_%s,\n", $_;
}
else
{
printf OUT " &ext_%s,\n", $_;
}
printf OUT " wow64_ext_%s,\n", $_;
}
print OUT "};\n\n";
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -61,4 +61,10 @@ static inline void *copy_wow64_ptr32s( UINT_PTR address, ULONG count )
return tmp;
}
static inline TEB *get_teb64( ULONG teb32 )
{
TEB32 *teb32_ptr = ULongToPtr( teb32 );
return (TEB *)((char *)teb32_ptr + teb32_ptr->WowTebOffset);
}
#endif /* __WINE_OPENGL32_UNIX_PRIVATE_H */
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.
......@@ -284,7 +284,7 @@ INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd)
*/
INT WINAPI wglGetPixelFormat(HDC hdc)
{
struct wglGetPixelFormat_params args = { .hdc = hdc, };
struct wglGetPixelFormat_params args = { .teb = NtCurrentTeb(), .hdc = hdc };
NTSTATUS status;
TRACE( "hdc %p\n", hdc );
......@@ -303,7 +303,7 @@ INT WINAPI wglGetPixelFormat(HDC hdc)
*/
BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers( HDC hdc )
{
struct wglSwapBuffers_params args = { .hdc = hdc, };
struct wglSwapBuffers_params args = { .teb = NtCurrentTeb(), .hdc = hdc };
NTSTATUS status;
if ((status = UNIX_CALL( wglSwapBuffers, &args ))) WARN( "wglSwapBuffers returned %#lx\n", status );
......@@ -373,7 +373,7 @@ int WINAPI wglGetLayerPaletteEntries(HDC hdc,
*/
PROC WINAPI wglGetProcAddress( LPCSTR name )
{
struct wglGetProcAddress_params args = { .lpszProc = name, };
struct wglGetProcAddress_params args = { .teb = NtCurrentTeb(), .lpszProc = name };
const void *proc;
NTSTATUS status;
......@@ -902,6 +902,7 @@ const GLubyte * WINAPI glGetStringi( GLenum name, GLuint index )
{
struct glGetStringi_params args =
{
.teb = NtCurrentTeb(),
.name = name,
.index = index,
};
......@@ -928,7 +929,7 @@ const GLubyte * WINAPI glGetStringi( GLenum name, GLuint index )
*/
const GLubyte * WINAPI glGetString( GLenum name )
{
struct glGetString_params args = { .name = name, };
struct glGetString_params args = { .teb = NtCurrentTeb(), .name = name };
NTSTATUS status;
#ifndef _WIN64
GLubyte *wow64_str = NULL;
......@@ -949,7 +950,7 @@ const GLubyte * WINAPI glGetString( GLenum name )
const char * WINAPI wglGetExtensionsStringARB( HDC hdc )
{
struct wglGetExtensionsStringARB_params args = { .hdc = hdc, };
struct wglGetExtensionsStringARB_params args = { .teb = NtCurrentTeb(), .hdc = hdc };
NTSTATUS status;
#ifndef _WIN64
char *wow64_str = NULL;
......@@ -970,7 +971,7 @@ const char * WINAPI wglGetExtensionsStringARB( HDC hdc )
const char * WINAPI wglGetExtensionsStringEXT(void)
{
struct wglGetExtensionsStringEXT_params args = {0};
struct wglGetExtensionsStringEXT_params args = { .teb = NtCurrentTeb() };
NTSTATUS status;
#ifndef _WIN64
char *wow64_str = NULL;
......@@ -991,7 +992,7 @@ const char * WINAPI wglGetExtensionsStringEXT(void)
const GLchar * WINAPI wglQueryCurrentRendererStringWINE( GLenum attribute )
{
struct wglQueryCurrentRendererStringWINE_params args = { .attribute = attribute, };
struct wglQueryCurrentRendererStringWINE_params args = { .teb = NtCurrentTeb(), .attribute = attribute };
NTSTATUS status;
#ifndef _WIN64
char *wow64_str = NULL;
......@@ -1014,6 +1015,7 @@ const GLchar * WINAPI wglQueryRendererStringWINE( HDC dc, GLint renderer, GLenum
{
struct wglQueryRendererStringWINE_params args =
{
.teb = NtCurrentTeb(),
.dc = dc,
.renderer = renderer,
.attribute = attribute,
......@@ -1060,6 +1062,7 @@ void * WINAPI glMapBuffer( GLenum target, GLenum access )
{
struct glMapBuffer_params args =
{
.teb = NtCurrentTeb(),
.target = target,
.access = access,
};
......@@ -1090,6 +1093,7 @@ void * WINAPI glMapBufferRange( GLenum target, GLintptr offset, GLsizeiptr lengt
{
struct glMapBufferRange_params args =
{
.teb = NtCurrentTeb(),
.target = target,
.offset = offset,
.length = length,
......@@ -1117,6 +1121,7 @@ void * WINAPI glMapNamedBuffer( GLuint buffer, GLenum access )
{
struct glMapNamedBuffer_params args =
{
.teb = NtCurrentTeb(),
.buffer = buffer,
.access = access,
};
......@@ -1147,6 +1152,7 @@ void * WINAPI glMapNamedBufferRange( GLuint buffer, GLintptr offset, GLsizeiptr
{
struct glMapNamedBufferRange_params args =
{
.teb = NtCurrentTeb(),
.buffer = buffer,
.offset = offset,
.length = length,
......@@ -1179,6 +1185,7 @@ GLboolean WINAPI glUnmapBuffer( GLenum target )
{
struct glUnmapBuffer_params args =
{
.teb = NtCurrentTeb(),
.target = target,
};
NTSTATUS status;
......@@ -1210,6 +1217,7 @@ GLboolean WINAPI glUnmapNamedBuffer( GLuint buffer )
{
struct glUnmapNamedBuffer_params args =
{
.teb = NtCurrentTeb(),
.buffer = buffer,
};
NTSTATUS status;
......@@ -1265,7 +1273,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
kernel_callback_table[NtUserCallOpenGLDebugMessageCallback] = call_opengl_debug_message_callback;
/* fallthrough */
case DLL_THREAD_ATTACH:
if ((status = UNIX_CALL( thread_attach, NULL )))
if ((status = UNIX_CALL( thread_attach, NtCurrentTeb() )))
{
WARN( "Failed to initialize thread, status %#lx\n", status );
return FALSE;
......
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