Skip to content

Reuse unchanged region draw batches and merge adjacent commands - #581

Open
BonsUnleashed wants to merge 1 commit into
FiniteReality:20.1/forgefrom
BonsUnleashed:bons-furious/embeddium-draw-batch-cache
Open

BonsUnleashed wants to merge 1 commit into
FiniteReality:20.1/forgefrom
BonsUnleashed:bons-furious/embeddium-draw-batch-cache

Conversation

@BonsUnleashed

Copy link
Copy Markdown

Proposed Changes

Terrain rendering rebuilds a region's draw commands even when its mesh data, visible sections and camera-facing tests have not changed. This keeps the last two command lists per region and terrain pass, allowing the main view and a shadow view to reuse their own entries.

Storage mutations invalidate both entries. Accessing the existing writable pointer permanently disables caching for that storage, including retained pointers; the renderer uses an explicit read-only accessor. Keys include section order, pass flags, culling and exact camera face-test results. Cache hits copy only active commands.

Adjacent commands using the shared quad index buffer can also merge when their vertex ranges touch. Triangle order stays unchanged. Merging remains disabled with shader packs because per-draw shader inputs may depend on command boundaries.

This follows work prepared for Bons and Furious 1.0.30. Native compilation passed, followed by roughly 25,000 checks using the compiled renderer and native buffers: command/index equivalence, camera boundaries, two-view reuse, storage mutations, retained writable pointers and sorted/shader fallbacks. The test uses a shader-state shim; it does not render a frame. These results verify command behavior and do not establish an FPS gain.

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