ScarletNX / ScarletNX documentation / Regression inventory for the buffer cache rewrite · ← previous · next →
Results that the GPU writes
R1. A result byte lands only where the shader changed it and guest memory still holds what the shader read.
- Without the rule: on the console the GPU stores while it runs, and a later CPU write wins. A landing of the whole
result puts old bytes over that CPU write. Each writable binding keeps its original bytes until the frame of its
draw completes.
- Comment:
writeback.c, the file header, compute.c, the file header, and buffer.c, above writer_of.
- Check:
check_writeback_merge in tests/vulkan_release.c, and check_owned_writable in
tests/vulkan_owned_readback.inc.
R2. A landing compares two host copies and reads guest memory only where the shader changed a byte.
- Without the rule: a compare against guest memory can fault on a page that the GPU holds. A result that changed
nothing must read no guest memory, allocate nothing and flush nothing. The merge takes eight bytes at a time.
Byte by byte, it was a tenth of one game's GPU thread.
- Comment:
writeback.c, vk_write_changed_runs.
- Check:
check_runs and check_writeback_merge in tests/vulkan_release.c.
R3. A logged result lands the bytes that its write logs give, and no others.
- Without the rule: a logged result has no original bytes for a compare. A byte that no writer wrote must keep what
guest memory holds. A run that the CPU wrote and the shader did not is not touched.
- Comment:
buffer.c, land_logged, writeback.c, vk_write_runs, and writelog.c, the file header.
- Check:
check_storage_logged in tests/vulkan_storage_logged.inc.
R4. A logged result is written in place only by a writer that also logs.
- Without the rule: a writer with no log leaves bytes that nothing lands. Such a writer composes a result of its own
over the logged one. A reader of a write-only result also composes, because that staging holds no guest memory.
- Comment:
buffer.c, gfx_gpu_src, and out_take_org for the writer that joins in the same draw.
- Check:
check_storage_logged in tests/vulkan_storage_logged.inc, the cases of a writer that logs nothing.
R5. The pending results are indexed by the guest pages that they cover.
- Without the rule: a binding or a read compared each of the hundreds of results that a frame keeps pending. The
search also narrows by the longest run in the index.
- Comment:
buffer.c, above OutIndex.
- Check:
check_pending_index in tests/vulkan_pending_index.inc. --bench-storage-lookup of the same program
times it.
R6. A set of the pages that pending results cover answers most reads and writes with no walk.
- Without the rule: almost every read or write of guest memory meets no result, and each one walked the results. A
change of the GMMU still checks every result, so a result over a page about to be mapped lands first.
- Comment:
buffer.c, above g_out_pages, compute.c, above g_pages, and mirror.c, above g_mir_pend.
- Check: the ctest
pending_pages, and check_map_lands_covered in tests/vulkan_headless.c.
R7. The block of a result is not zeroed when it is made.
- Without the rule: the caller fills the original bytes and the page lists. The zero pass before that was a tenth of
the copy time of one game's GPU thread.
- Comment:
buffer.c, gfx_out_new.
- Check: no test covers the cost.
R8. Two ranges that are each one run of guest memory meet in one span, with no walk by page.
- Without the rule: the walk looked up each page of the range in the pages of each result. A storage range of half
a megabyte against a few dozen results was a sixth of one game's GPU thread.
- Comment:
buffer.c, out_spans.
- Check: no test covers the cost.
check_pending_index covers the answers.
R9. The guest pages of a range are translated one time for a walk of the pending results.
- Without the rule: the translation for every result was the top cost of the GPU thread when results stayed pending
through a frame.
- Comment:
buffer.c, above RangePages.
- Check: no test covers the cost.
R10. A range meets a result only where the two share bytes, not where they share a page.
- Without the rule: a result lands its own bytes alone, so the rest of its page is free to read and write. One game
writes a word next to its transform feedback captures before each capture. Two storage buffers that share a page
made each read of one compose with the results of the other, which gave it nothing.
- Comment:
buffer.c, above out_meets, and above gfx_gpu_src.
- Check:
check_pending_index in tests/vulkan_pending_index.inc (a read beside a result on its page), and
check_storage_suffix in tests/vulkan_storage_suffix.inc.
R11. When a result lands, each later composed result takes the changed bytes as its own original bytes.
- Without the rule: the later result read the earlier result where they share memory, not the bytes that its
original copy holds. It took the landing for a guest write and dropped its own writes over those bytes.
- Comment:
buffer.c, above ChgRun (the code is out_rebase and out_rebase_later).
- Check: no test covers the rebase alone.
check_draw_storage_stages and check_storage_suffix use composed
results.
R12. A rebase uses the changed runs that the landing found.
- Without the rule: the rebase of every later composed result compared all the bytes of the landed result again.
One game landed 20,000 results in 10 s that changed 4 MB of their 590. The rebases read 42 GB, most of the release
thread, under
vk_lock, which the GPU thread waits for.
- Comment:
buffer.c, above ChgRun.
- Check: no test covers the cost.
vk_buf_checks gives the bytes compared.
R13. A rebase copies the changed bytes eight at a time.
- Without the rule: a result is mostly the bytes that it read. A byte loop was 84% of the time of the release thread
in one game.
- Comment:
buffer.c, above rebase_bytes.
- Check: no test covers the cost.
R14. The GPU copies of pending results run in the order of the results, with a barrier where two copies
overlap.
- Without the rule: one copy command must not overlap itself, and two copies with no order land in either order. The
later result must end on top.
- Comment:
buffer.c, above CopyBatch.
- Check:
check_storage_suffix in tests/vulkan_storage_suffix.inc reads a range under more than one result.
R15. A composition takes each byte from the newest result over it and skips the older results there.
- Without the rule: the copy of the older results, only to overwrite them, made a composition quadratic. One game
composed 200 bindings a frame over a few hundred results each. Its GPU copied 955 MB a frame, 147 ms.
- Comment:
buffer.c, above Covered.
- Check: no test holds the copied bytes.
R16. A composition writes on the CPU only the gaps that no result gives.
- Without the rule: the CPU copied the whole range first. A few results over storage ranges of half a megabyte,
bound and read a few hundred times a frame, made that a fifth of one game's GPU thread.
- Comment:
buffer.c, above gfx_overlay.
- Check: no test holds the cost.
R17. A draw can write a result of an earlier submit of the frame again in place.
- Without the rule: one game binds a suffix of a storage buffer for each of its passes, about thirty submits a
frame. Nearly every one made a new result, half a megabyte copied from guest memory and compared at the landing.
The rule holds only when no later result has bytes of the earlier one. Such a later result lands first, and the
moved result would land over its bytes.
- Comment:
buffer.c, above out_take_into_submit.
- Check:
check_storage_suffix in tests/vulkan_storage_suffix.inc.
R18. A result that is kept in its owner can be taken into a submit of a later frame.
- Without the rule: the kept result is in its owner, not in the staging of its frame, and it copies nothing back.
When the take was refused, each frame's binding composed again while the GPU ran a frame behind, and landed the
owner.
- Comment:
buffer.c, out_take_into_submit.
- Check:
check_storage_buffer_keep in tests/vulkan_storage_buffer_keep.inc, the second binding after the fence.
R19. When several results cover a binding inside one of them, the later ones merge into that one.
- Without the rule: one game writes a storage range of 384 KB whole, then 16 bytes in it at an address that a
binding offset cannot have. It reads the range in windows of 4 KB. Each read composed all the results again and
ended the rendering pass, 133 times a frame. The merged result compares with its original bytes when it lands, so
that the bytes of the dropped results are not lost. Either all the later results merge or none does.
- Comment:
buffer.c, above out_absorb.
- Check: no test covers it.
R20. A read takes the newest result in place when that result covers the whole range.
- Without the rule: the code required a single result over the range. Every binding after a second result composed
again. In one game each storage range was copied, written back and landed about 16 times a frame. That was 114,000
compositions in 600 frames, against 3,600 with the rule.
- Comment:
buffer.c, gfx_gpu_src.
- Check:
check_storage_suffix in tests/vulkan_storage_suffix.inc.
R21. A range inside the last result is found with no translation and no search.
- Without the rule: the comment gives no numbers. A new binding of a suffix is common for NVN storage draws, and the
full search selected the same result each time. Other addresses still use the search that knows the aliases.
- Comment:
buffer.c, gfx_gpu_src, at g_out_tail.
- Check:
--bench-storage-lookup in tests/vulkan_storage_lookup_bench.inc times recent and old ranges apart.
R22. A result of the frame before is read where it is, and the rings of that frame are held for the reader.
- Without the rule: transform feedback captures the same buffers every frame, over the capture of the last frame.
A copy through guest memory would land each one.
- Comment:
buffer.c, above gfx_gpu_src (the hold is vk_frame_hold in cmd.c).
- Check:
check_nvn_xfb in tests/vulkan_nvn_xfb.inc captures and draws again with no CPU read between.
R23. Maxwell bindings keep the automatic read and write order, and NVN bindings take their order from explicit
barriers.
- Without the rule: NVN permits draws that overlap, and a writable view alone makes no dependency there. A barrier
for each one ends the pass. Read-only consumers and new submissions keep their automatic checks.
- Comment:
buffer.c, gfx_gpu_src, and vk_buf_order_pending.
- Check:
tests/vulkan_nvn_storage.inc.
R24. A setup that is abandoned can add a barrier, but it cannot remove one or count a write.
- Without the rule: the write count would move for a draw that was never recorded. The count moves only after the
draw or dispatch is recorded. A stamp or a read flag that an abandoned setup leaves only adds a barrier.
- Comment:
buffer.c, vk_buf_writable_commit and gfx_gpu_src.
- Check: no test covers an abandoned setup.
R25. Repeated bindings of one writable range in one draw name the same storage.
- Without the rule: the comment gives no failure. Two storages for one range would each land.
- Comment:
buffer.c, copy_writable.
- Check:
check_storage_logged covers two writers of one draw. No test binds the same range two times.
R26. A writable binding stays on the GPU in an owner, and the trap lands it when the CPU touches the bytes.
← previous · next →