[perf] Per-glyph-constant SDF AA scale recomputed per pixel (ui-text.comp.glsl) #126

Closed
opened 2026-06-17 21:18:55 +02:00 by jorijnvdgraaf · 1 comment

Found by an adversarially-verified performance audit (confirmed real after a skeptic pass).

Location: shaders/ui-text.comp.glsl:93-98 (also ui-fused.comp.glsl:315-318)
Severity: low · Effort: trivial · Category: gpu

Problem

uvSpan / atlasPerScreen / scalePx / band depend only on the glyph yet are computed per pixel-glyph (a divide + two maxes).

Fix

Precompute band once during the cooperative load into a float[UI_CHUNK] shared slot. Marginal — the inner loop is dominated by the SDF texture() fetch, so the realized speedup is small.

Found by an adversarially-verified performance audit (confirmed real after a skeptic pass). **Location:** `shaders/ui-text.comp.glsl:93-98` (also `ui-fused.comp.glsl:315-318`) **Severity:** low · **Effort:** trivial · **Category:** gpu ### Problem `uvSpan` / `atlasPerScreen` / `scalePx` / `band` depend only on the glyph yet are computed per pixel-glyph (a divide + two maxes). ### Fix Precompute `band` once during the cooperative load into a `float[UI_CHUNK]` shared slot. Marginal — the inner loop is dominated by the SDF `texture()` fetch, so the realized speedup is small.
Author
Owner

Merged into #125 — the invRectSize hoist and the SDF-band hoist are the same technique in the same cooperative-load sections of ui-text/ui-fused; one pass through the shaders covers both.

Merged into #125 — the invRectSize hoist and the SDF-band hoist are the same technique in the same cooperative-load sections of ui-text/ui-fused; one pass through the shaders covers both.
Sign in to join this conversation.
No milestone
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
Catcrafts/Crafter.Graphics#126
No description provided.