Repository navigation
cvcGL: shader textures fit WebGL2's 16 units: the reserve is the mapper's arrays (terrain_lab's water in the browser) - #1313
Merged
Conversation
…er's arrays #1304 stopped shader-input textures holding their units between draws. The redeployed terrain_lab still ran out in every water draw: headless Chrome logged 2,318 out-of-units warnings in 75 s once the water came up. VTK sizes its texture-unit table from GL_MAX_TEXTURE_IMAGE_UNITS, which is 32 on a desktop GL but 16 in WebGL2. bindShaderTextures first reserved a fixed 8 units for the low-memory mapper's emulated vertex arrays, which left a draw 8 for its own textures, and the water binds 10 (three cascades, three coast grids, the wake, the bed, two cloud-shade textures). - LowMemoryPolyDataMapper::arrayTextureUnits(): the arrays the draw under way takes, vtkDrawTexturedElements::Arrays (bound in RenderPieceStart, before UpdateShaderEvent fires). bindShaderTextures reserves that many when the drawing mapper (the event's caller, or the node's own) is one of ours, else 8 as before. - A texture that still finds no unit is left unbound, so it no longer sets a -1 sampler, which was a second GL error every draw. cvcGL names the node and texture once. - ViewportManager::limitTextureUnits(n) and $CVCGL_TEXTURE_UNITS cap VTK's table, put back at the start of each render after a GL state reset. With CVCGL_LOWMEM_MAPPER=force, a native run draws within the browser's budget. Native terrain_lab that way logged 1,440 warnings with the fixed reserve ("far" and "near" out of units for uWake: 16 in all, 8 kept, 10 shader textures), and 0 with this change. - cvcgl_ariadne_realize: the water (with a swell, so the swash and coast grids are on), cloud_sky's shade and a shadow-casting sun, drawn with the low-memory mapper at 16 units, log no out-of-units warning. The count is checked to hear VTK's warning. - ARIADNE.md: the browser's texture units, natively. - The comment #1304 added said WebGL2 gives VTK 32 units; it gives 16.
transfix
enabled auto-merge (squash)
November 16, 2026 08:57
This was referenced Nov 16, 2026
transfix
added a commit
that referenced
this pull request
Nov 17, 2026
…o feat/water-lod #1313 made shader textures fit WebGL2's 16 units, and its realize test checks that no draw runs out with the low-memory mapper at 16. #1314 alone fails that check (its foam atlas is one sampler more than master's water); this branch's packing (the cascades in uDisp, the coast and the wind's fetch maps in uCoast) brings the water back under. No conflicts. cvcgl_ariadne_realize: the WebGL2 section passes (16 texture units, 0 out-of-units warnings).
transfix
added a commit
that referenced
this pull request
Nov 17, 2026
One conflict, in ci.yml's SAN_CXX_TESTS: this branch added stream_test, net_ws_client_test and ariadne_host_test to the sanitizer legs' list, and #1292 added gradient_vector_diffusion_test, critical_points_test and seed_generators_test (reflowing the lines). Kept both. ci.yml's line 1271 (the arigl-web path filter's files.h/files.cpp line) also goes back to master's bytes: master stores ci.yml with CRLF but that one line LF-only, and an earlier merge here had given it a CR, a whitespace-only change in this PR's diff.
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.
Second half of terrain_lab's browser lock-up, after #1304.
What the redeploy showed. With #1304 deployed, headless Chrome on terrain_lab logged 3,736 console messages in 75 s, down from 89,998. But 2,318 of them were still "Hardware does not support the number of textures defined", starting when the water's cascades came up.
Why.
GL_MAX_TEXTURE_IMAGE_UNITS(vtkTextureUnitManager::Initialize). That is 32 on this NVIDIA GL, but 16 in WebGL2: headless Chrome on ANGLE/D3D11 reports frag 16, vert 16, combined 32.GeometryNode::bindShaderTexturesfirst reserved a fixed 8 units for the low-memory mapper's emulated vertex arrays. That left a draw 8 for its own textures.The fix.
LowMemoryPolyDataMapper::arrayTextureUnits()returns the arrays the draw under way will take:vtkDrawTexturedElements::Arrays, bound inRenderPieceStartbeforeUpdateShaderEventfires and activated after it.bindShaderTexturesreserves exactly that many when the drawing mapper is one of ours. The drawing mapper is the event's caller, or the node's own mapper for the streaming hooks.cvcGL: near: no texture unit left for uWake (16 in all, 8 kept for the mapper's vertex data, 10 shader textures).ViewportManager::limitTextureUnits(n)and$CVCGL_TEXTURE_UNITScap VTK's table. The cap is put back at the start of each render, since VTK recreates its GL state on a reset. WithCVCGL_LOWMEM_MAPPER=force, a native run draws within the browser's budget.Checked (MSVC Release, Windows).
arigl snapshotof terrain_lab withCVCGL_LOWMEM_MAPPER=force CVCGL_TEXTURE_UNITS=16, 120 frames: 1,440 out-of-units warnings with the fixed reserve (the water'sfarandneargrids out of units foruWake), and 0 with this change.cvcgl_ariadne_realizegets a WebGL2 block. It draws the water (with a swell, so the swash and coast grids are on), cloud_sky's shade and a shadow-casting sun with the low-memory mapper at 16 units, and expects no out-of-units warning. It also checks that the counter hears VTK's warning.Not checked: Linux, macOS, and the browser itself. After this deploys: rerun the headless probe, then look at terrain_lab in a browser.
Budget note for open PRs: #1311 (O13) adds a ninth water sampler, so the water binds 11 with the shade. With the arrays taking about 4–5 units, that still fits in 16. The knob above checks it natively.