SDL3 EGL: try GLES API when desktop GL bind fails (Mali / gl4es)#2484
Draft
Zetarancio wants to merge 1 commit intoROCKNIX:nextfrom
Draft
SDL3 EGL: try GLES API when desktop GL bind fails (Mali / gl4es)#2484Zetarancio wants to merge 1 commit intoROCKNIX:nextfrom
Zetarancio wants to merge 1 commit intoROCKNIX:nextfrom
Conversation
GLES-only stacks (e.g. libmali on RK3566) cannot satisfy eglBindAPI(EGL_OPENGL_API). The previous patch returned NULL from SDL_EGL_CreateContext, which broke SDL 1.2 titles under box86 that route through SDL2-compat: SDL_SetVideoMode(..., SDL_OPENGL) never got a context (gl4es still provides GL-on-GLES at the libGL layer). If binding EGL_OPENGL_API fails, retry with EGL_OPENGL_ES_API before giving up. Only error out if both bindings fail. Fixes PortMaster / gl4es ports that regressed after the SDL2-compat + SDL3 transition on Mali-class devices.
Contributor
|
There is already a built in mechanism for it to fall back to GLES if GL fails tho |
Author
I saw it but it does not work for direct calls. Yet my patch is bad because it fixes direct calls but breaks portmaster app and other apps too. We need a better approach. |
Contributor
|
Yea I think this was my original intention just having full SDL2 package for things that aren't quiet there yet on sdl2-compat |
Author
Something like this might work? No? aenertia@2beb321 |
Contributor
|
yup it would |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After this #2345 on GLES-only stacks, eglBindAPI can fail while GLES remains valid. SDL3 EGL path currently treats a failed desktop-GL bind as fatal and returned NULL, which breaks apps that request an OpenGL window through the legacy stack (e.g. SDL 1.2 → box86 → SDL2-compat → SDL3 with SDL_OPENGL). With this if binding EGL_OPENGL_API fails, SDL retries EGL_OPENGL_ES_API before failing and allows GL-on-GLES layers to work.
The prior hard failurre on eglBindAPI is ok on desktop GL drivers, but on embedded Mali builds that only expose the GLES EGL API, the first bind fails. Wayland/SDL renderer fallback paths do not apply to raw SDL_GL_CreateContext / legacy OpenGL window creation.
If eglBindAPI(EGL_OPENGL_API) fails, call eglBindAPI(EGL_OPENGL_ES_API) and continue when that succeeds.
If both fail, set a single clear error: Could not bind EGL API (tried GL and GLES).
Verified with a PortMaster title using box86 + gl4es on an RK3566 device where only the Mali GLES path is available: check the logs.
Devices using native desktop GL (e.g. Mesa/Panfrost) are unaffected when EGL_OPENGL_API binds successfully on the first try and SHOULD BE unaffected when the first bind fails and then a retry is run.
log-postpatch.txt
log-panfrost.txt
log-prepatch.txt