Skip to content

refactor(overlay): derive histogram quad slots, fix stale geometry comments#75

Merged
mledour merged 1 commit into
mainfrom
refactor/overlay-slot-derivation
Jun 22, 2026
Merged

refactor(overlay): derive histogram quad slots, fix stale geometry comments#75
mledour merged 1 commit into
mainfrom
refactor/overlay-slot-derivation

Conversation

@mledour

@mledour mledour commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Addresses the overlay findings (4–5) from the code review — both on the 5-px/no-gap histogram bars merged in #70. No behaviour change (the bit-exact snapshot golden is unaffected).

4 · Quad-slot overlap not guarded (low-med)

kSlotBudget / kSlotBaseline / kSlotAxis / kQuadSlots were hand-assigned integers. The existing static_assert only checks grid-slot count vs tick count — not whether budget and grid write the same slot. A future change bumping kSlotGridEnd (e.g. a 5th interior gridline) would have to remember to bump all four in lockstep, or one line silently vanishes with the assert still green.

Fix: derive the trailing slots sequentially:

kSlotBudget   = kSlotGridEnd;       // 5
kSlotBaseline = kSlotBudget + 1;    // 6
kSlotAxis     = kSlotBaseline + 1;  // 7
kQuadSlots    = kSlotAxis + 1;      // 8

Values are identical to before — verified with a standalone constexpr check (first=1 end=5 budget=5 baseline=6 axis=7 total=8, all static_asserts green) — so rendering is unchanged.

5 · Stale geometry comments (low)

overlay_renderer.h still documented the old 4-px-bar / 1-px-gap … 133×4 + 132×1 = 664 px … fills exactly math, contradicting the .cpp's own updated 5-px/no-gap text. The pixel-shader CONTRACT comment likewise said "4-px width". Updated both to the 5-px/no-gap geometry (133×5 = 665 px). Comment-only — the covX edge-AA reasoning still holds since 5 is integer.

Declined (rationale)

  • 6 (usedW = n*step − (step−bar)): this is the correct general formula for n bars of width bar at pitch step; kBarPx/kStepPx exist precisely so a gap can be reintroduced, where n*step would be a latent off-by-one. Intentional generality, already documented.
  • 7 (bit-exact golden + host std::sin): pre-existing and a deliberate design choice (the workflow documents why the snapshot tolerates zero diff). Reviewer flagged for completeness, no action.

🤖 Generated with Claude Code

…mments

Code-review findings 4 & 5 on the 5-px/no-gap histogram bars (#70):

- overlay_renderer.cpp: kSlotBudget / kSlotBaseline / kSlotAxis /
  kQuadSlots were hand-pinned integers, and the static_assert only guards
  grid-vs-tick count, not slot overlap — so bumping kSlotGridEnd for
  another gridline could silently make budget and grid write the same slot
  (one line vanishes, assert still green). Derive the trailing slots
  sequentially from kSlotGridEnd so they shift in lockstep. Values are
  unchanged (1/5/5/6/7/8, verified via a standalone constexpr check), so
  there is no render change.

- overlay_renderer.h + overlay_bars_ps.hlsl: comments still described the
  old 4-px-bar / 1-px-gap / 664-px geometry. Update to the current
  5-px/no-gap layout (133×5 = 665 px). Comment-only; the pixel shader's
  covX edge-AA reasoning still holds (5 is integer).

No behaviour change — the bit-exact overlay snapshot golden is unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mledour mledour merged commit 28625b5 into main Jun 22, 2026
3 checks passed
@mledour mledour deleted the refactor/overlay-slot-derivation branch June 22, 2026 12:41
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