Weigh a reader of its pass's color by what it covered in its last measured pass

The area rule weighs a reader through no scissor at the share least favourable to each form,
since a draw's recording cannot know what it covers. A 1280x720 or 1080p reader covering the
whole target therefore took the snapshot, 1.97-2.34x the split's GPU time on the Radeon 780M,
while the consumer's readers over 3% of a 3662x2039 target need the snapshot (Iris 12.8 ->
1.7 ms a frame). Both shapes weigh the same at recording, so no static rule serves both.

Now, on a device with occlusionQueryPrecise that resets queries on the host, each reader the
rule would weigh records its drawing commands inside a precise occlusion query of its pass's
own pool (render/coverage.rs). As the command buffer completes, the count is kept on the
reader's first color's texture, keyed by the pipeline state and the reader's place among that
state's readers of the texture in the pass. Later passes weigh that reader at its count: the
snapshot where SNAPSHOT_PIXEL_COST per covered pixel per color costs no more than the split's
copy. A device without precise queries or host reset, a reader inside an app's visibility
query (already refused the snapshot), a pending pipeline's draw and a replay record no query
and keep the area rule. Instances recorded inline after a split keep the query's begin and end
with their draws. Both forms are exact; a stale count costs the form it chose until a pass
after the change completes.

Counted: WorkCounts::coverage_queries and reading_draws_by_coverage. The crossover lane runs
each cell once untimed so its timed frame is weighed by the learned count.

Tests: tests::learned_coverage (forms and bytes across a sparse -> whole -> sparse change;
an app's Counting visibility query keeps its count with a reader inside), coverage unit tests.

(cherry picked from commit 1108cd1bdebfb15f9da91b39ed80d91d8624bc28)
This commit is contained in:
Anees Iqbal committed 2026-11-08 01:41:29 -08:00
1 parent a335824604
commit 26d00a396c
13 files changed
+866 -13

No files matched your search

+1 -1
View File
@@ -1537,7 +1537,7 @@ driver cache record or not, or another caller's) and the link; and, once per rea
that reads its own pass's color attachment after a barrier took the split rather than a snapshot
(id name `metal2vulkan-snapshot-fallback`, `Info` severity; `WorkCounts::reading_draws_snapshotted`
counts those that took a snapshot), and now and then a count of the draws the snapshot's area rule
weighed, by their scissors' share of the target, texel bytes and side of the rule (id name
weighed, by their scissors' share of the target, texel bytes and the form each took (id name
`metal2vulkan-snapshot-readers`, `Info` severity). With `METAL2VULKAN_LOG_MEMORY` set, a device
logs one line per `VkDeviceMemory` it allocates, imports or frees (id name `metal2vulkan-memory`,
`Info` severity): what it holds (a block of buffers or images, a host-memory import with its host