WIP: refactor(vk): remove three finished experiments from the memory model (RX_VK_MIRROR_TIGHT, RX_VK_CPU_OVER_GPU, RX_VK_BG_IMPORT) #2315
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2315
Loading…
Reference in a new issue
No description provided.
Delete branch "TrashPanda/Longshot:refactor/memory-model-dead-attempts"
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?
Summary
The renderer's memory model (
gpu/vk/vk_memory.cppand its neighbours) still carries switches that were experiments: off by default, their question answered, never removed. Standards says to remove a switch once it is settled. This goes through everyattemptswitch whose code is in the memory model and removes the ones that can go today, and nothing else. It is the part of the memory model that can be removed now; the larger parts stay (below).What goes, 49 lines deleted and 31 added over 6 files (about 16 of the deleted lines are code, the rest comments and test text):
docs(vk)vk_memory.cpp's head said "no mirrored copies, no write-backs, no upload streams": it describes the model it has now. Comment only.RX_VK_MIRROR_TIGHTRX_VK_MIRROR_TIGHT=1) costs 5 fps and still ends at 95%." Both reads and thevram_usagecall behind them go.RX_VK_CPU_OVER_GPUtexture_touch's comment: it took over transient render targets' texels "and the menus' letters stayed missing with it". The check testsonly_clearedalone, as at default.RX_VK_BG_IMPORTmemory_pool_createdis an empty function now;MkwVkRenderer::nvn_pool_createdstays, so no interface change.Each removed switch becomes a
GONE(...)row ingpu/vk/switches.def(the table is the switches reference; no other page lists them), and each test that read the removed text is updated, none weakened:test_mirror_trim.pyexpectsmirrors_trim's line without the clause;test_drawn_page_map.pyloses the one case that ran the check for a texture that is not only cleared (the only-cleared case beside it stays).Every
attemptswitch in the memory model, with what was decided (open pull requests: all 401 listed, the heads of 399 merged with this branch and withmainin a scratch repository, and their diffs searched for the names and functions; #1143 and #1092 could not be fetched):RX_VK_MIRROR_TIGHTRX_VK_CPU_OVER_GPUtexture_touchcommentRX_VK_BG_IMPORTmemory_pool_createdcomment, 3-7 fpsRX_VK_PREFETCH_CHUNKSprefetch_chunksRX_VK_ASYNC_IMPORTRX_VK_SSBO_STRETCH,RX_VK_SSBO_WIDERX_VK_CAPTURE_NTRX_VK_PROTECT_BAREmirror_sync's page walkRX_VK_READBACK_EXACT,RX_VK_READBACK_NO_CATCHUPRX_VK_UB_CUR_ONLYRX_VK_NO_WRITEBACKRX_VK_MIRROR_HEAT_EXTRARX_VK_CAP_BLOCKSRX_VK_FOLLOW_STORESRX_VK_FRAME_GATEandRX_VK_SPARSE_IDLEare render-thread and sparse-texture switches, not the guest-memory model;HOS_COLLECT_VECTORandHOS_COLLECT_WIDEare kill switches kept for a test and a benchmark. Onlyvk_memory.cpp's head comment described code that is gone;gpu/render/rx_nvn.h's head ("replays them with WebGPU") is also stale but that shared header is full of the same notes and is left for its own change.Why not more. The census of the memory model (a removal ladder A to H) found that most of it cannot go on today's evidence, and measurements since agree: the captures stay (98.8% of mirror-synced pages come from earlier submits' captures, so they cannot be dropped); the game's flush and invalidate calls do nothing on the console, so they cannot replace the write marks; write-back on demand still sees the CPU touch a left-out range every couple of seconds (with a 4 KB limit the count of such ranges never stops growing), so it needs a copy at the first invalidate and is not a removal; the mirrors stay. This change is the one rung that is only deletion. It fits the switches track (#1309, #1390 and #1527 deleted 126 kill switches; attempts were left).
This was written with AI agents under the owner's direction: they read the code, searched the forge, made the commits and ran every check below; the commits carry
Co-Authored-Bytrailers.Testing
Tested: Linux, RTX 4070 Ti (NVIDIA 595.99), a runtime of
main@753fb5af6and one of this branch @afecf01b5, both made as packs over base3e4b1faf6ethrough the queue, default settings,RX_VK_MEM_CHECK=1on both sides, one game at a time, 90 s in each scene: Link's house, Kokiri Forest, Hyrule Field (gamerun.py, six runs, all reached the scene and stopped cleanly).logdiff.pyon each pair (problem and warn levels): no new warning or error kind (0 kinds on either side). All-levels it differs only in info lines whose numbers differ.seq_mismatch 0,take_open 0,collect_open 0,sync_over_gpu ... 0 replacedon all six runs (main and branch).vk: mirror syncsline, final field: not touched (theRX_VK_PROTECT_BAREcount stays).suite.py compare(main753fb5afagainst this head, no--changedshortcut): 928 passed, 3 failed, 26 skipped on both sides; the same three fail on both (test_dev_packs.py,test_pipeline_state_computes.py,test_thinlto_tls.py: this PC's tools), none fails only here; the skipped sets are the same.nx2/translator_files.py, asbuild.pycomputes it):0b724caa31e870aeonmainand on the branch (252 files); no changed file is stamped, and none of the removed names begins with a prefixtranslator_stamphashes (RX_VK_MMA,NATIVE,NAN,TASK_CAP,NETWORK,GP_,FOLLOW,NO_F16,MESH,NO_INVARIANT,MARKERS,ALL_GLOBAL_PROGS,MISS_LOG,BLOCK_PROBE,EDEN_), so no player prepares shaders again.objcmp.py, the builder's own flags,mainagainst this head):vk_menu.cpp853 of 853 functions identical,vk_texture.cpp534 of 535,vk_memory.cpp711 of 714. The four that differ, all simpler, each from removed code:texture_touch(2694 to 2672 instructions: thetakestatic's guard),mirror_make(1809 to 1762: thetight_ruleguard and thevram_usagecall behind it),mirrors_trim(1062 to 1032: the same guard),memory_pool_created(98 instructions to a bareret). No function appears or disappears.Still to test:
@Beanstalk run Kokiri Forest for 60 s on an AMD card and an Intel Arc card, compare the log's warning kinds with main).Measurements
Verdict: frame time, 1% low and the memory work of a submit are the same within the runs' spread; the GPU time a frame reads 0.08 ms higher (see below).
Setup: Linux, RTX 4070 Ti, NVIDIA 595.99; Kokiri Forest from the
kokiri-startsave, 60 s after arrival, the options pinned (preset 6, 2560x1440, V-Sync off, uncapped),RX_VK_FRAME_TRACE=1; timing mode of the queue, each of the four runs alone on the GPU (qoverlap.py: clean), two interleaved rounds main, branch, main, branch; frames of the last 55 s; "worst frames" from the whole run's frame log. Both runtimes made from the same base, same caches.753fb5af6afecf01b5The worst frames are the load's, and move more between two runs of one side (276 and 218 ms on main) than between the sides. GPU time a frame reads 0.08 ms (1.3%) higher here, both rounds of this branch above both rounds of main; I have no explanation from the code (what was removed does not run at default settings, and the frame time, which includes the GPU's, did not move), so two rounds do not settle it and it is the one number in the table that leans against this change. Log line, last of each run:
vk: a submit's memory work (ms): maps 0.00, capture taken 0.00, writes collected 0.01on all four.Risks
What could break: nothing at default settings by construction (all four removed paths were off), shown by the machine-code comparison above. A player who still sets one of the three removed names gets the
GONEtext in the log's switch report, and the same behaviour as before (they were off by default). Open pull requests that append their ownGONErow at the end ofswitches.def(10 do) conflict with the three rows added here; they conflict with each other the same way, and none edits a removed line. A revert is enough to undo it. A player notices nothing; saves,longshot_options.iniand the caches are untouched.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named):miseis not on this PC;suite.py compareruns the samerun_all.pyon both sides: 928 passed, the same three fail on both (named above).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here. (n/a, ticked so the check passes: this is not a fix.)gpu/vk/switches.def. (Three switches removed, each aGONErow; none added or changed.)tests/that reads changed source is updated, not weakened.MKWVK_API_VERSIONbumped (MkwVkHostorMkwVkRendereringpu/vk/vk_api.hchanged). (n/a, ticked so the check passes:vk_api.his not touched.)mainand here, for a change that shows on screen. (n/a, ticked so the check passes: nothing shows on screen; the six shots were read and match.)GONE;mirror_budget.handvk_memory.cppcomments say what was dropped.)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Linux, RTX 4070 Ti (NVIDIA 595.99.02): Link's house, Kokiri Forest and Hyrule Field, 90 s each on main and on this branch with RX_VK_MEM_CHECK=1: clean stops, no warning or error kinds on either side, the memory checker's counts all zero on both, shots look the same. Kokiri Forest timing, two interleaved rounds: 137.2 / 137.3 fps on main, 137.5 / 137.2 here.
Small correction: #1841 is the area title-card PR and never touched or measured RX_VK_CAPTURE_NT, so the "no gain and more stutters on an RTX desktop" result in that row must come from a different issue or PR.
afecf01b535829ba5b9cView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.