WIP: feat(vk): vertex input as dynamic state, so one pipeline serves every vertex layout of a program (RX_VK_DYNAMIC_VERTEX_INPUT, opt-in) #801
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!801
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:perf/vk-dynamic-vertex-input"
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?
Type: feat · Risk: low · Tested on: Windows 11 (the game-free checks; the game A/B is next) · Needs: a game run on NVIDIA, AMD and Intel
Why
Every graphics pipeline's key held its vertex layout, so a program drawn with several layouts was several pipelines: more compiles on first visits in play and more for the shader preparation to build (about 16,000). Vulkan's
VK_EXT_vertex_input_dynamic_statelets the draw set the layout instead. Found in an audit of the renderer's pipeline path; no issue on the tracker. This adds it behind a switch, off by default, to be measured.What changed
With
RX_VK_DYNAMIC_VERTEX_INPUT=1on a device that has the extension, ordinary graphics pipelines take the vertex layout as dynamic state, their play key leaves it out, and each draw sets its layout when it changes. The notes and pipeline state lists keep the layout, so their files mean the same in both modes. Off, nothing changes.Device::vertex_input_dynamic(gpu/vk/vk_main.cpp,vk_internal.h),vkCmdSetVertexInputEXTthrough the recorder (vk_loader.h,vk_recorder.h,vk_work.h)pipeline_key_of,pipeline_key,pipeline_note_key,note_pipeline_key,build_graphics,vertex_input_of,vertex_input_bindand its invalidations (gpu/vk/vk_draw.cpp); the precompile, warm-up, loader and prediction build each play pipeline once; the built and warmed stamps take the modetests/test_fallback_pipeline_state.pyruns the real keys andvertex_input_bind; four fixtures' stubsMeasurements
Verdict: not measured yet: A/B runs in the game (this PR against main on one base, interleaved) are next and will replace this section.
Flags and settings
One switch for an A/B.
RX_VK_DYNAMIC_VERTEX_INPUT=1Testing
Tested: Windows 11, llvm-mingw (the builder's v2.0.14 tools): the new and changed checks; every check that reads the
changed code;
-fsyntax-onlyof the changed renderer files with the build's flags and headers; python -I -B tests/run_all.py on this branch and on main @aa95d35f, same PC and environment: the same results apart from the extendedtest_fallback_pipeline_state; the failures main has here are named in the first comment.Not tested: the game yet. This PR is WIP until its A/B is in (next: this PR against main on one dev_packs base of
main @
aa95d35f, on an RTX 3080 with a Ryzen 9 3900X, Windows 11; AMD and Intel need other testers).Must be tested:
RX_VK_DYNAMIC_VERTEX_INPUT=1: a first start (the preparation's pipeline count and time against main) and Kokiri Forest and Castle Town a few minutes, expecting the same picture,vk: vertex input: set by each drawin the log, fewer pipelines made in play and no new stutter (Test Farm: @Beanstalk nvidia, amd, radv, intel: with RX_VK_DYNAMIC_VERTEX_INPUT=1)Risks
What could break: Only with the switch on: a driver whose dynamic vertex input is slow (RADV builds a small prologue per layout) or wrong (attributes read with the wrong layout: broken models). Off, the code paths are the old ones.
Turning it off: leave
RX_VK_DYNAMIC_VERTEX_INPUTunset (the default)Compatibility: Off: nothing changes. On: the noted pipelines are built again once (the built and warmed stamps take the mode); the program cache and the driver's pipeline cache are shared between modes.
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.tests/that reads changed source updated in this PR, not weakened.mainand passing here.🤖 Generated with Claude Code
The checks on this PC (Windows 11, RTX 3080, Ryzen 9 3900X, llvm-mingw from the builder's v2.0.14 tools):
python -I -B tests/run_all.pyon main @aa95d35ffails these 19 here, and so does this branch:test_appimage_player_build.py,test_bake_portability.py,test_cpm_discovery.py,test_cpp_preflight.py,test_crash_dialog.py,test_env_on.py,test_fpx_sticky.py,test_lift_cleanup_error.py,test_linux_preflight.py,test_make_game_cache.py,test_make_game_prepare.py,test_missing_nup.py,test_oot_state_tap.py,test_options_budget_once.py,test_readback_late.py,test_spawn_emit.py,test_tested_configurations.py,test_vk_pgo.py,test_walk_key.py. Any other failure in a full run on this branch was rerun on its own and passed (the full runs shared the PC with dev_packs builds: timing checks).Next: an interleaved A/B in the game against main on one dev_packs base of
aa95d35f; the numbers will replace the Measurements section.1e64adc07c7b51b1cbd5Rebased onto
main@7bacf846. Two conflicts: tests/test_fallback_pipeline_state.py (kept main's newprogram_modules_droppedstub and this PR's packednvn_va_st) and gpu/vk/vk_draw.cpp (kept this PR's dynamic-vertex-input block and main'sFlatMapfor the per-threadminetable). Pushed as7b51b1cb. No tests were run here; the test boxes stay yours.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.