Repository navigation
perf(recompiler): scan image-table key buffers in bulk - #7101
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
@XairRrR full CI on 4ca1dc6 fails one Windows check that comes from this PR: That's the new The other two Windows failures in that run ( |
Narrowing a table column read its key buffer one key at a time, with a page lookup and a single-word read per key; PPSA05684 scans about 20,000 keys per table snapshot. The scan now checks each page once and reads the keys with the bulk reader, and maps a key to its record without dividing when the multiplication cannot wrap. Gameplay, image-table time per snapshot: about 6.5 ms before, 5 ms after. AI-assisted: yes
4ca1dc6 to
bf0c51e
Compare
|
Thanks @oneandonlydean, good catch. Fixed in bf0c51e (amended): the key words are now read into a scratch vector that is a member of |
Main's #7101 reads a key buffer's words in one call where this branch names the reason a narrowing is skipped. Keep main's bulk read and count both of its unmapped-page skips as unmapped.
Main's #6402 stores to image tables: a table with a written entry takes the fresh path, as it does on main, and so does one without a sampled table binding, whose entries the fresh path rejects. The shared place step uses the binding as a pointer. Main's #6614 frees descriptor sets from shared pools one by one, while this branch keeps only dedicated pools, so both stay. #7101's bulk key read counts its unmapped-page skips as unmapped, and its key words sit next to this branch's write stamp and compared runs.
What
TableSnapshotter::Narrowreads the key buffer of an image-table column to find which records the shader can select. It read one key at a time: aPageAccessiblelookup and a single-wordreadMemoryper key. In Uncharted: Legacy of Thieves Collection (PPSA05684), gameplay scans about 20,000 keys per table snapshot.Changes (
ResourceMaterializer.cpponly):readWords) and the key stride is a multiple of 4 and at most 64 bytes, the scan checks each page of the key span once and reads the span with onereadWordscall. With a stride of 64 bytes or less every page in the span holds a key, so the pages checked are the ones the word-by-word scan checked. Other strides, and runtimes withoutreadWords, keep the word-by-word scan.key * stridecannot wrap. A key that wraps takes the old path (relative % stride,relative / stride), so wrapped keys still select the record the 32-bit address arithmetic reaches.ScalarBufferDwordtest is skipped for later keys.Measured in PPSA05684 gameplay with
APS5_PROFILE_DRAW=1, image-table time per snapshot: about 6.5 ms before, 5 ms after. That build also carried other local changes (the same scene, warm shader cache); this branch on its own was not run in the title.Overlap with open PRs:
ShaderMemory::readWordscopy lazy pages by block. That is complementary: with it the key span read here also avoids per-wordread()calls insideShaderMemory.skip()in the same loop a reason. Textual conflict only; whichever merges second needs to rebase.Tested
Arch Linux (kernel 7.2.9-zen), NVIDIA RTX 4070 Ti SUPER, driver 615.78.08, GCC 16.2.1, Release,
BUILD_TESTING=ON.verifyImageTableBulkKeyScaninagc_shader_bindless(agc_shader_memory_tests --bindless). It captures the material table shader twice, once with onlyreadMemoryand once withreadWordstoo. It checks that:0x08000003) wraps when multiplied by the 32-byte stride and is the only one that selects record 3.main'sResourceMaterializer.cppit fails withimage table bulk key scan: the keys were read word by word although a bulk reader exists.image table bulk key scan: the narrowed codes are wrong.ctest -j4 -R "image_table|bindless|agc_shader_": the 15 built tests pass (agc_driver_image_table,_cache,_cache_bounds,_reuse,agc_driver_bindless_images,agc_shader_bindless,agc_shader_memory,agc_shader_srt_read_patching, and the otheragc_shader_*tests ofagc_shader_memory_tests).python3 tools/check_conventions.py --base origin/main: passed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)