renderer_gl: support external textures (BGFX_CAPS_TEXTURE_EXTERNAL)#69
Open
cdschmidt wants to merge 1 commit into
Open
renderer_gl: support external textures (BGFX_CAPS_TEXTURE_EXTERNAL)#69cdschmidt wants to merge 1 commit into
cdschmidt wants to merge 1 commit into
Conversation
The OpenGL renderer never advertised BGFX_CAPS_TEXTURE_EXTERNAL and ignored the external native handle passed to createTexture, so createTexture2D(..., _external) tripped the "External texture is not supported!" assertion. The D3D11, D3D12, Metal and Vulkan renderers already support this path. Advertise the capability (importing an existing GL texture id via TextureGL::overrideInternal is valid on any GL/GLES context) and adopt the supplied id in createTexture. overrideInternal sets BGFX_SAMPLER_INTERNAL_SHARED so TextureGL::destroy will not delete the externally owned texture. 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.
What
Add OpenGL/OpenGL ES support for bgfx external textures (importing an existing, caller-owned GL texture id instead of allocating a new one).
Two changes in
src/renderer_gl.cpp:BGFX_CAPS_TEXTURE_EXTERNAL. The GL renderer never set this capability, socreateTexture2D(..., _external)tripped the"External texture is not supported!"assertion inbgfx.cpp. The D3D11, D3D12, Metal, and Vulkan renderers already advertise it._externalhandle increateTexture. The override previously didBX_UNUSED(_external)and always allocated a fresh texture. It now adopts the supplied id via the existingTextureGL::overrideInternal, which setsBGFX_SAMPLER_INTERNAL_SHAREDsoTextureGL::destroywill not delete the externally owned texture.Why
This is the renderer-side counterpart required by BabylonNative's ExternalTexture OpenGL backend (BabylonJS/BabylonNative#1780). Without it, the OpenGL/OpenGL ES path fatals at runtime with
External texture is not supported!because the GL renderer neither advertises the capability nor wraps the provided texture id.Importing an existing GL texture id is valid on any GL/GLES context, so the capability is advertised unconditionally, matching the other backends.