perf(ui): gate per-pixel clip compares behind a flags bit (#50) #91
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!91
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-50"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
uiResolveScreenPixelran four float compares againsthdr.clipRectPxfor every pixel of every UI dispatch, even though the clip rect is the full-surface default{0,0,1e9,1e9}in the overwhelmingly common case (issue #50).This reserves the high bit of the header
flagsword (UI_FLAG_CLIP) and gates the clip compares on it:UIRenderer::FillHeadernow sets the bit only when the clip rect is narrower than the surface. The decision is extracted into the pure, unit-testableUIRenderer::ClipFlags.The same gate is mirrored on the WebGPU/WGSL path (
additional/dom-webgpu.js) for parity. The frozen-layout contract is respected — this is an additive use of the reservedflagsbits.Testing
UIClipFlagCPU test drivesClipFlagsdirectly (full-surface vs. each narrowed edge, user-flag preservation, stale-bit clearing) — no Window/GPU needed.crafter-build test— 8 passed.Resolves #50
🤖 Generated with Claude Code
uiResolveScreenPixel ran four float compares against hdr.clipRectPx for every pixel of every UI dispatch, even though the clip rect is the full-surface default {0,0,1e9,1e9} in the overwhelmingly common case. Reserve the high bit of the header flags word (UI_FLAG_CLIP) and have FillHeader set it only when the clip rect is narrower than the surface (extracted into the unit-testable UIRenderer::ClipFlags). The shader gates the compares on the bit; the branch is push-constant-uniform so it never diverges. When the rect covers the surface the skipped compares could never reject an in-surface pixel, so output is pixel-identical. Mirrored on the WebGPU/WGSL path (dom-webgpu.js) for parity. Adds the UIClipFlag CPU test covering the gate decision. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>