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;