Repository navigation
BGF: Minor GLES code fixits - #128
Merged
Merged
Conversation
…ection
Fix GLES backend bugs in base_game_framework:
- Config selection:
- GenerateEGLConfigAttribList: add the missing break after the
RGBA5551 case, which fell through into RGB565 (and after RGB565).
- eglChooseConfig treats channel sizes as minimums and sorts larger
color depths first, so taking its first result meant RGB565,
RGBA5551 and RGBA4 requests got an 8888 config. InitializeEGLSurface
now takes all candidates, keeps only exact color matches (preferring
exact depth/stencil, in eglChooseConfig order), and tries them until
eglCreateWindowSurface succeeds. Zero matches is a failure.
- RestoreSurfaceGLES recreates the window surface with the config the
still-live context was created with, instead of re-choosing a
config. It also checks EGL_NO_SURFACE rather than nullptr.
- GenerateEGLConfigAttribList returns a std::vector instead of a raw
new[] array.
- sRGB:
- EGL_KHR_gl_colorspace was detected with HasEGLExtension(), which
queries the EGL_NO_DISPLAY client extension string, before
eglInitialize. It is a display extension, so detection always failed
and GLES never offered sRGB formats. Detect it on the initialized
display via a new PlatformUtilGLES::HasEGLDisplayExtension().
- Window surfaces now pass EGL_GL_COLORSPACE_KHR /
EGL_GL_COLORSPACE_SRGB_KHR when an sRGB format is requested. They
previously passed no attributes, so surfaces were always linear.
- Extension checks (client and display) share a whole-token matcher
that rejects null/empty names. HasEGLExtension previously matched
substrings.
- InitSwapchain: on failure, reset swapchain_frame_count_ (the
'initialized' flag) and the chosen config. The count stayed non-zero,
so every later InitSwapchain retry was refused.
- Resize detection: CheckScreenResolutionChange always returned true,
so PresentCurrentSwapchainFrame hid the callback behind a static
once-only flag. The display-changed callback then fired once,
spuriously, on the first frame and never for real resizes. It now
reports only real size changes, ignores failed queries and
non-positive sizes, and updates the orientation. The static flag is
removed.
- GetScreenResolutions clears its output and rejects failed queries
and non-positive sizes instead of reporting 0x0.
- Orientation: integer division ((width / height) >= 4.0f / 3.0f)
misclassified e.g. 1920x1080 as portrait and could divide by zero.
It is now width >= height of the surface (as displayed), so a
side-by-side split-screen pane reports portrait.
Tested on a Pixel 10 Pro with agdktunnel forced to GLES via temporary
test code, logging the actual config/colorspace of the current surface:
- RGBA8 sRGB request: 8888/D24S8 config, sRGB surface. Before, no sRGB
format was offered.
- RGB565 request: 565 config (id 233). Before this change it got an
8888 config (id 23).
- RGBA8 linear: 8888/D24S8, linear.
- For each: resizing the display (wm size 1080x2000, then reset) gives
exactly one display-changed callback per resize, and the UI re-lays
out. After background/resume, the restored surface uses the same
config as the context.
- Landscape <-> reverse-landscape rotation: no spurious callbacks or
EGL errors (tested on the first revision of this change).
The default Vulkan build starts and renders normally. RGBA5551/RGBA4
(no such configs on this device) and the InitSwapchain failure path
were not exercised.
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.
Fix GLES config selection, sRGB surfaces, resize/orientation detection