Add support for shared OpenGL contexts when using SDL2 for multithreaded OpenGL image processing
parent
fad265af9c
commit
1f81f59409
|
|
@ -716,6 +716,8 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
|
|||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, mFSAASamples);
|
||||
}
|
||||
|
||||
// <FS:Zi> Make shared context work on Linux for multithreaded OpenGL
|
||||
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
|
||||
mWindow = SDL_CreateWindow( mWindowTitle.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, mSDLFlags );
|
||||
|
||||
if( mWindow )
|
||||
|
|
@ -2563,25 +2565,57 @@ std::vector<std::string> LLWindowSDL::getDynamicFallbackFontList()
|
|||
return rtns;
|
||||
}
|
||||
|
||||
// <FS:Zi> Make shared context work on Linux for multithreaded OpenGL
|
||||
class sharedContext
|
||||
{
|
||||
public:
|
||||
SDL_GLContext mContext;
|
||||
};
|
||||
|
||||
void* LLWindowSDL::createSharedContext()
|
||||
{
|
||||
return SDL_GL_CreateContext(mWindow);
|
||||
sharedContext* sc = new sharedContext();
|
||||
sc->mContext = SDL_GL_CreateContext(mWindow);
|
||||
if (sc->mContext)
|
||||
{
|
||||
SDL_GL_SetSwapInterval(0);
|
||||
SDL_GL_MakeCurrent(mWindow, mContext);
|
||||
|
||||
LLCoordScreen size;
|
||||
if (getSize(&size))
|
||||
{
|
||||
setSize(size);
|
||||
}
|
||||
|
||||
LL_WARNS() << "Creating shared OpenGL context successful!" << LL_ENDL;
|
||||
|
||||
return (void*)sc;
|
||||
}
|
||||
|
||||
LL_WARNS() << "Creating shared OpenGL context failed!" << LL_ENDL;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void LLWindowSDL::makeContextCurrent(void* contextPtr)
|
||||
void LLWindowSDL::makeContextCurrent(void* context)
|
||||
{
|
||||
LL_PROFILER_GPU_CONTEXT;
|
||||
SDL_GL_MakeCurrent( mWindow, contextPtr );
|
||||
LL_PROFILER_GPU_CONTEXT;
|
||||
SDL_GL_MakeCurrent(mWindow, ((sharedContext*)context)->mContext);
|
||||
}
|
||||
|
||||
void LLWindowSDL::destroySharedContext(void* contextPtr)
|
||||
void LLWindowSDL::destroySharedContext(void* context)
|
||||
{
|
||||
SDL_GL_DeleteContext( contextPtr );
|
||||
sharedContext* sc = (sharedContext*)context;
|
||||
|
||||
SDL_GL_DeleteContext(sc->mContext);
|
||||
|
||||
delete sc;
|
||||
}
|
||||
|
||||
void LLWindowSDL::toggleVSync(bool enable_vsync)
|
||||
{
|
||||
SDL_GL_SetSwapInterval(enable_vsync);
|
||||
}
|
||||
// </FS:Zi>
|
||||
|
||||
#endif // LL_SDL
|
||||
|
|
|
|||
|
|
@ -66,6 +66,12 @@ public:
|
|||
/*virtual*/ BOOL setSizeImpl(LLCoordScreen size);
|
||||
/*virtual*/ BOOL setSizeImpl(LLCoordWindow size);
|
||||
/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL);
|
||||
// <FS:Zi> Make shared context work on Linux for multithreaded OpenGL
|
||||
void* createSharedContext() override;
|
||||
void makeContextCurrent(void* context) override;
|
||||
void destroySharedContext(void* context) override;
|
||||
/*virtual*/ void toggleVSync(bool enable_vsync);
|
||||
// </FS:Zi>
|
||||
/*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
|
||||
/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
|
||||
/*virtual*/ void showCursor();
|
||||
|
|
@ -148,11 +154,6 @@ public:
|
|||
static Display* get_SDL_Display(void);
|
||||
#endif // LL_X11
|
||||
|
||||
void* createSharedContext() override;
|
||||
void makeContextCurrent(void* context) override;
|
||||
void destroySharedContext(void* context) override;
|
||||
void toggleVSync(bool enable_vsync) override;
|
||||
|
||||
protected:
|
||||
LLWindowSDL(LLWindowCallbacks* callbacks,
|
||||
const std::string& title, int x, int y, int width, int height, U32 flags,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ RenderAvatarLODFactor 1 1.0
|
|||
RenderAvatarPhysicsLODFactor 1 1.0
|
||||
RenderAvatarMaxNonImpostors 1 16
|
||||
RenderAvatarMaxComplexity 1 350000
|
||||
RenderAvatarVP 1 1
|
||||
RenderAutoMuteSurfaceAreaLimit 1 1000.0
|
||||
RenderCubeMap 1 1
|
||||
RenderDelayVBUpdate 1 0
|
||||
|
|
@ -70,7 +69,7 @@ RenderShadowDetail 1 2
|
|||
RenderUseStreamVBO 1 1
|
||||
RenderFSAASamples 1 16
|
||||
RenderMaxTextureIndex 1 16
|
||||
RenderGLCoreProfile 1 1
|
||||
RenderGLContextCoreProfile 1 1
|
||||
RenderGLMultiThreaded 1 1
|
||||
|
||||
|
||||
|
|
@ -316,12 +315,12 @@ RenderAnisotropic 1 0
|
|||
RenderCubeMap 0 0
|
||||
RenderFSAASamples 1 0
|
||||
RenderGLMultiThreaded 1 0
|
||||
RenderGLCoreProfile 1 0
|
||||
RenderGLContextCoreProfile 1 0
|
||||
|
||||
// AMD cards generally perform better when not using VBOs for streaming data
|
||||
// AMD cards also prefer an OpenGL Compatibility Profile Context
|
||||
list AMD
|
||||
RenderUseStreamVBO 1 0
|
||||
RenderGLCoreProfile 1 0
|
||||
RenderGLContextCoreProfile 1 0
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue