The work (2)

What stays per draw is the handle reads, a bit test for each slot, and the bind of the table. The fs_key and the descriptor set of the texture slots go when the bits are all set and the handles did not change since the last draw of the same program (item 6's signature, for the texture slots alone).

The checks, as for the map:

The steps:

  1. The index and the events, with the bits only counted against today's memo (a shadow, as pool_map_shadow was). This shows that the events are complete before any draw uses them.
  2. The draws use the bits (no stamps, no checks by address).
  3. The pages written only where they change.
  4. The texture slots' set and fs_key left out when nothing changed.

Step 1 is in (tex_events_shadow). The events go into addr_gens, with a new space, ADDR_GENS_WRITE, for the GPU side's writes, the writes to targets, surfaces made or freed and pending storage images. A kept texture's generations are summed over every level and layer. Over the race route for 200 s, about 333 kept textures a present were claimed current, and no check contradicted a claim. About 13 a present were checked with nothing changed, from slots that ranges share. Two things it found:

A profile of the texture resolves before step 2 found two costs that the design did not need, now gone:

After them, the resolves are 8.5% of the renderer thread. The memo itself is about 3%. What step 2 could take out (the memo's header and pending checks, the quiet check, the take's search) is about 5.3%, about 0.4 ms of a present. The write tracking finds the CPU's writes when a check takes in the scans of its own range for the epoch (vk_ww_take), and the epoch moves at each submission and wait. So no event is not no write until every watched page is taken in. That is a wait for the scanner in the frame, or the intake that each check does now, which is most of what is left of tex_memo_unwritten and quiet_own.

8. Render targets published only when memory needs them. A profile of 2026-11-23 of an Ounce game's race, on a discrete GPU whose driver imports guest memory as dma-bufs (udmabuf), found vk_surf_publish at 21.5% of the GPU thread, its largest phase. 18.1% came from one path: the import branch of rt_watch publishes every target drawn over imported memory at each release. A counter of publishes by why (the render targets published a present line) found 2 such publishes a present. One is a 6144x6144 RGBA8 surface of 151 MB that compute writes as a storage image, published whole at each present. It costs the GPU thread 2.5 ms a present in the CPU's work for each page in own_publish: gpu_mem_written_cpu stamps about 36,900 pages written, and vk_rt_before_publish_cpu looks up the targets that alias them, under the page locks. It also copies 151 MB on the GPU a present, and its stamps make a 3072x3072x2 texture beside it load 36 MB of pieces again in each present. The CPU never asked for the surface.

A driver keeps a target's pixels in the image while only the GPU uses them. Memory gets them when something outside the GPU reads it, and a GPU reader of that address takes the image. yuzu and Ryujinx mark the range as modified by the GPU and download it when the CPU's access faults. The change:

  1. While only the GPU uses a target, GPU readers of its address take the image, as tex_resolve already does, and guest memory under it is not written.
  2. Memory gets the pixels on a CPU access (a watch's fault, vk_rt_watch_hit), or for an engine that reads guest memory directly. A target that the CPU read in the last few presents (cpu_asked) stays eager, so a game that reads a small target each frame takes no fault each frame.
  3. Over a dma-buf region, the watch traps the CPU's mapping only. The driver pinned the pages when it imported them, so the GPU keeps them (uma.c). This needs a watch that does not move the pages into the alias pool. Over a host pointer import, amdgpu takes the pages again at each submission and fails on a trapped one, so the publish stays eager and in place there.
  4. A publish that does run covers only the part of the surface written since the last one, and costs one step for each run of pages, not each page: one range stamp in the write record, one alias lookup for each target and one hold of each lock.
  5. The counter of publishes a present by why (a CPU read lately, an import, a CPU access, no traps, other callers), with their bytes and CPU time. It is in place.

The test vulkan_uma_region_trap shows that a dma-buf region takes a trap of the CPU's mapping with the driver's submissions unaffected: on RADV, its mapping stayed with no access through 100 submissions that wrote it on the GPU, and the CPU then read the last write. vk_uma_region_held tells such a region from a host pointer import. The change is done when the GPU thread's time for each frame drops in the race, the texture memo misses for memory written fall, the race's screenshots match at fixed frames, and the save thumbnail of commit 12f8977cd still holds its picture. On that host this is the largest single item, so it comes before items 6 and 7.

Points 1 to 3 and 5 are in place for dma-buf regions (commit 73e87dc43). In the race, A/B/B/A against the commit before it, the frame rate went from 52 to 54 fps to 64 to 66, the GPU thread from 15.7 to 16.5 ms a present to 13.3 to 13.5, and the staging of bindings from 147 MB a present on the GPU and 36 MB on the CPU to under 17 MB and 0.2 MB. What is left:


Made from docs/dev/draw-cost.md at 69237645142c. GPL-3.0-or-later.