More work to split the module, still not using the syscalls yet.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/wgl.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 7c8bbfa378f..d40e3b1c0ea 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -1236,15 +1236,14 @@ BOOL WINAPI wglQueryPbufferARB( HPBUFFERARB handle, int attrib, int *value ) */ static BOOL wglUseFontBitmaps_common( HDC hdc, DWORD first, DWORD count, DWORD listBase, BOOL unicode ) { - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; GLYPHMETRICS gm; unsigned int glyph, size = 0; void *bitmap = NULL, *gl_bitmap = NULL; int org_alignment; BOOL ret = TRUE;
- funcs->gl.p_glGetIntegerv(GL_UNPACK_ALIGNMENT, &org_alignment); - funcs->gl.p_glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glGetIntegerv( GL_UNPACK_ALIGNMENT, &org_alignment ); + glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
for (glyph = first; glyph < first + count; glyph++) { unsigned int needed_size, height, width, width_int; @@ -1317,20 +1316,18 @@ static BOOL wglUseFontBitmaps_common( HDC hdc, DWORD first, DWORD count, DWORD l } }
- funcs->gl.p_glNewList(listBase++, GL_COMPILE); + glNewList( listBase++, GL_COMPILE ); if (needed_size != 0) { - funcs->gl.p_glBitmap(gm.gmBlackBoxX, gm.gmBlackBoxY, - 0 - gm.gmptGlyphOrigin.x, (int) gm.gmBlackBoxY - gm.gmptGlyphOrigin.y, - gm.gmCellIncX, gm.gmCellIncY, - gl_bitmap); + glBitmap( gm.gmBlackBoxX, gm.gmBlackBoxY, 0 - gm.gmptGlyphOrigin.x, + (int)gm.gmBlackBoxY - gm.gmptGlyphOrigin.y, gm.gmCellIncX, gm.gmCellIncY, gl_bitmap ); } else { /* This is the case of 'empty' glyphs like the space character */ - funcs->gl.p_glBitmap(0, 0, 0, 0, gm.gmCellIncX, gm.gmCellIncY, NULL); + glBitmap( 0, 0, 0, 0, gm.gmCellIncX, gm.gmCellIncY, NULL ); } - funcs->gl.p_glEndList(); + glEndList(); }
- funcs->gl.p_glPixelStorei(GL_UNPACK_ALIGNMENT, org_alignment); + glPixelStorei( GL_UNPACK_ALIGNMENT, org_alignment ); HeapFree(GetProcessHeap(), 0, bitmap); HeapFree(GetProcessHeap(), 0, gl_bitmap); return ret;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/wgl.c | 78 ++++++++++++--------------------------------- 1 file changed, 21 insertions(+), 57 deletions(-)
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index d40e3b1c0ea..987fa36ce2a 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -1356,28 +1356,6 @@ static void fixed_to_double(POINTFX fixed, UINT em_size, GLdouble vertex[3]) vertex[2] = 0.0; }
-static void WINAPI tess_callback_vertex(GLvoid *vertex) -{ - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - GLdouble *dbl = vertex; - TRACE("%f, %f, %f\n", dbl[0], dbl[1], dbl[2]); - funcs->gl.p_glVertex3dv(vertex); -} - -static void WINAPI tess_callback_begin(GLenum which) -{ - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - TRACE("%d\n", which); - funcs->gl.p_glBegin(which); -} - -static void WINAPI tess_callback_end(void) -{ - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - TRACE("\n"); - funcs->gl.p_glEnd(); -} - typedef struct _bezier_vector { GLdouble x; GLdouble y; @@ -1459,7 +1437,6 @@ static BOOL wglUseFontOutlines_common(HDC hdc, LPGLYPHMETRICSFLOAT lpgmf, BOOL unicode) { - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; UINT glyph; GLUtesselator *tess = NULL; LOGFONTW lf; @@ -1481,9 +1458,9 @@ static BOOL wglUseFontOutlines_common(HDC hdc, ERR("glu32 is required for this function but isn't available\n"); return FALSE; } - gluTessCallback(tess, GLU_TESS_VERTEX, (void *)tess_callback_vertex); - gluTessCallback(tess, GLU_TESS_BEGIN, (void *)tess_callback_begin); - gluTessCallback(tess, GLU_TESS_END, tess_callback_end); + gluTessCallback( tess, GLU_TESS_VERTEX, (void *)glVertex3dv ); + gluTessCallback( tess, GLU_TESS_BEGIN, (void *)glBegin ); + gluTessCallback( tess, GLU_TESS_END, glEnd ); }
GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf); @@ -1536,11 +1513,11 @@ static BOOL wglUseFontOutlines_common(HDC hdc, lpgmf++; }
- funcs->gl.p_glNewList(listBase++, GL_COMPILE); - funcs->gl.p_glFrontFace(GL_CCW); + glNewList( listBase++, GL_COMPILE ); + glFrontFace( GL_CCW ); if(format == WGL_FONT_POLYGONS) { - funcs->gl.p_glNormal3d(0.0, 0.0, 1.0); + glNormal3d( 0.0, 0.0, 1.0 ); gluTessNormal(tess, 0, 0, 1); gluTessBeginPolygon(tess, NULL); } @@ -1560,18 +1537,14 @@ static BOOL wglUseFontOutlines_common(HDC hdc, if(vertices) TRACE("\tstart %d, %d\n", pph->pfxStart.x.value, pph->pfxStart.y.value);
- if(format == WGL_FONT_POLYGONS) - gluTessBeginContour(tess); - else - funcs->gl.p_glBegin(GL_LINE_LOOP); + if (format == WGL_FONT_POLYGONS) gluTessBeginContour( tess ); + else glBegin( GL_LINE_LOOP );
if(vertices) { fixed_to_double(pph->pfxStart, em_size, vertices); - if(format == WGL_FONT_POLYGONS) - gluTessVertex(tess, vertices, vertices); - else - funcs->gl.p_glVertex3d(vertices[0], vertices[1], vertices[2]); + if (format == WGL_FONT_POLYGONS) gluTessVertex( tess, vertices, vertices ); + else glVertex3d( vertices[0], vertices[1], vertices[2] ); vertices += 3; } vertex_total++; @@ -1591,10 +1564,8 @@ static BOOL wglUseFontOutlines_common(HDC hdc, TRACE("\t\tline to %d, %d\n", ppc->apfx[i].x.value, ppc->apfx[i].y.value); fixed_to_double(ppc->apfx[i], em_size, vertices); - if(format == WGL_FONT_POLYGONS) - gluTessVertex(tess, vertices, vertices); - else - funcs->gl.p_glVertex3d(vertices[0], vertices[1], vertices[2]); + if (format == WGL_FONT_POLYGONS) gluTessVertex( tess, vertices, vertices ); + else glVertex3d( vertices[0], vertices[1], vertices[2] ); vertices += 3; } fixed_to_double(ppc->apfx[i], em_size, previous); @@ -1639,10 +1610,8 @@ static BOOL wglUseFontOutlines_common(HDC hdc, vertices[0] = points[j].x; vertices[1] = points[j].y; vertices[2] = 0.0; - if(format == WGL_FONT_POLYGONS) - gluTessVertex(tess, vertices, vertices); - else - funcs->gl.p_glVertex3d(vertices[0], vertices[1], vertices[2]); + if (format == WGL_FONT_POLYGONS) gluTessVertex( tess, vertices, vertices ); + else glVertex3d( vertices[0], vertices[1], vertices[2] ); vertices += 3; } } @@ -1653,29 +1622,24 @@ static BOOL wglUseFontOutlines_common(HDC hdc, break; default: ERR("\t\tcurve type = %d\n", ppc->wType); - if(format == WGL_FONT_POLYGONS) - gluTessEndContour(tess); - else - funcs->gl.p_glEnd(); + if (format == WGL_FONT_POLYGONS) gluTessEndContour( tess ); + else glEnd(); goto error_in_list; }
ppc = (TTPOLYCURVE*)((char*)ppc + sizeof(*ppc) + (ppc->cpfx - 1) * sizeof(POINTFX)); } - if(format == WGL_FONT_POLYGONS) - gluTessEndContour(tess); - else - funcs->gl.p_glEnd(); + if (format == WGL_FONT_POLYGONS) gluTessEndContour( tess ); + else glEnd(); pph = (TTPOLYGONHEADER*)((char*)pph + pph->cb); } }
error_in_list: - if(format == WGL_FONT_POLYGONS) - gluTessEndPolygon(tess); - funcs->gl.p_glTranslated((GLdouble)gm.gmCellIncX / em_size, (GLdouble)gm.gmCellIncY / em_size, 0.0); - funcs->gl.p_glEndList(); + if (format == WGL_FONT_POLYGONS) gluTessEndPolygon( tess ); + glTranslated( (GLdouble)gm.gmCellIncX / em_size, (GLdouble)gm.gmCellIncY / em_size, 0.0 ); + glEndList(); HeapFree(GetProcessHeap(), 0, buf); HeapFree(GetProcessHeap(), 0, vertices); }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/wgl.c | 57 ++++++++++++++++++++++++++++++++++++-------- dlls/wow64win/user.c | 8 +++++++ include/ntuser.h | 2 ++ 3 files changed, 57 insertions(+), 10 deletions(-)
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 987fa36ce2a..cf0b8e0330f 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -22,25 +22,19 @@
#include <stdarg.h> #include <stdlib.h> -#include <string.h> -#include <sys/types.h> #include <math.h>
#include "ntstatus.h" #define WIN32_NO_STATUS #include "windef.h" #include "winbase.h" -#include "winuser.h" #include "winreg.h" -#include "wingdi.h" -#include "winternl.h" -#include "winnt.h" +#include "ntuser.h"
#include "opengl_ext.h"
#include "unixlib.h"
-#include "wine/gdi_driver.h" #include "wine/glu.h" #include "wine/debug.h"
@@ -1714,12 +1708,50 @@ const GLubyte * WINAPI glGetString( GLenum name ) }
/* wrapper for glDebugMessageCallback* functions */ +typedef void (WINAPI *gl_debug_cb)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *); + +struct wine_gl_debug_message_params +{ + gl_debug_cb user_callback; + const void *user_data; + + GLenum source; + GLenum type; + GLuint id; + GLenum severity; + GLsizei length; + const GLchar *message; +}; + +static BOOL WINAPI call_opengl_debug_message_callback( struct wine_gl_debug_message_params *params, ULONG size ) +{ + params->user_callback( params->source, params->type, params->id, params->severity, + params->length, params->message, params->user_data ); + return TRUE; +} + static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GLenum severity, - GLsizei length, const GLchar *message,const void *userParam ) + GLsizei length, const GLchar *message, const void *userParam ) { + struct wine_gl_debug_message_params params = + { + .source = source, + .type = type, + .id = id, + .severity = severity, + .length = length, + .message = message, + }; + void **kernel_callback_table; + BOOL (WINAPI *callback)( struct wine_gl_debug_message_params *params, ULONG size ); + struct wgl_handle *ptr = (struct wgl_handle *)userParam; - if (!ptr->u.context->debug_callback) return; - ptr->u.context->debug_callback( source, type, id, severity, length, message, ptr->u.context->debug_user ); + if (!(params.user_callback = ptr->u.context->debug_callback)) return; + params.user_data = ptr->u.context->debug_user; + + kernel_callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; + callback = kernel_callback_table[NtUserCallOpenGLDebugMessageCallback]; + callback( ¶ms, sizeof(params) ); }
/*********************************************************************** @@ -1772,10 +1804,15 @@ void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *user */ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) { + void **kernel_callback_table; + switch(reason) { case DLL_PROCESS_ATTACH: NtCurrentTeb()->glTable = &null_opengl_funcs; + + kernel_callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; + kernel_callback_table[NtUserCallOpenGLDebugMessageCallback] = call_opengl_debug_message_callback; break; case DLL_THREAD_ATTACH: NtCurrentTeb()->glTable = &null_opengl_funcs; diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index e1454347ecf..79f85d45834 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1008,6 +1008,12 @@ static NTSTATUS WINAPI wow64_NtUserCallVulkanDebugUtilsCallback( void *arg, ULON return 0; }
+static NTSTATUS WINAPI wow64_NtUserCallOpenGLDebugMessageCallback( void *arg, ULONG size ) +{ + FIXME( "\n" ); + return 0; +} + static NTSTATUS WINAPI wow64_NtUserDriverCallbackFirst0( void *arg, ULONG size ) { return dispatch_callback( NtUserDriverCallbackFirst + 0, arg, size ); @@ -1085,6 +1091,8 @@ user_callback user_callbacks[] = /* Vulkan support */ wow64_NtUserCallVulkanDebugReportCallback, wow64_NtUserCallVulkanDebugUtilsCallback, + /* OpenGL support */ + wow64_NtUserCallOpenGLDebugMessageCallback, /* Driver-specific callbacks */ wow64_NtUserDriverCallbackFirst0, wow64_NtUserDriverCallbackFirst1, diff --git a/include/ntuser.h b/include/ntuser.h index 7759f2b3174..0e14ee3ccb0 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -52,6 +52,8 @@ enum /* Vulkan support */ NtUserCallVulkanDebugReportCallback, NtUserCallVulkanDebugUtilsCallback, + /* OpenGL support */ + NtUserCallOpenGLDebugMessageCallback, /* Driver-specific callbacks */ NtUserDriverCallbackFirst, NtUserDriverCallbackLast = NtUserDriverCallbackFirst + 9,
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/Makefile.in | 1 + dlls/opengl32/make_opengl | 14 + dlls/opengl32/opengl_ext.h | 56 ++++ dlls/opengl32/unix_wgl.c | 459 +++++++++++++++++++++++++++++ dlls/opengl32/unixlib.h | 14 + dlls/opengl32/wgl.c | 588 +------------------------------------ 6 files changed, 550 insertions(+), 582 deletions(-) create mode 100644 dlls/opengl32/unix_wgl.c
diff --git a/dlls/opengl32/Makefile.in b/dlls/opengl32/Makefile.in index 380a686f261..16f5ab17120 100644 --- a/dlls/opengl32/Makefile.in +++ b/dlls/opengl32/Makefile.in @@ -9,6 +9,7 @@ EXTRADLLFLAGS = -Wl,--image-base,0x7a800000 -mcygwin C_SRCS = \ thunks.c \ unix_thunks.c \ + unix_wgl.c \ wgl.c
RC_SRCS = version.rc diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 6c40c51c3e0..f178ba462d0 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -837,6 +837,20 @@ foreach (sort keys %ext_functions) } print OUT "};\n\n";
+print OUT "typedef void (WINAPI *gl_debug_cb)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *);\n"; +print OUT "struct wine_gl_debug_message_params\n"; +print OUT "{\n"; +print OUT " gl_debug_cb user_callback;\n"; +print OUT " const void *user_data;\n"; +print OUT "\n"; +print OUT " GLenum source;\n"; +print OUT " GLenum type;\n"; +print OUT " GLuint id;\n"; +print OUT " GLenum severity;\n"; +print OUT " GLsizei length;\n"; +print OUT " const GLchar *message;\n"; +print OUT "};\n\n"; + print OUT "typedef NTSTATUS (*unixlib_function_t)( void *args );\n"; print OUT "extern const unixlib_function_t __wine_unix_call_funcs[] DECLSPEC_HIDDEN;\n"; print OUT "#define UNIX_CALL( func, params ) __wine_unix_call_funcs[unix_ ## func]( params )\n"; diff --git a/dlls/opengl32/opengl_ext.h b/dlls/opengl32/opengl_ext.h index 7873c974cc7..2a579e142b6 100644 --- a/dlls/opengl32/opengl_ext.h +++ b/dlls/opengl32/opengl_ext.h @@ -19,9 +19,14 @@ #ifndef __DLLS_OPENGL32_OPENGL_EXT_H #define __DLLS_OPENGL32_OPENGL_EXT_H
+#include <stdarg.h> +#include <stddef.h> + #include "windef.h" #include "winbase.h" +#include "winternl.h" #include "wingdi.h" + #include "wine/wgl.h" #include "wine/wgl_driver.h"
@@ -43,6 +48,57 @@ static inline struct opengl_funcs *get_dc_funcs( HDC hdc ) return funcs; }
+#define MAX_WGL_HANDLES 1024 + +/* handle management */ + +enum wgl_handle_type +{ + HANDLE_PBUFFER = 0 << 12, + HANDLE_CONTEXT = 1 << 12, + HANDLE_CONTEXT_V3 = 3 << 12, + HANDLE_TYPE_MASK = 15 << 12 +}; + +struct opengl_context +{ + DWORD tid; /* thread that the context is current in */ + HDC draw_dc; /* current drawing DC */ + HDC read_dc; /* current reading DC */ + void (CALLBACK *debug_callback)( GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void * ); /* debug callback */ + const void *debug_user; /* debug user parameter */ + GLubyte *extensions; /* extension string */ + GLuint *disabled_exts; /* indices of disabled extensions */ + struct wgl_context *drv_ctx; /* driver context */ +}; + +struct wgl_handle +{ + UINT handle; + struct opengl_funcs *funcs; + union + { + struct opengl_context *context; /* for HANDLE_CONTEXT */ + struct wgl_pbuffer *pbuffer; /* for HANDLE_PBUFFER */ + struct wgl_handle *next; /* for free handles */ + } u; +}; + +extern struct wgl_handle wgl_handles[MAX_WGL_HANDLES]; + +/* the current context is assumed valid and doesn't need locking */ +static inline struct wgl_handle *get_current_context_ptr(void) +{ + if (!NtCurrentTeb()->glCurrentRC) return NULL; + return &wgl_handles[LOWORD(NtCurrentTeb()->glCurrentRC) & ~HANDLE_TYPE_MASK]; +} + +static inline enum wgl_handle_type get_current_context_type(void) +{ + if (!NtCurrentTeb()->glCurrentRC) return HANDLE_CONTEXT; + return LOWORD(NtCurrentTeb()->glCurrentRC) & HANDLE_TYPE_MASK; +} + extern int WINAPI wglDescribePixelFormat( HDC hdc, int ipfd, UINT cjpfd, PIXELFORMATDESCRIPTOR *ppfd );
#endif /* __DLLS_OPENGL32_OPENGL_EXT_H */ diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c new file mode 100644 index 00000000000..70ee0a5cdab --- /dev/null +++ b/dlls/opengl32/unix_wgl.c @@ -0,0 +1,459 @@ +/* Window-specific OpenGL functions implementation. + * + * Copyright (c) 1999 Lionel Ulmer + * Copyright (c) 2005 Raphael Junqueira + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" + +#include <stdarg.h> +#include <stdlib.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "ntuser.h" + +#include "opengl_ext.h" + +#include "unixlib.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wgl); + +struct wgl_handle wgl_handles[MAX_WGL_HANDLES]; +static struct wgl_handle *next_free; +static unsigned int handle_count; + +static CRITICAL_SECTION wgl_section; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &wgl_section, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": wgl_section") } +}; +static CRITICAL_SECTION wgl_section = { &critsect_debug, -1, 0, 0, 0, 0 }; + +static inline HANDLE next_handle( struct wgl_handle *ptr, enum wgl_handle_type type ) +{ + WORD generation = HIWORD( ptr->handle ) + 1; + if (!generation) generation++; + ptr->handle = MAKELONG( ptr - wgl_handles, generation ) | type; + return ULongToHandle( ptr->handle ); +} + +static struct wgl_handle *get_handle_ptr( HANDLE handle, enum wgl_handle_type type ) +{ + unsigned int index = LOWORD( handle ) & ~HANDLE_TYPE_MASK; + + EnterCriticalSection( &wgl_section ); + if (index < handle_count && ULongToHandle(wgl_handles[index].handle) == handle) + return &wgl_handles[index]; + + LeaveCriticalSection( &wgl_section ); + SetLastError( ERROR_INVALID_HANDLE ); + return NULL; +} + +static void release_handle_ptr( struct wgl_handle *ptr ) +{ + if (ptr) LeaveCriticalSection( &wgl_section ); +} + +static HANDLE alloc_handle( enum wgl_handle_type type, struct opengl_funcs *funcs, void *user_ptr ) +{ + HANDLE handle = 0; + struct wgl_handle *ptr = NULL; + + EnterCriticalSection( &wgl_section ); + if ((ptr = next_free)) + next_free = next_free->u.next; + else if (handle_count < MAX_WGL_HANDLES) + ptr = &wgl_handles[handle_count++]; + + if (ptr) + { + ptr->funcs = funcs; + ptr->u.context = user_ptr; + handle = next_handle( ptr, type ); + } + else SetLastError( ERROR_NOT_ENOUGH_MEMORY ); + LeaveCriticalSection( &wgl_section ); + return handle; +} + +static void free_handle_ptr( struct wgl_handle *ptr ) +{ + ptr->handle |= 0xffff; + ptr->u.next = next_free; + ptr->funcs = NULL; + next_free = ptr; + LeaveCriticalSection( &wgl_section ); +} + +BOOL WINAPI wglCopyContext( HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask ) +{ + struct wgl_handle *src, *dst; + BOOL ret = FALSE; + + if (!(src = get_handle_ptr( hglrcSrc, HANDLE_CONTEXT ))) return FALSE; + if ((dst = get_handle_ptr( hglrcDst, HANDLE_CONTEXT ))) + { + if (src->funcs != dst->funcs) SetLastError( ERROR_INVALID_HANDLE ); + else ret = src->funcs->wgl.p_wglCopyContext( src->u.context->drv_ctx, dst->u.context->drv_ctx, mask ); + } + release_handle_ptr( dst ); + release_handle_ptr( src ); + return ret; +} + +HGLRC WINAPI wglCreateContext( HDC hdc ) +{ + HGLRC ret = 0; + struct wgl_context *drv_ctx; + struct opengl_context *context; + struct opengl_funcs *funcs = get_dc_funcs( hdc ); + + if (!funcs) return 0; + if (!(drv_ctx = funcs->wgl.p_wglCreateContext( hdc ))) return 0; + if ((context = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*context) ))) + { + context->drv_ctx = drv_ctx; + if (!(ret = alloc_handle( HANDLE_CONTEXT, funcs, context ))) + HeapFree( GetProcessHeap(), 0, context ); + } + if (!ret) funcs->wgl.p_wglDeleteContext( drv_ctx ); + return ret; +} + +BOOL WINAPI wglDeleteContext( HGLRC hglrc ) +{ + struct wgl_handle *ptr = get_handle_ptr( hglrc, HANDLE_CONTEXT ); + + if (!ptr) return FALSE; + + if (ptr->u.context->tid && ptr->u.context->tid != GetCurrentThreadId()) + { + SetLastError( ERROR_BUSY ); + release_handle_ptr( ptr ); + return FALSE; + } + if (hglrc == NtCurrentTeb()->glCurrentRC) wglMakeCurrent( 0, 0 ); + ptr->funcs->wgl.p_wglDeleteContext( ptr->u.context->drv_ctx ); + HeapFree( GetProcessHeap(), 0, ptr->u.context->disabled_exts ); + HeapFree( GetProcessHeap(), 0, ptr->u.context->extensions ); + HeapFree( GetProcessHeap(), 0, ptr->u.context ); + free_handle_ptr( ptr ); + return TRUE; +} + +BOOL WINAPI wglMakeCurrent( HDC hdc, HGLRC hglrc ) +{ + BOOL ret = TRUE; + struct wgl_handle *ptr, *prev = get_current_context_ptr(); + + if (hglrc) + { + if (!(ptr = get_handle_ptr( hglrc, HANDLE_CONTEXT ))) return FALSE; + if (!ptr->u.context->tid || ptr->u.context->tid == GetCurrentThreadId()) + { + ret = ptr->funcs->wgl.p_wglMakeCurrent( hdc, ptr->u.context->drv_ctx ); + if (ret) + { + if (prev) prev->u.context->tid = 0; + ptr->u.context->tid = GetCurrentThreadId(); + ptr->u.context->draw_dc = hdc; + ptr->u.context->read_dc = hdc; + NtCurrentTeb()->glCurrentRC = hglrc; + NtCurrentTeb()->glTable = ptr->funcs; + } + } + else + { + SetLastError( ERROR_BUSY ); + ret = FALSE; + } + release_handle_ptr( ptr ); + } + else if (prev) + { + if (!prev->funcs->wgl.p_wglMakeCurrent( 0, NULL )) return FALSE; + prev->u.context->tid = 0; + NtCurrentTeb()->glCurrentRC = 0; + NtCurrentTeb()->glTable = &null_opengl_funcs; + } + else if (!hdc) + { + SetLastError( ERROR_INVALID_HANDLE ); + ret = FALSE; + } + return ret; +} + +BOOL WINAPI wglShareLists( HGLRC hglrcSrc, HGLRC hglrcDst ) +{ + BOOL ret = FALSE; + struct wgl_handle *src, *dst; + + if (!(src = get_handle_ptr( hglrcSrc, HANDLE_CONTEXT ))) return FALSE; + if ((dst = get_handle_ptr( hglrcDst, HANDLE_CONTEXT ))) + { + if (src->funcs != dst->funcs) SetLastError( ERROR_INVALID_HANDLE ); + else ret = src->funcs->wgl.p_wglShareLists( src->u.context->drv_ctx, dst->u.context->drv_ctx ); + } + release_handle_ptr( dst ); + release_handle_ptr( src ); + return ret; +} + +BOOL WINAPI wglBindTexImageARB( HPBUFFERARB handle, int buffer ) +{ + struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); + BOOL ret; + + if (!ptr) return FALSE; + ret = ptr->funcs->ext.p_wglBindTexImageARB( ptr->u.pbuffer, buffer ); + release_handle_ptr( ptr ); + return ret; +} + +HGLRC WINAPI wglCreateContextAttribsARB( HDC hdc, HGLRC share, const int *attribs ) +{ + HGLRC ret = 0; + struct wgl_context *drv_ctx; + struct wgl_handle *share_ptr = NULL; + struct opengl_context *context; + struct opengl_funcs *funcs = get_dc_funcs( hdc ); + + if (!funcs) + { + SetLastError( ERROR_DC_NOT_FOUND ); + return 0; + } + if (!funcs->ext.p_wglCreateContextAttribsARB) return 0; + if (share && !(share_ptr = get_handle_ptr( share, HANDLE_CONTEXT ))) + { + SetLastError( ERROR_INVALID_OPERATION ); + return 0; + } + if ((drv_ctx = funcs->ext.p_wglCreateContextAttribsARB( hdc, share_ptr ? share_ptr->u.context->drv_ctx : NULL, attribs ))) + { + if ((context = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*context) ))) + { + enum wgl_handle_type type = HANDLE_CONTEXT; + + if (attribs) + { + while (*attribs) + { + if (attribs[0] == WGL_CONTEXT_MAJOR_VERSION_ARB) + { + if (attribs[1] >= 3) type = HANDLE_CONTEXT_V3; + break; + } + attribs += 2; + } + } + + context->drv_ctx = drv_ctx; + if (!(ret = alloc_handle( type, funcs, context ))) HeapFree( GetProcessHeap(), 0, context ); + } + if (!ret) funcs->wgl.p_wglDeleteContext( drv_ctx ); + } + + release_handle_ptr( share_ptr ); + return ret; +} + +HPBUFFERARB WINAPI wglCreatePbufferARB( HDC hdc, int format, int width, int height, const int *attribs ) +{ + HPBUFFERARB ret; + struct wgl_pbuffer *pbuffer; + struct opengl_funcs *funcs = get_dc_funcs( hdc ); + + if (!funcs || !funcs->ext.p_wglCreatePbufferARB) return 0; + if (!(pbuffer = funcs->ext.p_wglCreatePbufferARB( hdc, format, width, height, attribs ))) return 0; + ret = alloc_handle( HANDLE_PBUFFER, funcs, pbuffer ); + if (!ret) funcs->ext.p_wglDestroyPbufferARB( pbuffer ); + return ret; +} + +BOOL WINAPI wglDestroyPbufferARB( HPBUFFERARB handle ) +{ + struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); + + if (!ptr) return FALSE; + ptr->funcs->ext.p_wglDestroyPbufferARB( ptr->u.pbuffer ); + free_handle_ptr( ptr ); + return TRUE; +} + +HDC WINAPI wglGetPbufferDCARB( HPBUFFERARB handle ) +{ + struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); + HDC ret; + + if (!ptr) return 0; + ret = ptr->funcs->ext.p_wglGetPbufferDCARB( ptr->u.pbuffer ); + release_handle_ptr( ptr ); + return ret; +} + +BOOL WINAPI wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC hglrc ) +{ + BOOL ret = TRUE; + struct wgl_handle *ptr, *prev = get_current_context_ptr(); + + if (hglrc) + { + if (!(ptr = get_handle_ptr( hglrc, HANDLE_CONTEXT ))) return FALSE; + if (!ptr->u.context->tid || ptr->u.context->tid == GetCurrentThreadId()) + { + ret = (ptr->funcs->ext.p_wglMakeContextCurrentARB && + ptr->funcs->ext.p_wglMakeContextCurrentARB( draw_hdc, read_hdc, ptr->u.context->drv_ctx )); + if (ret) + { + if (prev) prev->u.context->tid = 0; + ptr->u.context->tid = GetCurrentThreadId(); + ptr->u.context->draw_dc = draw_hdc; + ptr->u.context->read_dc = read_hdc; + NtCurrentTeb()->glCurrentRC = hglrc; + NtCurrentTeb()->glTable = ptr->funcs; + } + } + else + { + SetLastError( ERROR_BUSY ); + ret = FALSE; + } + release_handle_ptr( ptr ); + } + else if (prev) + { + if (!prev->funcs->wgl.p_wglMakeCurrent( 0, NULL )) return FALSE; + prev->u.context->tid = 0; + NtCurrentTeb()->glCurrentRC = 0; + NtCurrentTeb()->glTable = &null_opengl_funcs; + } + return ret; +} + +BOOL WINAPI wglQueryPbufferARB( HPBUFFERARB handle, int attrib, int *value ) +{ + struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); + BOOL ret; + + if (!ptr) return FALSE; + ret = ptr->funcs->ext.p_wglQueryPbufferARB( ptr->u.pbuffer, attrib, value ); + release_handle_ptr( ptr ); + return ret; +} + +int WINAPI wglReleasePbufferDCARB( HPBUFFERARB handle, HDC hdc ) +{ + struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); + BOOL ret; + + if (!ptr) return FALSE; + ret = ptr->funcs->ext.p_wglReleasePbufferDCARB( ptr->u.pbuffer, hdc ); + release_handle_ptr( ptr ); + return ret; +} + +BOOL WINAPI wglReleaseTexImageARB( HPBUFFERARB handle, int buffer ) +{ + struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); + BOOL ret; + + if (!ptr) return FALSE; + ret = ptr->funcs->ext.p_wglReleaseTexImageARB( ptr->u.pbuffer, buffer ); + release_handle_ptr( ptr ); + return ret; +} + +BOOL WINAPI wglSetPbufferAttribARB( HPBUFFERARB handle, const int *attribs ) +{ + struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); + BOOL ret; + + if (!ptr) return FALSE; + ret = ptr->funcs->ext.p_wglSetPbufferAttribARB( ptr->u.pbuffer, attribs ); + release_handle_ptr( ptr ); + return ret; +} + +static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GLenum severity, + GLsizei length, const GLchar *message, const void *userParam ) +{ + struct wine_gl_debug_message_params params = + { + .source = source, + .type = type, + .id = id, + .severity = severity, + .length = length, + .message = message, + }; + BOOL (WINAPI *callback)( struct wine_gl_debug_message_params *params, ULONG size ); + void **kernel_callback_table; + + struct wgl_handle *ptr = (struct wgl_handle *)userParam; + if (!(params.user_callback = ptr->u.context->debug_callback)) return; + params.user_data = ptr->u.context->debug_user; + + kernel_callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; + callback = kernel_callback_table[NtUserCallOpenGLDebugMessageCallback]; + callback( ¶ms, sizeof(params) ); +} + +void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam ) +{ + struct wgl_handle *ptr = get_current_context_ptr(); + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + + TRACE( "(%p, %p)\n", callback, userParam ); + + ptr->u.context->debug_callback = callback; + ptr->u.context->debug_user = userParam; + funcs->ext.p_glDebugMessageCallback( gl_debug_message_callback, ptr ); +} + +void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam ) +{ + struct wgl_handle *ptr = get_current_context_ptr(); + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + + TRACE( "(%p, %p)\n", callback, userParam ); + + ptr->u.context->debug_callback = callback; + ptr->u.context->debug_user = userParam; + funcs->ext.p_glDebugMessageCallbackAMD( gl_debug_message_callback, ptr ); +} + +void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam ) +{ + struct wgl_handle *ptr = get_current_context_ptr(); + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + + TRACE( "(%p, %p)\n", callback, userParam ); + + ptr->u.context->debug_callback = callback; + ptr->u.context->debug_user = userParam; + funcs->ext.p_glDebugMessageCallbackARB( gl_debug_message_callback, ptr ); +} diff --git a/dlls/opengl32/unixlib.h b/dlls/opengl32/unixlib.h index 88b744d0f10..68e66b47a3a 100644 --- a/dlls/opengl32/unixlib.h +++ b/dlls/opengl32/unixlib.h @@ -25335,6 +25335,20 @@ enum unix_funcs unix_wglSwapIntervalEXT, };
+typedef void (WINAPI *gl_debug_cb)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *); +struct wine_gl_debug_message_params +{ + gl_debug_cb user_callback; + const void *user_data; + + GLenum source; + GLenum type; + GLuint id; + GLenum severity; + GLsizei length; + const GLchar *message; +}; + typedef NTSTATUS (*unixlib_function_t)( void *args ); extern const unixlib_function_t __wine_unix_call_funcs[] DECLSPEC_HIDDEN; #define UNIX_CALL( func, params ) __wine_unix_call_funcs[unix_ ## func]( params ) diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index cf0b8e0330f..d5b0a78b916 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -41,319 +41,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(wgl); WINE_DECLARE_DEBUG_CHANNEL(fps);
-/* handle management */ - -#define MAX_WGL_HANDLES 1024 - -enum wgl_handle_type -{ - HANDLE_PBUFFER = 0 << 12, - HANDLE_CONTEXT = 1 << 12, - HANDLE_CONTEXT_V3 = 3 << 12, - HANDLE_TYPE_MASK = 15 << 12 -}; - -struct opengl_context -{ - DWORD tid; /* thread that the context is current in */ - HDC draw_dc; /* current drawing DC */ - HDC read_dc; /* current reading DC */ - void (CALLBACK *debug_callback)(GLenum, GLenum, GLuint, GLenum, - GLsizei, const GLchar *, const void *); /* debug callback */ - const void *debug_user; /* debug user parameter */ - GLubyte *extensions; /* extension string */ - GLuint *disabled_exts; /* indices of disabled extensions */ - struct wgl_context *drv_ctx; /* driver context */ -}; - -struct wgl_handle -{ - UINT handle; - struct opengl_funcs *funcs; - union - { - struct opengl_context *context; /* for HANDLE_CONTEXT */ - struct wgl_pbuffer *pbuffer; /* for HANDLE_PBUFFER */ - struct wgl_handle *next; /* for free handles */ - } u; -}; - -static struct wgl_handle wgl_handles[MAX_WGL_HANDLES]; -static struct wgl_handle *next_free; -static unsigned int handle_count; - -static CRITICAL_SECTION wgl_section; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &wgl_section, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": wgl_section") } -}; -static CRITICAL_SECTION wgl_section = { &critsect_debug, -1, 0, 0, 0, 0 }; - static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
-static inline HANDLE next_handle( struct wgl_handle *ptr, enum wgl_handle_type type ) -{ - WORD generation = HIWORD( ptr->handle ) + 1; - if (!generation) generation++; - ptr->handle = MAKELONG( ptr - wgl_handles, generation ) | type; - return ULongToHandle( ptr->handle ); -} - -/* the current context is assumed valid and doesn't need locking */ -static inline struct wgl_handle *get_current_context_ptr(void) -{ - if (!NtCurrentTeb()->glCurrentRC) return NULL; - return &wgl_handles[LOWORD(NtCurrentTeb()->glCurrentRC) & ~HANDLE_TYPE_MASK]; -} - -static struct wgl_handle *get_handle_ptr( HANDLE handle, enum wgl_handle_type type ) -{ - unsigned int index = LOWORD( handle ) & ~HANDLE_TYPE_MASK; - - EnterCriticalSection( &wgl_section ); - if (index < handle_count && ULongToHandle(wgl_handles[index].handle) == handle) - return &wgl_handles[index]; - - LeaveCriticalSection( &wgl_section ); - SetLastError( ERROR_INVALID_HANDLE ); - return NULL; -} - -static void release_handle_ptr( struct wgl_handle *ptr ) -{ - if (ptr) LeaveCriticalSection( &wgl_section ); -} - -static HANDLE alloc_handle( enum wgl_handle_type type, struct opengl_funcs *funcs, void *user_ptr ) -{ - HANDLE handle = 0; - struct wgl_handle *ptr = NULL; - - EnterCriticalSection( &wgl_section ); - if ((ptr = next_free)) - next_free = next_free->u.next; - else if (handle_count < MAX_WGL_HANDLES) - ptr = &wgl_handles[handle_count++]; - - if (ptr) - { - ptr->funcs = funcs; - ptr->u.context = user_ptr; - handle = next_handle( ptr, type ); - } - else SetLastError( ERROR_NOT_ENOUGH_MEMORY ); - LeaveCriticalSection( &wgl_section ); - return handle; -} - -static void free_handle_ptr( struct wgl_handle *ptr ) -{ - ptr->handle |= 0xffff; - ptr->u.next = next_free; - ptr->funcs = NULL; - next_free = ptr; - LeaveCriticalSection( &wgl_section ); -} - -static inline enum wgl_handle_type get_current_context_type(void) -{ - if (!NtCurrentTeb()->glCurrentRC) return HANDLE_CONTEXT; - return LOWORD(NtCurrentTeb()->glCurrentRC) & HANDLE_TYPE_MASK; -} - -/*********************************************************************** - * wglCopyContext (OPENGL32.@) - */ -BOOL WINAPI wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask) -{ - struct wgl_handle *src, *dst; - BOOL ret = FALSE; - - if (!(src = get_handle_ptr( hglrcSrc, HANDLE_CONTEXT ))) return FALSE; - if ((dst = get_handle_ptr( hglrcDst, HANDLE_CONTEXT ))) - { - if (src->funcs != dst->funcs) SetLastError( ERROR_INVALID_HANDLE ); - else ret = src->funcs->wgl.p_wglCopyContext( src->u.context->drv_ctx, - dst->u.context->drv_ctx, mask ); - } - release_handle_ptr( dst ); - release_handle_ptr( src ); - return ret; -} - -/*********************************************************************** - * wglDeleteContext (OPENGL32.@) - */ -BOOL WINAPI wglDeleteContext(HGLRC hglrc) -{ - struct wgl_handle *ptr = get_handle_ptr( hglrc, HANDLE_CONTEXT ); - - if (!ptr) return FALSE; - - if (ptr->u.context->tid && ptr->u.context->tid != GetCurrentThreadId()) - { - SetLastError( ERROR_BUSY ); - release_handle_ptr( ptr ); - return FALSE; - } - if (hglrc == NtCurrentTeb()->glCurrentRC) wglMakeCurrent( 0, 0 ); - ptr->funcs->wgl.p_wglDeleteContext( ptr->u.context->drv_ctx ); - HeapFree( GetProcessHeap(), 0, ptr->u.context->disabled_exts ); - HeapFree( GetProcessHeap(), 0, ptr->u.context->extensions ); - HeapFree( GetProcessHeap(), 0, ptr->u.context ); - free_handle_ptr( ptr ); - return TRUE; -} - -/*********************************************************************** - * wglMakeCurrent (OPENGL32.@) - */ -BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc) -{ - BOOL ret = TRUE; - struct wgl_handle *ptr, *prev = get_current_context_ptr(); - - if (hglrc) - { - if (!(ptr = get_handle_ptr( hglrc, HANDLE_CONTEXT ))) return FALSE; - if (!ptr->u.context->tid || ptr->u.context->tid == GetCurrentThreadId()) - { - ret = ptr->funcs->wgl.p_wglMakeCurrent( hdc, ptr->u.context->drv_ctx ); - if (ret) - { - if (prev) prev->u.context->tid = 0; - ptr->u.context->tid = GetCurrentThreadId(); - ptr->u.context->draw_dc = hdc; - ptr->u.context->read_dc = hdc; - NtCurrentTeb()->glCurrentRC = hglrc; - NtCurrentTeb()->glTable = ptr->funcs; - } - } - else - { - SetLastError( ERROR_BUSY ); - ret = FALSE; - } - release_handle_ptr( ptr ); - } - else if (prev) - { - if (!prev->funcs->wgl.p_wglMakeCurrent( 0, NULL )) return FALSE; - prev->u.context->tid = 0; - NtCurrentTeb()->glCurrentRC = 0; - NtCurrentTeb()->glTable = &null_opengl_funcs; - } - else if (!hdc) - { - SetLastError( ERROR_INVALID_HANDLE ); - ret = FALSE; - } - return ret; -} - -/*********************************************************************** - * wglCreateContextAttribsARB - * - * Provided by the WGL_ARB_create_context extension. - */ -HGLRC WINAPI wglCreateContextAttribsARB( HDC hdc, HGLRC share, const int *attribs ) -{ - HGLRC ret = 0; - struct wgl_context *drv_ctx; - struct wgl_handle *share_ptr = NULL; - struct opengl_context *context; - struct opengl_funcs *funcs = get_dc_funcs( hdc ); - - if (!funcs) - { - SetLastError( ERROR_DC_NOT_FOUND ); - return 0; - } - if (!funcs->ext.p_wglCreateContextAttribsARB) return 0; - if (share && !(share_ptr = get_handle_ptr( share, HANDLE_CONTEXT ))) - { - SetLastError( ERROR_INVALID_OPERATION ); - return 0; - } - if ((drv_ctx = funcs->ext.p_wglCreateContextAttribsARB( hdc, - share_ptr ? share_ptr->u.context->drv_ctx : NULL, attribs ))) - { - if ((context = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*context) ))) - { - enum wgl_handle_type type = HANDLE_CONTEXT; - - if (attribs) - { - while (*attribs) - { - if (attribs[0] == WGL_CONTEXT_MAJOR_VERSION_ARB) - { - if (attribs[1] >= 3) - type = HANDLE_CONTEXT_V3; - break; - } - attribs += 2; - } - } - - context->drv_ctx = drv_ctx; - if (!(ret = alloc_handle( type, funcs, context ))) - HeapFree( GetProcessHeap(), 0, context ); - } - if (!ret) funcs->wgl.p_wglDeleteContext( drv_ctx ); - } - release_handle_ptr( share_ptr ); - return ret; - -} - -/*********************************************************************** - * wglMakeContextCurrentARB - * - * Provided by the WGL_ARB_make_current_read extension. - */ -BOOL WINAPI wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC hglrc ) -{ - BOOL ret = TRUE; - struct wgl_handle *ptr, *prev = get_current_context_ptr(); - - if (hglrc) - { - if (!(ptr = get_handle_ptr( hglrc, HANDLE_CONTEXT ))) return FALSE; - if (!ptr->u.context->tid || ptr->u.context->tid == GetCurrentThreadId()) - { - ret = (ptr->funcs->ext.p_wglMakeContextCurrentARB && - ptr->funcs->ext.p_wglMakeContextCurrentARB( draw_hdc, read_hdc, - ptr->u.context->drv_ctx )); - if (ret) - { - if (prev) prev->u.context->tid = 0; - ptr->u.context->tid = GetCurrentThreadId(); - ptr->u.context->draw_dc = draw_hdc; - ptr->u.context->read_dc = read_hdc; - NtCurrentTeb()->glCurrentRC = hglrc; - NtCurrentTeb()->glTable = ptr->funcs; - } - } - else - { - SetLastError( ERROR_BUSY ); - ret = FALSE; - } - release_handle_ptr( ptr ); - } - else if (prev) - { - if (!prev->funcs->wgl.p_wglMakeCurrent( 0, NULL )) return FALSE; - prev->u.context->tid = 0; - NtCurrentTeb()->glCurrentRC = 0; - NtCurrentTeb()->glTable = &null_opengl_funcs; - } - return ret; -} - /*********************************************************************** * wglGetCurrentReadDCARB * @@ -367,25 +56,6 @@ HDC WINAPI wglGetCurrentReadDCARB(void) return ptr->u.context->read_dc; }
-/*********************************************************************** - * wglShareLists (OPENGL32.@) - */ -BOOL WINAPI wglShareLists(HGLRC hglrcSrc, HGLRC hglrcDst) -{ - BOOL ret = FALSE; - struct wgl_handle *src, *dst; - - if (!(src = get_handle_ptr( hglrcSrc, HANDLE_CONTEXT ))) return FALSE; - if ((dst = get_handle_ptr( hglrcDst, HANDLE_CONTEXT ))) - { - if (src->funcs != dst->funcs) SetLastError( ERROR_INVALID_HANDLE ); - else ret = src->funcs->wgl.p_wglShareLists( src->u.context->drv_ctx, dst->u.context->drv_ctx ); - } - release_handle_ptr( dst ); - release_handle_ptr( src ); - return ret; -} - /*********************************************************************** * wglGetCurrentDC (OPENGL32.@) */ @@ -397,36 +67,6 @@ HDC WINAPI wglGetCurrentDC(void) return ptr->u.context->draw_dc; }
-/*********************************************************************** - * wgl_create_context wrapper for hooking - */ -static HGLRC wgl_create_context(HDC hdc) -{ - HGLRC ret = 0; - struct wgl_context *drv_ctx; - struct opengl_context *context; - struct opengl_funcs *funcs = get_dc_funcs( hdc ); - - if (!funcs) return 0; - if (!(drv_ctx = funcs->wgl.p_wglCreateContext( hdc ))) return 0; - if ((context = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*context) ))) - { - context->drv_ctx = drv_ctx; - if (!(ret = alloc_handle( HANDLE_CONTEXT, funcs, context ))) - HeapFree( GetProcessHeap(), 0, context ); - } - if (!ret) funcs->wgl.p_wglDeleteContext( drv_ctx ); - return ret; -} - -/*********************************************************************** - * wglCreateContext (OPENGL32.@) - */ -HGLRC WINAPI wglCreateContext(HDC hdc) -{ - return wgl_create_context(hdc); -} - /*********************************************************************** * wglGetCurrentContext (OPENGL32.@) */ @@ -658,16 +298,14 @@ BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers( HDC hdc ) /*********************************************************************** * wglCreateLayerContext (OPENGL32.@) */ -HGLRC WINAPI wglCreateLayerContext(HDC hdc, - int iLayerPlane) { - TRACE("(%p,%d)\n", hdc, iLayerPlane); +HGLRC WINAPI wglCreateLayerContext( HDC hdc, int iLayerPlane ) +{ + TRACE("(%p,%d)\n", hdc, iLayerPlane);
- if (iLayerPlane == 0) { - return wgl_create_context(hdc); - } - FIXME("no handler for layer %d\n", iLayerPlane); + if (iLayerPlane == 0) return wglCreateContext( hdc );
- return NULL; + FIXME("no handler for layer %d\n", iLayerPlane); + return NULL; }
/*********************************************************************** @@ -1096,135 +734,6 @@ BOOL WINAPI wglSwapLayerBuffers(HDC hdc, return TRUE; }
-/*********************************************************************** - * wglBindTexImageARB - * - * Provided by the WGL_ARB_render_texture extension. - */ -BOOL WINAPI wglBindTexImageARB( HPBUFFERARB handle, int buffer ) -{ - struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); - BOOL ret; - - if (!ptr) return FALSE; - ret = ptr->funcs->ext.p_wglBindTexImageARB( ptr->u.pbuffer, buffer ); - release_handle_ptr( ptr ); - return ret; -} - -/*********************************************************************** - * wglReleaseTexImageARB - * - * Provided by the WGL_ARB_render_texture extension. - */ -BOOL WINAPI wglReleaseTexImageARB( HPBUFFERARB handle, int buffer ) -{ - struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); - BOOL ret; - - if (!ptr) return FALSE; - ret = ptr->funcs->ext.p_wglReleaseTexImageARB( ptr->u.pbuffer, buffer ); - release_handle_ptr( ptr ); - return ret; -} - -/*********************************************************************** - * wglSetPbufferAttribARB - * - * Provided by the WGL_ARB_render_texture extension. - */ -BOOL WINAPI wglSetPbufferAttribARB( HPBUFFERARB handle, const int *attribs ) -{ - struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); - BOOL ret; - - if (!ptr) return FALSE; - ret = ptr->funcs->ext.p_wglSetPbufferAttribARB( ptr->u.pbuffer, attribs ); - release_handle_ptr( ptr ); - return ret; -} - -/*********************************************************************** - * wglCreatePbufferARB - * - * Provided by the WGL_ARB_pbuffer extension. - */ -HPBUFFERARB WINAPI wglCreatePbufferARB( HDC hdc, int format, int width, int height, const int *attribs ) -{ - HPBUFFERARB ret; - struct wgl_pbuffer *pbuffer; - struct opengl_funcs *funcs = get_dc_funcs( hdc ); - - if (!funcs || !funcs->ext.p_wglCreatePbufferARB) return 0; - if (!(pbuffer = funcs->ext.p_wglCreatePbufferARB( hdc, format, width, height, attribs ))) return 0; - ret = alloc_handle( HANDLE_PBUFFER, funcs, pbuffer ); - if (!ret) funcs->ext.p_wglDestroyPbufferARB( pbuffer ); - return ret; -} - -/*********************************************************************** - * wglGetPbufferDCARB - * - * Provided by the WGL_ARB_pbuffer extension. - */ -HDC WINAPI wglGetPbufferDCARB( HPBUFFERARB handle ) -{ - struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); - HDC ret; - - if (!ptr) return 0; - ret = ptr->funcs->ext.p_wglGetPbufferDCARB( ptr->u.pbuffer ); - release_handle_ptr( ptr ); - return ret; -} - -/*********************************************************************** - * wglReleasePbufferDCARB - * - * Provided by the WGL_ARB_pbuffer extension. - */ -int WINAPI wglReleasePbufferDCARB( HPBUFFERARB handle, HDC hdc ) -{ - struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); - BOOL ret; - - if (!ptr) return FALSE; - ret = ptr->funcs->ext.p_wglReleasePbufferDCARB( ptr->u.pbuffer, hdc ); - release_handle_ptr( ptr ); - return ret; -} - -/*********************************************************************** - * wglDestroyPbufferARB - * - * Provided by the WGL_ARB_pbuffer extension. - */ -BOOL WINAPI wglDestroyPbufferARB( HPBUFFERARB handle ) -{ - struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); - - if (!ptr) return FALSE; - ptr->funcs->ext.p_wglDestroyPbufferARB( ptr->u.pbuffer ); - free_handle_ptr( ptr ); - return TRUE; -} - -/*********************************************************************** - * wglQueryPbufferARB - * - * Provided by the WGL_ARB_pbuffer extension. - */ -BOOL WINAPI wglQueryPbufferARB( HPBUFFERARB handle, int attrib, int *value ) -{ - struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); - BOOL ret; - - if (!ptr) return FALSE; - ret = ptr->funcs->ext.p_wglQueryPbufferARB( ptr->u.pbuffer, attrib, value ); - release_handle_ptr( ptr ); - return ret; -} - /*********************************************************************** * wglUseFontBitmaps_common */ @@ -1707,22 +1216,6 @@ const GLubyte * WINAPI glGetString( GLenum name ) return args.ret; }
-/* wrapper for glDebugMessageCallback* functions */ -typedef void (WINAPI *gl_debug_cb)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *); - -struct wine_gl_debug_message_params -{ - gl_debug_cb user_callback; - const void *user_data; - - GLenum source; - GLenum type; - GLuint id; - GLenum severity; - GLsizei length; - const GLchar *message; -}; - static BOOL WINAPI call_opengl_debug_message_callback( struct wine_gl_debug_message_params *params, ULONG size ) { params->user_callback( params->source, params->type, params->id, params->severity, @@ -1730,75 +1223,6 @@ static BOOL WINAPI call_opengl_debug_message_callback( struct wine_gl_debug_mess return TRUE; }
-static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GLenum severity, - GLsizei length, const GLchar *message, const void *userParam ) -{ - struct wine_gl_debug_message_params params = - { - .source = source, - .type = type, - .id = id, - .severity = severity, - .length = length, - .message = message, - }; - void **kernel_callback_table; - BOOL (WINAPI *callback)( struct wine_gl_debug_message_params *params, ULONG size ); - - struct wgl_handle *ptr = (struct wgl_handle *)userParam; - if (!(params.user_callback = ptr->u.context->debug_callback)) return; - params.user_data = ptr->u.context->debug_user; - - kernel_callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; - callback = kernel_callback_table[NtUserCallOpenGLDebugMessageCallback]; - callback( ¶ms, sizeof(params) ); -} - -/*********************************************************************** - * glDebugMessageCallback - */ -void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam ) -{ - struct wgl_handle *ptr = get_current_context_ptr(); - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - - TRACE( "(%p, %p)\n", callback, userParam ); - - ptr->u.context->debug_callback = callback; - ptr->u.context->debug_user = userParam; - funcs->ext.p_glDebugMessageCallback( gl_debug_message_callback, ptr ); -} - -/*********************************************************************** - * glDebugMessageCallbackAMD - */ -void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam ) -{ - struct wgl_handle *ptr = get_current_context_ptr(); - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - - TRACE( "(%p, %p)\n", callback, userParam ); - - ptr->u.context->debug_callback = callback; - ptr->u.context->debug_user = userParam; - funcs->ext.p_glDebugMessageCallbackAMD( gl_debug_message_callback, ptr ); -} - -/*********************************************************************** - * glDebugMessageCallbackARB - */ -void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam ) -{ - struct wgl_handle *ptr = get_current_context_ptr(); - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - - TRACE( "(%p, %p)\n", callback, userParam ); - - ptr->u.context->debug_callback = callback; - ptr->u.context->debug_user = userParam; - funcs->ext.p_glDebugMessageCallbackARB( gl_debug_message_callback, ptr ); -} - /*********************************************************************** * OpenGL initialisation routine */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/make_opengl | 90 +++++++++++-------- dlls/opengl32/thunks.c | 172 +++++++++++++++++++++++++++++++++--- dlls/opengl32/unix_thunks.c | 166 ++++------------------------------ dlls/opengl32/unix_wgl.c | 168 ++++++++++++++++++++++++++++++----- 4 files changed, 374 insertions(+), 222 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index f178ba462d0..78368ec6c2f 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -140,6 +140,36 @@ my %khronos_types = "khronos_uint32_t" => "unsigned int", "khronos_float_t" => "float", ); + +my %manual_win_functions = + ( + "glDebugEntry" => 1, + "wglChoosePixelFormat" => 1, + "wglCreateLayerContext" => 1, + "wglDescribeLayerPlane" => 1, + "wglGetCurrentContext" => 1, + "wglGetCurrentDC" => 1, + "wglGetDefaultProcAddress" => 1, + "wglGetLayerPaletteEntries" => 1, + "wglRealizeLayerPalette" => 1, + "wglSetLayerPaletteEntries" => 1, + "wglSwapLayerBuffers" => 1, + "wglUseFontBitmapsA" => 1, + "wglUseFontBitmapsW" => 1, + "wglUseFontOutlinesA" => 1, + "wglUseFontOutlinesW" => 1, + ); +my %manual_win_thunks = + ( + "glGetIntegerv" => 1, + "glGetString" => 1, + "glGetStringi" => 1, + "wglGetCurrentReadDCARB" => 1, + "wglGetPixelFormat" => 1, + "wglGetProcAddress" => 1, + "wglSwapBuffers" => 1, + ); + # # Used to convert some types # @@ -419,25 +449,6 @@ my %wgl_functions; my %gl_enums; my (%gl_types, @gl_types); # also use an array to preserve declaration order
-my %manual_win_functions = - ( - "glDebugEntry" => 1, - "wglChoosePixelFormat" => 1, - "wglCreateLayerContext" => 1, - "wglDescribeLayerPlane" => 1, - "wglGetCurrentContext" => 1, - "wglGetCurrentDC" => 1, - "wglGetDefaultProcAddress" => 1, - "wglGetLayerPaletteEntries" => 1, - "wglRealizeLayerPalette" => 1, - "wglSetLayerPaletteEntries" => 1, - "wglSwapLayerBuffers" => 1, - "wglUseFontBitmapsA" => 1, - "wglUseFontBitmapsW" => 1, - "wglUseFontOutlinesA" => 1, - "wglUseFontOutlinesW" => 1, - ); - my %remapped_wgl_functions = ( "ChoosePixelFormat" => "wglChoosePixelFormat", @@ -498,23 +509,10 @@ sub is_supported_api($) # some functions need a hand-written wrapper sub needs_wrapper($$) { - my %funcs = - ( - "glDebugEntry" => 1, - "glDebugMessageCallback" => 1, - "glDebugMessageCallbackAMD" => 1, - "glDebugMessageCallbackARB" => 1, - "glGetIntegerv" => 1, - "glGetString" => 1, - "glGetStringi" => 1, - "wglGetCurrentReadDCARB" => 1, - "wglGetPixelFormat" => 1, - "wglGetProcAddress" => 1, - "wglSwapBuffers" => 1, - ); my ($name, $func) = @_;
- return 1 if defined $funcs{$name}; + return 1 if $name =~ /^glDebugMessageCallback/; + # check if return value needs special handling (my $type = $func->[0]->textContent()) =~ s/ $//; return 1 if defined $remap_types{$type}; @@ -881,26 +879,26 @@ print OUT "WINE_DEFAULT_DEBUG_CHANNEL(opengl);\n"; foreach (sort keys %wgl_functions) { next if defined $manual_win_functions{$_}; - next if needs_wrapper( $_, $wgl_functions{$_} ); + next if defined $manual_win_thunks{$_}; print OUT "\n" . generate_win_thunk($_, $wgl_functions{$_}); } foreach (sort keys %norm_functions) { next if defined $manual_win_functions{$_}; - next if needs_wrapper( $_, $norm_functions{$_} ); + next if defined $manual_win_thunks{$_}; print OUT "\n" . generate_win_thunk($_, $norm_functions{$_}); } foreach (sort keys %ext_functions) { next if defined $manual_win_functions{$_}; - next if needs_wrapper( $_, $ext_functions{$_} ); + next if defined $manual_win_thunks{$_}; print OUT "\nstatic " . generate_win_thunk($_, $ext_functions{$_}); } print OUT "\n";
foreach (sort keys %ext_functions) { - next unless defined $manual_win_functions{$_} || needs_wrapper( $_, $ext_functions{$_} ); + next unless defined $manual_win_functions{$_} || $manual_win_thunks{$_}; my $decl_args = get_func_args( $ext_functions{$_}, 1, 0, "" ); my $func_ret = get_func_ret( $ext_functions{$_}, 0 ); printf OUT "extern %s WINAPI %s(%s) DECLSPEC_HIDDEN;\n", $func_ret, $_, $decl_args; @@ -941,6 +939,21 @@ print OUT "#include "opengl_ext.h"\n\n"; foreach (sort keys %wgl_functions) { next if defined $manual_win_functions{$_}; + next unless needs_wrapper( $_, $wgl_functions{$_} ); + print OUT "extern NTSTATUS wgl_$_( void *args ) DECLSPEC_HIDDEN;\n"; +} +foreach (sort keys %ext_functions) +{ + next if defined $manual_win_functions{$_}; + next unless needs_wrapper( $_, $ext_functions{$_} ); + print OUT "extern NTSTATUS ext_$_( void *args ) DECLSPEC_HIDDEN;\n"; +} +print OUT "\n"; + +foreach (sort keys %wgl_functions) +{ + next if defined $manual_win_functions{$_}; + next if needs_wrapper( $_, $wgl_functions{$_} ); print OUT generate_unix_thunk($_, $wgl_functions{$_}, "wgl"); } foreach (sort keys %norm_functions) @@ -951,6 +964,7 @@ foreach (sort keys %norm_functions) foreach (sort keys %ext_functions) { next if defined $manual_win_functions{$_}; + next if needs_wrapper( $_, $ext_functions{$_} ); print OUT generate_unix_thunk($_, $ext_functions{$_}, "ext"); }
diff --git a/dlls/opengl32/thunks.c b/dlls/opengl32/thunks.c index b54a2952975..a2a78bff97d 100644 --- a/dlls/opengl32/thunks.c +++ b/dlls/opengl32/thunks.c @@ -17,6 +17,33 @@
WINE_DEFAULT_DEBUG_CHANNEL(opengl);
+BOOL WINAPI wglCopyContext( HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask ) +{ + struct wglCopyContext_params args = { .hglrcSrc = hglrcSrc, .hglrcDst = hglrcDst, .mask = mask, }; + NTSTATUS status; + TRACE( "hglrcSrc %p, hglrcDst %p, mask %u\n", hglrcSrc, hglrcDst, mask ); + if ((status = UNIX_CALL( wglCopyContext, &args ))) WARN( "wglCopyContext returned %#x\n", status ); + return args.ret; +} + +HGLRC WINAPI wglCreateContext( HDC hDc ) +{ + struct wglCreateContext_params args = { .hDc = hDc, }; + NTSTATUS status; + TRACE( "hDc %p\n", hDc ); + if ((status = UNIX_CALL( wglCreateContext, &args ))) WARN( "wglCreateContext returned %#x\n", status ); + return args.ret; +} + +BOOL WINAPI wglDeleteContext( HGLRC oldContext ) +{ + struct wglDeleteContext_params args = { .oldContext = oldContext, }; + NTSTATUS status; + TRACE( "oldContext %p\n", oldContext ); + if ((status = UNIX_CALL( wglDeleteContext, &args ))) WARN( "wglDeleteContext returned %#x\n", status ); + return args.ret; +} + int WINAPI wglDescribePixelFormat( HDC hdc, int ipfd, UINT cjpfd, PIXELFORMATDESCRIPTOR *ppfd ) { struct wglDescribePixelFormat_params args = { .hdc = hdc, .ipfd = ipfd, .cjpfd = cjpfd, .ppfd = ppfd, }; @@ -26,6 +53,15 @@ int WINAPI wglDescribePixelFormat( HDC hdc, int ipfd, UINT cjpfd, PIXELFORMATDES return args.ret; }
+BOOL WINAPI wglMakeCurrent( HDC hDc, HGLRC newContext ) +{ + struct wglMakeCurrent_params args = { .hDc = hDc, .newContext = newContext, }; + NTSTATUS status; + TRACE( "hDc %p, newContext %p\n", hDc, newContext ); + if ((status = UNIX_CALL( wglMakeCurrent, &args ))) WARN( "wglMakeCurrent returned %#x\n", status ); + return args.ret; +} + BOOL WINAPI wglSetPixelFormat( HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR *ppfd ) { struct wglSetPixelFormat_params args = { .hdc = hdc, .ipfd = ipfd, .ppfd = ppfd, }; @@ -35,6 +71,15 @@ BOOL WINAPI wglSetPixelFormat( HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR *p return args.ret; }
+BOOL WINAPI wglShareLists( HGLRC hrcSrvShare, HGLRC hrcSrvSource ) +{ + struct wglShareLists_params args = { .hrcSrvShare = hrcSrvShare, .hrcSrvSource = hrcSrvSource, }; + NTSTATUS status; + TRACE( "hrcSrvShare %p, hrcSrvSource %p\n", hrcSrvShare, hrcSrvSource ); + if ((status = UNIX_CALL( wglShareLists, &args ))) WARN( "wglShareLists returned %#x\n", status ); + return args.ret; +} + void WINAPI glAccum( GLenum op, GLfloat value ) { struct glAccum_params args = { .op = op, .value = value, }; @@ -5418,6 +5463,30 @@ static void WINAPI glCurrentPaletteMatrixARB( GLint index ) if ((status = UNIX_CALL( glCurrentPaletteMatrixARB, &args ))) WARN( "glCurrentPaletteMatrixARB returned %#x\n", status ); }
+static void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam ) +{ + struct glDebugMessageCallback_params args = { .callback = callback, .userParam = userParam, }; + NTSTATUS status; + TRACE( "callback %p, userParam %p\n", callback, userParam ); + if ((status = UNIX_CALL( glDebugMessageCallback, &args ))) WARN( "glDebugMessageCallback returned %#x\n", status ); +} + +static void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam ) +{ + struct glDebugMessageCallbackAMD_params args = { .callback = callback, .userParam = userParam, }; + NTSTATUS status; + TRACE( "callback %p, userParam %p\n", callback, userParam ); + if ((status = UNIX_CALL( glDebugMessageCallbackAMD, &args ))) WARN( "glDebugMessageCallbackAMD returned %#x\n", status ); +} + +static void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam ) +{ + struct glDebugMessageCallbackARB_params args = { .callback = callback, .userParam = userParam, }; + NTSTATUS status; + TRACE( "callback %p, userParam %p\n", callback, userParam ); + if ((status = UNIX_CALL( glDebugMessageCallbackARB, &args ))) WARN( "glDebugMessageCallbackARB returned %#x\n", status ); +} + static void WINAPI glDebugMessageControl( GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled ) { struct glDebugMessageControl_params args = { .source = source, .type = type, .severity = severity, .count = count, .ids = ids, .enabled = enabled, }; @@ -24187,6 +24256,15 @@ static void * WINAPI wglAllocateMemoryNV( GLsizei size, GLfloat readfreq, GLfloa return args.ret; }
+static BOOL WINAPI wglBindTexImageARB( HPBUFFERARB hPbuffer, int iBuffer ) +{ + struct wglBindTexImageARB_params args = { .hPbuffer = hPbuffer, .iBuffer = iBuffer, }; + NTSTATUS status; + TRACE( "hPbuffer %p, iBuffer %d\n", hPbuffer, iBuffer ); + if ((status = UNIX_CALL( wglBindTexImageARB, &args ))) WARN( "wglBindTexImageARB returned %#x\n", status ); + return args.ret; +} + static BOOL WINAPI wglChoosePixelFormatARB( HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats ) { struct wglChoosePixelFormatARB_params args = { .hdc = hdc, .piAttribIList = piAttribIList, .pfAttribFList = pfAttribFList, .nMaxFormats = nMaxFormats, .piFormats = piFormats, .nNumFormats = nNumFormats, }; @@ -24196,6 +24274,33 @@ static BOOL WINAPI wglChoosePixelFormatARB( HDC hdc, const int *piAttribIList, c return args.ret; }
+static HGLRC WINAPI wglCreateContextAttribsARB( HDC hDC, HGLRC hShareContext, const int *attribList ) +{ + struct wglCreateContextAttribsARB_params args = { .hDC = hDC, .hShareContext = hShareContext, .attribList = attribList, }; + NTSTATUS status; + TRACE( "hDC %p, hShareContext %p, attribList %p\n", hDC, hShareContext, attribList ); + if ((status = UNIX_CALL( wglCreateContextAttribsARB, &args ))) WARN( "wglCreateContextAttribsARB returned %#x\n", status ); + return args.ret; +} + +static HPBUFFERARB WINAPI wglCreatePbufferARB( HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList ) +{ + struct wglCreatePbufferARB_params args = { .hDC = hDC, .iPixelFormat = iPixelFormat, .iWidth = iWidth, .iHeight = iHeight, .piAttribList = piAttribList, }; + NTSTATUS status; + TRACE( "hDC %p, iPixelFormat %d, iWidth %d, iHeight %d, piAttribList %p\n", hDC, iPixelFormat, iWidth, iHeight, piAttribList ); + if ((status = UNIX_CALL( wglCreatePbufferARB, &args ))) WARN( "wglCreatePbufferARB returned %#x\n", status ); + return args.ret; +} + +static BOOL WINAPI wglDestroyPbufferARB( HPBUFFERARB hPbuffer ) +{ + struct wglDestroyPbufferARB_params args = { .hPbuffer = hPbuffer, }; + NTSTATUS status; + TRACE( "hPbuffer %p\n", hPbuffer ); + if ((status = UNIX_CALL( wglDestroyPbufferARB, &args ))) WARN( "wglDestroyPbufferARB returned %#x\n", status ); + return args.ret; +} + static void WINAPI wglFreeMemoryNV( void *pointer ) { struct wglFreeMemoryNV_params args = { .pointer = pointer, }; @@ -24222,6 +24327,15 @@ static const char * WINAPI wglGetExtensionsStringEXT(void) return args.ret; }
+static HDC WINAPI wglGetPbufferDCARB( HPBUFFERARB hPbuffer ) +{ + struct wglGetPbufferDCARB_params args = { .hPbuffer = hPbuffer, }; + NTSTATUS status; + TRACE( "hPbuffer %p\n", hPbuffer ); + if ((status = UNIX_CALL( wglGetPbufferDCARB, &args ))) WARN( "wglGetPbufferDCARB returned %#x\n", status ); + return args.ret; +} + static BOOL WINAPI wglGetPixelFormatAttribfvARB( HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues ) { struct wglGetPixelFormatAttribfvARB_params args = { .hdc = hdc, .iPixelFormat = iPixelFormat, .iLayerPlane = iLayerPlane, .nAttributes = nAttributes, .piAttributes = piAttributes, .pfValues = pfValues, }; @@ -24249,6 +24363,15 @@ static int WINAPI wglGetSwapIntervalEXT(void) return args.ret; }
+static BOOL WINAPI wglMakeContextCurrentARB( HDC hDrawDC, HDC hReadDC, HGLRC hglrc ) +{ + struct wglMakeContextCurrentARB_params args = { .hDrawDC = hDrawDC, .hReadDC = hReadDC, .hglrc = hglrc, }; + NTSTATUS status; + TRACE( "hDrawDC %p, hReadDC %p, hglrc %p\n", hDrawDC, hReadDC, hglrc ); + if ((status = UNIX_CALL( wglMakeContextCurrentARB, &args ))) WARN( "wglMakeContextCurrentARB returned %#x\n", status ); + return args.ret; +} + static BOOL WINAPI wglQueryCurrentRendererIntegerWINE( GLenum attribute, GLuint *value ) { struct wglQueryCurrentRendererIntegerWINE_params args = { .attribute = attribute, .value = value, }; @@ -24267,6 +24390,15 @@ static const GLchar * WINAPI wglQueryCurrentRendererStringWINE( GLenum attribute return args.ret; }
+static BOOL WINAPI wglQueryPbufferARB( HPBUFFERARB hPbuffer, int iAttribute, int *piValue ) +{ + struct wglQueryPbufferARB_params args = { .hPbuffer = hPbuffer, .iAttribute = iAttribute, .piValue = piValue, }; + NTSTATUS status; + TRACE( "hPbuffer %p, iAttribute %d, piValue %p\n", hPbuffer, iAttribute, piValue ); + if ((status = UNIX_CALL( wglQueryPbufferARB, &args ))) WARN( "wglQueryPbufferARB returned %#x\n", status ); + return args.ret; +} + static BOOL WINAPI wglQueryRendererIntegerWINE( HDC dc, GLint renderer, GLenum attribute, GLuint *value ) { struct wglQueryRendererIntegerWINE_params args = { .dc = dc, .renderer = renderer, .attribute = attribute, .value = value, }; @@ -24285,6 +24417,33 @@ static const GLchar * WINAPI wglQueryRendererStringWINE( HDC dc, GLint renderer, return args.ret; }
+static int WINAPI wglReleasePbufferDCARB( HPBUFFERARB hPbuffer, HDC hDC ) +{ + struct wglReleasePbufferDCARB_params args = { .hPbuffer = hPbuffer, .hDC = hDC, }; + NTSTATUS status; + TRACE( "hPbuffer %p, hDC %p\n", hPbuffer, hDC ); + if ((status = UNIX_CALL( wglReleasePbufferDCARB, &args ))) WARN( "wglReleasePbufferDCARB returned %#x\n", status ); + return args.ret; +} + +static BOOL WINAPI wglReleaseTexImageARB( HPBUFFERARB hPbuffer, int iBuffer ) +{ + struct wglReleaseTexImageARB_params args = { .hPbuffer = hPbuffer, .iBuffer = iBuffer, }; + NTSTATUS status; + TRACE( "hPbuffer %p, iBuffer %d\n", hPbuffer, iBuffer ); + if ((status = UNIX_CALL( wglReleaseTexImageARB, &args ))) WARN( "wglReleaseTexImageARB returned %#x\n", status ); + return args.ret; +} + +static BOOL WINAPI wglSetPbufferAttribARB( HPBUFFERARB hPbuffer, const int *piAttribList ) +{ + struct wglSetPbufferAttribARB_params args = { .hPbuffer = hPbuffer, .piAttribList = piAttribList, }; + NTSTATUS status; + TRACE( "hPbuffer %p, piAttribList %p\n", hPbuffer, piAttribList ); + if ((status = UNIX_CALL( wglSetPbufferAttribARB, &args ))) WARN( "wglSetPbufferAttribARB returned %#x\n", status ); + return args.ret; +} + static BOOL WINAPI wglSetPixelFormatWINE( HDC hdc, int format ) { struct wglSetPixelFormatWINE_params args = { .hdc = hdc, .format = format, }; @@ -24303,21 +24462,8 @@ static BOOL WINAPI wglSwapIntervalEXT( int interval ) return args.ret; }
-extern void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam ) DECLSPEC_HIDDEN; -extern void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam ) DECLSPEC_HIDDEN; -extern void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam ) DECLSPEC_HIDDEN; extern const GLubyte * WINAPI glGetStringi( GLenum name, GLuint index ) DECLSPEC_HIDDEN; -extern BOOL WINAPI wglBindTexImageARB( HPBUFFERARB hPbuffer, int iBuffer ) DECLSPEC_HIDDEN; -extern HGLRC WINAPI wglCreateContextAttribsARB( HDC hDC, HGLRC hShareContext, const int *attribList ) DECLSPEC_HIDDEN; -extern HPBUFFERARB WINAPI wglCreatePbufferARB( HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList ) DECLSPEC_HIDDEN; -extern BOOL WINAPI wglDestroyPbufferARB( HPBUFFERARB hPbuffer ) DECLSPEC_HIDDEN; extern HDC WINAPI wglGetCurrentReadDCARB(void) DECLSPEC_HIDDEN; -extern HDC WINAPI wglGetPbufferDCARB( HPBUFFERARB hPbuffer ) DECLSPEC_HIDDEN; -extern BOOL WINAPI wglMakeContextCurrentARB( HDC hDrawDC, HDC hReadDC, HGLRC hglrc ) DECLSPEC_HIDDEN; -extern BOOL WINAPI wglQueryPbufferARB( HPBUFFERARB hPbuffer, int iAttribute, int *piValue ) DECLSPEC_HIDDEN; -extern int WINAPI wglReleasePbufferDCARB( HPBUFFERARB hPbuffer, HDC hDC ) DECLSPEC_HIDDEN; -extern BOOL WINAPI wglReleaseTexImageARB( HPBUFFERARB hPbuffer, int iBuffer ) DECLSPEC_HIDDEN; -extern BOOL WINAPI wglSetPbufferAttribARB( HPBUFFERARB hPbuffer, const int *piAttribList ) DECLSPEC_HIDDEN;
const int extension_registry_size = 2694; const OpenGL_extension extension_registry[2694] = diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 1efbd1d192a..86af754b278 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -13,30 +13,24 @@
#include "opengl_ext.h"
-static NTSTATUS wgl_wglCopyContext( void *args ) -{ - struct wglCopyContext_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - params->ret = funcs->wgl.p_wglCopyContext( (struct wgl_context *)params->hglrcSrc, (struct wgl_context *)params->hglrcDst, params->mask ); - return STATUS_SUCCESS; -} - -static NTSTATUS wgl_wglCreateContext( void *args ) -{ - struct wglCreateContext_params *params = args; - const struct opengl_funcs *funcs = get_dc_funcs( params->hDc ); - if (!funcs || !funcs->wgl.p_wglCreateContext) return STATUS_NOT_IMPLEMENTED; - params->ret = (HGLRC)funcs->wgl.p_wglCreateContext( params->hDc ); - return STATUS_SUCCESS; -} - -static NTSTATUS wgl_wglDeleteContext( void *args ) -{ - struct wglDeleteContext_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - params->ret = funcs->wgl.p_wglDeleteContext( (struct wgl_context *)params->oldContext ); - return STATUS_SUCCESS; -} +extern NTSTATUS wgl_wglCopyContext( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wgl_wglCreateContext( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wgl_wglDeleteContext( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wgl_wglMakeCurrent( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wgl_wglShareLists( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glDebugMessageCallback( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glDebugMessageCallbackAMD( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_glDebugMessageCallbackARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_wglBindTexImageARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_wglCreateContextAttribsARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_wglCreatePbufferARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_wglDestroyPbufferARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_wglGetPbufferDCARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_wglMakeContextCurrentARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_wglQueryPbufferARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_wglReleasePbufferDCARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_wglReleaseTexImageARB( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS ext_wglSetPbufferAttribARB( void *args ) DECLSPEC_HIDDEN;
static NTSTATUS wgl_wglDescribePixelFormat( void *args ) { @@ -64,15 +58,6 @@ static NTSTATUS wgl_wglGetProcAddress( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS wgl_wglMakeCurrent( void *args ) -{ - struct wglMakeCurrent_params *params = args; - const struct opengl_funcs *funcs = get_dc_funcs( params->hDc ); - if (!funcs || !funcs->wgl.p_wglMakeCurrent) return STATUS_NOT_IMPLEMENTED; - params->ret = funcs->wgl.p_wglMakeCurrent( params->hDc, (struct wgl_context *)params->newContext ); - return STATUS_SUCCESS; -} - static NTSTATUS wgl_wglSetPixelFormat( void *args ) { struct wglSetPixelFormat_params *params = args; @@ -82,14 +67,6 @@ static NTSTATUS wgl_wglSetPixelFormat( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS wgl_wglShareLists( void *args ) -{ - struct wglShareLists_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - params->ret = funcs->wgl.p_wglShareLists( (struct wgl_context *)params->hrcSrvShare, (struct wgl_context *)params->hrcSrvSource ); - return STATUS_SUCCESS; -} - static NTSTATUS wgl_wglSwapBuffers( void *args ) { struct wglSwapBuffers_params *params = args; @@ -5451,30 +5428,6 @@ static NTSTATUS ext_glCurrentPaletteMatrixARB( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_glDebugMessageCallback( void *args ) -{ - struct glDebugMessageCallback_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - funcs->ext.p_glDebugMessageCallback( params->callback, params->userParam ); - return STATUS_SUCCESS; -} - -static NTSTATUS ext_glDebugMessageCallbackAMD( void *args ) -{ - struct glDebugMessageCallbackAMD_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - funcs->ext.p_glDebugMessageCallbackAMD( params->callback, params->userParam ); - return STATUS_SUCCESS; -} - -static NTSTATUS ext_glDebugMessageCallbackARB( void *args ) -{ - struct glDebugMessageCallbackARB_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - funcs->ext.p_glDebugMessageCallbackARB( params->callback, params->userParam ); - return STATUS_SUCCESS; -} - static NTSTATUS ext_glDebugMessageControl( void *args ) { struct glDebugMessageControl_params *params = args; @@ -24098,14 +24051,6 @@ static NTSTATUS ext_wglAllocateMemoryNV( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_wglBindTexImageARB( void *args ) -{ - struct wglBindTexImageARB_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - params->ret = funcs->ext.p_wglBindTexImageARB( (struct wgl_pbuffer *)params->hPbuffer, params->iBuffer ); - return STATUS_SUCCESS; -} - static NTSTATUS ext_wglChoosePixelFormatARB( void *args ) { struct wglChoosePixelFormatARB_params *params = args; @@ -24115,32 +24060,6 @@ static NTSTATUS ext_wglChoosePixelFormatARB( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_wglCreateContextAttribsARB( void *args ) -{ - struct wglCreateContextAttribsARB_params *params = args; - const struct opengl_funcs *funcs = get_dc_funcs( params->hDC ); - if (!funcs || !funcs->ext.p_wglCreateContextAttribsARB) return STATUS_NOT_IMPLEMENTED; - params->ret = (HGLRC)funcs->ext.p_wglCreateContextAttribsARB( params->hDC, (struct wgl_context *)params->hShareContext, params->attribList ); - return STATUS_SUCCESS; -} - -static NTSTATUS ext_wglCreatePbufferARB( void *args ) -{ - struct wglCreatePbufferARB_params *params = args; - const struct opengl_funcs *funcs = get_dc_funcs( params->hDC ); - if (!funcs || !funcs->ext.p_wglCreatePbufferARB) return STATUS_NOT_IMPLEMENTED; - params->ret = (HPBUFFERARB)funcs->ext.p_wglCreatePbufferARB( params->hDC, params->iPixelFormat, params->iWidth, params->iHeight, params->piAttribList ); - return STATUS_SUCCESS; -} - -static NTSTATUS ext_wglDestroyPbufferARB( void *args ) -{ - struct wglDestroyPbufferARB_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - params->ret = funcs->ext.p_wglDestroyPbufferARB( (struct wgl_pbuffer *)params->hPbuffer ); - return STATUS_SUCCESS; -} - static NTSTATUS ext_wglFreeMemoryNV( void *args ) { struct wglFreeMemoryNV_params *params = args; @@ -24174,14 +24093,6 @@ static NTSTATUS ext_wglGetExtensionsStringEXT( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_wglGetPbufferDCARB( void *args ) -{ - struct wglGetPbufferDCARB_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - params->ret = funcs->ext.p_wglGetPbufferDCARB( (struct wgl_pbuffer *)params->hPbuffer ); - return STATUS_SUCCESS; -} - static NTSTATUS ext_wglGetPixelFormatAttribfvARB( void *args ) { struct wglGetPixelFormatAttribfvARB_params *params = args; @@ -24208,15 +24119,6 @@ static NTSTATUS ext_wglGetSwapIntervalEXT( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_wglMakeContextCurrentARB( void *args ) -{ - struct wglMakeContextCurrentARB_params *params = args; - const struct opengl_funcs *funcs = get_dc_funcs( params->hDrawDC ); - if (!funcs || !funcs->ext.p_wglMakeContextCurrentARB) return STATUS_NOT_IMPLEMENTED; - params->ret = funcs->ext.p_wglMakeContextCurrentARB( params->hDrawDC, params->hReadDC, (struct wgl_context *)params->hglrc ); - return STATUS_SUCCESS; -} - static NTSTATUS ext_wglQueryCurrentRendererIntegerWINE( void *args ) { struct wglQueryCurrentRendererIntegerWINE_params *params = args; @@ -24233,14 +24135,6 @@ static NTSTATUS ext_wglQueryCurrentRendererStringWINE( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_wglQueryPbufferARB( void *args ) -{ - struct wglQueryPbufferARB_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - params->ret = funcs->ext.p_wglQueryPbufferARB( (struct wgl_pbuffer *)params->hPbuffer, params->iAttribute, params->piValue ); - return STATUS_SUCCESS; -} - static NTSTATUS ext_wglQueryRendererIntegerWINE( void *args ) { struct wglQueryRendererIntegerWINE_params *params = args; @@ -24259,30 +24153,6 @@ static NTSTATUS ext_wglQueryRendererStringWINE( void *args ) return STATUS_SUCCESS; }
-static NTSTATUS ext_wglReleasePbufferDCARB( void *args ) -{ - struct wglReleasePbufferDCARB_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - params->ret = funcs->ext.p_wglReleasePbufferDCARB( (struct wgl_pbuffer *)params->hPbuffer, params->hDC ); - return STATUS_SUCCESS; -} - -static NTSTATUS ext_wglReleaseTexImageARB( void *args ) -{ - struct wglReleaseTexImageARB_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - params->ret = funcs->ext.p_wglReleaseTexImageARB( (struct wgl_pbuffer *)params->hPbuffer, params->iBuffer ); - return STATUS_SUCCESS; -} - -static NTSTATUS ext_wglSetPbufferAttribARB( void *args ) -{ - struct wglSetPbufferAttribARB_params *params = args; - const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; - params->ret = funcs->ext.p_wglSetPbufferAttribARB( (struct wgl_pbuffer *)params->hPbuffer, params->piAttribList ); - return STATUS_SUCCESS; -} - static NTSTATUS ext_wglSetPixelFormatWINE( void *args ) { struct wglSetPixelFormatWINE_params *params = args; diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 70ee0a5cdab..4771205a47e 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -35,8 +35,6 @@
#include "wine/debug.h"
-WINE_DEFAULT_DEBUG_CHANNEL(wgl); - struct wgl_handle wgl_handles[MAX_WGL_HANDLES]; static struct wgl_handle *next_free; static unsigned int handle_count; @@ -107,7 +105,7 @@ static void free_handle_ptr( struct wgl_handle *ptr ) LeaveCriticalSection( &wgl_section ); }
-BOOL WINAPI wglCopyContext( HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask ) +static BOOL wrap_wglCopyContext( HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask ) { struct wgl_handle *src, *dst; BOOL ret = FALSE; @@ -123,7 +121,7 @@ BOOL WINAPI wglCopyContext( HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask ) return ret; }
-HGLRC WINAPI wglCreateContext( HDC hdc ) +static HGLRC wrap_wglCreateContext( HDC hdc ) { HGLRC ret = 0; struct wgl_context *drv_ctx; @@ -142,7 +140,7 @@ HGLRC WINAPI wglCreateContext( HDC hdc ) return ret; }
-BOOL WINAPI wglDeleteContext( HGLRC hglrc ) +static BOOL wrap_wglDeleteContext( HGLRC hglrc ) { struct wgl_handle *ptr = get_handle_ptr( hglrc, HANDLE_CONTEXT );
@@ -163,7 +161,7 @@ BOOL WINAPI wglDeleteContext( HGLRC hglrc ) return TRUE; }
-BOOL WINAPI wglMakeCurrent( HDC hdc, HGLRC hglrc ) +static BOOL wrap_wglMakeCurrent( HDC hdc, HGLRC hglrc ) { BOOL ret = TRUE; struct wgl_handle *ptr, *prev = get_current_context_ptr(); @@ -206,7 +204,7 @@ BOOL WINAPI wglMakeCurrent( HDC hdc, HGLRC hglrc ) return ret; }
-BOOL WINAPI wglShareLists( HGLRC hglrcSrc, HGLRC hglrcDst ) +static BOOL wrap_wglShareLists( HGLRC hglrcSrc, HGLRC hglrcDst ) { BOOL ret = FALSE; struct wgl_handle *src, *dst; @@ -222,7 +220,7 @@ BOOL WINAPI wglShareLists( HGLRC hglrcSrc, HGLRC hglrcDst ) return ret; }
-BOOL WINAPI wglBindTexImageARB( HPBUFFERARB handle, int buffer ) +static BOOL wrap_wglBindTexImageARB( HPBUFFERARB handle, int buffer ) { struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); BOOL ret; @@ -233,7 +231,7 @@ BOOL WINAPI wglBindTexImageARB( HPBUFFERARB handle, int buffer ) return ret; }
-HGLRC WINAPI wglCreateContextAttribsARB( HDC hdc, HGLRC share, const int *attribs ) +static HGLRC wrap_wglCreateContextAttribsARB( HDC hdc, HGLRC share, const int *attribs ) { HGLRC ret = 0; struct wgl_context *drv_ctx; @@ -281,7 +279,7 @@ HGLRC WINAPI wglCreateContextAttribsARB( HDC hdc, HGLRC share, const int *attrib return ret; }
-HPBUFFERARB WINAPI wglCreatePbufferARB( HDC hdc, int format, int width, int height, const int *attribs ) +static HPBUFFERARB wrap_wglCreatePbufferARB( HDC hdc, int format, int width, int height, const int *attribs ) { HPBUFFERARB ret; struct wgl_pbuffer *pbuffer; @@ -294,7 +292,7 @@ HPBUFFERARB WINAPI wglCreatePbufferARB( HDC hdc, int format, int width, int heig return ret; }
-BOOL WINAPI wglDestroyPbufferARB( HPBUFFERARB handle ) +static BOOL wrap_wglDestroyPbufferARB( HPBUFFERARB handle ) { struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER );
@@ -304,7 +302,7 @@ BOOL WINAPI wglDestroyPbufferARB( HPBUFFERARB handle ) return TRUE; }
-HDC WINAPI wglGetPbufferDCARB( HPBUFFERARB handle ) +static HDC wrap_wglGetPbufferDCARB( HPBUFFERARB handle ) { struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); HDC ret; @@ -315,7 +313,7 @@ HDC WINAPI wglGetPbufferDCARB( HPBUFFERARB handle ) return ret; }
-BOOL WINAPI wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC hglrc ) +static BOOL wrap_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC hglrc ) { BOOL ret = TRUE; struct wgl_handle *ptr, *prev = get_current_context_ptr(); @@ -354,7 +352,7 @@ BOOL WINAPI wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC hglrc ) return ret; }
-BOOL WINAPI wglQueryPbufferARB( HPBUFFERARB handle, int attrib, int *value ) +static BOOL wrap_wglQueryPbufferARB( HPBUFFERARB handle, int attrib, int *value ) { struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); BOOL ret; @@ -365,7 +363,7 @@ BOOL WINAPI wglQueryPbufferARB( HPBUFFERARB handle, int attrib, int *value ) return ret; }
-int WINAPI wglReleasePbufferDCARB( HPBUFFERARB handle, HDC hdc ) +static int wrap_wglReleasePbufferDCARB( HPBUFFERARB handle, HDC hdc ) { struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); BOOL ret; @@ -376,7 +374,7 @@ int WINAPI wglReleasePbufferDCARB( HPBUFFERARB handle, HDC hdc ) return ret; }
-BOOL WINAPI wglReleaseTexImageARB( HPBUFFERARB handle, int buffer ) +static BOOL wrap_wglReleaseTexImageARB( HPBUFFERARB handle, int buffer ) { struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); BOOL ret; @@ -387,7 +385,7 @@ BOOL WINAPI wglReleaseTexImageARB( HPBUFFERARB handle, int buffer ) return ret; }
-BOOL WINAPI wglSetPbufferAttribARB( HPBUFFERARB handle, const int *attribs ) +static BOOL wrap_wglSetPbufferAttribARB( HPBUFFERARB handle, const int *attribs ) { struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER ); BOOL ret; @@ -422,38 +420,162 @@ static void gl_debug_message_callback( GLenum source, GLenum type, GLuint id, GL callback( ¶ms, sizeof(params) ); }
-void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam ) +static void WINAPI wrap_glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam ) { struct wgl_handle *ptr = get_current_context_ptr(); const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
- TRACE( "(%p, %p)\n", callback, userParam ); + if (!funcs->ext.p_glDebugMessageCallback) return;
ptr->u.context->debug_callback = callback; ptr->u.context->debug_user = userParam; funcs->ext.p_glDebugMessageCallback( gl_debug_message_callback, ptr ); }
-void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam ) +static void WINAPI wrap_glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam ) { struct wgl_handle *ptr = get_current_context_ptr(); const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
- TRACE( "(%p, %p)\n", callback, userParam ); + if (!funcs->ext.p_glDebugMessageCallbackAMD) return;
ptr->u.context->debug_callback = callback; ptr->u.context->debug_user = userParam; funcs->ext.p_glDebugMessageCallbackAMD( gl_debug_message_callback, ptr ); }
-void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam ) +static void WINAPI wrap_glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam ) { struct wgl_handle *ptr = get_current_context_ptr(); const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
- TRACE( "(%p, %p)\n", callback, userParam ); + if (!funcs->ext.p_glDebugMessageCallbackARB) return;
ptr->u.context->debug_callback = callback; ptr->u.context->debug_user = userParam; funcs->ext.p_glDebugMessageCallbackARB( gl_debug_message_callback, ptr ); } + +NTSTATUS wgl_wglCopyContext( void *args ) +{ + struct wglCopyContext_params *params = args; + params->ret = wrap_wglCopyContext( params->hglrcSrc, params->hglrcDst, params->mask ); + return STATUS_SUCCESS; +} + +NTSTATUS wgl_wglCreateContext( void *args ) +{ + struct wglCreateContext_params *params = args; + params->ret = wrap_wglCreateContext( params->hDc ); + return STATUS_SUCCESS; +} + +NTSTATUS wgl_wglDeleteContext( void *args ) +{ + struct wglDeleteContext_params *params = args; + params->ret = wrap_wglDeleteContext( params->oldContext ); + return STATUS_SUCCESS; +} + +NTSTATUS wgl_wglMakeCurrent( void *args ) +{ + struct wglMakeCurrent_params *params = args; + params->ret = wrap_wglMakeCurrent( params->hDc, params->newContext ); + return STATUS_SUCCESS; +} + +NTSTATUS wgl_wglShareLists( void *args ) +{ + struct wglShareLists_params *params = args; + params->ret = wrap_wglShareLists( params->hrcSrvShare, params->hrcSrvSource ); + return STATUS_SUCCESS; +} + +NTSTATUS ext_glDebugMessageCallback( void *args ) +{ + struct glDebugMessageCallback_params *params = args; + wrap_glDebugMessageCallback( params->callback, params->userParam ); + return STATUS_SUCCESS; +} +NTSTATUS ext_glDebugMessageCallbackAMD( void *args ) +{ + struct glDebugMessageCallbackAMD_params *params = args; + wrap_glDebugMessageCallbackAMD( params->callback, params->userParam ); + return STATUS_SUCCESS; +} +NTSTATUS ext_glDebugMessageCallbackARB( void *args ) +{ + struct glDebugMessageCallbackARB_params *params = args; + wrap_glDebugMessageCallbackARB( params->callback, params->userParam ); + return STATUS_SUCCESS; +} + +NTSTATUS ext_wglBindTexImageARB( void *args ) +{ + struct wglBindTexImageARB_params *params = args; + params->ret = wrap_wglBindTexImageARB( params->hPbuffer, params->iBuffer ); + return STATUS_SUCCESS; +} + +NTSTATUS ext_wglCreateContextAttribsARB( void *args ) +{ + struct wglCreateContextAttribsARB_params *params = args; + params->ret = wrap_wglCreateContextAttribsARB( params->hDC, params->hShareContext, params->attribList ); + return STATUS_SUCCESS; +} + +NTSTATUS ext_wglCreatePbufferARB( void *args ) +{ + struct wglCreatePbufferARB_params *params = args; + params->ret = wrap_wglCreatePbufferARB( params->hDC, params->iPixelFormat, params->iWidth, params->iHeight, params->piAttribList ); + return STATUS_SUCCESS; +} + +NTSTATUS ext_wglDestroyPbufferARB( void *args ) +{ + struct wglDestroyPbufferARB_params *params = args; + params->ret = wrap_wglDestroyPbufferARB( params->hPbuffer ); + return STATUS_SUCCESS; +} + +NTSTATUS ext_wglGetPbufferDCARB( void *args ) +{ + struct wglGetPbufferDCARB_params *params = args; + params->ret = wrap_wglGetPbufferDCARB( params->hPbuffer ); + return STATUS_SUCCESS; +} + +NTSTATUS ext_wglMakeContextCurrentARB( void *args ) +{ + struct wglMakeContextCurrentARB_params *params = args; + params->ret = wrap_wglMakeContextCurrentARB( params->hDrawDC, params->hReadDC, params->hglrc ); + return STATUS_SUCCESS; +} + +NTSTATUS ext_wglQueryPbufferARB( void *args ) +{ + struct wglQueryPbufferARB_params *params = args; + params->ret = wrap_wglQueryPbufferARB( params->hPbuffer, params->iAttribute, params->piValue ); + return STATUS_SUCCESS; +} + +NTSTATUS ext_wglReleasePbufferDCARB( void *args ) +{ + struct wglReleasePbufferDCARB_params *params = args; + params->ret = wrap_wglReleasePbufferDCARB( params->hPbuffer, params->hDC ); + return STATUS_SUCCESS; +} + +NTSTATUS ext_wglReleaseTexImageARB( void *args ) +{ + struct wglReleaseTexImageARB_params *params = args; + params->ret = wrap_wglReleaseTexImageARB( params->hPbuffer, params->iBuffer ); + return STATUS_SUCCESS; +} + +NTSTATUS ext_wglSetPbufferAttribARB( void *args ) +{ + struct wglSetPbufferAttribARB_params *params = args; + params->ret = wrap_wglSetPbufferAttribARB( params->hPbuffer, params->piAttribList ); + return STATUS_SUCCESS; +}
I don't understand these macOS build failures. Looks like I fixed it again while trying to debug it with another MR against my own repository. Re-running it here then also fixed the build.
I honestly don't think we should keep build state across jobs like that.