Repository navigation
Fix in-game geometry corruption: apply the base vertex on web - #22
Merged
Merged
Conversation
…game) WebGL 2 has no glDrawRangeElementsBaseVertex, so the browser build's DrawIndexedPrimitive computed a base-vertex-adjusted attribute setup in FlushVertexBindings, but that setup is only latched (m_drawVertexSetup is unused). FlushDrawStates rebuilt the GL vertex attribs from the bound streams with a base vertex of 0, so every indexed draw with a non-zero BaseVertexIndex read the wrong vertices: triangles stretched across the screen, stair-stepped smears, blown-out white surfaces and saturated blue/green/cyan from mismatched positions, texcoords and colors. On web, pass BaseVertexIndex through to FlushDrawStates and start every vertex attribute that many vertices into its stream; the base vertex is part of the attrib-cache key so it is re-applied whenever it changes. Native builds are unchanged (they pass it to glDrawRangeElementsBaseVertex). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qy5DKdwTqGQqScWvJyNcft
This branch was successfully deployed
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.
Problem
In game, surfaces rendered as stretched, stair-stepped smears with blown-out white and saturated blue/green/cyan colors.
Cause
WebGL 2 has no
glDrawRangeElementsBaseVertex. The browser build'sDrawIndexedPrimitivecomputed a base-vertex-adjusted attribute setup inFlushVertexBindings, but that setup is only latched and never used (m_drawVertexSetupis marked "no longer used").FlushDrawStatesthen rebuilt the GL vertex attributes from the bound streams with a base vertex of 0. Every indexed draw with a non-zeroBaseVertexIndexread the wrong vertices: wrong positions, texcoords, lightmap coordinates and colors.Fix
BaseVertexIndexis passed toFlushDrawStates, and every vertex attribute startsBaseVertexIndex × stridebytes into its stream.glDrawRangeElementsBaseVertex.Checks
em++ -fsyntax-only(Emscripten 4.0.9) passes onglmgr.cpp,dxabstract.cppandcglmbuffer.cpp.🤖 Generated with Claude Code
https://claude.ai/code/session_01Qy5DKdwTqGQqScWvJyNcft
Generated by Claude Code