mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-01 18:50:16 +03:00
Fix GL resource sharing across native application windows
Decouple GL object sharing between native windows from auxiliary worker-thread context support. Platforms without threaded GL contexts, such as Haiku, must still share textures and other GL resources between their window contexts. Always configure SDL_GL_SHARE_WITH_CURRENT_CONTEXT according to the requested context settings, while continuing to create the auxiliary thread context only on supported platforms. Explicitly reset the SDL attribute for non-shared contexts to avoid leaking state into subsequent window creation. Apply the fix to both SDL2 and SDL3 backends. Also link the Haiku unit test executable against libbsd and libnetwork to resolve its PTY and socket dependencies.
This commit is contained in:
@@ -86,3 +86,4 @@ ecode.dmg
|
||||
/projects/android-project/.project
|
||||
/projects/android-project/app/.project
|
||||
/design/
|
||||
/projects/haiku/ecode/ecode.app/*
|
||||
Binary file not shown.
@@ -2011,6 +2011,9 @@ solution "eepp"
|
||||
if not os.is("windows") and not os.is("haiku") then
|
||||
links { "pthread" }
|
||||
end
|
||||
if os.is("haiku") then
|
||||
links { "bsd", "network" }
|
||||
end
|
||||
files { "src/tests/unit_tests/*.cpp",
|
||||
"src/tools/ecode/jsonhelper.cpp",
|
||||
"src/tools/ecode/plugins/git/git.cpp",
|
||||
|
||||
@@ -2033,6 +2033,8 @@ workspace "eepp"
|
||||
"src/tools/ecode/plugins/autocomplete/usersnippetstore.cpp" }
|
||||
filter { "system:not windows", "system:not haiku" }
|
||||
links { "pthread" }
|
||||
filter "system:haiku"
|
||||
links { "bsd", "network" }
|
||||
filter {}
|
||||
eepp_module_backward_add( false )
|
||||
build_link_configuration( "eepp-unit_tests", true )
|
||||
|
||||
@@ -217,19 +217,16 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) {
|
||||
SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 0 );
|
||||
}
|
||||
|
||||
// Sharing window contexts is independent from supporting an auxiliary context on a worker
|
||||
// thread. Platforms without threaded GL contexts still need shared object namespaces for
|
||||
// resources used by multiple native windows.
|
||||
SDL_GL_SetAttribute( SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
|
||||
mWindow.ContextConfig.SharedGLContext ? 1 : 0 );
|
||||
#ifdef SDL2_THREADED_GLCONTEXT
|
||||
if ( mWindow.ContextConfig.SharedGLContext ) {
|
||||
SDL_GL_SetAttribute( SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1 );
|
||||
|
||||
if ( mWindow.ContextConfig.SharedGLContext )
|
||||
mGLContextThread = SDL_GL_CreateContext( mSDLWindow );
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
} else {
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
}
|
||||
#else
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
mWindow.ContextConfig.SharedGLContext = false;
|
||||
#endif
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
|
||||
if ( nullptr == mGLContext
|
||||
#ifdef SDL2_THREADED_GLCONTEXT
|
||||
|
||||
@@ -188,19 +188,16 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Sharing window contexts is independent from supporting an auxiliary context on a worker
|
||||
// thread. Platforms without threaded GL contexts still need shared object namespaces for
|
||||
// resources used by multiple native windows.
|
||||
SDL_GL_SetAttribute( SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
|
||||
mWindow.ContextConfig.SharedGLContext ? 1 : 0 );
|
||||
#ifdef SDL3_THREADED_GLCONTEXT
|
||||
if ( mWindow.ContextConfig.SharedGLContext ) {
|
||||
SDL_GL_SetAttribute( SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1 );
|
||||
|
||||
if ( mWindow.ContextConfig.SharedGLContext )
|
||||
mGLContextThread = SDL_GL_CreateContext( mSDLWindow );
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
} else {
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
}
|
||||
#else
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
mWindow.ContextConfig.SharedGLContext = false;
|
||||
#endif
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
|
||||
if ( nullptr == mGLContext
|
||||
#ifdef SDL3_THREADED_GLCONTEXT
|
||||
|
||||
Reference in New Issue
Block a user