OSmesa is deprecated and has been removed from latest mesa releases, this replaces it with pbuffer rendering and flushing of the surface onto the bitmap at some specific sync points. The tests show that this is roughly how Windows seem to behave anyway, instead of rendering directly to the memory as OSmesa does.
-- v5: win32u: Remove now unnecessary context and pbuffer funcs. win32u: Drop now unnecessary OSMesa dependency. win32u: Use a pbuffer to implement GL on memory DCs. opengl32: Flush the contexts on gl(Draw|Read)Pixels and glViewport.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/make_opengl | 3 +++ dlls/opengl32/unix_private.h | 3 +++ dlls/opengl32/unix_thunks.c | 9 +++------ dlls/opengl32/unix_wgl.c | 21 +++++++++++++++++++++ 4 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index bc8eb05aaa5..d43ee4abf3e 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -200,11 +200,14 @@ my %manual_unix_thunks = "glDebugMessageCallback" => 1, "glDebugMessageCallbackAMD" => 1, "glDebugMessageCallbackARB" => 1, + "glDrawPixels" => 1, "glFinish" => 1, "glFlush" => 1, "glGetIntegerv" => 1, "glGetString" => 1, "glGetStringi" => 1, + "glReadPixels" => 1, + "glViewport" => 1, "wglGetProcAddress" => 1, "wglSwapBuffers" => 1, ); diff --git a/dlls/opengl32/unix_private.h b/dlls/opengl32/unix_private.h index 30b90545105..c15bda2c99a 100644 --- a/dlls/opengl32/unix_private.h +++ b/dlls/opengl32/unix_private.h @@ -82,6 +82,9 @@ extern PROC wrap_wglGetProcAddress( TEB *teb, LPCSTR lpszProc ); extern BOOL wrap_wglMakeCurrent( TEB *teb, HDC hDc, HGLRC newContext ); extern void wrap_glFinish( TEB *teb ); extern void wrap_glFlush( TEB *teb ); +extern void wrap_glDrawPixels( TEB *teb, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels ); +extern void wrap_glReadPixels( TEB *teb, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels ); +extern void wrap_glViewport( TEB *teb, GLint x, GLint y, GLsizei width, GLsizei height ); extern BOOL wrap_wglSwapBuffers( TEB *teb, HDC hdc ); extern BOOL wrap_wglShareLists( TEB *teb, HGLRC hrcSrvShare, HGLRC hrcSrvSource ); extern void wrap_glGetIntegerv( TEB *teb, GLenum pname, GLint *data ); diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index ae97dfbec47..91aaadbe9c0 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -718,8 +718,7 @@ static NTSTATUS gl_glDrawElements( void *args ) static NTSTATUS gl_glDrawPixels( void *args ) { struct glDrawPixels_params *params = args; - const struct opengl_funcs *funcs = params->teb->glTable; - funcs->p_glDrawPixels( params->width, params->height, params->format, params->type, params->pixels ); + wrap_glDrawPixels( params->teb, params->width, params->height, params->format, params->type, params->pixels ); set_context_attribute( params->teb, -1 /* unsupported */, NULL, 0 ); return STATUS_SUCCESS; } @@ -2203,8 +2202,7 @@ static NTSTATUS gl_glReadBuffer( void *args ) static NTSTATUS gl_glReadPixels( void *args ) { struct glReadPixels_params *params = args; - const struct opengl_funcs *funcs = params->teb->glTable; - funcs->p_glReadPixels( params->x, params->y, params->width, params->height, params->format, params->type, params->pixels ); + wrap_glReadPixels( params->teb, params->x, params->y, params->width, params->height, params->format, params->type, params->pixels ); set_context_attribute( params->teb, -1 /* unsupported */, NULL, 0 ); return STATUS_SUCCESS; } @@ -3085,8 +3083,7 @@ static NTSTATUS gl_glVertexPointer( void *args ) static NTSTATUS gl_glViewport( void *args ) { struct glViewport_params *params = args; - const struct opengl_funcs *funcs = params->teb->glTable; - funcs->p_glViewport( params->x, params->y, params->width, params->height ); + wrap_glViewport( params->teb, params->x, params->y, params->width, params->height ); set_context_attribute( params->teb, GL_VIEWPORT, ¶ms->x, 2 * sizeof(GLint) + 2 * sizeof(GLsizei) ); return STATUS_SUCCESS; } diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index f009c74e209..d203f4781a7 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1010,6 +1010,27 @@ void wrap_glFlush( TEB *teb ) flush_context( teb, funcs->p_glFlush ); }
+void wrap_glDrawPixels( TEB *teb, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels ) +{ + const struct opengl_funcs *funcs = teb->glTable; + flush_context( teb, NULL ); + funcs->p_glDrawPixels( width, height, format, type, pixels ); +} + +void wrap_glReadPixels( TEB *teb, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels ) +{ + const struct opengl_funcs *funcs = teb->glTable; + flush_context( teb, NULL ); + funcs->p_glReadPixels( x, y, width, height, format, type, pixels ); +} + +void wrap_glViewport( TEB *teb, GLint x, GLint y, GLsizei width, GLsizei height ) +{ + const struct opengl_funcs *funcs = teb->glTable; + flush_context( teb, NULL ); + funcs->p_glViewport( x, y, width, height ); +} + BOOL wrap_wglSwapBuffers( TEB *teb, HDC hdc ) { const struct opengl_funcs *funcs = get_dc_funcs( hdc );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/tests/opengl.c | 25 ++++---- dlls/win32u/opengl.c | 108 ++++++++++++++++++++++++++++++----- 2 files changed, 107 insertions(+), 26 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index 10d4e9a491f..901745098f1 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -1597,7 +1597,7 @@ static void test_bitmap_rendering( BOOL use_dib ) ok( EqualRect( (RECT *)viewport, &expect_rect ), "got viewport %s\n", wine_dbgstr_rect( (RECT *)viewport ) );
glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); - todo_wine ok( (pixel & 0xffffff) == 0xcdcdcd, "got %#x\n", pixel ); + ok( (pixel & 0xffffff) == 0xcdcdcd, "got %#x\n", pixel );
glClearColor( (float)0x22 / 0xff, (float)0x33 / 0xff, (float)0x44 / 0xff, (float)0x11 / 0xff ); glClear( GL_COLOR_BUFFER_BIT ); @@ -1642,7 +1642,7 @@ static void test_bitmap_rendering( BOOL use_dib ) ok( (pixel & 0xffffff) == 0x443322, "got %#x\n", pixel ); if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); - todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); ok( (pixels2[0] & 0xffffff) == 0xdcdcdc, "got %#x\n", pixels2[0] );
@@ -1657,13 +1657,13 @@ static void test_bitmap_rendering( BOOL use_dib ) /* pixels are read from the selected bitmap */
glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); - todo_wine ok( (pixel & 0xffffff) == 0xdcdcdc, "got %#x\n", pixel ); + ok( (pixel & 0xffffff) == 0xdcdcdc, "got %#x\n", pixel );
if (use_dib) { memset( buffer2, 0xa5, sizeof(buffer2) ); glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); - todo_wine ok( (pixel & 0xffffff) == 0xdcdcdc, "got %#x\n", pixel ); + ok( (pixel & 0xffffff) == 0xdcdcdc, "got %#x\n", pixel ); memset( buffer2, 0xdc, sizeof(buffer2) ); }
@@ -1676,7 +1676,7 @@ static void test_bitmap_rendering( BOOL use_dib )
if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); - todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); ok( (pixels2[0] & 0xffffff) == 0xdcdcdc, "got %#x\n", pixels2[0] );
glFinish(); @@ -1685,8 +1685,8 @@ static void test_bitmap_rendering( BOOL use_dib ) ok( (pixel & 0xffffff) == 0x223344, "got %#x\n", pixel ); if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); - todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); - todo_wine ok( (pixels2[0] & 0xffffff) == 0x443322, "got %#x\n", pixels2[0] ); + ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels2[0] & 0xffffff) == 0x443322, "got %#x\n", pixels2[0] );
ret = wglMakeCurrent( NULL, NULL ); @@ -1704,7 +1704,7 @@ static void test_bitmap_rendering( BOOL use_dib )
if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); - todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); ok( (pixels2[0] & 0xffffff) == 0x445566, "got %#x\n", pixels2[0] );
@@ -1726,7 +1726,7 @@ static void test_bitmap_rendering( BOOL use_dib )
if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); - todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); if (use_dib) todo_wine ok( (pixels2[0] & 0xffffff) == 0x03148, "got %#x\n", pixels2[0] ); else ok( (pixels2[0] & 0xffffff) == 0x665544, "got %#x\n", pixels2[0] );
@@ -1743,7 +1743,7 @@ static void test_bitmap_rendering( BOOL use_dib )
if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); - todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); ok( (pixels2[0] & 0xffffff) == 0x667788, "got %#x\n", pixels2[0] );
@@ -1789,6 +1789,7 @@ static void test_d3dkmt_rendering(void) NTSTATUS status; HGLRC hglrc;
+ memset( (void *)pixels, 0xcd, sizeof(*pixels) * 4 * 4 ); create.pMemory = pixels; create.Format = D3DDDIFMT_A8R8G8B8; create.Width = 4; @@ -1858,7 +1859,7 @@ static void test_d3dkmt_rendering(void)
memset( (void *)pixels, 0xcd, sizeof(*pixels) * 4 * 4 ); glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); - todo_wine ok( (pixel & 0xffffff) == 0xcdcdcd, "got %#x\n", pixel ); + ok( (pixel & 0xffffff) == 0xcdcdcd, "got %#x\n", pixel );
glClearColor( (float)0x44 / 0xff, (float)0x33 / 0xff, (float)0x22 / 0xff, (float)0x11 / 0xff ); glClear( GL_COLOR_BUFFER_BIT ); @@ -1881,7 +1882,7 @@ static void test_d3dkmt_rendering(void) ok( (pixels[0] & 0xffffff) == 0x556677, "got %#x\n", pixels[0] ); glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); ok( (pixel & 0xffffff) == 0x223344, "got %#x\n", pixel ); - todo_wine ok( (pixels[0] & 0xffffff) == 0x443322, "got %#x\n", pixels[0] ); + ok( (pixels[0] & 0xffffff) == 0x443322, "got %#x\n", pixels[0] );
glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); ok( (pixel & 0xffffff) == 0x223344, "got %#x\n", pixel ); diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 13c9d230925..310beaa8922 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -45,6 +45,9 @@ struct wgl_context const struct opengl_funcs *funcs; void *driver_private; int pixel_format; + + HBITMAP memory_bitmap; + struct wgl_pbuffer *memory_pbuffer; };
struct wgl_pbuffer @@ -935,6 +938,76 @@ static int win32u_wglGetPixelFormat( HDC hdc ) return format > 0 ? format : 0; }
+static struct wgl_pbuffer *create_memory_pbuffer( HDC hdc, int format ) +{ + const struct opengl_funcs *funcs = &display_funcs; + struct wgl_pbuffer *pbuffer = NULL; + BITMAPOBJ *bmp; + dib_info dib; + BOOL ret; + DC *dc; + + if (!(dc = get_dc_ptr( hdc ))) return NULL; + if (get_gdi_object_type( hdc ) != NTGDI_OBJ_MEMDC) ret = FALSE; + else if (!(bmp = GDI_GetObjPtr( dc->hBitmap, NTGDI_OBJ_BITMAP ))) ret = FALSE; + else + { + ret = init_dib_info_from_bitmapobj( &dib, bmp ); + GDI_ReleaseObj( dc->hBitmap ); + } + release_dc_ptr( dc ); + + if (ret) + { + int width = dib.rect.right - dib.rect.left, height = dib.rect.bottom - dib.rect.top; + pbuffer = funcs->p_wglCreatePbufferARB( hdc, format, width, height, NULL ); + } + + if (pbuffer) TRACE( "Created pbuffer %p for memory DC %p\n", pbuffer, hdc ); + else WARN( "Failed to create pbuffer for memory DC %p\n", hdc ); + return pbuffer; +} + +static BOOL flush_memory_pbuffer( struct wgl_context *context, HDC hdc, BOOL write, void (*flush)(void) ) +{ + const struct opengl_funcs *funcs = &display_funcs; + BITMAPOBJ *bmp; + DC *dc; + + if (flush) flush(); + + if (!(dc = get_dc_ptr( hdc ))) return TRUE; + if ((bmp = GDI_GetObjPtr( dc->hBitmap, NTGDI_OBJ_BITMAP ))) + { + char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + BITMAPINFO *info = (BITMAPINFO *)buffer; + struct bitblt_coords src = {0}; + struct gdi_image_bits bits; + + if (dc->hBitmap != context->memory_bitmap) write = TRUE; + context->memory_bitmap = dc->hBitmap; + + if (!get_image_from_bitmap( bmp, info, &bits, &src )) + { + int width = info->bmiHeader.biWidth, height = abs( info->bmiHeader.biHeight ); + if (write) funcs->p_glDrawPixels( width, height, GL_BGRA, GL_UNSIGNED_BYTE, bits.ptr ); + else funcs->p_glReadPixels( 0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, bits.ptr ); + } + GDI_ReleaseObj( dc->hBitmap ); + } + release_dc_ptr( dc ); + + return TRUE; +} + +static void destroy_memory_pbuffer( struct wgl_context *context, HDC hdc ) +{ + const struct opengl_funcs *funcs = context->funcs; + flush_memory_pbuffer( context, hdc, FALSE, funcs->p_glFinish ); + funcs->p_wglDestroyPbufferARB( context->memory_pbuffer ); + context->memory_pbuffer = NULL; +} + static BOOL set_dc_pixel_format( HDC hdc, int new_format, BOOL internal ) { const struct opengl_funcs *funcs; @@ -1038,7 +1111,7 @@ static struct wgl_context *context_create( HDC hdc, struct wgl_context *shared, context->funcs = funcs; context->pixel_format = format;
- if (!driver_funcs->p_context_create( hdc, format, shared_private, attribs, &context->driver_private )) + if (!context->driver_funcs->p_context_create( hdc, format, shared_private, attribs, &context->driver_private )) { free( context ); return NULL; @@ -1079,14 +1152,18 @@ static BOOL win32u_wglDeleteContext( struct wgl_context *context )
static BOOL win32u_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct wgl_context *context ) { + HDC hdc = draw_hdc, prev_draw = NtCurrentTeb()->glReserved1[0]; + struct wgl_context *prev_context = NtCurrentTeb()->glContext; const struct opengl_driver_funcs *funcs; int format;
TRACE( "draw_hdc %p, read_hdc %p, context %p\n", draw_hdc, read_hdc, context );
+ if (prev_context && prev_context->memory_pbuffer) destroy_memory_pbuffer( prev_context, prev_draw ); + if (!context) { - if (!(context = NtCurrentTeb()->glContext)) return TRUE; + if (!(context = prev_context)) return TRUE; funcs = context->driver_funcs; if (!funcs->p_context_make_current( NULL, NULL, NULL )) return FALSE; NtCurrentTeb()->glContext = NULL; @@ -1106,9 +1183,16 @@ static BOOL win32u_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct return FALSE; }
+ if ((context->memory_pbuffer = create_memory_pbuffer( draw_hdc, context->pixel_format ))) + { + if (read_hdc != draw_hdc) ERR( "read != draw not supported\n" ); + draw_hdc = read_hdc = context->memory_pbuffer->hdc; + } + funcs = context->driver_funcs; if (!funcs->p_context_make_current( draw_hdc, read_hdc, context->driver_private )) return FALSE; NtCurrentTeb()->glContext = context; + if (context->memory_pbuffer) flush_memory_pbuffer( context, hdc, TRUE, NULL ); return TRUE; }
@@ -1147,7 +1231,7 @@ static struct wgl_pbuffer *win32u_wglCreatePbufferARB( HDC hdc, int format, int return NULL; } NtGdiSetPixelFormat( pbuffer->hdc, format ); - pbuffer->driver_funcs = funcs == &display_funcs ? display_driver_funcs : memory_driver_funcs; + pbuffer->driver_funcs = display_driver_funcs; pbuffer->funcs = funcs; pbuffer->width = width; pbuffer->height = height; @@ -1553,13 +1637,14 @@ static BOOL win32u_wgl_context_flush( struct wgl_context *context, void (*flush) else interval = get_window_swap_interval( hwnd );
TRACE( "context %p, hwnd %p, draw_hdc %p, interval %d, flush %p\n", context, hwnd, draw_hdc, interval, flush ); + + if (context->memory_pbuffer) return flush_memory_pbuffer( context, draw_hdc, FALSE, flush ); return context->driver_funcs->p_context_flush( context->driver_private, hwnd, draw_hdc, interval, flush ); }
static BOOL win32u_wglSwapBuffers( HDC hdc ) { struct wgl_context *context = NtCurrentTeb()->glContext; - const struct opengl_driver_funcs *driver_funcs; const struct opengl_funcs *funcs; int interval; HWND hwnd; @@ -1569,12 +1654,13 @@ static BOOL win32u_wglSwapBuffers( HDC hdc ) RtlSetLastWin32Error( ERROR_DC_NOT_FOUND ); return FALSE; } - driver_funcs = funcs == &display_funcs ? display_driver_funcs : memory_driver_funcs; + context->driver_funcs = funcs == &display_funcs ? display_driver_funcs : memory_driver_funcs;
if (!(hwnd = NtUserWindowFromDC( hdc ))) interval = 0; else interval = get_window_swap_interval( hwnd );
- return driver_funcs->p_swap_buffers( context ? context->driver_private : NULL, hwnd, hdc, interval ); + if (context->memory_pbuffer) return flush_memory_pbuffer( context, hdc, FALSE, funcs->p_glFlush ); + return context->driver_funcs->p_swap_buffers( context ? context->driver_private : NULL, hwnd, hdc, interval ); }
static BOOL win32u_wglSwapIntervalEXT( int interval ) @@ -1635,7 +1721,7 @@ static void init_opengl_funcs( struct opengl_funcs *funcs, const struct opengl_d #undef USE_GL_FUNC }
-static void memory_funcs_init(void) +static inline void memory_funcs_init(void) { if (!osmesa_get_wgl_driver( &memory_driver_funcs )) WARN( "Failed to initialize OSMesa functions\n" );
@@ -1749,18 +1835,12 @@ static const struct opengl_funcs *get_dc_funcs( HDC hdc, const struct opengl_fun release_dc_ptr( dc );
if (is_disabled) return NULL; - if (is_display) + if (is_display || is_memdc) { static pthread_once_t display_init_once = PTHREAD_ONCE_INIT; pthread_once( &display_init_once, display_funcs_init ); return &display_funcs; } - if (is_memdc) - { - static pthread_once_t memory_init_once = PTHREAD_ONCE_INIT; - pthread_once( &memory_init_once, memory_funcs_init ); - return &memory_funcs; - } return NULL; }
From: Rémi Bernon rbernon@codeweavers.com
--- configure.ac | 7 - dlls/win32u/opengl.c | 399 +++++--------------------------------- tools/gitlab/image.docker | 1 - 3 files changed, 49 insertions(+), 358 deletions(-)
diff --git a/configure.ac b/configure.ac index 848d8329554..6bc0e8c9b22 100644 --- a/configure.ac +++ b/configure.ac @@ -47,7 +47,6 @@ AC_ARG_WITH(netapi, AS_HELP_STRING([--without-netapi],[do not use the Samba N AC_ARG_WITH(opencl, AS_HELP_STRING([--without-opencl],[do not use OpenCL]), [if test "x$withval" = "xno"; then ac_cv_header_CL_cl_h=no; ac_cv_header_OpenCL_opencl_h=no; fi]) AC_ARG_WITH(opengl, AS_HELP_STRING([--without-opengl],[do not use OpenGL])) -AC_ARG_WITH(osmesa, AS_HELP_STRING([--without-osmesa],[do not use the OSMesa library])) AC_ARG_WITH(oss, AS_HELP_STRING([--without-oss],[do not use the OSS sound support])) AC_ARG_WITH(pcap, AS_HELP_STRING([--without-pcap],[do not use the Packet Capture library]), [if test "x$withval" = "xno"; then ac_cv_header_pcap_pcap_h=no; fi]) @@ -1390,12 +1389,6 @@ This probably prevents linking to OpenGL. Try deleting the file and restarting c fi], $X_LIBS -lm -dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib)], $X_LIBS -lm) - if test "x$with_osmesa" != "xno" - then - WINE_CHECK_SONAME(OSMesa,OSMesaGetProcAddress,,,[$X_LIBS -lm]) - WINE_NOTICE_WITH(osmesa,[test "x$ac_cv_lib_soname_OSMesa" = "x"], - [libOSMesa ${notice_platform}development files not found (or too old), OpenGL rendering in bitmaps won't be supported.]) - fi fi WINE_WARNING_WITH(opengl,[test -n "$opengl_msg"],[$opengl_msg OpenGL and Direct3D won't be supported.]) diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 310beaa8922..6b0fa5bd481 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -71,9 +71,6 @@ struct wgl_pbuffer static const struct opengl_funcs *default_funcs; /* default GL function table from opengl32 */ static struct egl_platform display_egl; static struct opengl_funcs display_funcs; -static struct opengl_funcs memory_funcs; - -static const struct opengl_funcs *get_dc_funcs( HDC hdc, const struct opengl_funcs *null_funcs );
static const struct { @@ -564,233 +561,6 @@ static void init_egl_platform( struct egl_platform *egl, struct opengl_funcs *fu
#endif /* SONAME_LIBEGL */
-#ifdef SONAME_LIBOSMESA - -#define OSMESA_COLOR_INDEX GL_COLOR_INDEX -#define OSMESA_RGBA GL_RGBA -#define OSMESA_BGRA 0x1 -#define OSMESA_ARGB 0x2 -#define OSMESA_RGB GL_RGB -#define OSMESA_BGR 0x4 -#define OSMESA_RGB_565 0x5 -#define OSMESA_ROW_LENGTH 0x10 -#define OSMESA_Y_UP 0x11 - -typedef struct osmesa_context *OSMesaContext; - -struct osmesa_context -{ - OSMesaContext context; - UINT format; -}; - -static const struct opengl_driver_funcs osmesa_driver_funcs; - -static OSMesaContext (*pOSMesaCreateContextExt)( GLenum format, GLint depthBits, GLint stencilBits, - GLint accumBits, OSMesaContext sharelist ); -static void (*pOSMesaDestroyContext)( OSMesaContext ctx ); -static void * (*pOSMesaGetProcAddress)( const char *funcName ); -static GLboolean (*pOSMesaMakeCurrent)( OSMesaContext ctx, void *buffer, GLenum type, - GLsizei width, GLsizei height ); -static void (*pOSMesaPixelStore)( GLint pname, GLint value ); -static void describe_pixel_format( int fmt, PIXELFORMATDESCRIPTOR *descr ); - -static BOOL osmesa_get_wgl_driver( const struct opengl_driver_funcs **driver_funcs ) -{ - static void *osmesa_handle; - - osmesa_handle = dlopen( SONAME_LIBOSMESA, RTLD_NOW ); - if (osmesa_handle == NULL) - { - ERR( "Failed to load OSMesa: %s\n", dlerror() ); - return FALSE; - } - -#define LOAD_FUNCPTR(f) do if (!(p##f = dlsym( osmesa_handle, #f ))) \ - { \ - ERR( "%s not found in %s (%s), disabling.\n", #f, SONAME_LIBOSMESA, dlerror() ); \ - goto failed; \ - } while(0) - - LOAD_FUNCPTR(OSMesaCreateContextExt); - LOAD_FUNCPTR(OSMesaDestroyContext); - LOAD_FUNCPTR(OSMesaGetProcAddress); - LOAD_FUNCPTR(OSMesaMakeCurrent); - LOAD_FUNCPTR(OSMesaPixelStore); -#undef LOAD_FUNCPTR - - *driver_funcs = &osmesa_driver_funcs; - return TRUE; - -failed: - dlclose( osmesa_handle ); - osmesa_handle = NULL; - return FALSE; -} - -static const char *osmesa_init_wgl_extensions( struct opengl_funcs *funcs ) -{ - return ""; -} - -static UINT osmesa_init_pixel_formats( UINT *onscreen_count ) -{ - *onscreen_count = ARRAY_SIZE(pixel_formats); - return ARRAY_SIZE(pixel_formats); -} - -static BOOL osmesa_describe_pixel_format( int format, struct wgl_pixel_format *desc ) -{ - if (format <= 0 || format > ARRAY_SIZE(pixel_formats)) return FALSE; - describe_pixel_format( format, &desc->pfd ); - return TRUE; -} - -static BOOL osmesa_set_pixel_format( HWND hwnd, int old_format, int new_format, BOOL internal ) -{ - return TRUE; -} - -static BOOL osmesa_context_create( HDC hdc, int format, void *shared, const int *attribs, void **private ) -{ - struct osmesa_context *context; - PIXELFORMATDESCRIPTOR descr; - UINT gl_format; - - if (attribs) - { - ERR( "attribs not supported\n" ); - return FALSE; - } - - describe_pixel_format( format, &descr ); - - switch (descr.cColorBits) - { - case 32: - if (descr.cRedShift == 8) gl_format = OSMESA_ARGB; - else if (descr.cRedShift == 16) gl_format = OSMESA_BGRA; - else gl_format = OSMESA_RGBA; - break; - case 24: - gl_format = descr.cRedShift == 16 ? OSMESA_BGR : OSMESA_RGB; - break; - case 16: - gl_format = OSMESA_RGB_565; - break; - default: - return FALSE; - } - - if (!(context = malloc( sizeof(*context) ))) return FALSE; - context->format = gl_format; - if (!(context->context = pOSMesaCreateContextExt( gl_format, descr.cDepthBits, descr.cStencilBits, - descr.cAccumBits, 0 ))) - { - free( context ); - return FALSE; - } - - *private = context; - return TRUE; -} - -static BOOL osmesa_context_destroy( void *private ) -{ - struct osmesa_context *context = private; - pOSMesaDestroyContext( context->context ); - free( context ); - return TRUE; -} - -static void *osmesa_get_proc_address( const char *proc ) -{ - if (!strncmp( proc, "wgl", 3 )) return NULL; - return (PROC)pOSMesaGetProcAddress( proc ); -} - -static BOOL osmesa_swap_buffers( void *private, HWND hwnd, HDC hdc, int interval ) -{ - return TRUE; -} - -static BOOL osmesa_context_make_current( HDC draw_hdc, HDC read_hdc, void *private ) -{ - struct osmesa_context *context = private; - HBITMAP bitmap; - BITMAPOBJ *bmp; - dib_info dib; - BOOL ret = FALSE; - - if (!private) - { - pOSMesaMakeCurrent( NULL, NULL, GL_UNSIGNED_BYTE, 0, 0 ); - return TRUE; - } - - if (draw_hdc != read_hdc) - { - ERR( "read != draw not supported\n" ); - return FALSE; - } - - bitmap = NtGdiGetDCObject( draw_hdc, NTGDI_OBJ_SURF ); - bmp = GDI_GetObjPtr( bitmap, NTGDI_OBJ_BITMAP ); - if (!bmp) return FALSE; - - if (init_dib_info_from_bitmapobj( &dib, bmp )) - { - char *bits; - int width = dib.rect.right - dib.rect.left; - int height = dib.rect.bottom - dib.rect.top; - GLenum type; - - if (dib.stride < 0) bits = (char *)dib.bits.ptr + (dib.rect.bottom - 1) * dib.stride; - else bits = (char *)dib.bits.ptr + dib.rect.top * dib.stride; - bits += dib.rect.left * dib.bit_count / 8; - - TRACE( "context %p bits %p size %ux%u\n", context, bits, width, height ); - - type = context->format == OSMESA_RGB_565 ? GL_UNSIGNED_SHORT_5_6_5 : GL_UNSIGNED_BYTE; - ret = pOSMesaMakeCurrent( context->context, bits, type, width, height ); - if (ret) - { - pOSMesaPixelStore( OSMESA_ROW_LENGTH, abs( dib.stride ) * 8 / dib.bit_count ); - pOSMesaPixelStore( OSMESA_Y_UP, 1 ); /* Windows seems to assume bottom-up */ - } - } - GDI_ReleaseObj( bitmap ); - return ret; -} - -static BOOL osmesa_context_flush( void *private, HWND hwnd, HDC hdc, int interval, void (*flush)(void) ) -{ - return FALSE; -} - -static const struct opengl_driver_funcs osmesa_driver_funcs = -{ - .p_get_proc_address = osmesa_get_proc_address, - .p_init_pixel_formats = osmesa_init_pixel_formats, - .p_describe_pixel_format = osmesa_describe_pixel_format, - .p_init_wgl_extensions = osmesa_init_wgl_extensions, - .p_set_pixel_format = osmesa_set_pixel_format, - .p_swap_buffers = osmesa_swap_buffers, - .p_context_create = osmesa_context_create, - .p_context_destroy = osmesa_context_destroy, - .p_context_flush = osmesa_context_flush, - .p_context_make_current = osmesa_context_make_current, -}; - -#else /* SONAME_LIBOSMESA */ - -static BOOL osmesa_get_wgl_driver( const struct opengl_driver_funcs **driver_funcs ) -{ - return FALSE; -} - -#endif /* SONAME_LIBOSMESA */ - static void *nulldrv_get_proc_address( const char *name ) { return NULL; @@ -883,10 +653,8 @@ static const struct opengl_driver_funcs nulldrv_funcs = .p_context_make_current = nulldrv_context_make_current, };
-static const struct opengl_driver_funcs *memory_driver_funcs = &nulldrv_funcs; -static const struct opengl_driver_funcs *display_driver_funcs = &nulldrv_funcs; -static UINT display_formats_count, display_onscreen_count; -static UINT memory_formats_count, memory_onscreen_count; +static const struct opengl_driver_funcs *driver_funcs = &nulldrv_funcs; +static UINT formats_count, onscreen_count;
static char wgl_extensions[4096];
@@ -919,7 +687,7 @@ static int get_dc_pixel_format( HDC hdc, BOOL internal ) /* Offscreen formats can't be used with traditional WGL calls. As has been * verified on Windows GetPixelFormat doesn't fail but returns 1. */ - if (is_display && ret >= 0 && ret > display_onscreen_count) ret = 1; + if (is_display && ret >= 0 && ret > onscreen_count) ret = 1; } else { @@ -1010,11 +778,10 @@ static void destroy_memory_pbuffer( struct wgl_context *context, HDC hdc )
static BOOL set_dc_pixel_format( HDC hdc, int new_format, BOOL internal ) { - const struct opengl_funcs *funcs; + const struct opengl_funcs *funcs = &display_funcs; UINT total, onscreen; HWND hwnd;
- if (!(funcs = get_dc_funcs( hdc, NULL ))) return FALSE; funcs->p_get_pixel_formats( NULL, 0, &total, &onscreen ); if (new_format <= 0 || new_format > total) return FALSE;
@@ -1031,7 +798,7 @@ static BOOL set_dc_pixel_format( HDC hdc, int new_format, BOOL internal ) TRACE( "%p/%p format %d, internal %u\n", hdc, hwnd, new_format, internal );
if ((old_format = get_window_pixel_format( hwnd, FALSE )) && !internal) return old_format == new_format; - if (!display_driver_funcs->p_set_pixel_format( hwnd, old_format, new_format, internal )) return FALSE; + if (!driver_funcs->p_set_pixel_format( hwnd, old_format, new_format, internal )) return FALSE; return set_window_pixel_format( hwnd, new_format, internal ); }
@@ -1049,49 +816,29 @@ static BOOL win32u_wglSetPixelFormatWINE( HDC hdc, int format ) return set_dc_pixel_format( hdc, format, TRUE ); }
-static PROC win32u_memory_wglGetProcAddress( const char *name ) -{ - PROC ret; - if (!strncmp( name, "wgl", 3 )) return NULL; - ret = memory_driver_funcs->p_get_proc_address( name ); - TRACE( "%s -> %p\n", debugstr_a(name), ret ); - return ret; -} - -static PROC win32u_display_wglGetProcAddress( const char *name ) +static PROC win32u_wglGetProcAddress( const char *name ) { PROC ret; if (!strncmp( name, "wgl", 3 )) return NULL; - ret = display_driver_funcs->p_get_proc_address( name ); + ret = driver_funcs->p_get_proc_address( name ); TRACE( "%s -> %p\n", debugstr_a(name), ret ); return ret; }
-static void win32u_display_get_pixel_formats( struct wgl_pixel_format *formats, UINT max_formats, - UINT *num_formats, UINT *num_onscreen_formats ) -{ - UINT i = 0; - - if (formats) while (i < max_formats && display_driver_funcs->p_describe_pixel_format( i + 1, &formats[i] )) i++; - *num_formats = display_formats_count; - *num_onscreen_formats = display_onscreen_count; -} - -static void win32u_memory_get_pixel_formats( struct wgl_pixel_format *formats, UINT max_formats, - UINT *num_formats, UINT *num_onscreen_formats ) +static void win32u_get_pixel_formats( struct wgl_pixel_format *formats, UINT max_formats, + UINT *num_formats, UINT *num_onscreen_formats ) { UINT i = 0;
- if (formats) while (i < max_formats && memory_driver_funcs->p_describe_pixel_format( i + 1, &formats[i] )) i++; - *num_formats = memory_formats_count; - *num_onscreen_formats = memory_onscreen_count; + if (formats) while (i < max_formats && driver_funcs->p_describe_pixel_format( i + 1, &formats[i] )) i++; + *num_formats = formats_count; + *num_onscreen_formats = onscreen_count; }
static struct wgl_context *context_create( HDC hdc, struct wgl_context *shared, const int *attribs ) { void *shared_private = shared ? shared->driver_private : NULL; - const struct opengl_driver_funcs *driver_funcs; - const struct opengl_funcs *funcs; + const struct opengl_funcs *funcs = &display_funcs; struct wgl_context *context; int format;
@@ -1103,9 +850,6 @@ static struct wgl_context *context_create( HDC hdc, struct wgl_context *shared, return NULL; }
- if (!(funcs = get_dc_funcs( hdc, NULL ))) return NULL; - driver_funcs = funcs == &display_funcs ? display_driver_funcs : memory_driver_funcs; - if (!(context = calloc( 1, sizeof(*context) ))) return NULL; context->driver_funcs = driver_funcs; context->funcs = funcs; @@ -1154,7 +898,6 @@ static BOOL win32u_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct { HDC hdc = draw_hdc, prev_draw = NtCurrentTeb()->glReserved1[0]; struct wgl_context *prev_context = NtCurrentTeb()->glContext; - const struct opengl_driver_funcs *funcs; int format;
TRACE( "draw_hdc %p, read_hdc %p, context %p\n", draw_hdc, read_hdc, context ); @@ -1164,8 +907,7 @@ static BOOL win32u_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct if (!context) { if (!(context = prev_context)) return TRUE; - funcs = context->driver_funcs; - if (!funcs->p_context_make_current( NULL, NULL, NULL )) return FALSE; + if (!driver_funcs->p_context_make_current( NULL, NULL, NULL )) return FALSE; NtCurrentTeb()->glContext = NULL; return TRUE; } @@ -1189,8 +931,7 @@ static BOOL win32u_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct draw_hdc = read_hdc = context->memory_pbuffer->hdc; }
- funcs = context->driver_funcs; - if (!funcs->p_context_make_current( draw_hdc, read_hdc, context->driver_private )) return FALSE; + if (!driver_funcs->p_context_make_current( draw_hdc, read_hdc, context->driver_private )) return FALSE; NtCurrentTeb()->glContext = context; if (context->memory_pbuffer) flush_memory_pbuffer( context, hdc, TRUE, NULL ); return TRUE; @@ -1204,14 +945,13 @@ static BOOL win32u_wglMakeCurrent( HDC hdc, struct wgl_context *context ) static struct wgl_pbuffer *win32u_wglCreatePbufferARB( HDC hdc, int format, int width, int height, const int *attribs ) { + const struct opengl_funcs *funcs = &display_funcs; UINT total, onscreen, size, max_level = 0; - const struct opengl_funcs *funcs; struct wgl_pbuffer *pbuffer; BOOL largest = FALSE;
TRACE( "(%p, %d, %d, %d, %p)\n", hdc, format, width, height, attribs );
- if (!(funcs = get_dc_funcs( hdc, NULL ))) return FALSE; funcs->p_get_pixel_formats( NULL, 0, &total, &onscreen ); if (format <= 0 || format > total) { @@ -1231,7 +971,7 @@ static struct wgl_pbuffer *win32u_wglCreatePbufferARB( HDC hdc, int format, int return NULL; } NtGdiSetPixelFormat( pbuffer->hdc, format ); - pbuffer->driver_funcs = display_driver_funcs; + pbuffer->driver_funcs = driver_funcs; pbuffer->funcs = funcs; pbuffer->width = width; pbuffer->height = height; @@ -1645,17 +1385,10 @@ static BOOL win32u_wgl_context_flush( struct wgl_context *context, void (*flush) static BOOL win32u_wglSwapBuffers( HDC hdc ) { struct wgl_context *context = NtCurrentTeb()->glContext; - const struct opengl_funcs *funcs; + const struct opengl_funcs *funcs = &display_funcs; int interval; HWND hwnd;
- if (!(funcs = get_dc_funcs( hdc, NULL ))) - { - RtlSetLastWin32Error( ERROR_DC_NOT_FOUND ); - return FALSE; - } - context->driver_funcs = funcs == &display_funcs ? display_driver_funcs : memory_driver_funcs; - if (!(hwnd = NtUserWindowFromDC( hdc ))) interval = 0; else interval = get_window_swap_interval( hwnd );
@@ -1709,58 +1442,31 @@ static int win32u_wglGetSwapIntervalEXT(void) return interval; }
-static void init_opengl_funcs( struct opengl_funcs *funcs, const struct opengl_driver_funcs *driver_funcs ) -{ -#define USE_GL_FUNC(func) \ - if (!funcs->p_##func && !(funcs->p_##func = driver_funcs->p_get_proc_address( #func ))) \ - { \ - WARN( "%s not found for memory DCs.\n", #func ); \ - funcs->p_##func = default_funcs->p_##func; \ - } - ALL_GL_FUNCS -#undef USE_GL_FUNC -} - -static inline void memory_funcs_init(void) -{ - if (!osmesa_get_wgl_driver( &memory_driver_funcs )) WARN( "Failed to initialize OSMesa functions\n" ); - - memory_formats_count = memory_driver_funcs->p_init_pixel_formats( &memory_onscreen_count ); - init_opengl_funcs( &memory_funcs, memory_driver_funcs ); - - memory_funcs.p_wglGetProcAddress = win32u_memory_wglGetProcAddress; - memory_funcs.p_get_pixel_formats = win32u_memory_get_pixel_formats; - - memory_funcs.p_wglGetPixelFormat = win32u_wglGetPixelFormat; - memory_funcs.p_wglSetPixelFormat = win32u_wglSetPixelFormat; - - memory_funcs.p_wglCreateContext = win32u_wglCreateContext; - memory_funcs.p_wglDeleteContext = win32u_wglDeleteContext; - memory_funcs.p_wglCopyContext = (void *)1; /* never called */ - memory_funcs.p_wglShareLists = (void *)1; /* never called */ - memory_funcs.p_wglMakeCurrent = win32u_wglMakeCurrent; - - memory_funcs.p_wglSwapBuffers = win32u_wglSwapBuffers; - memory_funcs.p_wgl_context_flush = win32u_wgl_context_flush; -} - static void display_funcs_init(void) { UINT status;
- if (egl_init( &display_driver_funcs )) TRACE( "Initialized EGL library\n" ); + if (egl_init( &driver_funcs )) TRACE( "Initialized EGL library\n" );
- if ((status = user_driver->pOpenGLInit( WINE_OPENGL_DRIVER_VERSION, &display_funcs, &display_driver_funcs ))) + if ((status = user_driver->pOpenGLInit( WINE_OPENGL_DRIVER_VERSION, &display_funcs, &driver_funcs ))) WARN( "Failed to initialize the driver OpenGL functions, status %#x\n", status ); - init_egl_platform( &display_egl, &display_funcs, display_driver_funcs ); + init_egl_platform( &display_egl, &display_funcs, driver_funcs ); + + formats_count = driver_funcs->p_init_pixel_formats( &onscreen_count );
- display_formats_count = display_driver_funcs->p_init_pixel_formats( &display_onscreen_count ); - init_opengl_funcs( &display_funcs, display_driver_funcs ); +#define USE_GL_FUNC(func) \ + if (!display_funcs.p_##func && !(display_funcs.p_##func = driver_funcs->p_get_proc_address( #func ))) \ + { \ + WARN( "%s not found for memory DCs.\n", #func ); \ + display_funcs.p_##func = default_funcs->p_##func; \ + } + ALL_GL_FUNCS +#undef USE_GL_FUNC
- display_funcs.p_wglGetProcAddress = win32u_display_wglGetProcAddress; - display_funcs.p_get_pixel_formats = win32u_display_get_pixel_formats; + display_funcs.p_wglGetProcAddress = win32u_wglGetProcAddress; + display_funcs.p_get_pixel_formats = win32u_get_pixel_formats;
- strcpy( wgl_extensions, display_driver_funcs->p_init_wgl_extensions( &display_funcs ) ); + strcpy( wgl_extensions, driver_funcs->p_init_wgl_extensions( &display_funcs ) ); display_funcs.p_wglGetPixelFormat = win32u_wglGetPixelFormat; display_funcs.p_wglSetPixelFormat = win32u_wglSetPixelFormat;
@@ -1823,32 +1529,15 @@ static void display_funcs_init(void) display_funcs.p_wglGetSwapIntervalEXT = win32u_wglGetSwapIntervalEXT; }
-static const struct opengl_funcs *get_dc_funcs( HDC hdc, const struct opengl_funcs *null_funcs ) -{ - DWORD is_disabled, is_display, is_memdc; - DC *dc; - - if (!(dc = get_dc_ptr( hdc ))) return NULL; - is_memdc = get_gdi_object_type( hdc ) == NTGDI_OBJ_MEMDC; - is_display = dc->is_display; - is_disabled = dc->attr->disabled; - release_dc_ptr( dc ); - - if (is_disabled) return NULL; - if (is_display || is_memdc) - { - static pthread_once_t display_init_once = PTHREAD_ONCE_INIT; - pthread_once( &display_init_once, display_funcs_init ); - return &display_funcs; - } - return NULL; -} - /*********************************************************************** * __wine_get_wgl_driver (win32u.@) */ const struct opengl_funcs *__wine_get_wgl_driver( HDC hdc, UINT version, const struct opengl_funcs *null_funcs ) { + static pthread_once_t init_once = PTHREAD_ONCE_INIT; + DWORD is_disabled, is_display, is_memdc; + DC *dc; + if (version != WINE_OPENGL_DRIVER_VERSION) { ERR( "version mismatch, opengl32 wants %u but dibdrv has %u\n", @@ -1857,5 +1546,15 @@ const struct opengl_funcs *__wine_get_wgl_driver( HDC hdc, UINT version, const s }
InterlockedExchangePointer( (void *)&default_funcs, (void *)null_funcs ); - return get_dc_funcs( hdc, null_funcs ); + + if (!(dc = get_dc_ptr( hdc ))) return NULL; + is_memdc = get_gdi_object_type( hdc ) == NTGDI_OBJ_MEMDC; + is_display = dc->is_display; + is_disabled = dc->attr->disabled; + release_dc_ptr( dc ); + + if (is_disabled) return NULL; + if (!is_display && !is_memdc) return NULL; + pthread_once( &init_once, display_funcs_init ); + return &display_funcs; } diff --git a/tools/gitlab/image.docker b/tools/gitlab/image.docker index ac59ee8937b..0a1d9f788b7 100644 --- a/tools/gitlab/image.docker +++ b/tools/gitlab/image.docker @@ -29,7 +29,6 @@ RUN export DEBIAN_FRONTEND=noninteractive; \ libgphoto2-dev:amd64 libgphoto2-dev:i386 \ libice-dev:amd64 libice-dev:i386 \ libkrb5-dev:amd64 libkrb5-dev:i386 \ - libosmesa6-dev:amd64 libosmesa6-dev:i386 \ libpcap-dev:amd64 libpcap-dev:i386 \ libpcsclite-dev:amd64 \ libpulse-dev:amd64 libpulse-dev:i386 \
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 57 +++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 32 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 6b0fa5bd481..b997ea4a8a8 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -41,8 +41,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(wgl);
struct wgl_context { - const struct opengl_driver_funcs *driver_funcs; - const struct opengl_funcs *funcs; void *driver_private; int pixel_format;
@@ -52,8 +50,6 @@ struct wgl_context
struct wgl_pbuffer { - const struct opengl_driver_funcs *driver_funcs; - const struct opengl_funcs *funcs; void *driver_private;
HDC hdc; @@ -770,7 +766,7 @@ static BOOL flush_memory_pbuffer( struct wgl_context *context, HDC hdc, BOOL wri
static void destroy_memory_pbuffer( struct wgl_context *context, HDC hdc ) { - const struct opengl_funcs *funcs = context->funcs; + const struct opengl_funcs *funcs = &display_funcs; flush_memory_pbuffer( context, hdc, FALSE, funcs->p_glFinish ); funcs->p_wglDestroyPbufferARB( context->memory_pbuffer ); context->memory_pbuffer = NULL; @@ -838,7 +834,6 @@ static void win32u_get_pixel_formats( struct wgl_pixel_format *formats, UINT max static struct wgl_context *context_create( HDC hdc, struct wgl_context *shared, const int *attribs ) { void *shared_private = shared ? shared->driver_private : NULL; - const struct opengl_funcs *funcs = &display_funcs; struct wgl_context *context; int format;
@@ -851,11 +846,9 @@ static struct wgl_context *context_create( HDC hdc, struct wgl_context *shared, }
if (!(context = calloc( 1, sizeof(*context) ))) return NULL; - context->driver_funcs = driver_funcs; - context->funcs = funcs; context->pixel_format = format;
- if (!context->driver_funcs->p_context_create( hdc, format, shared_private, attribs, &context->driver_private )) + if (!driver_funcs->p_context_create( hdc, format, shared_private, attribs, &context->driver_private )) { free( context ); return NULL; @@ -883,12 +876,11 @@ static struct wgl_context *win32u_wglCreateContext( HDC hdc )
static BOOL win32u_wglDeleteContext( struct wgl_context *context ) { - const struct opengl_driver_funcs *funcs = context->driver_funcs; BOOL ret;
TRACE( "context %p\n", context );
- ret = funcs->p_context_destroy( context->driver_private ); + ret = driver_funcs->p_context_destroy( context->driver_private ); free( context );
return ret; @@ -971,8 +963,6 @@ static struct wgl_pbuffer *win32u_wglCreatePbufferARB( HDC hdc, int format, int return NULL; } NtGdiSetPixelFormat( pbuffer->hdc, format ); - pbuffer->driver_funcs = driver_funcs; - pbuffer->funcs = funcs; pbuffer->width = width; pbuffer->height = height; pbuffer->mipmap_level = -1; @@ -1060,9 +1050,9 @@ static struct wgl_pbuffer *win32u_wglCreatePbufferARB( HDC hdc, int format, int } }
- if (pbuffer->driver_funcs->p_pbuffer_create( pbuffer->hdc, format, largest, pbuffer->texture_format, - pbuffer->texture_target, max_level, &pbuffer->width, - &pbuffer->height, &pbuffer->driver_private )) + if (driver_funcs->p_pbuffer_create( pbuffer->hdc, format, largest, pbuffer->texture_format, + pbuffer->texture_target, max_level, &pbuffer->width, + &pbuffer->height, &pbuffer->driver_private )) return pbuffer;
failed: @@ -1074,10 +1064,12 @@ failed:
static BOOL win32u_wglDestroyPbufferARB( struct wgl_pbuffer *pbuffer ) { + const struct opengl_funcs *funcs = &display_funcs; + TRACE( "pbuffer %p\n", pbuffer );
- pbuffer->driver_funcs->p_pbuffer_destroy( pbuffer->hdc, pbuffer->driver_private ); - if (pbuffer->tmp_context) pbuffer->funcs->p_wglDeleteContext( pbuffer->tmp_context ); + driver_funcs->p_pbuffer_destroy( pbuffer->hdc, pbuffer->driver_private ); + if (pbuffer->tmp_context) funcs->p_wglDeleteContext( pbuffer->tmp_context ); NtGdiDeleteObjectApp( pbuffer->hdc ); free( pbuffer );
@@ -1199,6 +1191,7 @@ static GLenum binding_from_target( GLenum target )
static BOOL win32u_wglBindTexImageARB( struct wgl_pbuffer *pbuffer, int buffer ) { + const struct opengl_funcs *funcs = &display_funcs; HDC prev_draw = NtCurrentTeb()->glReserved1[0], prev_read = NtCurrentTeb()->glReserved1[1]; int prev_texture = 0, format = win32u_wglGetPixelFormat( pbuffer->hdc ); struct wgl_context *prev_context = NtCurrentTeb()->glContext; @@ -1214,7 +1207,7 @@ static BOOL win32u_wglBindTexImageARB( struct wgl_pbuffer *pbuffer, int buffer ) return GL_FALSE; }
- if (!pbuffer->driver_funcs->p_describe_pixel_format( format, &desc )) + if (!driver_funcs->p_describe_pixel_format( format, &desc )) { RtlSetLastWin32Error( ERROR_INVALID_PIXEL_FORMAT ); return FALSE; @@ -1257,29 +1250,29 @@ static BOOL win32u_wglBindTexImageARB( struct wgl_pbuffer *pbuffer, int buffer ) return GL_FALSE; }
- if ((ret = pbuffer->driver_funcs->p_pbuffer_bind( pbuffer->hdc, pbuffer->driver_private, source )) != -1) + if ((ret = driver_funcs->p_pbuffer_bind( pbuffer->hdc, pbuffer->driver_private, source )) != -1) return ret;
if (!pbuffer->tmp_context || pbuffer->prev_context != prev_context) { - if (pbuffer->tmp_context) pbuffer->funcs->p_wglDeleteContext( pbuffer->tmp_context ); - pbuffer->tmp_context = pbuffer->funcs->p_wglCreateContextAttribsARB( pbuffer->hdc, prev_context, NULL ); + if (pbuffer->tmp_context) funcs->p_wglDeleteContext( pbuffer->tmp_context ); + pbuffer->tmp_context = funcs->p_wglCreateContextAttribsARB( pbuffer->hdc, prev_context, NULL ); pbuffer->prev_context = prev_context; }
- pbuffer->funcs->p_glGetIntegerv( binding_from_target( pbuffer->texture_target ), &prev_texture ); + funcs->p_glGetIntegerv( binding_from_target( pbuffer->texture_target ), &prev_texture );
/* Switch to our pbuffer */ - pbuffer->funcs->p_wglMakeCurrent( pbuffer->hdc, pbuffer->tmp_context ); + funcs->p_wglMakeCurrent( pbuffer->hdc, pbuffer->tmp_context );
/* Make sure that the prev_texture is set as the current texture state isn't shared * between contexts. After that copy the pbuffer texture data. */ - pbuffer->funcs->p_glBindTexture( pbuffer->texture_target, prev_texture ); - pbuffer->funcs->p_glCopyTexImage2D( pbuffer->texture_target, 0, pbuffer->texture_format, 0, 0, + funcs->p_glBindTexture( pbuffer->texture_target, prev_texture ); + funcs->p_glCopyTexImage2D( pbuffer->texture_target, 0, pbuffer->texture_format, 0, 0, pbuffer->width, pbuffer->height, 0 );
/* Switch back to the original drawable and context */ - pbuffer->funcs->p_wglMakeContextCurrentARB( prev_draw, prev_read, prev_context ); + funcs->p_wglMakeContextCurrentARB( prev_draw, prev_read, prev_context ); return GL_TRUE; }
@@ -1293,7 +1286,7 @@ static BOOL win32u_wglReleaseTexImageARB( struct wgl_pbuffer *pbuffer, int buffe return GL_FALSE; }
- return !!pbuffer->driver_funcs->p_pbuffer_bind( pbuffer->hdc, pbuffer->driver_private, GL_NONE ); + return !!driver_funcs->p_pbuffer_bind( pbuffer->hdc, pbuffer->driver_private, GL_NONE ); }
static BOOL win32u_wglSetPbufferAttribARB( struct wgl_pbuffer *pbuffer, const int *attribs ) @@ -1351,8 +1344,8 @@ static BOOL win32u_wglSetPbufferAttribARB( struct wgl_pbuffer *pbuffer, const in } }
- return pbuffer->driver_funcs->p_pbuffer_updated( pbuffer->hdc, pbuffer->driver_private, - pbuffer->cube_face, max( pbuffer->mipmap_level, 0 ) ); + return driver_funcs->p_pbuffer_updated( pbuffer->hdc, pbuffer->driver_private, + pbuffer->cube_face, max( pbuffer->mipmap_level, 0 ) ); }
static int get_window_swap_interval( HWND hwnd ) @@ -1379,7 +1372,7 @@ static BOOL win32u_wgl_context_flush( struct wgl_context *context, void (*flush) TRACE( "context %p, hwnd %p, draw_hdc %p, interval %d, flush %p\n", context, hwnd, draw_hdc, interval, flush );
if (context->memory_pbuffer) return flush_memory_pbuffer( context, draw_hdc, FALSE, flush ); - return context->driver_funcs->p_context_flush( context->driver_private, hwnd, draw_hdc, interval, flush ); + return driver_funcs->p_context_flush( context->driver_private, hwnd, draw_hdc, interval, flush ); }
static BOOL win32u_wglSwapBuffers( HDC hdc ) @@ -1393,7 +1386,7 @@ static BOOL win32u_wglSwapBuffers( HDC hdc ) else interval = get_window_swap_interval( hwnd );
if (context->memory_pbuffer) return flush_memory_pbuffer( context, hdc, FALSE, funcs->p_glFlush ); - return context->driver_funcs->p_swap_buffers( context ? context->driver_private : NULL, hwnd, hdc, interval ); + return driver_funcs->p_swap_buffers( context ? context->driver_private : NULL, hwnd, hdc, interval ); }
static BOOL win32u_wglSwapIntervalEXT( int interval )
v5: Split first commit and rebase.