Crafter.Graphics/shaders
catbot 6eb11fbf71 perf(ui): cooperative shared-memory tile culling in UI compute shaders
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 for items that never touch the tile — O(tiles × N)
item loads dominated by SSBO traffic.

The workgroup now streams the item list in chunks of 64: each thread
loads one item, tests its AABB against the whole tile, and the survivors
are compacted — in original buffer order — into shared memory. Every
thread then runs the unchanged per-pixel accumulate over only those
survivors. This drops SSBO traffic ~64× (each item read once per
workgroup instead of once per pixel) and shrinks the inner loop to the
items that actually overlap the tile.

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 inner loop
body is byte-for-byte the original per-pixel logic, so output is
pixel-identical — the cull only decides which items reach it. Threads
no longer early-return so every thread reaches the workgroup barriers.

Applied to ui-quads, ui-circles, ui-images and ui-text; shared helpers
(uiTileBounds / uiAabbOverlapsTile) live in ui-shared.glsl.

Resolves #46

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 15:45:12 +00:00
..
ui-circles.comp.glsl perf(ui): cooperative shared-memory tile culling in UI compute shaders 2026-06-16 15:45:12 +00:00
ui-images.comp.glsl perf(ui): cooperative shared-memory tile culling in UI compute shaders 2026-06-16 15:45:12 +00:00
ui-quads.comp.glsl perf(ui): cooperative shared-memory tile culling in UI compute shaders 2026-06-16 15:45:12 +00:00
ui-shared.glsl perf(ui): cooperative shared-memory tile culling in UI compute shaders 2026-06-16 15:45:12 +00:00
ui-text.comp.glsl perf(ui): cooperative shared-memory tile culling in UI compute shaders 2026-06-16 15:45:12 +00:00