ExternalTexture_OpenGL: implement GetInfo/Set/Get for GL texture handles#1780
Open
cdschmidt wants to merge 2 commits into
Open
ExternalTexture_OpenGL: implement GetInfo/Set/Get for GL texture handles#1780cdschmidt wants to merge 2 commits into
cdschmidt wants to merge 2 commits into
Conversation
cdschmidt
force-pushed
the
users/caschmidt/external-texture-opengl
branch
2 times, most recently
from
July 13, 2026 22:03
ac67b20 to
44becb9
Compare
cdschmidt
force-pushed
the
users/caschmidt/external-texture-opengl
branch
from
July 13, 2026 22:13
44becb9 to
7733546
Compare
Author
|
@microsoft-github-policy-service agree company="Microsoft" |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request replaces the previously stubbed OpenGL(OpenGLES) ExternalTexture backend with a working implementation, aligning the OpenGL path with the existing per-API Impl + shared-dispatcher pattern used by the other backends.
Changes:
- Implement OpenGL
ExternalTexture::ImplGetInfo/Set/Getto support importing GL texture handles into bgfx. - Add a bgfx-format ⇄ GL internalFormat reverse-lookup table (with sRGB detection) plus guarded enum fallbacks for minimal GLES headers.
- Validate texture handles via
glIsTexture, enforceGL_TEXTURE_2D-only handles, and query dimensions/mip count via GL texture level parameters.
Implements the previously-stubbed OpenGL backend of the ExternalTexture plugin. Mirrors the D3D11 backend pattern: per-API Impl class derived from ImplBase, GetInfo/Set/Get triplet, full bgfx<->GL format table. Key details: - 96-row s_textureFormat[] with static_assert against bgfx::TextureFormat::Count. - All non-core extension constants (S3TC, BPTC, ASTC, BGRA, etc.) guarded with #ifndef + OpenGL registry hex fallbacks so it compiles on minimal Mesa GLES headers. - Always sets BGFX_TEXTURE_RT (FBO bridging is the only supported use case; GL has no introspection equivalent of D3D11 BIND_RENDER_TARGET). - glIsTexture validation + pre/post-bind error drain; bounded mip walk; GL_TEXTURE_BINDING_2D save/restore on every exit path. - Sets NumLayers = 1 (GL_TEXTURE_2D is single-layer); array/multisample/cube handles are rejected by the GL_TEXTURE_2D-only bind check. - Reverse format lookup skips the BGRA-ordered rows (BGRA8/BGRA4/BGR5A1/ B5G6R5): GL has no distinct BGRA internal format, so bgfx maps them to the same GL internal format as their RGBA twins. Skipping ensures a GL_RGBA8 attachment resolves to RGBA8 rather than the earlier-listed BGRA8 (which would swap R/B). - Throws on unsupported format rather than returning Unknown. - MSAA explicitly unsupported for now (would need TEXTURE_2D_MULTISAMPLE + GL_TEXTURE_SAMPLES query). Review feedback: - Guard the GLES 3.1 header include with __has_include, falling back to gl3.h (declaring glGetTexLevelParameteriv + GL_TEXTURE_WIDTH/HEIGHT) so builds on toolchains without gl31.h don't fail. - Expand the GL_TEXTURE_2D-only rejection message to also name array textures. - Enable OpenGL test coverage: implement the GL Helpers::CreateTexture/ DestroyTexture, drop SKIP_EXTERNAL_TEXTURE_TESTS on UNIX (run Construction/ CreateForJavaScript/Update/AddToContextAsyncAndUpdate). Render-path tests (SKIP_RENDER_TESTS) and the array/layer-index test (SKIP_EXTERNAL_TEXTURE_ ARRAY_TESTS) remain skipped pending GL readback + array support. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
cdschmidt
force-pushed
the
users/caschmidt/external-texture-opengl
branch
from
July 14, 2026 22:05
0f2a2eb to
c7e9a7f
Compare
Grow the OpenGL backend's s_textureFormat[] reverse-map table to cover all 100 bgfx::TextureFormat::Count formats (was 96), fixing the "bgfx::TextureFormat::Count == BX_COUNTOF(s_textureFormat)" static assertion that broke every Linux/OpenGL build. Reads GL internal formats back via ES 3.0 framebuffer-attachment queries and matches them to bgfx formats. Add optional width/height hints to the ExternalTexture constructor and Update: required on the OpenGL/OpenGL ES backend (ES 3.0 cannot query a texture's dimensions from a bare handle) and ignored on D3D/Metal, which introspect the native texture. Move the UnitTests SKIP_RENDER_TESTS / SKIP_EXTERNAL_TEXTURE_ARRAY_TESTS definitions into a GRAPHICS_API==OpenGL block so they apply to every OpenGL build rather than only the Linux path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 266f2ffa-1a30-41c7-96de-0ec7782df1bd
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.
Implements the previously-stubbed OpenGL backend of the ExternalTexture plugin. Mirrors the D3D11 backend pattern: per-API
Implclass derived fromImplBase,GetInfo/Set/Gettriplet, full bgfx<->GL format table.Key details:
s_textureFormat[]withstatic_assertagainstbgfx::TextureFormat::Count.#ifndef+ OpenGL registry hex fallbacks so it compiles on minimal Mesa GLES headers.BGFX_TEXTURE_RT(FBO bridging is the only supported use case; GL has no introspection equivalent of D3D11BIND_RENDER_TARGET).glIsTexturevalidation + pre/post-bind error drain; bounded mip walk;GL_TEXTURE_BINDING_2Dsave/restore on every exit path.NumLayers = 1(GL_TEXTURE_2Dis single-layer); array/multisample/cube handles are rejected by theGL_TEXTURE_2D-only bind check.TEXTURE_2D_MULTISAMPLE+GL_TEXTURE_SAMPLESquery).Rebased onto latest master and ported to the shared-dispatcher ExternalTexture interface (#1566).