Ken Thomases : winemac: Avoid overdriving single-buffered GL if possible; the system throttles us.
Alexandre Julliard
julliard at winehq.org
Fri Jun 21 11:28:10 CDT 2013
Module: wine
Branch: master
Commit: 3c7bc8202c3fbf63b36572b9ac97f980d25152ce
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3c7bc8202c3fbf63b36572b9ac97f980d25152ce
Author: Ken Thomases <ken at codeweavers.com>
Date: Fri Jun 21 03:34:03 2013 -0500
winemac: Avoid overdriving single-buffered GL if possible; the system throttles us.
Use glFlushRenderAPPLE(), if available, instead of glFlush() calls less
than 1/60th of a second since the last.
---
dlls/winemac.drv/opengl.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c
index 931b9ee..904158b 100644
--- a/dlls/winemac.drv/opengl.c
+++ b/dlls/winemac.drv/opengl.c
@@ -66,6 +66,7 @@ struct wgl_context
struct wgl_pbuffer *read_pbuffer;
BOOL has_been_current;
BOOL sharing;
+ DWORD last_flush_time;
};
@@ -101,6 +102,8 @@ static const char *opengl_func_names[] = { ALL_WGL_FUNCS };
static void (*pglCopyColorTable)(GLenum target, GLenum internalformat, GLint x, GLint y,
GLsizei width);
static void (*pglCopyPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
+static void (*pglFlush)(void);
+static void (*pglFlushRenderAPPLE)(void);
static void (*pglReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, void *pixels);
static void (*pglViewport)(GLint x, GLint y, GLsizei width, GLsizei height);
@@ -1490,6 +1493,28 @@ static void macdrv_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height,
}
+static void macdrv_glFlush(void)
+{
+ struct wgl_context *context = NtCurrentTeb()->glContext;
+ const pixel_format *pf = &pixel_formats[context->format - 1];
+ DWORD now = GetTickCount();
+
+ TRACE("double buffer %d last flush time %d now %d\n", (int)pf->double_buffer,
+ context->last_flush_time, now);
+ if (pglFlushRenderAPPLE && !pf->double_buffer && (now - context->last_flush_time) < 17)
+ {
+ TRACE("calling glFlushRenderAPPLE()\n");
+ pglFlushRenderAPPLE();
+ }
+ else
+ {
+ TRACE("calling glFlush()\n");
+ pglFlush();
+ context->last_flush_time = now;
+ }
+}
+
+
/**********************************************************************
* macdrv_glReadPixels
*
@@ -3024,6 +3049,7 @@ static BOOL init_opengl(void)
#define REDIRECT(func) \
do { p##func = opengl_funcs.gl.p_##func; opengl_funcs.gl.p_##func = macdrv_##func; } while(0)
REDIRECT(glCopyPixels);
+ REDIRECT(glFlush);
REDIRECT(glReadPixels);
REDIRECT(glViewport);
#undef REDIRECT
@@ -3037,6 +3063,9 @@ static BOOL init_opengl(void)
if (!init_gl_info())
goto failed;
+ if (gluCheckExtension((GLubyte*)"GL_APPLE_flush_render", (GLubyte*)gl_info.glExtensions))
+ pglFlushRenderAPPLE = wine_dlsym(opengl_handle, "glFlushRenderAPPLE", NULL, 0);
+
load_extensions();
if (!init_pixel_formats())
goto failed;
More information about the wine-cvs
mailing list