WIP: perf(vk): programs with the same bindings share one set layout and pipeline layout, so a program change pushes only what changed #800
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!800
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:perf/vk-shared-pipeline-layouts"
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: perf · 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
Each shader program had its own descriptor set layout and pipeline layout, and the replay pushes only the descriptors that changed only while the layout is the one it pushed with: every program change pushed every descriptor again, even between programs whose bindings are laid out the same way. Programs change often within a pass. Found in an audit of the renderer's per-draw path; no issue on the tracker.
What changed
Programs whose layouts' create infos are the same now share one set layout and pipeline layout, kept for the device's life, so a program change between them pushes only the writes that differ. Pipelines are made from the same create infos as before and no pipeline key holds a layout handle.
layout_signature,layouts_for,SharedLayoutsandensure_layout; the preparation's compute warm leaves shared layouts alone (gpu/vk/vk_draw.cpp)program_cache_borrowleaves shared layouts alone (gpu/vk/vk_progcache.cpp);Program::layout_shared(gpu/vk/vk_shader.h, not a stamped translator file)RX_VK_LAYOUT_EACH=1row in docs/development.mdtests/test_shared_layouts.pyMeasurements
Verdict: not measured yet: the measurements are pending from the RX_VK_BENCH A/B of this PR @
e2a24c1aagainst main @b9e95173(under way), which will replace this section.Flags and settings
One switch for an A/B.
RX_VK_LAYOUT_EACH=1=1for an A/BTesting
Tested: Windows 11 (Ryzen 9 3900X), llvm-mingw and the Vulkan headers of the builder's v2.0.14 tools: rebased onto main @
b9e95173(this PR @e2a24c1a; it stands alone on main, on no other PR). The 135 checks that read this diff (listed below: those under tests/ and nx2/ that name a changed file, and the ones this PR adds or changes), not the whole suite:python -I -B tests/run_all.py --jobs 6 <those checks>withRX_CPMat the builder's CPM cache: 127 passed, 7 failed; each failure (tests/test_crash_dialog.py,tests/test_linux_driver_fault_guard.py,tests/test_oot_state_tap.py,tests/test_pipeline_tour.py,tests/test_vk_occlusion_queries.py,tests/test_vk_pgo.py,tests/test_walk_key.py) also fails on main @b9e95173in the same checks, on the same PC and the same day.The 135 checks
nx2/test_cbuf_table_extent.pynx2/test_dump_ssbo_read.pynx2/test_mesh_dynamic_state.pytests/test_amd_fragment_warp.pytests/test_bake_ds.pytests/test_bank_gen.pytests/test_bc_raw_targets.pytests/test_check_pr_description.pytests/test_commit_room.pytests/test_crash_dialog.pytests/test_desc_clock.pytests/test_desc_counts.pytests/test_dev_packs.pytests/test_device_lost_exit.pytests/test_dispatch_clock.pytests/test_dlss_checks.pytests/test_draw_binds.pytests/test_draw_side_effects.pytests/test_draw_stream_visibility.pytests/test_drawn_page_map.pytests/test_driver_cache_room.pytests/test_driver_faults.pytests/test_dummy_views.pytests/test_equal_depth_margin.pytests/test_fallback_buffer_cleanup.pytests/test_fallback_depth_hold.pytests/test_fallback_loaded.pytests/test_fallback_pipeline_state.pytests/test_fallback_size_policy.pytests/test_flat_map.pytests/test_framegen_preset.pytests/test_fsr_uniform_ownership.pytests/test_global_table_loop.pytests/test_gpl_cold_library.pytests/test_gpl_library_cache.pytests/test_handle_lookup.pytests/test_handle_table_arrays.pytests/test_hold_gpu.pytests/test_intel_compiler_gate.pytests/test_intel_quick_compute.pytests/test_jobs_failure.pytests/test_jobs_wait_runs_queued.pytests/test_linux_driver_fault_guard.pytests/test_linux_pressure.pytests/test_load_default.pytests/test_masked_clear_failure.pytests/test_mem_trim.pytests/test_menu_env_on.pytests/test_mesh_args_cleanup.pytests/test_mesh_fallback.pytests/test_mesh_fallback_failed_once.pytests/test_mesh_query_feature.pytests/test_met_wait_capture.pytests/test_module_ids.pytests/test_native_float_atomic_add.pytests/test_oot_state_tap.pytests/test_parallel_dry_marks.pytests/test_parallel_rb_refresh.pytests/test_pass_hazard.pytests/test_pcache_fetch_lock.pytests/test_pcache_header_read.pytests/test_pcache_stamp.pytests/test_pipeline_cache_save.pytests/test_pipeline_notes_open.pytests/test_pipeline_play_cache.pytests/test_pipeline_share.pytests/test_pipeline_state_computes.pytests/test_pipeline_state_counts.pytests/test_pipeline_state_portable.pytests/test_pipeline_states.pytests/test_pipeline_tour.pytests/test_precompile_compute_guard.pytests/test_precompile_pipeline_cleanup.pytests/test_predict_resume.pytests/test_predict_sees_loaded.pytests/test_predict_types.pytests/test_predicted_check.pytests/test_prepare_cache_save.pytests/test_prepare_cpus.pytests/test_prepare_seed_stamp.pytests/test_prepare_stall.pytests/test_prepare_workers.pytests/test_prepared_stamps.pytests/test_prof_sampling.pytests/test_program_answer_domains.pytests/test_program_cache_cleanup.pytests/test_program_cache_format.pytests/test_program_cache_index.pytests/test_program_cache_one_variant.pytests/test_program_cache_reader.pytests/test_program_load_wait.pytests/test_program_record_head.pytests/test_program_stamp_knobs.pytests/test_psychov35_dlss.pytests/test_psychov35_taau.pytests/test_push_state.pytests/test_quick_pipelines.pytests/test_radv_mesh_optimizer.pytests/test_reactive_mask.pytests/test_recomplauncher_json.pytests/test_recorder_own_idle.pytests/test_recorder_sync.pytests/test_recording_admission.pytests/test_replay_copies.pytests/test_rumble_menu.pytests/test_same_draw.pytests/test_same_dyn.pytests/test_sampler_admission.pytests/test_seed_variant_cleanup.pytests/test_shader_module_guard.pytests/test_shader_stamp_cache.pytests/test_shader_stamp_inputs.pytests/test_shadow_mask_guard.pytests/test_shared_layouts.pytests/test_split_before_draw.pytests/test_startup_progress.pytests/test_state_list_plain.pytests/test_taau_env_lookup.pytests/test_taau_fxaa.pytests/test_taau_typed_dispatch.pytests/test_table_track.pytests/test_texture_handle_banks.pytests/test_texture_squeeze.pytests/test_third_party_objects.pytests/test_threaded_rendering.pytests/test_tls_objects.pytests/test_tree_shadow_mask.pytests/test_ub_threads.pytests/test_upscale_fallback.pytests/test_upscaler_rows.pytests/test_vertex_bind.pytests/test_vk_occlusion_queries.pytests/test_vk_pgo.pytests/test_walk_key.pytests/test_warm_bounded.pyNot tested: the game yet. This PR is WIP until its A/B is in: the RX_VK_BENCH A/B against main is running on an RTX 3080 with a Ryzen 9 3900X, Windows 11; AMD and Intel need other testers.
Must be tested:
RX_VK_LAYOUT_EACH=1: Kokiri Forest and Castle Town a few minutes, expecting the same picture and, withRX_VK_PROF_FINE=1, fewerfull pushesa draw (Test Farm: @Beanstalk any, those scenes with and without RX_VK_LAYOUT_EACH=1)Risks
What could break: A push elsewhere in the same command buffer at the same bind point that does not mark the game's pushed descriptors as disturbed (the temporal actor pass, frame generation, FSR, ASTC decode): the next game draw's delta push would leave the other bindings as that push set them. Two draws of the same program already relied on this; shared layouts make it more frequent.
Turning it off:
RX_VK_LAYOUT_EACH=1Compatibility: Nothing changes: no caches, settings or vk ABI involved.
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.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.67156a1f65e2a24c1a90Rebased onto main @
b9e95173(nowe2a24c1a; stands alone on main, not stacked); the 135 checks that read this diff, not the whole suite: 127 passed, 7 failed, each failure also failing on main @b9e95173in the same checks. Stays WIP: measurements pending from the RX_VK_BENCH A/B.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.