perf(runner): draw static world faces via the surface cache - #21
Merged
Conversation
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>
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.
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 viaBakeSurfaceinto a per-faceCachedSurface(keyed by face index, persisted for the map's lifetime — static faces never change, so no invalidation) and painted withFillPerspectiveCachedPolygon: 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/texMinTcome straight fromlmInfo.MinS/MinT(TransformFaceLightmappeddefinesLmS=(U-MinS)/16, and the cache is indexed byLmS*16 / LmT*16).Verification (Firefox/Playwright, lq_e0m1)
🤖 Generated with Claude Code