Skip to content

Speed up dense vegetation and prevent million-instance traversal overflow - #86

Merged
SamG-Coder merged 1 commit into
mainfrom
codex/vegetation-stress
Nov 13, 2026
Merged

SamG-Coder merged 1 commit into
mainfrom
codex/vegetation-stress

Conversation

@SamG-Coder

@SamG-Coder SamG-Coder commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Dense forests waste raster work on pixel centres outside tiny triangles and can overflow the traversal queue with nodes that the next dispatch immediately rejects for LOD. Reject those children before enqueueing and bound raster loops using the existing fixed-point vertices, preserving the detail threshold and coverage rules.

This PR is stacked on #85. Its base is codex/performance-history-fixes so the diff contains only the vegetation follow-up.

Also defer unused particle-pool buffers until the first effect is prepared (27.58 MiB at the default capacity), and reuse the sky-view table when its exact shader parameters are unchanged. Add a reproducible procedural grass/tree benchmark, sequential comparison runner, per-pass measurements, image checks, and GPU regressions.

Results

RTX 5080 / Ryzen 7 9800X3D, native Vulkan, 1920×1080, unchanged default quality. Medians over two 240-frame runs per version:

Workload GPU before GPU after Reduction
16,384 grass patches + 1,024 trees, ground 5.938 ms 5.357 ms 9.8%
Same forest, walking/turning 5.976 ms 5.426 ms 9.2%
262,144 grass patches + 16,384 trees, overview 4.271 ms 3.547 ms 17.0%

All 1,440 paired frame positions have identical selected cluster and triangle counts. The million-patch / 65,536-tree scene now renders 1,179,649 instances with zero measured drops: 6.043 ms GPU in overview and 6.620 ms at ground level. Before early LOD rejection, the overview dropped more than ten million queue entries. Its shorter incomplete render is excluded from speed comparisons.

CPU medians changed little and exploratory variability prevents claiming a reliable CPU speedup. The memory saving is GPU buffer allocation; whole-process RAM did not show a consistent decrease. Whole shaded images are not bit-identical; measured differences and baseline-repeat variation are reported.

Validation

  • 289 renderer unit tests passed, one existing ignored test.
  • Expanded real-GPU traversal test passed, including early child rejection at the exact LOD threshold.
  • 3,430,912 sample positions match exhaustive raster coverage/depth bit-for-bit.
  • Sky-cache pixels match a forced rebuild; late particle effects retain the full requested budget.
  • Shader/region validation, native workspace/all-target Clippy, and minimal/default/editor WASM builds and Clippy passed.
  • Four full camera rotations completed over 2,400 measured frames with no dropped work.
  • Final GPU integration sweep and startup-overflow checks are still running; this remains a draft until they finish.

Detailed audit and measurements. These are shared-renderer native tests, not browser FPS or a rebuild of the reported street application.

Authorship

Reviewed by: Claude Sonnet 5.5 (independent review, no correctness bugs found: early LOD rejection uses the consumer's exact predicate, the software-raster bounds keep every covered sample centre including ties, the lazy particle pool is always allocated before use, and the sky-view cache key covers every input). Noted, not blocking: the LOD predicate is duplicated rather than shared; the particle pool is now allocated when the first effect starts, which may cost a one-off frame; the new dev-dependencies (solstice-procgen, png, already in the lockfile) stay out of the browser build. Locally verified by Claude Opus 5.5 at 2918919 on top of #85: bash scripts/check-changed.sh --all (1012 passed, 0 failed, all checks passed, including the full GPU integration suite) and node apps/viewer/web/editor/test.mjs (all passed). Retargeted to main after #85 merged.

  • All code, text and comments in this pull request were written by a frontier AI model, with no human-written code, and will be reviewed by a frontier AI model before merging, as the Code of Conduct requires.

@SamG-Coder
SamG-Coder changed the base branch from codex/performance-history-fixes to main November 13, 2026 10:16
@SamG-Coder
SamG-Coder marked this pull request as ready for review November 13, 2026 10:23
@SamG-Coder
SamG-Coder merged commit cf9b382 into main Nov 13, 2026
1 check passed
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