From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/opengl.c | 107 +--------------------------------- 1 file changed, 2 insertions(+), 105 deletions(-)
diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index d7eb99dde13..f27d35c67a8 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -46,14 +46,9 @@ static const struct egl_platform *egl; static const struct opengl_funcs *funcs; static const struct opengl_drawable_funcs wayland_drawable_funcs;
-static pthread_mutex_t gl_object_mutex = PTHREAD_MUTEX_INITIALIZER; -static struct list gl_drawables = LIST_INIT(gl_drawables); -static struct list gl_contexts = LIST_INIT(gl_contexts); - struct wayland_gl_drawable { struct opengl_drawable base; - struct list entry; struct wayland_client_surface *client; struct wl_egl_window *wl_egl_window; EGLSurface surface; @@ -67,50 +62,14 @@ static struct wayland_gl_drawable *impl_from_opengl_drawable(struct opengl_drawa
struct wayland_context { - struct list entry; EGLConfig config; EGLContext context; - struct wayland_gl_drawable *draw, *read; -}; - -struct wgl_pbuffer -{ - struct list entry; - struct wayland_gl_drawable *gl; - int width, height, pixel_format; - int texture_format, texture_target, texture_binding; - EGLContext tmp_context, prev_context; };
-struct wayland_pbuffer_dc -{ - struct list entry; - HDC hdc; - struct wayland_gl_drawable *gl; -}; - -/* lookup the existing drawable for a window, gl_object_mutex must be held */ -static struct wayland_gl_drawable *find_drawable(HWND hwnd, HDC hdc) -{ - struct wayland_gl_drawable *gl; - LIST_FOR_EACH_ENTRY(gl, &gl_drawables, struct wayland_gl_drawable, entry) - { - if (hwnd && gl->base.hwnd == hwnd) return gl; - if (hdc && gl->base.hdc == hdc) return gl; - } - return NULL; -} - static void wayland_drawable_destroy(struct opengl_drawable *base) { struct wayland_gl_drawable *gl = impl_from_opengl_drawable(base);
- if (!gl->base.hwnd) - { - pthread_mutex_lock(&gl_object_mutex); - list_remove(&gl->entry); - pthread_mutex_unlock(&gl_object_mutex); - } if (gl->surface) funcs->p_eglDestroySurface(egl->display, gl->surface); if (gl->wl_egl_window) wl_egl_window_destroy(gl->wl_egl_window); if (gl->client) @@ -127,16 +86,7 @@ static void wayland_drawable_destroy(struct opengl_drawable *base)
static void wayland_drawable_detach(struct opengl_drawable *base) { - struct wayland_gl_drawable *gl = impl_from_opengl_drawable(base), *old; - HWND hwnd = base->hwnd; - TRACE("%s\n", debugstr_opengl_drawable(base)); - - pthread_mutex_lock(&gl_object_mutex); - if ((old = find_drawable(hwnd, 0)) && old == gl) list_remove(&gl->entry); - pthread_mutex_unlock(&gl_object_mutex); - - if (gl) opengl_drawable_release(&gl->base); }
static void wayland_drawable_update(struct opengl_drawable *base) @@ -206,20 +156,6 @@ err: return NULL; }
-static void wayland_update_gl_drawable(HWND hwnd, struct wayland_gl_drawable *new) -{ - struct wayland_gl_drawable *old; - - pthread_mutex_lock(&gl_object_mutex); - - if ((old = find_drawable(hwnd, 0))) list_remove(&old->entry); - if (new) list_add_head(&gl_drawables, &new->entry); - - pthread_mutex_unlock(&gl_object_mutex); - - if (old) opengl_drawable_release(&old->base); -} - static void wayland_gl_drawable_sync_size(struct wayland_gl_drawable *gl) { int client_width, client_height; @@ -236,9 +172,7 @@ static void wayland_gl_drawable_sync_size(struct wayland_gl_drawable *gl) static BOOL wayland_make_current(struct opengl_drawable *draw_base, struct opengl_drawable *read_base, void *private) { struct wayland_gl_drawable *draw = impl_from_opengl_drawable(draw_base), *read = impl_from_opengl_drawable(read_base); - BOOL ret; struct wayland_context *ctx = private; - struct wayland_gl_drawable *old_draw = NULL, *old_read = NULL;
TRACE("draw %s, read %s, context %p\n", debugstr_opengl_drawable(draw_base), debugstr_opengl_drawable(read_base), private);
@@ -248,26 +182,7 @@ static BOOL wayland_make_current(struct opengl_drawable *draw_base, struct openg return TRUE; }
- pthread_mutex_lock(&gl_object_mutex); - - ret = funcs->p_eglMakeCurrent(egl->display, - draw ? draw->surface : EGL_NO_SURFACE, - read ? read->surface : EGL_NO_SURFACE, - ctx->context); - if (ret) - { - old_draw = ctx->draw; - old_read = ctx->read; - if ((ctx->draw = draw)) opengl_drawable_add_ref(&draw->base); - if ((ctx->read = read)) opengl_drawable_add_ref(&read->base); - } - - pthread_mutex_unlock(&gl_object_mutex); - - if (old_draw) opengl_drawable_release(&old_draw->base); - if (old_read) opengl_drawable_release(&old_read->base); - - return ret; + return funcs->p_eglMakeCurrent(egl->display, draw->surface, read->surface, ctx->context); }
static BOOL wayland_opengl_surface_create(HWND hwnd, HDC hdc, int format, struct opengl_drawable **drawable) @@ -283,10 +198,8 @@ static BOOL wayland_opengl_surface_create(HWND hwnd, HDC hdc, int format, struct if (rect.bottom == rect.top) rect.bottom = rect.top + 1;
if (!(gl = wayland_gl_drawable_create(hwnd, 0, format, rect.right - rect.left, rect.bottom - rect.top))) return FALSE; - wayland_update_gl_drawable(hwnd, gl); - if (previous) opengl_drawable_release( previous ); - opengl_drawable_add_ref( (*drawable = &gl->base) ); + *drawable = &gl->base; return TRUE; }
@@ -365,11 +278,6 @@ static BOOL wayland_context_create(int format, void *share_private, const int *a ctx->context = funcs->p_eglCreateContext(egl->display, EGL_NO_CONFIG_KHR, share ? share->context : EGL_NO_CONTEXT, attribs ? egl_attribs : NULL); - - pthread_mutex_lock(&gl_object_mutex); - list_add_head(&gl_contexts, &ctx->entry); - pthread_mutex_unlock(&gl_object_mutex); - TRACE("ctx=%p egl_context=%p\n", ctx, ctx->context);
*private = ctx; @@ -379,13 +287,7 @@ static BOOL wayland_context_create(int format, void *share_private, const int *a static BOOL wayland_context_destroy(void *private) { struct wayland_context *ctx = private; - - pthread_mutex_lock(&gl_object_mutex); - list_remove(&ctx->entry); - pthread_mutex_unlock(&gl_object_mutex); funcs->p_eglDestroyContext(egl->display, ctx->context); - if (ctx->draw) opengl_drawable_release(&ctx->draw->base); - if (ctx->read) opengl_drawable_release(&ctx->read->base); free(ctx); return TRUE; } @@ -435,11 +337,6 @@ static BOOL wayland_pbuffer_create(HDC hdc, int format, BOOL largest, GLenum tex
/* Use an unmapped wayland surface as our offscreen "pbuffer" surface. */ if (!(drawable = wayland_gl_drawable_create(0, hdc, format, *width, *height))) return FALSE; - - pthread_mutex_lock(&gl_object_mutex); - list_add_head(&gl_drawables, &drawable->entry); - pthread_mutex_unlock(&gl_object_mutex); - *surface = &drawable->base; return TRUE; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/opengl.c | 78 +++------------------------------------ 1 file changed, 6 insertions(+), 72 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 563b43bf992..80554860bdc 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -197,9 +197,6 @@ struct glx_pixel_format struct x11drv_context { GLXContext ctx; - struct gl_drawable *draw; - struct gl_drawable *read; - struct list entry; };
struct gl_drawable @@ -228,12 +225,6 @@ enum glx_swap_control_method GLX_SWAP_CONTROL_MESA };
-/* X context to associate a struct gl_drawable to an hwnd */ -static XContext gl_hwnd_context; -/* X context to associate a struct gl_drawable to a pbuffer hdc */ -static XContext gl_pbuffer_context; - -static struct list context_list = LIST_INIT( context_list ); static struct glx_pixel_format *pixel_formats; static int nb_pixel_formats, nb_onscreen_formats;
@@ -243,8 +234,6 @@ static enum glx_swap_control_method swap_control_method = GLX_SWAP_CONTROL_NONE; static BOOL has_swap_control_tear = FALSE; static BOOL has_swap_method = FALSE;
-static pthread_mutex_t context_mutex = PTHREAD_MUTEX_INITIALIZER; - static const BOOL is_win64 = sizeof(void *) > sizeof(int);
static BOOL glxRequireVersion(int requiredVersion); @@ -585,8 +574,6 @@ UINT X11DRV_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, c ERR( "GLX extension is missing, disabling OpenGL.\n" ); goto failed; } - gl_hwnd_context = XUniqueContext(); - gl_pbuffer_context = XUniqueContext();
/* In case of GLX you have direct and indirect rendering. Most of the time direct rendering is used * as in general only that is hardware accelerated. In some cases like in case of remote X indirect @@ -889,7 +876,7 @@ static BOOL x11drv_surface_create( HWND hwnd, HDC hdc, int format, struct opengl { struct glx_pixel_format *fmt = glx_pixel_format_from_format( format ); struct opengl_drawable *previous; - struct gl_drawable *gl, *prev; + struct gl_drawable *gl; RECT rect;
if ((previous = *drawable) && previous->format == format) return TRUE; @@ -912,17 +899,10 @@ static BOOL x11drv_surface_create( HWND hwnd, HDC hdc, int format, struct opengl }
TRACE( "Created drawable %s with client window %lx\n", debugstr_opengl_drawable( &gl->base ), gl->window ); - - pthread_mutex_lock( &context_mutex ); - if (XFindContext( gdi_display, (XID)hwnd, gl_hwnd_context, (char **)&prev )) prev = NULL; - XSaveContext( gdi_display, (XID)hwnd, gl_hwnd_context, (char *)gl ); - pthread_mutex_unlock( &context_mutex ); - if (prev) opengl_drawable_release( &prev->base ); - XFlush( gdi_display );
if (previous) opengl_drawable_release( previous ); - opengl_drawable_add_ref( (*drawable = &gl->base) ); + *drawable = &gl->base; return TRUE; }
@@ -1005,17 +985,7 @@ static void x11drv_surface_update( struct opengl_drawable *base )
static void x11drv_surface_detach( struct opengl_drawable *base ) { - struct gl_drawable *gl = impl_from_opengl_drawable( base ), *current; - HWND hwnd = base->hwnd; - TRACE( "%s\n", debugstr_opengl_drawable( base ) ); - - pthread_mutex_lock( &context_mutex ); - if (XFindContext( gdi_display, (XID)hwnd, gl_hwnd_context, (char **)¤t )) current = NULL; - else if (current == gl) XDeleteContext( gdi_display, (XID)hwnd, gl_hwnd_context ); - pthread_mutex_unlock( &context_mutex ); - - if (current == gl) opengl_drawable_release( ¤t->base ); }
@@ -1215,13 +1185,7 @@ static BOOL x11drv_context_destroy(void *private)
TRACE("(%p)\n", ctx);
- pthread_mutex_lock( &context_mutex ); - list_remove( &ctx->entry ); - pthread_mutex_unlock( &context_mutex ); - if (ctx->ctx) pglXDestroyContext( gdi_display, ctx->ctx ); - if (ctx->draw) opengl_drawable_release( &ctx->draw->base ); - if (ctx->read) opengl_drawable_release( &ctx->read->base ); free( ctx ); return TRUE; } @@ -1235,9 +1199,9 @@ static void *x11drv_get_proc_address( const char *name )
static BOOL x11drv_make_current( struct opengl_drawable *draw_base, struct opengl_drawable *read_base, void *private ) { - struct gl_drawable *old_draw, *old_read, *draw = impl_from_opengl_drawable( draw_base ), *read = impl_from_opengl_drawable( read_base ); + struct gl_drawable *draw = impl_from_opengl_drawable( draw_base ), *read = impl_from_opengl_drawable( read_base ); struct x11drv_context *ctx = private; - BOOL ret = FALSE; + BOOL ret;
TRACE( "draw %s, read %s, context %p\n", debugstr_opengl_drawable( draw_base ), debugstr_opengl_drawable( read_base ), private );
@@ -1250,20 +1214,8 @@ static BOOL x11drv_make_current( struct opengl_drawable *draw_base, struct openg
if (!pglXMakeContextCurrent) ret = pglXMakeCurrent( gdi_display, draw->drawable, ctx->ctx ); else ret = pglXMakeContextCurrent( gdi_display, draw->drawable, read->drawable, ctx->ctx ); - if (!ret) return FALSE; - - pthread_mutex_lock( &context_mutex ); - old_draw = ctx->draw; - old_read = ctx->read; - if ((ctx->draw = draw)) opengl_drawable_add_ref( &draw->base ); - if ((ctx->read = read)) opengl_drawable_add_ref( &read->base ); - pthread_mutex_unlock( &context_mutex ); - - if (old_draw) opengl_drawable_release( &old_draw->base ); - if (old_read) opengl_drawable_release( &old_read->base ); - NtCurrentTeb()->glReserved2 = ctx; - return TRUE; + return ret; }
static void present_gl_drawable( struct gl_drawable *gl, BOOL flush, BOOL gl_finish ) @@ -1309,12 +1261,7 @@ static void x11drv_surface_flush( struct opengl_drawable *base, UINT flags )
TRACE( "%s flags %#x\n", debugstr_opengl_drawable( base ), flags );
- if (flags & GL_FLUSH_INTERVAL) - { - pthread_mutex_lock( &context_mutex ); - set_swap_interval( gl, base->interval ); - pthread_mutex_unlock( &context_mutex ); - } + if (flags & GL_FLUSH_INTERVAL) set_swap_interval( gl, base->interval );
update_gl_drawable_size( gl ); update_gl_drawable_offscreen( gl ); @@ -1393,10 +1340,6 @@ static BOOL x11drv_context_create( int format, void *share_private, const int *a free( ret ); return FALSE; } - - pthread_mutex_lock( &context_mutex ); - list_add_head( &context_list, &ret->entry ); - pthread_mutex_unlock( &context_mutex ); }
TRACE( "-> %p\n", ret ); @@ -1440,10 +1383,6 @@ static BOOL x11drv_pbuffer_create( HDC hdc, int format, BOOL largest, GLenum tex SetRect( &rect, 0, 0, *width, *height ); set_dc_drawable( hdc, gl->drawable, &rect, IncludeInferiors );
- pthread_mutex_lock( &context_mutex ); - XSaveContext( gdi_display, (XID)hdc, gl_pbuffer_context, (char *)gl ); - pthread_mutex_unlock( &context_mutex ); - *drawable = &gl->base; return TRUE; } @@ -1451,14 +1390,9 @@ static BOOL x11drv_pbuffer_create( HDC hdc, int format, BOOL largest, GLenum tex static void x11drv_pbuffer_destroy( struct opengl_drawable *base ) { struct gl_drawable *gl = impl_from_opengl_drawable( base ); - HDC hdc = gl->base.hdc;
TRACE( "drawable %s\n", debugstr_opengl_drawable( base ) );
- pthread_mutex_lock( &context_mutex ); - XDeleteContext( gdi_display, (XID)hdc, gl_pbuffer_context ); - pthread_mutex_unlock( &context_mutex ); - if (gl->drawable) pglXDestroyPbuffer( gdi_display, gl->drawable ); }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/opengl.c | 45 +++++++---------------------------- 1 file changed, 9 insertions(+), 36 deletions(-)
diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index f27d35c67a8..aa357358645 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -60,12 +60,6 @@ static struct wayland_gl_drawable *impl_from_opengl_drawable(struct opengl_drawa return CONTAINING_RECORD(base, struct wayland_gl_drawable, base); }
-struct wayland_context -{ - EGLConfig config; - EGLContext context; -}; - static void wayland_drawable_destroy(struct opengl_drawable *base) { struct wayland_gl_drawable *gl = impl_from_opengl_drawable(base); @@ -169,20 +163,11 @@ static void wayland_gl_drawable_sync_size(struct wayland_gl_drawable *gl) wl_egl_window_resize(gl->wl_egl_window, client_width, client_height, 0, 0); }
-static BOOL wayland_make_current(struct opengl_drawable *draw_base, struct opengl_drawable *read_base, void *private) +static BOOL wayland_make_current(struct opengl_drawable *draw_base, struct opengl_drawable *read_base, void *context) { struct wayland_gl_drawable *draw = impl_from_opengl_drawable(draw_base), *read = impl_from_opengl_drawable(read_base); - struct wayland_context *ctx = private; - - TRACE("draw %s, read %s, context %p\n", debugstr_opengl_drawable(draw_base), debugstr_opengl_drawable(read_base), private); - - if (!private) - { - funcs->p_eglMakeCurrent(egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - return TRUE; - } - - return funcs->p_eglMakeCurrent(egl->display, draw->surface, read->surface, ctx->context); + TRACE("draw %s, read %s, context %p\n", debugstr_opengl_drawable(draw_base), debugstr_opengl_drawable(read_base), context); + return funcs->p_eglMakeCurrent(egl->display, context ? draw->surface : EGL_NO_SURFACE, context ? read->surface : EGL_NO_SURFACE, context); }
static BOOL wayland_opengl_surface_create(HWND hwnd, HDC hdc, int format, struct opengl_drawable **drawable) @@ -203,9 +188,8 @@ static BOOL wayland_opengl_surface_create(HWND hwnd, HDC hdc, int format, struct return TRUE; }
-static BOOL wayland_context_create(int format, void *share_private, const int *attribs, void **private) +static BOOL wayland_context_create(int format, void *share, const int *attribs, void **context) { - struct wayland_context *share = share_private, *ctx; EGLint egl_attribs[16], *attribs_end = egl_attribs;
TRACE("format=%d share=%p attribs=%p\n", format, share, attribs); @@ -261,12 +245,6 @@ static BOOL wayland_context_create(int format, void *share_private, const int *a } *attribs_end = EGL_NONE;
- if (!(ctx = calloc(1, sizeof(*ctx)))) - { - ERR("Failed to allocate memory for GL context\n"); - return FALSE; - } - /* For now only OpenGL is supported. It's enough to set the API only for * context creation, since: * 1. the default API is EGL_OPENGL_ES_API @@ -275,20 +253,15 @@ static BOOL wayland_context_create(int format, void *share_private, const int *a * > purposes except eglCreateContext. */ funcs->p_eglBindAPI(EGL_OPENGL_API); - ctx->context = funcs->p_eglCreateContext(egl->display, EGL_NO_CONFIG_KHR, - share ? share->context : EGL_NO_CONTEXT, - attribs ? egl_attribs : NULL); - TRACE("ctx=%p egl_context=%p\n", ctx, ctx->context); - - *private = ctx; + *context = funcs->p_eglCreateContext(egl->display, EGL_NO_CONFIG_KHR, share, + attribs ? egl_attribs : NULL); + TRACE("egl_context=%p\n", *context); return TRUE; }
-static BOOL wayland_context_destroy(void *private) +static BOOL wayland_context_destroy(void *context) { - struct wayland_context *ctx = private; - funcs->p_eglDestroyContext(egl->display, ctx->context); - free(ctx); + funcs->p_eglDestroyContext(egl->display, context); return TRUE; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/wineandroid.drv/opengl.c | 45 +++++++---------------------------- 1 file changed, 8 insertions(+), 37 deletions(-)
diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index d41ff76e320..9a970922530 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -51,17 +51,6 @@ static const struct opengl_funcs *funcs; static const struct opengl_drawable_funcs android_drawable_funcs; static const int egl_client_version = 2;
-struct egl_pixel_format -{ - EGLConfig config; -}; - -struct android_context -{ - EGLConfig config; - EGLContext context; -}; - struct gl_drawable { struct opengl_drawable base; @@ -161,9 +150,8 @@ static BOOL android_surface_create( HWND hwnd, HDC hdc, int format, struct openg return TRUE; }
-static BOOL android_context_create( int format, void *share, const int *attribs, void **private ) +static BOOL android_context_create( int format, void *share, const int *attribs, void **context ) { - struct android_context *ctx, *shared_ctx = share; int count = 0, egl_attribs[3]; BOOL opengl_es = FALSE;
@@ -198,41 +186,24 @@ static BOOL android_context_create( int format, void *share, const int *attribs, egl_attribs[count] = EGL_NONE; attribs = egl_attribs;
- ctx = malloc( sizeof(*ctx) ); - - ctx->config = egl_config_for_format(format); - ctx->context = funcs->p_eglCreateContext( egl->display, ctx->config, shared_ctx ? shared_ctx->context : EGL_NO_CONTEXT, attribs ); - TRACE( "fmt %d ctx %p\n", format, ctx->context ); - - *private = ctx; + *context = funcs->p_eglCreateContext( egl->display, egl_config_for_format(format), share, attribs ); + TRACE( "fmt %d ctx %p\n", format, *context ); return TRUE; }
-static BOOL android_make_current( struct opengl_drawable *draw_base, struct opengl_drawable *read_base, void *private ) +static BOOL android_make_current( struct opengl_drawable *draw_base, struct opengl_drawable *read_base, void *context ) { struct gl_drawable *draw = impl_from_opengl_drawable( draw_base ), *read = impl_from_opengl_drawable( read_base ); - struct android_context *ctx = private; - - TRACE( "draw %s, read %s, context %p\n", debugstr_opengl_drawable( draw_base ), debugstr_opengl_drawable( read_base ), private ); - - if (!private) - { - funcs->p_eglMakeCurrent( egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); - return TRUE; - } - - if (!funcs->p_eglMakeCurrent( egl->display, draw->surface, read->surface, ctx->context )) return FALSE; - return TRUE; + TRACE( "draw %s, read %s, context %p\n", debugstr_opengl_drawable( draw_base ), debugstr_opengl_drawable( read_base ), context ); + return funcs->p_eglMakeCurrent( egl->display, context ? draw->surface : EGL_NO_SURFACE, context ? read->surface : EGL_NO_SURFACE, context ); }
/*********************************************************************** * android_wglDeleteContext */ -static BOOL android_context_destroy( void *private ) +static BOOL android_context_destroy( void *context ) { - struct android_context *ctx = private; - funcs->p_eglDestroyContext( egl->display, ctx->context ); - free( ctx ); + funcs->p_eglDestroyContext( egl->display, context ); return TRUE; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 79 +++++++++++++++++++++++++++++++--- dlls/wineandroid.drv/opengl.c | 55 +----------------------- dlls/winewayland.drv/opengl.c | 81 +---------------------------------- 3 files changed, 78 insertions(+), 137 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 107078f6108..a2e5a29ffd8 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -490,16 +490,85 @@ static UINT egldrv_pbuffer_bind( HDC hdc, struct opengl_drawable *drawable, GLen return -1; /* use default implementation */ }
-static BOOL egldrv_context_create( int format, void *share, const int *attribs, void **private ) +static BOOL egldrv_context_create( int format, void *share, const int *attribs, void **context ) { - FIXME( "stub!\n" ); + const struct opengl_funcs *funcs = &display_funcs; + const struct egl_platform *egl = &display_egl; + EGLint egl_attribs[16], *attribs_end = egl_attribs; + + TRACE( "format %d, share %p, attribs %p\n", format, share, attribs ); + + for (; attribs && attribs[0] != 0; attribs += 2) + { + EGLint name; + + TRACE( "%#x %#x\n", attribs[0], attribs[1] ); + + /* Find the EGL attribute names corresponding to the WGL names. + * For all of the attributes below, the values match between the two + * systems, so we can use them directly. */ + switch (attribs[0]) + { + case WGL_CONTEXT_MAJOR_VERSION_ARB: + name = EGL_CONTEXT_MAJOR_VERSION_KHR; + break; + case WGL_CONTEXT_MINOR_VERSION_ARB: + name = EGL_CONTEXT_MINOR_VERSION_KHR; + break; + case WGL_CONTEXT_FLAGS_ARB: + name = EGL_CONTEXT_FLAGS_KHR; + break; + case WGL_CONTEXT_OPENGL_NO_ERROR_ARB: + name = EGL_CONTEXT_OPENGL_NO_ERROR_KHR; + break; + case WGL_CONTEXT_PROFILE_MASK_ARB: + if (attribs[1] & WGL_CONTEXT_ES2_PROFILE_BIT_EXT) + { + ERR( "OpenGL ES contexts are not supported\n" ); + return FALSE; + } + name = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR; + break; + default: + name = EGL_NONE; + FIXME( "Unhandled attributes: %#x %#x\n", attribs[0], attribs[1] ); + } + + if (name != EGL_NONE) + { + EGLint *dst = egl_attribs; + /* Check if we have already set the same attribute and replace it. */ + for (; dst != attribs_end && *dst != name; dst += 2) continue; + /* Our context attribute array should have enough space for all the + * attributes we support (we merge repetitions), plus EGL_NONE. */ + assert( dst - egl_attribs <= ARRAY_SIZE(egl_attribs) - 3 ); + dst[0] = name; + dst[1] = attribs[1]; + if (dst == attribs_end) attribs_end += 2; + } + } + *attribs_end = EGL_NONE; + + /* For now only OpenGL is supported. It's enough to set the API only for + * context creation, since: + * 1. the default API is EGL_OPENGL_ES_API + * 2. the EGL specification says in section 3.7: + * > EGL_OPENGL_API and EGL_OPENGL_ES_API are interchangeable for all + * > purposes except eglCreateContext. + */ + funcs->p_eglBindAPI( EGL_OPENGL_API ); + *context = funcs->p_eglCreateContext( egl->display, EGL_NO_CONFIG_KHR, share, attribs ? egl_attribs : NULL ); + TRACE( "Created context %p\n", *context ); return TRUE; }
-static BOOL egldrv_context_destroy( void *private ) +static BOOL egldrv_context_destroy( void *context ) { - FIXME( "stub!\n" ); - return FALSE; + const struct opengl_funcs *funcs = &display_funcs; + const struct egl_platform *egl = &display_egl; + + funcs->p_eglDestroyContext( egl->display, context ); + return TRUE; }
static BOOL egldrv_make_current( struct opengl_drawable *draw_base, struct opengl_drawable *read_base, void *private ) diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index 9a970922530..c3c77b03170 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -49,7 +49,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(android); static const struct egl_platform *egl; static const struct opengl_funcs *funcs; static const struct opengl_drawable_funcs android_drawable_funcs; -static const int egl_client_version = 2;
struct gl_drawable { @@ -150,47 +149,6 @@ static BOOL android_surface_create( HWND hwnd, HDC hdc, int format, struct openg return TRUE; }
-static BOOL android_context_create( int format, void *share, const int *attribs, void **context ) -{ - int count = 0, egl_attribs[3]; - BOOL opengl_es = FALSE; - - if (!attribs) opengl_es = TRUE; - while (attribs && *attribs && count < 2) - { - switch (*attribs) - { - case WGL_CONTEXT_PROFILE_MASK_ARB: - if (attribs[1] == WGL_CONTEXT_ES2_PROFILE_BIT_EXT) - opengl_es = TRUE; - break; - case WGL_CONTEXT_MAJOR_VERSION_ARB: - egl_attribs[count++] = EGL_CONTEXT_CLIENT_VERSION; - egl_attribs[count++] = attribs[1]; - break; - default: - FIXME("Unhandled attributes: %#x %#x\n", attribs[0], attribs[1]); - } - attribs += 2; - } - if (!opengl_es) - { - WARN("Requested creation of an OpenGL (non ES) context, that's not supported.\n"); - return FALSE; - } - if (!count) /* FIXME: force version if not specified */ - { - egl_attribs[count++] = EGL_CONTEXT_CLIENT_VERSION; - egl_attribs[count++] = egl_client_version; - } - egl_attribs[count] = EGL_NONE; - attribs = egl_attribs; - - *context = funcs->p_eglCreateContext( egl->display, egl_config_for_format(format), share, attribs ); - TRACE( "fmt %d ctx %p\n", format, *context ); - return TRUE; -} - static BOOL android_make_current( struct opengl_drawable *draw_base, struct opengl_drawable *read_base, void *context ) { struct gl_drawable *draw = impl_from_opengl_drawable( draw_base ), *read = impl_from_opengl_drawable( read_base ); @@ -198,15 +156,6 @@ static BOOL android_make_current( struct opengl_drawable *draw_base, struct open return funcs->p_eglMakeCurrent( egl->display, context ? draw->surface : EGL_NO_SURFACE, context ? read->surface : EGL_NO_SURFACE, context ); }
-/*********************************************************************** - * android_wglDeleteContext - */ -static BOOL android_context_destroy( void *context ) -{ - funcs->p_eglDestroyContext( egl->display, context ); - return TRUE; -} - static EGLenum android_init_egl_platform( const struct egl_platform *platform, EGLNativeDisplayType *platform_display ) { egl = platform; @@ -251,8 +200,6 @@ static struct opengl_driver_funcs android_driver_funcs = .p_get_proc_address = android_get_proc_address, .p_init_wgl_extensions = android_init_wgl_extensions, .p_surface_create = android_surface_create, - .p_context_create = android_context_create, - .p_context_destroy = android_context_destroy, .p_make_current = android_make_current, };
@@ -285,6 +232,8 @@ UINT ANDROID_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs,
android_driver_funcs.p_init_pixel_formats = (*driver_funcs)->p_init_pixel_formats; android_driver_funcs.p_describe_pixel_format = (*driver_funcs)->p_describe_pixel_format; + android_driver_funcs.p_context_create = (*driver_funcs)->p_context_create; + android_driver_funcs.p_context_destroy = (*driver_funcs)->p_context_destroy;
*driver_funcs = &android_driver_funcs; return STATUS_SUCCESS; diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index aa357358645..bfc3ac7518f 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -188,83 +188,6 @@ static BOOL wayland_opengl_surface_create(HWND hwnd, HDC hdc, int format, struct return TRUE; }
-static BOOL wayland_context_create(int format, void *share, const int *attribs, void **context) -{ - EGLint egl_attribs[16], *attribs_end = egl_attribs; - - TRACE("format=%d share=%p attribs=%p\n", format, share, attribs); - - for (; attribs && attribs[0] != 0; attribs += 2) - { - EGLint name; - - TRACE("%#x %#x\n", attribs[0], attribs[1]); - - /* Find the EGL attribute names corresponding to the WGL names. - * For all of the attributes below, the values match between the two - * systems, so we can use them directly. */ - switch (attribs[0]) - { - case WGL_CONTEXT_MAJOR_VERSION_ARB: - name = EGL_CONTEXT_MAJOR_VERSION_KHR; - break; - case WGL_CONTEXT_MINOR_VERSION_ARB: - name = EGL_CONTEXT_MINOR_VERSION_KHR; - break; - case WGL_CONTEXT_FLAGS_ARB: - name = EGL_CONTEXT_FLAGS_KHR; - break; - case WGL_CONTEXT_OPENGL_NO_ERROR_ARB: - name = EGL_CONTEXT_OPENGL_NO_ERROR_KHR; - break; - case WGL_CONTEXT_PROFILE_MASK_ARB: - if (attribs[1] & WGL_CONTEXT_ES2_PROFILE_BIT_EXT) - { - ERR("OpenGL ES contexts are not supported\n"); - return FALSE; - } - name = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR; - break; - default: - name = EGL_NONE; - FIXME("Unhandled attributes: %#x %#x\n", attribs[0], attribs[1]); - } - - if (name != EGL_NONE) - { - EGLint *dst = egl_attribs; - /* Check if we have already set the same attribute and replace it. */ - for (; dst != attribs_end && *dst != name; dst += 2) continue; - /* Our context attribute array should have enough space for all the - * attributes we support (we merge repetitions), plus EGL_NONE. */ - assert(dst - egl_attribs <= ARRAY_SIZE(egl_attribs) - 3); - dst[0] = name; - dst[1] = attribs[1]; - if (dst == attribs_end) attribs_end += 2; - } - } - *attribs_end = EGL_NONE; - - /* For now only OpenGL is supported. It's enough to set the API only for - * context creation, since: - * 1. the default API is EGL_OPENGL_ES_API - * 2. the EGL specification says in section 3.7: - * > EGL_OPENGL_API and EGL_OPENGL_ES_API are interchangeable for all - * > purposes except eglCreateContext. - */ - funcs->p_eglBindAPI(EGL_OPENGL_API); - *context = funcs->p_eglCreateContext(egl->display, EGL_NO_CONFIG_KHR, share, - attribs ? egl_attribs : NULL); - TRACE("egl_context=%p\n", *context); - return TRUE; -} - -static BOOL wayland_context_destroy(void *context) -{ - funcs->p_eglDestroyContext(egl->display, context); - return TRUE; -} - static EGLenum wayland_init_egl_platform(const struct egl_platform *platform, EGLNativeDisplayType *platform_display) { egl = platform; @@ -328,8 +251,6 @@ static struct opengl_driver_funcs wayland_driver_funcs = { .p_init_egl_platform = wayland_init_egl_platform, .p_surface_create = wayland_opengl_surface_create, - .p_context_create = wayland_context_create, - .p_context_destroy = wayland_context_destroy, .p_make_current = wayland_make_current, .p_pbuffer_create = wayland_pbuffer_create, .p_pbuffer_updated = wayland_pbuffer_updated, @@ -364,6 +285,8 @@ UINT WAYLAND_OpenGLInit(UINT version, const struct opengl_funcs *opengl_funcs, c wayland_driver_funcs.p_init_pixel_formats = (*driver_funcs)->p_init_pixel_formats; wayland_driver_funcs.p_describe_pixel_format = (*driver_funcs)->p_describe_pixel_format; wayland_driver_funcs.p_init_wgl_extensions = (*driver_funcs)->p_init_wgl_extensions; + wayland_driver_funcs.p_context_create = (*driver_funcs)->p_context_create; + wayland_driver_funcs.p_context_destroy = (*driver_funcs)->p_context_destroy;
*driver_funcs = &wayland_driver_funcs; return STATUS_SUCCESS;