mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-29 02:32:01 +01:00
The compositor submitted only between 2048x2048 page cells, so one cell of a deep stack recorded every pass into a single command buffer: 700 full-size layers make 1403 render passes, and wgpu-core opens two hal command buffers per pass. Metal allows 4096 command buffers per queue, so a few thousand passes in one cell can lose the device. run_cell now counts copies and render passes and, when a refresh may submit in between, submits the batch after FLUSH_OPS (1000) of them, waiting for the previous batch as the page-cell flush does. Chunk textures, uniforms and bind groups outlive the submit and the queue keeps the order, so a chunk continues in the next command buffer. A device lost in such a submit ends the refresh with an error instead of recording more work. Not measurably slower on Vulkan (RTX 3090): perf_scenarios rows are within noise. Test: many_layers_submit_inside_one_chunk (700 noise layers on a 64x48 document) needs flushes > 0 inside one chunk and matches the CPU composite; main records all 1403 passes without a flush.