From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/win32u/opengl.c | 44 ++++++++++++++++++++++++----------- dlls/winewayland.drv/opengl.c | 9 +++---- dlls/winex11.drv/opengl.c | 9 +++---- include/wine/opengl_driver.h | 5 ++++ 4 files changed, 45 insertions(+), 22 deletions(-) diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 0815f4378e8..6c1040554b9 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -111,7 +111,23 @@ void *opengl_drawable_create( UINT size, const struct opengl_drawable_funcs *fun drawable->doublebuffer = !!(pixel_formats[format - 1].pfd.dwFlags & PFD_DOUBLEBUFFER); drawable->stereo = !!(pixel_formats[format - 1].pfd.dwFlags & PFD_STEREO); if ((drawable->client = client)) client_surface_add_ref( client ); - for (UINT i = 0; i < ARRAY_SIZE(drawable->buffer_map); i++) drawable->buffer_map[i] = GL_FRONT_LEFT + i; + + opengl_drawable_map_buffer( drawable, GL_FRONT_LEFT, GL_FRONT_LEFT ); + opengl_drawable_map_buffer( drawable, GL_FRONT, GL_FRONT ); + opengl_drawable_map_buffer( drawable, GL_LEFT, GL_LEFT ); + opengl_drawable_map_buffer( drawable, GL_FRONT_AND_BACK, GL_FRONT_AND_BACK ); + + if (drawable->doublebuffer) + { + opengl_drawable_map_buffer( drawable, GL_BACK_LEFT, GL_BACK_LEFT ); + opengl_drawable_map_buffer( drawable, GL_BACK, GL_BACK ); + } + if (drawable->stereo) + { + opengl_drawable_map_buffer( drawable, GL_FRONT_RIGHT, GL_FRONT_RIGHT ); + opengl_drawable_map_buffer( drawable, GL_RIGHT, GL_RIGHT ); + if (drawable->doublebuffer) opengl_drawable_map_buffer( drawable, GL_BACK_RIGHT, GL_BACK_RIGHT ); + } TRACE( "created %s\n", debugstr_opengl_drawable( drawable ) ); return drawable; @@ -404,23 +420,23 @@ static struct opengl_drawable *framebuffer_surface_create( int format, struct cl struct framebuffer_surface *surface; if (!(surface = opengl_drawable_create( sizeof(*surface), &framebuffer_surface_funcs, format, client ))) return NULL; - surface->base.buffer_map[0] = GL_COLOR_ATTACHMENT0; - surface->base.buffer_map[2] = surface->base.doublebuffer ? GL_COLOR_ATTACHMENT1 : GL_NONE; - if (surface->base.stereo) + opengl_drawable_map_buffer( &surface->base, GL_FRONT_LEFT, GL_COLOR_ATTACHMENT0 ); + opengl_drawable_map_buffer( &surface->base, GL_FRONT, GL_COLOR_ATTACHMENT0 ); /* only front left */ + opengl_drawable_map_buffer( &surface->base, GL_LEFT, GL_COLOR_ATTACHMENT0 ); /* only front left */ + opengl_drawable_map_buffer( &surface->base, GL_FRONT_AND_BACK, GL_COLOR_ATTACHMENT0 ); /* only front left */ + + if (surface->base.doublebuffer) { - surface->base.buffer_map[1] = surface->base.doublebuffer ? GL_COLOR_ATTACHMENT2 : GL_COLOR_ATTACHMENT1; - surface->base.buffer_map[3] = surface->base.doublebuffer ? GL_COLOR_ATTACHMENT3 : GL_NONE; + opengl_drawable_map_buffer( &surface->base, GL_BACK_LEFT, GL_COLOR_ATTACHMENT1 ); + opengl_drawable_map_buffer( &surface->base, GL_BACK, GL_COLOR_ATTACHMENT1 ); /* only back left */ } - else + if (surface->base.stereo) { - surface->base.buffer_map[1] = GL_NONE; - surface->base.buffer_map[3] = GL_NONE; + GLenum attachment = surface->base.doublebuffer ? GL_COLOR_ATTACHMENT2 : GL_COLOR_ATTACHMENT1; + opengl_drawable_map_buffer( &surface->base, GL_FRONT_RIGHT, attachment ); + opengl_drawable_map_buffer( &surface->base, GL_RIGHT, attachment ); /* only front right */ + if (surface->base.doublebuffer) opengl_drawable_map_buffer( &surface->base, GL_BACK_RIGHT, GL_COLOR_ATTACHMENT3 ); } - surface->base.buffer_map[GL_FRONT - GL_FRONT_LEFT] = surface->base.buffer_map[0]; /* only front left */ - surface->base.buffer_map[GL_BACK - GL_FRONT_LEFT] = surface->base.buffer_map[2]; /* only back left */ - surface->base.buffer_map[GL_LEFT - GL_FRONT_LEFT] = surface->base.buffer_map[0]; /* only front left */ - surface->base.buffer_map[GL_RIGHT - GL_FRONT_LEFT] = surface->base.buffer_map[1]; /* only front right */ - surface->base.buffer_map[GL_FRONT_AND_BACK - GL_FRONT_LEFT] = surface->base.buffer_map[0]; /* only front left */ return &surface->base; } diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index 1486e411734..66457e1aea5 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -110,10 +110,11 @@ static BOOL wayland_opengl_surface_create(HWND hwnd, int format, struct opengl_d gl = opengl_drawable_create(sizeof(*gl), &wayland_drawable_funcs, format, &client->client); client_surface_release(&client->client); if (!gl) return FALSE; - gl->base.buffer_map[0] = GL_BACK_LEFT; - gl->base.buffer_map[1] = GL_BACK_RIGHT; - gl->base.buffer_map[GL_FRONT - GL_FRONT_LEFT] = GL_BACK; - gl->base.buffer_map[GL_FRONT_AND_BACK - GL_FRONT_LEFT] = GL_BACK; + + opengl_drawable_map_buffer(&gl->base, GL_FRONT_LEFT, GL_BACK_LEFT); + opengl_drawable_map_buffer(&gl->base, GL_FRONT, GL_BACK); + opengl_drawable_map_buffer(&gl->base, GL_FRONT_AND_BACK, GL_BACK); + if (gl->base.stereo) opengl_drawable_map_buffer(&gl->base, GL_FRONT_RIGHT, GL_BACK_RIGHT); if (!(gl->wl_egl_window = wl_egl_window_create(client->wl_surface, rect.right, rect.bottom))) goto err; if (!(gl->base.surface = funcs->p_eglCreateWindowSurface(egl->display, config, gl->wl_egl_window, attribs))) goto err; diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 7ebc2c43753..56c22ab7ee7 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -531,10 +531,11 @@ static BOOL x11drv_egl_surface_create( HWND hwnd, int format, struct opengl_draw gl = opengl_drawable_create( sizeof(*gl), &x11drv_egl_surface_funcs, format, client ); client_surface_release( client ); if (!gl) return FALSE; - gl->base.buffer_map[0] = GL_BACK_LEFT; - gl->base.buffer_map[1] = GL_BACK_RIGHT; - gl->base.buffer_map[GL_FRONT - GL_FRONT_LEFT] = GL_BACK; - gl->base.buffer_map[GL_FRONT_AND_BACK - GL_FRONT_LEFT] = GL_BACK; + + opengl_drawable_map_buffer( &gl->base, GL_FRONT_LEFT, GL_BACK_LEFT ); + opengl_drawable_map_buffer( &gl->base, GL_FRONT, GL_BACK ); + opengl_drawable_map_buffer( &gl->base, GL_FRONT_AND_BACK, GL_BACK ); + if (gl->base.stereo) opengl_drawable_map_buffer( &gl->base, GL_FRONT_RIGHT, GL_BACK_RIGHT ); if (!(gl->base.surface = funcs->p_eglCreateWindowSurface( egl->display, egl_config_for_format( format ), (void *)window, NULL ))) diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 777a82c338a..8249a6a5e82 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -223,6 +223,11 @@ static inline const char *debugstr_opengl_drawable( struct opengl_drawable *draw return wine_dbg_sprintf( "%s/%p (format %u)", debugstr_client_surface( drawable->client ), drawable, drawable->format ); } +static inline void opengl_drawable_map_buffer( struct opengl_drawable *drawable, GLenum buffer, GLenum set ) +{ + drawable->buffer_map[buffer - GL_FRONT_LEFT] = set; +} + W32KAPI void *opengl_drawable_create( UINT size, const struct opengl_drawable_funcs *funcs, int format, struct client_surface *client ); W32KAPI void opengl_drawable_add_ref( struct opengl_drawable *drawable ); W32KAPI void opengl_drawable_release( struct opengl_drawable *drawable ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10784