Commit 3c7bc820 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

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.
parent a8efa527
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment