WIP: feat(vk): the renderer's switches in the switch store: nine draw, submit, pipeline-wait and memory switches change during a run #2209
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!2209
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:feat/switch-store-renderer"
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
#2185 made 16 of the host's switches change during a run, set and applied through the control bridge (
switch_set,switch_apply) and alternated byHOS_AB. This PR gives the renderer the same store and lists its first nine switches. They can then be tried at another value with no restart, and A/B'd in one run:RX_VK_INDEX_REBASE, each draw's index bind.bind_indexcompares the buffer, offset and type, so rebased and plain binds mix in one command buffer;RX_VK_PUSH_ALL, each descriptor push.RX_VK_BATCH_MAX(each held submit),RX_VK_BATCH_POLL_US(each progress poll).RX_VK_QUICK_MS,RX_VK_PIPE_WAIT_MSandRX_VK_TRANSLATE_WAIT_MS, the budgets each frame is refilled from. Each is logged when it changes.RX_VK_TARGET_POOL_MB:pool_trimasks it at every present. The rule's size is still worked out once, by what the driver allows at the first look;RX_VK_COMPACT_PCT: each compaction pass.How it reads the store:
sw_env(a switch's text as the game reads it now) andsw_gen(the store's generation).gpu/vk/vk_live.hgives the renderer the host's reader pattern (vk_sw_env,vk_sw_on,vk_sw_int,vk_sw_due,vk_sw_seen). Each reader keeps its value with its own rule, default and clamps, and works it out again when the generation has moved: two loads a use, no lock.Stacked on #2185: this PR carries #2185's commits until it merges. The new commit is the last one.
Left out on purpose:
RX_VK_VRAM_MB: on an integrated GPU,texture_frameworks the texture budget out again every pass from its own last value (driver_budget = own; own = integrated_texture_budget(driver_budget, …)). That wants untangling, and a look at whether it is meant, before the budget can change.Read first:
gpu/vk/vk_live.h, theMkwVkHostaddition ingpu/vk/vk_api.handhost/rx_backend.c, then one converted reader,batch_maxingpu/vk/vk_replay.cpp.Testing
Tested: nothing yet. Not compiled, not run in the game and no checks run, by the request of the person I work for: opened untested.
vk_live.h:test_quick_pipelines,test_draw_side_effects,sampler_admission_test. The last answersRX_VK_PUSH_ALLthrough its owngetenv;vk_live.hcalls an unqualifiedgetenvfor that reason.test_target_image_pool,test_vram_compactandtest_quick_pipelinesread the store's call in the source.test_hos_ab's table of the host's functions gainshos_sw_env.test_switch_storeholds the nine reads to the store.Still to test:
HOS_CONTROLset,switch_set RX_VK_BATCH_MAX 4withapplytrue, thenRX_VK_TARGET_POOL_MB 0the same way. Expectingchanged: 1each time, the log'sswitches: appliedlines, and the game playing on (by hand)HOS_AB=RX_VK_INDEX_REBASE=0,3,20for a minute of play, expecting the A/B's end line with both sides' frames and no visual change (by hand)tests/run_all.py --changed, expecting no check failing that passes on main (by hand)Measurements
Not measured yet. Nothing has run. What it costs with nothing set, an extra load at each read of these nine switches, wants a
dev.py abagainst main before it leaves WIP.Risks
switch_set; reverting is enough.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). Not run yet.main, or Measurements says why there is nothing to measure. Not yet.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened.MKWVK_API_VERSIONbumped (MkwVkHostorMkwVkRendereringpu/vk/vk_api.hchanged).Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
A live change can land inside a frame-wide budget or a memory pass, so five of the nine do not meet the "each use stands alone" rule. Read from the source, not run here.
RX_VK_QUICK_MS,RX_VK_PIPE_WAIT_MSandRX_VK_TRANSLATE_WAIT_MSare per-frame budgets, not per-draw values:quick_budget_ms(),pipe_wait_budget_ms()and the translate reader return the new total at each draw whilequick_pipe::FrameBudget/ the wait budget is keyed by the frame, so one frame can run with two budgets.RX_VK_TARGET_POOL_MBis asked bypool_trimat every present andRX_VK_COMPACT_PCTby each compaction pass; both can free or compact images within a frame, not only between draws. That may be safe, but it is not a frame boundary, and "nothing rebuilt" is not the same as "nothing changed". The docs already say "a frame may draw with both values"; for these five the unit of use is a frame or a pass, so the criterion in the description ("every use stands alone") is weaker than it reads. Either move these five to a frame-start apply (the PR's own "left out on purpose" bucket) or state per switch why a mid-frame change is safe; do not list a frame budget as a per-use value.The test gap is the same shape.
tests/test_switch_store.pyfails on main becausehost/switch_store.candswitches_live.defdo not exist (so it is more than a switch-table parse): it compiles and runs the store, covers set/apply/refusals,hos_sw_each, the path redaction, and four readers against 2000 applies. But it exercisesHOS_SPIN_USonly.test_quick_pipelines,test_draw_side_effectsandsampler_admission_teststubvk_sw_due()to return 1 once, so a second generation never reaches a renderer reader. No check changes any of the nine renderer switches live or asserts the effect (a rebased bind, a batch cap flush, a quick/pipe budget, a pool cap or compaction percentage). Add one live change per reader kind (bool, int, float, string), or at least one per section, and assert the effect rather than only that the name is read through the store.Q1: all nine keep their
switches.defrows; none isplayer, so there is nolongshot_options.inikey to lose and no settings break. The newswitches.mdsection covers the list (only QUICK_MS and TRANSLATE_WAIT_MS have individual rows, which is the page's stated scope). Q3: the writer is the control thread underswitch_store.c's lock; readers are lock-free with atomic pointers and generation, and the texts are kept for the run (old texts are not freed, deliberately, so a reader may hold one; that is a slow leak, not a race). Q5: no overlap with #2215/#2216 or the menu keys/ini table; the shared surface isswitches.def's sort/test.MKWVK_API_VERSION45 is a collision point for any other interface PR.vk_replay.cppoverlaps #2211/#2212 only by file (rebase), so a measurement must pinRX_VK_ASYNC_PARTSandRX_VK_ASYNC_FENCESon both arms; the #1988 drain sharesvk_texture.cppbut not these hunks.No fix claim; the PR is WIP and nothing has run yet.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.