Add the ability to handle external textures#363
Merged
Conversation
Owner
|
Is this going to be problematic when calling any texture-related functions and passing the external texture we create here? I think we'd try to look up the key in the slotmap and fail. |
Contributor
Author
|
but it does insert into the slot map. The only functional difference for external textures is that it doesn't call |
Owner
|
Oh sorry - I completely missed the |
grovesNL
reviewed
May 13, 2026
grovesNL
reviewed
May 15, 2026
grovesNL
approved these changes
May 21, 2026
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.
This PR adds two methods on the
webglContextso external code can hand glow aWebGlTextureit does not own, and readback the underlying handle from a glow
Texturekey.On the
webglcfg,glow::Textureis aWebTextureKey(an opaque slotmap key) and the only way to create one today iscreate_texture, which allocates a freshWebGlTextureviagl.createTexture().There is no path for callers that already hold a
web_sys::WebGlTexture(produced outside glow) to use it through glow.There is also no public way to recover the
web_sys::WebGlTexturefrom aglow::Texturekey.This blocks zero-copy texture import/export on top of glow on the web target.
In particular,
wgpu_hal::gles::Device::texture_from_rawis not possible for webgl because of that missing API in glow.Caller retains ownership of the underlying
WebGlTexture. glow's slotmap entry is bookkeeping only for the key's lifetime. Passing the key todelete_texturereleases the slot but does not touch the JS handle.