From 65fb4e67cb55f048c3ac8d0e46fc585f737c48ad Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 2 Nov 2023 10:47:15 -0500 Subject: SL-19979 Fix for frame stalls on mac with shadows enabled. Also fix multihreaded GL not working on mac (thanks, Rye!) --- indra/llwindow/llwindowmacosx.cpp | 54 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'indra/llwindow/llwindowmacosx.cpp') 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((mFSAASamples > 0 ? 1 : 0)), + kCGLPFASamples, static_cast(mFSAASamples), + kCGLPFAStencilSize, static_cast(8), + kCGLPFADepthSize, static_cast(24), + kCGLPFAAlphaSize, static_cast(8), + kCGLPFAColorSize, static_cast(24), + kCGLPFAOpenGLProfile, static_cast(kCGLOGLPVersion_GL4_Core), + static_cast(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) -- cgit v1.2.3 From 70721bae390ab49ff24022c5c8f75bc274adc8c8 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 3 Nov 2023 11:15:19 -0500 Subject: DRTVWR-559 Fix for mac build. --- indra/llwindow/llwindowmacosx.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/llwindow/llwindowmacosx.cpp') diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index b99af1ae4c..778e5d3898 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -1962,10 +1962,12 @@ public: void* LLWindowMacOSX::createSharedContext() { sharedContext* sc = new sharedContext(); - CGLError err = CGLCreateContext(mPixelFormat, mContext, &(sc->mContext)); - llassert(err == kCGLNoError); - - CGLEnable(mContext, kCGLCEMPEngine); + CGLCreateContext(mPixelFormat, mContext, &(sc->mContext)); + + if (sUseMultGL) + { + CGLEnable(mContext, kCGLCEMPEngine); + } return (void *)sc; } -- cgit v1.2.3