perf(ui): Atlas deep rungs draw one gridunit per 2x2 px block

DISPLAY_RATIO_DEEP 1.0 -> 2.0, so a viewport-fit request at District/
Quarter/Block/Chunk asks for ~4x fewer gridunits (1920x1080: ~2.07M
cells -> ~518K) and the server-side derive cost falls with it. Texel-
exactness is preserved — the ratio stays a whole number of screen px
per gridunit, so every source texel still lands on whole pixels; only
the block size changes. Non-integer ratios are not an option here:
they reintroduce exactly the sub-pixel blur D-255's texel-exactness
exists to prevent.

Judged live by Jeroen against the 1x1 build (pair session): the deep
rungs read as crisp larger pixels rather than blur, and the speedup is
substantial. Looks were the gate.

Both transport tests that pinned the old literal now assert the
RELATIONSHIP instead — deep rungs share the constant, viewport-fit
divides by it — plus a new guard that the ratio stays whole, so the
value remains tunable without editing tests that are not about it.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-07-26 17:11:44 +02:00
co-authored by Claude
parent b58b02c98a
commit ae03ea2de7
2 changed files with 35 additions and 7 deletions
+24 -6
View File
@@ -76,9 +76,21 @@ func test_spacing_for_rung_matches_d243_metre_values() -> void:
# =============================================================================
func test_display_ratio_deep_rungs_are_one_to_one() -> void:
## The four deep rungs share ONE display ratio, whatever its current value —
## asserting the relationship rather than the literal, so tuning
## DISPLAY_RATIO_DEEP (pair session 2026-07-26: 1.0 -> 2.0, the cost/looks
## experiment) doesn't require editing a test that isn't about the number.
## The value itself is a presentation tunable (D-255(a)); what must hold is
## that the deep rungs agree with each other and stay a texel-exact integer.
func test_display_ratio_deep_rungs_all_share_the_deep_ratio() -> void:
var deep: float = StepCanvasTransport.DISPLAY_RATIO_DEEP
for rung in ["District", "Quarter", "Block", "Chunk"]:
assert_float(StepCanvasTransport.display_ratio_for_rung(rung)).is_equal_approx(1.0, 0.001)
assert_float(StepCanvasTransport.display_ratio_for_rung(rung)).is_equal_approx(deep, 0.001)
assert_float(deep).override_failure_message(
"the deep display ratio must be a whole number of screen px per gridunit —"
+ " a fractional ratio reintroduces the sub-pixel blur D-255 texel-exactness prevents"
).is_equal_approx(floorf(deep), 0.0001)
assert_float(deep).is_greater(0.0)
func test_display_ratio_shallow_rungs_use_the_five_x_five_fallback() -> void:
@@ -98,10 +110,16 @@ func test_is_orbital_rung_true_only_for_global_and_region() -> void:
# =============================================================================
func test_viewport_fit_extent_at_deep_ratio_matches_viewport_pixels() -> void:
# 1x1 ratio -> extent in gridunits == viewport px, 1:1.
var extent: Vector2i = StepCanvasTransport.viewport_fit_extent(Vector2(800.0, 600.0), "Chunk")
assert_that(extent).is_equal(Vector2i(800, 600))
## A deep-rung request asks for viewport_px / DISPLAY_RATIO_DEEP gridunits —
## derived from the constant, not the literal, so the ratio stays tunable
## (see the deep-ratio test above). This IS the cost lever: doubling the
## ratio quarters the requested cell count.
func test_viewport_fit_extent_at_deep_ratio_divides_by_the_deep_ratio() -> void:
var deep: float = StepCanvasTransport.DISPLAY_RATIO_DEEP
var viewport := Vector2(800.0, 600.0)
var extent: Vector2i = StepCanvasTransport.viewport_fit_extent(viewport, "Chunk")
var expected := Vector2i(int(ceil(viewport.x / deep)), int(ceil(viewport.y / deep)))
assert_that(extent).is_equal(expected)
func test_viewport_fit_extent_at_shallow_ratio_divides_by_the_display_ratio() -> void:
@@ -57,7 +57,17 @@ const RUNG_SPACING_M: Dictionary = {
## client-side, viewport-dependent parameter, kept architecturally separate
## from gridunit spacing") — it never touches a cache key or a wire request,
## only how many screen px one already-fetched gridunit occupies.
const DISPLAY_RATIO_DEEP: float = 1.0
## PAIR SESSION 2026-07-26 EXPERIMENT (Jeroen): DISPLAY_RATIO_DEEP raised
## 1.0 -> 2.0. One gridunit now occupies a 2x2 screen-px block, so a
## viewport-fit request asks for ~4x FEWER gridunits (a 1920x1080 window:
## ~2.07M cells at 1x1 -> ~518K at 2x2) and the server-side derive cost falls
## with it — the whole point of the experiment. Texel-exact either way (an
## integer ratio, no fractional-pixel blur); the tradeoff is purely visual
## chunkiness. LOOKS ARE THE GATE: revert to 1.0 if Jeroen judges the deep
## rungs too coarse. Non-integer ratios are NOT an option here — they
## reintroduce exactly the fractional-pixel blur D-255's texel-exactness
## exists to prevent.
const DISPLAY_RATIO_DEEP: float = 2.0
const DISPLAY_RATIO_SHALLOW: float = 5.0
## Global/Region read at the shallow ratio (orbital-scale canvases — extent