perf(renderer): per-fragment lighting and shadows dominate both Android forward and deferred paths #1085

Closed
opened 2026-11-10 00:32:23 +00:00 by SakulFlee · 2 comments
Owner

Summary

The Android regression is not deferred-renderer-specific. Forward and deferred now spend nearly the same time in shared per-fragment lighting and shadow evaluation.

Fresh phone A/B at native resolution (Mali-G720, 1220x2582, same scene/settings):

Variant Scene total Notes
A: deferred baseline 78.00 ms gpu_deferred 73.61 ms
B: forward 71.19 ms forward opaque 66.46 ms; only 8.7% faster than A
C: deferred, all 8 shadow casters disabled 36.25 ms gpu_deferred 33.15 ms
D: deferred, shadows off, only directional fill 7.00 ms gpu_deferred 4.01 ms

Attribution from the controlled A/B:

  • ~40.5 ms/frame in shadow sampling/PCF (A -> C).
  • ~29.1 ms/frame in the 16 point/spot light loop (C -> D).
  • ~4 ms/frame base fullscreen BRDF/IBL at this resolution (D).
  • The forward path only saves ~6.8 ms over deferred, so fixing deferred alone cannot recover the regression.

All four runs had exact subpass sums; this is real GPU work, not timestamp accounting. Variant C still reports 8 shadow caster components because they exist but are disabled; gpu_shadow confirms none are rendered.

Conclusion

The actionable levers are the 16 point/spot lights and the 8 shadowed lights, plus shadow-sampling quality/culling, in both forward and deferred paths. Do not treat this as a deferred-pass-only issue.

Follow-ups

  • #1086 — shadow sampling/PCF cost.
  • #1087 — point/spot light loop and tile-culling effectiveness.

Acceptance criteria

  • The per-fragment light/shadow cost is reduced on device with measured before/after data.
  • Deferred and forward paths are both considered; a deferred-only fix is insufficient.
  • No automatic resolution/refresh changes; #1083 remains separate.
## Summary The Android regression is not deferred-renderer-specific. Forward and deferred now spend nearly the same time in shared per-fragment lighting and shadow evaluation. Fresh phone A/B at native resolution (Mali-G720, 1220x2582, same scene/settings): | Variant | Scene total | Notes | |---|---:|---| | A: deferred baseline | 78.00 ms | `gpu_deferred` 73.61 ms | | B: forward | 71.19 ms | forward opaque 66.46 ms; only 8.7% faster than A | | C: deferred, all 8 shadow casters disabled | 36.25 ms | `gpu_deferred` 33.15 ms | | D: deferred, shadows off, only directional fill | 7.00 ms | `gpu_deferred` 4.01 ms | Attribution from the controlled A/B: - ~40.5 ms/frame in shadow sampling/PCF (A -> C). - ~29.1 ms/frame in the 16 point/spot light loop (C -> D). - ~4 ms/frame base fullscreen BRDF/IBL at this resolution (D). - The forward path only saves ~6.8 ms over deferred, so fixing deferred alone cannot recover the regression. All four runs had exact subpass sums; this is real GPU work, not timestamp accounting. Variant C still reports 8 shadow caster components because they exist but are disabled; `gpu_shadow` confirms none are rendered. ## Conclusion The actionable levers are the 16 point/spot lights and the 8 shadowed lights, plus shadow-sampling quality/culling, in both forward and deferred paths. Do not treat this as a deferred-pass-only issue. ## Follow-ups - #1086 — shadow sampling/PCF cost. - #1087 — point/spot light loop and tile-culling effectiveness. ## Acceptance criteria - The per-fragment light/shadow cost is reduced on device with measured before/after data. - Deferred and forward paths are both considered; a deferred-only fix is insufficient. - No automatic resolution/refresh changes; #1083 remains separate.
SakulFlee changed title from perf(android): deferred lighting dominates hybrid renderer at ~74 ms on Mali-G720 to perf(renderer): per-fragment lighting and shadows dominate both Android forward and deferred paths 2026-11-10 00:51:44 +00:00
Author
Owner

The batch points to a root cause that explains the earlier culling result: #1088. Point/spot range is packed as intensity / 0.01; intensities of 30–60 therefore produce radii of ~55–77 world units, larger than the scene. Every light covers every tile, so tiled culling is all-inclusive and every pixel evaluates most lights and shadow slots.

Supporting evidence:

  • Forced full light loop is slightly faster than tiled culling; tile size 8/16/32 has no effect.
  • 9→1 PCF tap saves only 4.2 ms; 512/2048 shadow maps are unchanged. Shadow cost is not tap count.
  • 5 spot shadows ≈24.7 ms; 3 point shadows ≈13.7 ms.
  • Removing the eight unshadowed R5 point lights saves ≈31.9 ms.
  • Forward no-shadows (30.05 ms) and deferred no-shadows (36.25 ms) are close, confirming shared cost.

Fix #1088 first (real range + smooth falloff), then remeasure both paths. A per-light shadow-slot index remains a secondary optimization.

The batch points to a root cause that explains the earlier culling result: #1088. Point/spot range is packed as `intensity / 0.01`; intensities of 30–60 therefore produce radii of ~55–77 world units, larger than the scene. Every light covers every tile, so tiled culling is all-inclusive and every pixel evaluates most lights and shadow slots. Supporting evidence: - Forced full light loop is slightly faster than tiled culling; tile size 8/16/32 has no effect. - 9→1 PCF tap saves only 4.2 ms; 512/2048 shadow maps are unchanged. Shadow cost is not tap count. - 5 spot shadows ≈24.7 ms; 3 point shadows ≈13.7 ms. - Removing the eight unshadowed R5 point lights saves ≈31.9 ms. - Forward no-shadows (30.05 ms) and deferred no-shadows (36.25 ms) are close, confirming shared cost. Fix #1088 first (real range + smooth falloff), then remeasure both paths. A per-light shadow-slot index remains a secondary optimization.
Author
Owner

Fixed on feat/perf-timings in b7086621. The light range is now explicit (default 10 units), glTF range is honored, params.z packs range², and forward/deferred/volumetric shading uses a smooth range window.

Device confirmation before the fix: changing the packed range to radius 10 reduced gpu_deferred from 73.83 to 21.26 ms and improved FPS from 9.50 to 20.00; radius 20 was 44.00 ms. The next capture should use the real range field and then re-run culling/shadow tests.

Fixed on `feat/perf-timings` in `b7086621`. The light range is now explicit (default 10 units), glTF range is honored, `params.z` packs range², and forward/deferred/volumetric shading uses a smooth range window. Device confirmation before the fix: changing the packed range to radius 10 reduced `gpu_deferred` from 73.83 to 21.26 ms and improved FPS from 9.50 to 20.00; radius 20 was 44.00 ms. The next capture should use the real range field and then re-run culling/shadow tests.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
SakulFlee/Orbital#1085
No description provided.