perf(agc): take the texture detiler's Vulkan entry points from the device table #10764
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10764"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-24T23:26:52Z.
What
Every detile, repack, image and CMASK dispatch of the texture detiler looked up
vkUpdateDescriptorSets,vkCmdBindPipeline,vkCmdBindDescriptorSets,vkCmdPushConstantsandvkCmdDispatchby name throughvkGetDeviceProcAddr(Context::Function), and every descriptor set it allocated looked upvkAllocateDescriptorSetsthe same way. NVIDIA'svkGetDeviceProcAddrcompares the name against its entry points, so this lookup cost is paid on the draw committer each time a draw creates a texture.In Forspoken (PPSA03984) on
mainc8d34aa8f4, a 20 s DWARF profile of the whole process at 200 s (Linux, RTX 4070 Ti, NVIDIA 615.71.09, warm caches) put 21.7 % of all samples invkGetDeviceProcAddrand thestrcmpit calls, underTextureDetiler::Dispatch(18.3 %) andTextureDetiler::allocateFrom(3.4 %). The draw committer, which spent 82 % of its samples inShaderResources::resolveImageBindingthere, is the thread the title waits on.How
TextureDetiler.cpp: the 22 per-dispatch calls inDispatch,DispatchRepack,DispatchCmaskClearandDispatchImagetake their entry points from the device's function table throughContext::Resolved, as other recording paths (ShaderResources, the dispatch and draw recorders) already do.Resolvedstill falls back to a lookup when the context has no table.TextureDetilerDescriptors.cpp:allocateFromtakesvkAllocateDescriptorSetsthe same way.DeviceProcLookups()(Context.hpp) is now defined inShaderResources.cppinstead of inline, so a test executable andlibSceAgcDrivercount into one counter. On Windows each had its own inlinethread_localcopy, so the new test could not see the library's lookups (wachi35676).Overlap (
tools/pr_overlap.py,git merge-tree):push.splitStridenext to twovkCmdPushConstantslines this PR changes. Keeping both sides resolves it: their new line, then theResolvedcall.Dispatchinto an addressed path and the descriptor path, both still calling throughContext::Function. Whichever lands second keeps #9508's paths and takes their calls from the table.TextureDetiler.cppconflict withmainalready, so the tool couldn't compare them.Tested
Linux (Ubuntu 26.04.1, GCC 15.2, Release, RTX 4070 Ti, NVIDIA 615.71.09) unless noted.
agc_driver_graphicsgains a case that gives the mock context a function table and countsDeviceProcLookups()across a second detile dispatch (after the first one built the pipeline and pool). With the test alone onmain(d01680a012) it fails 3 of 3 witha detile dispatch looked up 6 Vulkan functions by name while the device's function table holds them; with this change it passes 3 of 3.main'sTextureDetiler.cppandTextureDetilerDescriptors.cpp(test/10764-red),agc_driver_graphicsfails 3 of 3 with the same message as on Linux. With this head, the 9 tests pass 3 of 3, and 9 of 9 on the merge basec8d34aa8f4. On Linux the red branch fails the same way, and this head passes the 9 tests 3 of 3.92e80bf347(run) and on this head merged ontomain448450275f(re-check). Their first run found that the new case couldn't fail on Windows, because the test and the library each had their own inline counter; that is why the counter moved into the library. On this head, withmain'sTextureDetiler.cppandTextureDetilerDescriptors.cpp, the case fails on both GPUs with the same message as on Linux.^agc_driver_graphics$|texture|tiled|detile|cmask|repackpass 3 of 3 on this head. On the Windows 11 VM (GT 1030, driver 582.78, WinLibs GCC 15.2.0 r7) the same 9 pass 3 of 3 on the merge base and on this head, with none skipped.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R "$R" -V -j4: 9 of 9 pass onmainc8d34aa8f4and on this head, with no layer-missing line and noVUID-message on either. Correction (10-27): only 3 of those 9 tests create a Vulkan device, so only they put the layer to work:agc_driver_cmask_fast_clear,agc_driver_image_repacked_floatandagc_driver_image_volume_address_planar_texture. I countedPhysical device selectedper test on currentmain. The other six run on a test fixture's own device and never load the layer, so the clean result covers the three only.main:__strcmp_avx221.7 % of all samples (plusstrcmp@plt2.3 %), fromvkGetDeviceProcAddrunderTextureDetiler::Dispatch(18.3 %) andTextureDetiler::allocateFrom(3.4 %).__strcmp_avx20.20 % andvkGetDeviceProcAddr0.04 %. That run was in a lighter scene (draw commits at ~60 us), so it shows the lookups gone, not the saving in the heavier one.APS5_TRACE_SECONDS=130:60, no other trace or profile switch, warm, 6 runs interleaved PR/main). Traces, digests and summary lines: release on my fork.main11.9 / 7.2 / 8.4 s, this PR 10.2 / 8.7 s. The sixth (PR run 1) was already past that stretch at present 1204 and ran at 100.6 ms.compute shader 0x9009201900: AGC graphics: vkWaitForFences graphics: Vulkan result -4; the kernel logged Xid 31, an MMU fault on copy engine CE0 at an unmapped address). The same loss, at the same compute shader with the same message, happened on 10-22 on a branch that behaves likemainthere (my memo branch with its budget at 0). This change only changes where the same entry points are taken from. An 8-run interleaved check (4 runs each, 250 s, no trace or profile switch) lost the device once, onmain: run 4 at 215 s, the same compute shader, message and Xid 31 copy-engine fault. Over the 20 runs of these three A/B sets,mainand this head each lost the device once. The loss is an existing intermittent one onmain, and I'm chasing it separately.Performance captures
Forspoken (PPSA03984), the opening's texture-heavy stretch,
APS5_TRACE_SECONDS=130:60, warm caches, same machine (Linux, RTX 4070 Ti, NVIDIA 615.71.09). The pair below is the closest-matched one (both windows start near present 550, both in the stretch where the draw committer is ~93 % busy); all six runs, their traces and digests are in the release on my fork. As said under Tested, frame time in this stretch moves with what each window loads, and these runs show no measurable difference.mainc8d34aa8f4(run main-3):tools/trace_digest.py
seconds 130:60 from present 545: 7 presents, frame p50 8353.5 / p90 10574.6 / p99 10574.6 / max 10574.6 ms, GPU busy 2721.6 ms per present
NVIDIA GeForce RTX 4070 Ti, NVIDIA 615.71.09, Linux 7.0.0-38-generic, 1920x1080, commit
c8d34aa8f4, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 25406.3, Driver.Packet.memory_wait 16332.3, Graphics.Draw 8140.4, Resources.Complete 8125.7, Graphics.Draw.draw_and_resource_release 8081.7, Driver.Packet.draw 7617.3, Driver.Draw 7614.5, Driver.Draw.draw_enqueued 7450.7, batch 2806.6, Driver.Packet.pipeline_drain 813.4
This PR 92e80bf347 (run pr-3):
tools/trace_digest.py
seconds 130:60 from present 565: 7 presents, frame p50 8683.9 / p90 13434.9 / p99 13434.9 / max 13434.9 ms, GPU busy 3441.9 ms per present
NVIDIA GeForce RTX 4070 Ti, NVIDIA 615.71.09, Linux 7.0.0-38-generic, 1920x1080, commit 92e80bf347e4, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 26139.3, Driver.Packet.memory_wait 16528.0, Resources.Complete 8427.6, Graphics.Draw 8370.9, Graphics.Draw.draw_and_resource_release 8302.9, Driver.Packet.draw 7675.2, Driver.Draw 7671.9, Driver.Draw.draw_enqueued 7501.6, batch 3825.6, Driver.Packet.pipeline_drain 1063.2
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T23:29:35Z.
Review: APPROVED
Reviewed the device-function substitutions across detile, repack, CMASK clear, image dispatch, and descriptor allocation. The function-table test verifies that a warmed detile dispatch performs zero additional name lookups, and the reported Linux and Windows focused runs plus the main/change Vulkan-validation comparison cover the behavioral risk. The recorded profile isolates repeated work on the draw-committer path, so this is a concrete optimization with evidence.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T09:40:05Z.
Review: APPROVED
Re-checked — approved
The current-main rebase preserves the device-table substitutions from the previously reviewed head. It also keeps
main'ssplitStridepush-constant additions at the two detiler dispatch sites. The author reports the focused graphics/texture/detile/CMASK/repack set passing 10 tests, 3/3 runs on the rebased Linux RTX 4070 Ti build.What I checked
2705c900a2a9d93ac4106b9b0546a92fc2ee8ec0on currentmainaaccd0ba39b7d40fdbf19664575a7e567d8542f7.I did not run a local C++/GPU build or reproduce the benchmark. The exact-head focused test evidence above is author-reported. No blocking source issue found; approval covers this head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T02:35:08Z.
Review: APPROVED
Re-checked — new head, looks good
The rebase keeps the previously reviewed detiler function-table change, and the additional test-link fix now uses the driver library’s shared lookup counter.
What I ran
Reviewed head
2781d72d189afdb8f314212c01ae803b1ec3e51bagainst the PR’s current base. Its merge preview against currentmaincf79276fee2f042feb6a7c71d0d6a27e9cfe2592is clean. Environment: Debian Linux x86-64, Python 3.11.2; no local C++ or GPU build.Results
Findings
Blocking
None found in the updated head.
Non-blocking
I did not independently reproduce the build, GPU tests or performance measurement. The author reports the C++ implementation is unchanged from the previously reviewed version; the new commit fixes the standalone test’s link to the shared driver lookup counter.
Sources
Not verified
I did not run a local C++ build, GPU tests or performance capture. Linux and specialized hosted build jobs were skipped.