BabylonJS / BabylonJS/BabylonNative

OpenGL: ExternalTexture device-loss test cannot run - test helpers cannot create a GL context

Open
#1,810 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
919
Forks
162
Avg merge
1d 15h
Merged PRs (30d)
19

Description

[Filed by Copilot on behalf of @bghgary]

`ExternalTexture.RestoreAfterDeviceLoss` is skipped on OpenGL via `SKIP_DEVICE_LOSS_TESTS`
(`Apps/UnitTests/CMakeLists.txt`).

The test creates a second device, tears down the first, and allocates a texture against the
second while no `Babylon::Graphics::Device` is alive. On D3D11 and Metal `Helpers::CreateDevice`
hands back a real `ID3D11Device` / `MTLDevice`, and texture creation is a method on that object.

OpenGL has no equivalent:

- `DeviceImpl_OpenGL::GetPlatformInfo()` returns `bgfx::getInternalData()->context` — a context
**bgfx created**, not one the test owns.
- `Babylon::Graphics::DeviceT` is a bare `void*` on OpenGL. It carries no display and no surface,
so it cannot be made current on its own.
- GL object creation targets whichever context is current on the calling thread, so the helper
would have to create *and* make current its own context.

Supporting this means adding per-platform context creation (EGL on Android and Windows/ANGLE,
EGL or GLX on Linux) to the unit-test helpers, plus make-current/restore handling around each
helper call. No EGL or GLX context-creation code exists under `Apps/` or `Core/` today. On
Windows, `CMakeLists.txt` synthesizes an import library for `libGLESv2.dll` only, so `libEGL.dll`
would need one too.

Contributor guide

Open the contributing guide

Research direction

Start with Apps/UnitTests/CMakeLists.txt, ExternalTexture.RestoreAfterDeviceLoss, Helpers::CreateDevice, and DeviceImpl_OpenGL::GetPlatformInfo(). Review how the existing D3D11 and Metal helpers handle devices, then trace the OpenGL test setup. Done means the OpenGL device-loss test can run with helper-owned contexts and make-current/restore handling on the listed platforms, including required Windows linking.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system, computer-graphics, testing-qa
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.