[perf][LOW] uiResolveScreenPixel runs clip-rect compares even when unclipped #50

Closed
opened 2026-06-16 16:51:31 +02:00 by jorijnvdgraaf · 0 comments

Subsystem: UI GLSL shaders
Location: shaders/ui-shared.glsl:121-129
Impact: LOW · Effort: Small

Problem

uiResolveScreenPixel runs four float compares against hdr.clipRectPx per thread per dispatch even though the default clip is {0,0,1e9,1e9} (the overwhelmingly common case).

Proposed fix

Gate the compares behind a "clip enabled" bit in hdr.flags (set by FillHeader when clipRect != full surface). flags already exists and is currently always 0; the branch is push-constant-uniform (no divergence).

Note

Runs once per pixel (not per item); negligible next to the inner item loop's SDF math.

**Subsystem:** UI GLSL shaders **Location:** `shaders/ui-shared.glsl:121-129` **Impact:** LOW · **Effort:** Small ### Problem `uiResolveScreenPixel` runs four float compares against `hdr.clipRectPx` per thread per dispatch even though the default clip is `{0,0,1e9,1e9}` (the overwhelmingly common case). ### Proposed fix Gate the compares behind a "clip enabled" bit in `hdr.flags` (set by `FillHeader` when clipRect != full surface). `flags` already exists and is currently always 0; the branch is push-constant-uniform (no divergence). ### Note Runs once per pixel (not per item); negligible next to the inner item loop's SDF math.
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#50
No description provided.