Repository navigation
[GL] Fix unused and overly-broad __deps entries in WebGL JS libraries. NFC - #28037
Merged
Merged
Conversation
…es. NFC
Align the preprocessor guards on `__deps` arrays with the actual call
sites in the corresponding function bodies so symbols are only pulled in
when referenced:
- In `src/lib/libwebgl.js`:
- Guard `'$webglBufferSubData'` in `$GL__deps` and
`glDrawElements__deps` with `#if FULL_ES2`. In `$GL`,
`webglBufferSubData` is only called from
`preDrawHandleClientVertexAttribBindings` (which is guarded by
`#if FULL_ES2`, not `LEGACY_GL_EMULATION`). Similarly,
`glDrawElements` only calls `webglBufferSubData` inside its
`#if FULL_ES2` client-side index buffer block.
- Guard `'$heapObjectForWebGLType'` and `'$toTypedArrayIndex'` in
`glTexImage2D__deps`, `glTexSubImage2D__deps`, and
`glReadPixels__deps` with `#if WEBGL_USE_GARBAGE_FREE_APIS` instead
of `#if MAX_WEBGL_VERSION >= 2`. Those functions only call
`heapObjectForWebGLType` and `toTypedArrayIndex` directly inside
`#if WEBGL_USE_GARBAGE_FREE_APIS` blocks; otherwise they delegate to
`emscriptenWebGLGetTexPixelData` (which declares its own `__deps`).
- Guard `$webglGetProgramUniformLocation__deps` with
`#if GL_EXPLICIT_UNIFORM_LOCATION`, matching the sole call to
`webglPrepareUniformLocationsBeforeFirstUse` inside
`$webglGetProgramUniformLocation`.
- In `src/lib/libwebgl2.js`:
- Guard `'$toTypedArrayIndex'` in `glTexImage3D__deps` and
`glTexSubImage3D__deps` with `#if WEBGL_USE_GARBAGE_FREE_APIS`,
since `toTypedArrayIndex` is only called in that branch (the `#else`
branch delegates to `emscriptenWebGLGetTexPixelData`).
- Remove `glGetVertexAttribIuiv__deps`. `glGetVertexAttribIuiv` is a
string alias for `'glGetVertexAttribIiv'`, which already declares
`glGetVertexAttribIiv__deps: ['$emscriptenWebGLGetVertexAttrib']`.
Split out from emscripten-core#27995
There was a problem hiding this comment.
Code Review
This pull request refactors WebGL and WebGL2 library dependencies in Emscripten. It replaces checks for MAX_WEBGL_VERSION >= 2 with WEBGL_USE_GARBAGE_FREE_APIS for garbage-free API dependencies, optimizes conditional dependency inclusions for FULL_ES2 and GL_EXPLICIT_UNIFORM_LOCATION, and removes an unused dependency declaration for glGetVertexAttribIuiv. There are no review comments, so I have no feedback to provide.
kripken
approved these changes
Oct 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.
Align the preprocessor guards on
__depsarrays with the actual call sites in the corresponding function bodies so symbols are only pulled in when referenced:src/lib/libwebgl.js:'$webglBufferSubData'in$GL__depsandglDrawElements__depswith#if FULL_ES2. In$GL,webglBufferSubDatais only called frompreDrawHandleClientVertexAttribBindings(which is guarded by#if FULL_ES2, notLEGACY_GL_EMULATION). Similarly,glDrawElementsonly callswebglBufferSubDatainside its#if FULL_ES2client-side index buffer block.'$heapObjectForWebGLType'and'$toTypedArrayIndex'inglTexImage2D__deps,glTexSubImage2D__deps, andglReadPixels__depswith#if WEBGL_USE_GARBAGE_FREE_APISinstead of#if MAX_WEBGL_VERSION >= 2. Those functions only callheapObjectForWebGLTypeandtoTypedArrayIndexdirectly inside#if WEBGL_USE_GARBAGE_FREE_APISblocks; otherwise they delegate toemscriptenWebGLGetTexPixelData(which declares its own__deps).$webglGetProgramUniformLocation__depswith#if GL_EXPLICIT_UNIFORM_LOCATION, matching the sole call towebglPrepareUniformLocationsBeforeFirstUseinside$webglGetProgramUniformLocation.src/lib/libwebgl2.js:'$toTypedArrayIndex'inglTexImage3D__depsandglTexSubImage3D__depswith#if WEBGL_USE_GARBAGE_FREE_APIS, sincetoTypedArrayIndexis only called in that branch (the#elsebranch delegates toemscriptenWebGLGetTexPixelData).glGetVertexAttribIuiv__deps.glGetVertexAttribIuivis a string alias for'glGetVertexAttribIiv', which already declaresglGetVertexAttribIiv__deps: ['$emscriptenWebGLGetVertexAttrib'].Split out from #27999