perf(ui): cooperative shared-memory tile culling in UI compute shaders #85
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!85
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-46"
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
Each 8×8-tile workgroup previously had all 64 threads walk the entire item list — re-reading every item from the SSBO 64× and running the per-pixel reject even for items that never touch the tile. That is O(tiles × N) item loads, dominated by SSBO traffic (32,400 tiles at 1080p).
This adds a cooperative shared-memory tile cull (the interim, hazard-free fix called out in the issue): the workgroup streams the item list in chunks of 64, each thread loads one item and tests its AABB against the whole tile, and survivors are compacted into shared memory. Every thread then runs the per-pixel accumulate over only those survivors.
Correctness (load-bearing)
Draw order is preserved exactly — chunks run in array order and the in-chunk compaction is a stable in-order scan, so later items still overdraw earlier ones. No atomic-append nondeterminism (the blending hazard the issue warns about). The inner per-pixel loop body is byte-for-byte the original, and the tile cull is a conservative superset of the per-pixel reject (it can only keep more items, never drop one a pixel needs), so output is pixel-identical. Threads no longer early-return, so every thread reaches the workgroup barriers.
Applied to
ui-quads,ui-circles,ui-images,ui-text; shared helpers (uiTileBounds/uiAabbOverlapsTile) added toui-shared.glsl.Scope is the GLSL/Vulkan shaders named in the issue; the WebGPU/WGSL mirror is unchanged and could be a follow-up.
Testing
crafter-build test→ 3 passed (MouseScroll, BLASBuildOptions, PushConstantRewrite).Screenshots
Resolves #46