Skip to content

Fix in-game geometry corruption: apply the base vertex on web - #22

Merged
matthewcodergamer merged 1 commit into
masterfrom
render360/iphone-baseline-lowmem
Oct 10, 2026
Merged

matthewcodergamer merged 1 commit into
masterfrom
render360/iphone-baseline-lowmem

Conversation

@matthewcodergamer

Copy link
Copy Markdown
Owner

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's DrawIndexedPrimitive computed a base-vertex-adjusted attribute setup in FlushVertexBindings, but that setup is only latched and never used (m_drawVertexSetup is marked "no longer used"). FlushDrawStates then rebuilt the GL vertex attributes from the bound streams with a base vertex of 0. Every indexed draw with a non-zero BaseVertexIndex read the wrong vertices: wrong positions, texcoords, lightmap coordinates and colors.

Fix

  • On web, BaseVertexIndex is passed to FlushDrawStates, and every vertex attribute starts BaseVertexIndex × stride bytes into its stream.
  • The base vertex is part of the attribute-cache key, so it's re-applied whenever it changes.
  • Native builds are unchanged; they still pass it to glDrawRangeElementsBaseVertex.

Checks

  • em++ -fsyntax-only (Emscripten 4.0.9) passes on glmgr.cpp, dxabstract.cpp and cglmbuffer.cpp.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Qy5DKdwTqGQqScWvJyNcft


Generated by Claude Code

…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
@matthewcodergamer
matthewcodergamer merged commit e8a015e into master Oct 10, 2026
2 checks passed

This branch was successfully deployed

1 active deployment
portal-iphone-staging — 68c3c3fb Deployed Oct 10, 2026 by matthewcodergamer via Deploy iPhone staging page #326
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.

2 participants