Skip to content

perf: 24-byte depth stream for shadow casters; crop the water probe to its screen rect - #251

Open
proggeramlug wants to merge 2 commits into
fix/windows-output-scale-renderer-leakfrom
perf/compact-shadow-stream-probe-crop
Open

proggeramlug wants to merge 2 commits into
fix/windows-output-scale-renderer-leakfrom
perf/compact-shadow-stream-probe-crop

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Two speed-ups that keep the picture, measured on an integrated Radeon 760M (High preset, fight perftest, fixed resolution). Stacked on #242; retarget to main once that lands.

1. Shadow casters read a 24-byte depth twin of the geometry arena

Static meshes in the shared arena are 96-byte Vertex3D; a shadow pass needs only position (plus uv and alpha for cutouts). The arena now keeps a DepthVertex twin (24 bytes, a 4:1 ratio so base_vertex is unchanged), written on upload and copied on grow. Sun cascades and lamp shadow cubes draw arena geometry from it through two compact pipelines; skinned and non-arena buffers keep the full stream.

both off (2 runs) compact stream
shadow_pass 4.2 ms 2.9 ms
fight mean 28.9 fps 30.0 fps
worst window 24.9 27.4

Costs ~26 MB of VRAM for a forest arena. BLOOM_SKIP=shadow_compact restores the full stream for an A/B.

2. Crop a horizontal planar probe to where its water is on screen

Water samples the probe at screen_uv + n.xz * 0.08, so only the screen rect of the visible linked surfaces (plus a 0.25 NDC margin) is ever read. For a horizontal plane the mirrored view maps plane points to the same screen position, so the probe passes are scissored to that rect and cull against the cropped frustum. Instanced or unbounded water and tilted planes keep the full rect. planar_probe_models ~4.1 → ~3.8 ms. BLOOM_SKIP=probe_crop disables it.

Verification

  • New unit tests in planar_reflection (rect, cropped planes, scissor); cargo test --lib planar_reflection passes.
  • Twelve SCENESHOT views compared with both changes off and on: differences are wind and cloud motion only.
  • On this Windows checkout two lib tests fail independently of this change (capabilities::checked_documentation_table_matches_runtime_definitions, visibility_shading::virtual_shading_reuses_the_authoritative_pbr_and_all_mrts); both compare text with LF line endings and are not touched here.

Tried and dropped

The same 24-byte stream for the model depth prepass gained nothing (4.0 ms either way), so that pass is not vertex-fetch bound; it is not in this PR.

Ralph Kuepper added 2 commits November 16, 2026 19:43
…ry arena

Static meshes in the shared geometry arena are 96-byte Vertex3D; a shadow
pass only needs position (and uv + alpha for cutouts). The arena now keeps
a DepthVertex twin (position, uv, alpha; 24 bytes, 4:1 so base_vertex is
unchanged) written on upload and copied on grow. Sun cascades and lamp
shadow cubes draw arena geometry from the twin with two compact pipelines;
skinned and non-arena buffers keep the full stream.

Radeon 760M, High, fight at fixed resolution: shadow_pass 4.2 -> 2.9 ms,
fight 28.9 -> 30.0 fps, worst window 24.9 -> 27.4. SCENESHOT views match
(differences are wind and clouds only). Costs ~26 MB of extra VRAM for the
forest arena. BLOOM_SKIP=shadow_compact restores the full stream for A/B.
Water samples the probe at screen_uv + n.xz * 0.08, so only the screen
rect of the visible linked surfaces (plus a 0.25 NDC margin) is ever read.
For a horizontal plane the mirrored view maps plane points to the same
screen position, so the probe passes are scissored to that rect and cull
against the cropped frustum. Instanced or unbounded water, and tilted
planes, keep the full rect. Unit tests cover rect, planes and scissor.

Radeon 760M, High fight: planar_probe_models ~4.1 -> ~3.8 ms; picture
unchanged. BLOOM_SKIP=probe_crop disables it.
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fe794d6a-bf93-456e-a99e-1127610e23b6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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