Module: wine Branch: master Commit: 1581af4793f83260f4754af885ef997b8e2bf537 URL: https://gitlab.winehq.org/wine/wine/-/commit/1581af4793f83260f4754af885ef997...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Wed Jun 26 14:30:11 2024 +0800
winemac.drv: Remove the clear OpenGL views to black hack.
Fix black screen issues for Active Trader Pro and Assetto Corsa. This reverts commit 4124478b.
For Active Trader Pro, the hack ends up clearing a context that was previously drawn to to black, possibly because multiple OpenGL contexts are involved according to Henri's investigation.
Assetto Corsa creates a D3D device for a window but doesn't actually do any rendering with it. After ceefcca7, having an OpenGL context for a window clears its OpenGL surface to black after its view becomes visible. The OpenGL surface is on top of other layers for the window so the window becomes black after that. The blackness is originally from glDrawBuffer(GL_FRONT_AND_BACK), which presumably prepares a zero-initialized OpenGL front draw buffer. This also suggests that 4124478b is no longer necessary. I could delay the clearToBlackIfNeeded() call so it uses the behavior before ceefcca7, but now that it seems the hack is no longer necessary and might cause more errors. CrossOver has disabled the hack for a while and it seems fine. I think it's time to remove the hack.
---
dlls/winemac.drv/cocoa_opengl.h | 2 -- dlls/winemac.drv/cocoa_opengl.m | 58 +---------------------------------------- dlls/winemac.drv/cocoa_window.m | 11 -------- 3 files changed, 1 insertion(+), 70 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_opengl.h b/dlls/winemac.drv/cocoa_opengl.h index bcd257f139b..c90d814931d 100644 --- a/dlls/winemac.drv/cocoa_opengl.h +++ b/dlls/winemac.drv/cocoa_opengl.h @@ -26,13 +26,11 @@ NSView* latentView; BOOL needsUpdate; BOOL needsReattach; - BOOL shouldClearToBlack;
GLint backing_size[2]; }
@property BOOL needsUpdate; @property BOOL needsReattach; -@property BOOL shouldClearToBlack;
@end diff --git a/dlls/winemac.drv/cocoa_opengl.m b/dlls/winemac.drv/cocoa_opengl.m index fa69be7d927..5e3ad03a8b2 100644 --- a/dlls/winemac.drv/cocoa_opengl.m +++ b/dlls/winemac.drv/cocoa_opengl.m @@ -39,7 +39,7 @@
@implementation WineOpenGLContext -@synthesize latentView, needsUpdate, needsReattach, shouldClearToBlack; +@synthesize latentView, needsUpdate, needsReattach;
- (void) dealloc { @@ -92,7 +92,6 @@ [super clearDrawable]; [super setView:save]; }); - shouldClearToBlack = TRUE; } }
@@ -168,57 +167,6 @@ [self clearDrawable]; }
- - (void) clearToBlackIfNeeded - { - if (shouldClearToBlack) - { - NSOpenGLContext* origContext = [NSOpenGLContext currentContext]; - const char *gl_version; - unsigned int major; - GLint draw_framebuffer_binding, draw_buffer; - GLboolean scissor_test, color_mask[4]; - GLfloat clear_color[4]; - - [self makeCurrentContext]; - - gl_version = (const char *)glGetString(GL_VERSION); - major = gl_version[0] - '0'; - /* FIXME: Should check for GL_ARB_framebuffer_object and GL_EXT_framebuffer_object - * for older GL versions. */ - if (major >= 3) - { - glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_framebuffer_binding); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - } - glGetIntegerv(GL_DRAW_BUFFER, &draw_buffer); - scissor_test = glIsEnabled(GL_SCISSOR_TEST); - glGetBooleanv(GL_COLOR_WRITEMASK, color_mask); - glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color); - glDrawBuffer(GL_FRONT_AND_BACK); - glDisable(GL_SCISSOR_TEST); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glClearColor(0, 0, 0, gl_surface_mode == GL_SURFACE_IN_FRONT_TRANSPARENT ? 0 : 1); - - glClear(GL_COLOR_BUFFER_BIT); - - glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]); - glColorMask(color_mask[0], color_mask[1], color_mask[2], color_mask[3]); - if (scissor_test) - glEnable(GL_SCISSOR_TEST); - glDrawBuffer(draw_buffer); - if (major >= 3) - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, draw_framebuffer_binding); - glFlush(); - - if (origContext) - [origContext makeCurrentContext]; - else - [NSOpenGLContext clearCurrentContext]; - - shouldClearToBlack = FALSE; - } - } - - (void) removeFromViews:(BOOL)removeViews { if ([self view]) @@ -319,9 +267,6 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect }
[context makeCurrentContext]; - - if ([context view]) - [context clearToBlackIfNeeded]; } else { @@ -360,7 +305,6 @@ void macdrv_update_opengl_context(macdrv_opengl_context c) context.latentView = nil;
[context resetSurfaceIfBackingSizeChanged]; - [context clearToBlackIfNeeded]; } else { diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index a56dbbc4614..bae2e21fb48 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -373,7 +373,6 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi BOOL _everHadGLContext; BOOL _cachedHasGLDescendant; BOOL _cachedHasGLDescendantValid; - BOOL clearedGlSurface;
NSMutableAttributedString* markedText; NSRange markedTextSelection; @@ -587,11 +586,6 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
for (WineOpenGLContext* context in pendingGlContexts) { - if (!clearedGlSurface) - { - context.shouldClearToBlack = TRUE; - clearedGlSurface = TRUE; - } context.needsUpdate = TRUE; macdrv_update_opengl_context((macdrv_opengl_context)context); } @@ -610,11 +604,6 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi if ([[self window] windowNumber] > 0 && !NSIsEmptyRect([self visibleRect])) { [glContexts addObject:context]; - if (!clearedGlSurface) - { - context.shouldClearToBlack = TRUE; - clearedGlSurface = TRUE; - } context.needsUpdate = TRUE; } else