[perf][HIGH] UI tiles scan the full item list — no spatial culling #46
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics#46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Subsystem: UI compute pipeline + GLSL shaders
Location:
shaders/ui-quads.comp.glsl:21-48(verbatim inui-circles:18-45,ui-images:18-40,ui-text:28-62)Impact: HIGH · Effort: Large
Problem
Each 8x8-tile workgroup iterates the entire item list with a per-pixel AABB reject. At 1080p that is 32,400 tiles each walking the whole buffer — O(tiles x N) item loads, nearly all rejected at the branch but still paying the SSBO read + math. Dominant GPU cost for typical UIs.
Proposed fix
coarse tile-binning pre-pass appends item indices to per-tile lists; render shaders iterate only their tile's items. The existing compute->compute barrier in
Dispatchalready gives binning->render visibility for free.Correctness caveat (load-bearing)
Binning must preserve draw order (
ui-shared.glsl:109-118: later items overdraw earlier). A naive atomic-append bin produces nondeterministic order — a blending bug. Use counting-sort / prefix-sum binning, or sort each tile's indices ascending by original item index. The interim shared-memory fix has no such hazard.