summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2023-11-02 10:47:15 -0500
committerDave Parks <davep@lindenlab.com>2023-11-02 10:47:15 -0500
commit65fb4e67cb55f048c3ac8d0e46fc585f737c48ad (patch)
tree825d4818773ae96d0543daecc9a3aa0ad155dffd /indra/llwindow
parentf72309a17eab1be1979c58a135e061ebffc37e21 (diff)
SL-19979 Fix for frame stalls on mac with shadows enabled. Also fix multihreaded GL not working on mac (thanks, Rye!)
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/llwindowmacosx.cpp54
1 files changed, 52 insertions, 2 deletions
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index 8bfaeca614..b99af1ae4c 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -186,7 +186,7 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks,
return;
}
- //start with arrow cursor
+ //start with arrow cursor
initCursors();
setCursor( UI_CURSOR_ARROW );
@@ -637,6 +637,34 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
mGLView = createOpenGLView(mWindow, mFSAASamples, enable_vsync);
mContext = getCGLContextObj(mGLView);
gGLManager.mVRAM = getVramSize(mGLView);
+
+ if(!mPixelFormat)
+ {
+ CGLPixelFormatAttribute attribs[] =
+ {
+ kCGLPFANoRecovery,
+ kCGLPFADoubleBuffer,
+ kCGLPFAClosestPolicy,
+ kCGLPFAAccelerated,
+ kCGLPFAMultisample,
+ kCGLPFASampleBuffers, static_cast<CGLPixelFormatAttribute>((mFSAASamples > 0 ? 1 : 0)),
+ kCGLPFASamples, static_cast<CGLPixelFormatAttribute>(mFSAASamples),
+ kCGLPFAStencilSize, static_cast<CGLPixelFormatAttribute>(8),
+ kCGLPFADepthSize, static_cast<CGLPixelFormatAttribute>(24),
+ kCGLPFAAlphaSize, static_cast<CGLPixelFormatAttribute>(8),
+ kCGLPFAColorSize, static_cast<CGLPixelFormatAttribute>(24),
+ kCGLPFAOpenGLProfile, static_cast<CGLPixelFormatAttribute>(kCGLOGLPVersion_GL4_Core),
+ static_cast<CGLPixelFormatAttribute>(0)
+ };
+
+ GLint numPixelFormats;
+ CGLChoosePixelFormat (attribs, &mPixelFormat, &numPixelFormats);
+
+ if(mPixelFormat == NULL) {
+ CGLChoosePixelFormat (attribs, &mPixelFormat, &numPixelFormats);
+ }
+ }
+
}
// This sets up our view to recieve text from our non-inline text input window.
@@ -1934,7 +1962,10 @@ public:
void* LLWindowMacOSX::createSharedContext()
{
sharedContext* sc = new sharedContext();
- CGLCreateContext(mPixelFormat, mContext, &(sc->mContext));
+ CGLError err = CGLCreateContext(mPixelFormat, mContext, &(sc->mContext));
+ llassert(err == kCGLNoError);
+
+ CGLEnable(mContext, kCGLCEMPEngine);
return (void *)sc;
}
@@ -1942,6 +1973,25 @@ void* LLWindowMacOSX::createSharedContext()
void LLWindowMacOSX::makeContextCurrent(void* context)
{
CGLSetCurrentContext(((sharedContext*)context)->mContext);
+
+ //enable multi-threaded OpenGL
+ if (sUseMultGL)
+ {
+ CGLError cgl_err;
+ CGLContextObj ctx = CGLGetCurrentContext();
+
+ cgl_err = CGLEnable( ctx, kCGLCEMPEngine);
+
+ if (cgl_err != kCGLNoError )
+ {
+ LL_INFOS("GLInit") << "Multi-threaded OpenGL not available." << LL_ENDL;
+ }
+ else
+ {
+ LL_INFOS("GLInit") << "Multi-threaded OpenGL enabled." << LL_ENDL;
+ }
+ }
+
}
void LLWindowMacOSX::destroySharedContext(void* context)