Skip to content

GLES external texture implementation#9485

Open
cmeissl wants to merge 3 commits intogfx-rs:trunkfrom
cmeissl:feature/glsl_external_texture
Open

GLES external texture implementation#9485
cmeissl wants to merge 3 commits intogfx-rs:trunkfrom
cmeissl:feature/glsl_external_texture

Conversation

@cmeissl
Copy link
Copy Markdown

@cmeissl cmeissl commented May 2, 2026

Connections
Part of #4386
closes #4528

Description
GLES implementation of external texture, similar to the implementation for HLSL in #8117.

The main difference is the use of OES_EGL_image_external_essl3 which will do the YUV color conversion implicitly in the driver.

sample/load/size are mapped to inserted helper functions using samplerExternalOES.

An alternative would be to map the planes to multiple views and do the YUV-RGB
conversion in the shader. But I not sure this would work with all tiling formats as
some require shadow copies in the driver.

The last commit (gl api override) is not necessary for this feature, but was required for
testing the gles implementation on desktop mesa.

Testing

Naga tests for external textures enabled for glsl backend.

External test client using gstreamer and wgpu to render dmabuf based
video buffers.

Squash or Rebase?

Rebase

Checklist

  • I self-reviewed and fully understand this PR.
  • WebGPU implementations built with wgpu may be affected behaviorally.
  • Validation and feature gates are in place to confine behavioral changes.
  • Tests demonstrate the validation and altered logic works.
  • CHANGELOG.md entries for the user-facing effects of this change are present.
  • The PR is minimal, and doesn't make sense to land as multiple PRs.
  • Commits are logically scoped and individually reviewable.
  • The PR description has enough context to understand the motivation and solution implemented.

@cmeissl cmeissl force-pushed the feature/glsl_external_texture branch 2 times, most recently from 9e2cd8d to 45af623 Compare May 2, 2026 14:10
@AdrianEddy
Copy link
Copy Markdown
Contributor

This probably closes #4528 as well?

@cmeissl
Copy link
Copy Markdown
Author

cmeissl commented May 3, 2026

This probably closes #4528 as well?

Oh yeah, added, thanks!

What I wonder is where the use of the external sampler and its expectation could be documented.

cmeissl added 3 commits May 4, 2026 09:22
This adds GLSL backend support for `ImageClass::External`. (ie WGSL's
`external_texture` texture type). This is implemented similarily
to the MSL implementation in gfx-rs#8117.

The main difference to the MSL and HLSL implementation is that
this uses GL_OES_EGL_image_external_essl3 instead of reading
raw YUV data. This limits the usage to external textures imported
through egl represented as a single RGBA texture. The YUV conversion
is done in the driver.

The WGSL builtins `textureDimensions()`, `textureLoad()`, and
`textureSampleBaseClampToEdge()` are implemented using helper
functions mapping to externalEOS.
This enables the use of GL_OES_EGL_image_external_essl3 on gles
when the `EXTERNAL_TEXTURE` feature is requested and creates
the required bindings.
On desktop Linux (Mesa), EGL reports both OpenGL and OpenGL ES as
available client APIs. wgpu-hal automatically prefers desktop OpenGL,
which prevents GLES-only features (e.g. EXTERNAL_TEXTURE /
GL_OES_EGL_image_external_essl3) from being advertised by the adapter.

Add a `GlClientApi` enum and a `client_api` field to `GlBackendOptions`
so callers can explicitly request `OpenGlEs` (or `OpenGl`) instead of
relying on the auto-detection heuristic.
@cmeissl cmeissl force-pushed the feature/glsl_external_texture branch from 45af623 to 2726221 Compare May 4, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[glsl-out] Feature to generate samplerExternalOES instead of sampler2D

3 participants