Skip to content

perf(runner): draw static world faces via the surface cache - #21

Merged
tannevaled merged 1 commit into
mainfrom
wire-surface-cache
Jul 6, 2026
Merged

perf(runner): draw static world faces via the surface cache#21
tannevaled merged 1 commit into
mainfrom
wire-surface-cache

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Wires the surface-cache primitives (#20) into the world-face draw — the payoff of the renderer perf work.

What

A face is cacheable when its lightmap is constant over time — fullbright (LightOfs<0) or every active lightstyle is style 0 ('m', the only time-independent style) — and its texture is not animated (no + chain). Such a face is baked once via BakeSurface into a per-face CachedSurface (keyed by face index, persisted for the map's lifetime — static faces never change, so no invalidation) and painted with FillPerspectiveCachedPolygon: a single fetch+store per pixel instead of a per-pixel lightmap bilinear + colormap lookup.

Animated faces (flickering lights, + textures) keep the per-pixel lightmapped path; sky/turbulent unchanged.

texMinS/texMinT come straight from lmInfo.MinS/MinT (TransformFaceLightmapped defines LmS=(U-MinS)/16, and the cache is indexed by LmS*16 / LmT*16).

Verification (Firefox/Playwright, lq_e0m1)

  • Pixel-identical render to the per-pixel path — walls fully textured + lit, no artifacts (screenshot).
  • Same scene, identical throttled harness: 1.32 → 1.56 fps (+18%).
  • Scene-dependent: larger in wall-heavy views, bounded here by the ~half-screen of (uncached) water + sky. The isolated cached fill benchmarks 2.45× faster than the lightmapped fill (feat(render): surface-cache primitives (baked fill + BakeSurface) #20).

🤖 Generated with Claude Code

Wires the surface-cache primitives (#20) into the world-face draw. A face is
CACHEABLE when its lightmap is constant over time -- fullbright (LightOfs<0)
or every active lightstyle is style 0 ('m', the only time-independent style)
-- AND its texture is not animated (no '+' chain). Such a face is baked ONCE
via render.BakeSurface into a per-face render.CachedSurface (keyed by face
index, persisted for the map's lifetime -- static faces never change, so no
invalidation) and painted with render.FillPerspectiveCachedPolygon: a single
fetch+store per pixel instead of a per-pixel lightmap bilinear + colormap
lookup. Animated faces (flickering lights, '+' textures) keep the per-pixel
lightmapped path; sky/turbulent are unchanged.

texMinS/texMinT for the bake come straight from lmInfo.MinS/MinT, since
TransformFaceLightmapped defines LmS=(U-MinS)/16 (so U=MinS+LmS*16, and the
cache is indexed by LmS*16 / LmT*16).

Verified in-browser (Firefox/Playwright, lq_e0m1): the world renders
pixel-identical to the per-pixel path (walls fully textured + lit, no
artifacts) and the same scene measured 1.32 -> 1.56 fps (+18%) under the
identical throttled harness. The win is scene-dependent -- larger in
wall-heavy views, bounded here by the ~half-screen of (uncached) water + sky;
the isolated cached fill benchmarks 2.45x faster than the lightmapped fill.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 32131f2 into main Jul 6, 2026
7 checks passed
@tannevaled
tannevaled deleted the wire-surface-cache branch July 6, 2026 08:35
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.

1 participant