From 9b451a09132ebd3bdf3cad3ecf1f5f972167e355 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 14 Mar 2007 10:33:43 +0000 Subject: [PATCH] add apple_multithreadedgl cvar (offloads OpenGL driver to a second thread if possible), off by default (may change to on if I get feedback from testers) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6971 d7cf8633-e32d-0410-b094-e92efae38249 --- vid_agl.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/vid_agl.c b/vid_agl.c index 191e7e56..a6e00a62 100644 --- a/vid_agl.c +++ b/vid_agl.c @@ -46,6 +46,7 @@ GLboolean (*qaglSetFullScreen) (AGLContext ctx, GLsizei width, GLsizei height, G GLboolean (*qaglSetInteger) (AGLContext ctx, GLenum pname, const GLint *params); void (*qaglSwapBuffers) (AGLContext ctx); +static qboolean multithreadedgl; static qboolean mouse_avail = true; static qboolean vid_usingmouse = false; static float mouse_x, mouse_y; @@ -57,6 +58,8 @@ static qboolean sound_active = true; static int scr_width, scr_height; +static cvar_t apple_multithreadedgl = {CVAR_SAVE, "apple_multithreadedgl", "0", "makes use of a second thread for the OpenGL driver (if possible) rather than using the engine thread (note: this is done automatically on most other operating systems)"}; + static AGLContext context; static WindowRef window; @@ -146,6 +149,33 @@ void VID_Finish (qboolean allowmousegrab) qaglSwapBuffers(context); } VID_UpdateGamma(false, GAMMA_TABLE_SIZE); + +#ifdef kCGLCEMPEngine + if (apple_multithreadedgl.integer) + { + if (!multithreadedgl) + { + CGLError err = 0; + CGLContextObj ctx = CGLGetCurrentContext(); + err = CGLEnable(ctx, kCGLEMPEngine); + if (err == kCGLNoError) + multithreadedgl = true; + else + Cvar_SetQuickValue(&apple_multithreadedgl, 0); + } + } + else + { + if (multithreadedgl) + { + multithreadedgl = false; + CGLDisable(ctx, kCGLEMPEngine); + } + } +#else + if (apple_multithreadedgl.integer) + Cvar_SetQuickValue(&apple_multithreadedgl, 0); +#endif } int VID_SetGamma(unsigned short *ramps, int rampsize) @@ -228,6 +258,7 @@ void InitSig(void) void VID_Init(void) { InitSig(); // trap evil signals + Cvar_RegisterVariable(&apple_multithreadedgl); // COMMANDLINEOPTION: Input: -nomouse disables mouse support (see also vid_mouse cvar) if (COM_CheckParm ("-nomouse") || COM_CheckParm("-safe")) mouse_avail = false; @@ -553,6 +584,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate gl_platform = "AGL"; gl_videosyncavailable = true; + multithreadedgl = false; vid_isfullscreen = fullscreen; vid_usingmouse = false; vid_hidden = false; -- 2.39.2