Files
metal2vulkan/crates
Anees Iqbal a96bd76fef Keep a draw's shape across scissor rectangle changes
A render encoder's draw takes its settings, draw state and VkPipeline from
its shape memo while the encoder's state keeps its version. Setting a
scissor rectangle took the state mutably, so a program that sets one before
each draw, as a window compositor does, derived every draw's shape again:
settings, draw state, and the pipeline lookup by key.

The scissor rectangles now live beside the versioned EncoderState
(render_state::ScissorRects). No piece of a draw's shape reads them but its
draw state's Vulkan scissors, which each draw now sets from the rectangles
it finds, on a draw state it derives or reuses. The commands recorded are
the same: each draw records its own scissor as before.

Verified: a device test (draw_shape_notices::
draws_after_new_scissor_rectangles_reuse_shapes) draws 8 times through 8
rectangles and finds 7 draws reusing their shape and 8 scissors recorded;
with the version bump put back into set_scissor_rect it fails (0 reused).
render_state unit tests and the draw_shape_notices device tests pass on
MoltenVK (M3 Max).

Release, the per-draw repro on the M3 Max over MoltenVK, flat out, cache
mode, 3000 buffers: draws_shapes_reused goes from 0 to 13 per buffer (35
draws, 6 passes; the others are the first draw of their pipeline state in
their encoder); every other WorkCounts field per buffer is unchanged. A
draw with its setters p50 4.25 -> 4.12 us, mean 4.63 -> 4.42 us; the draw
call alone p50 3.92 -> 3.79 us (two interleaved rounds each).

(cherry picked from commit 603c78fcb85c5d0a732ec6004028d990e0ec8d64)
2026-11-02 05:16:44 -08:00
..