WIP: perf(vk): a written storage buffer bound again in the same recording is not noted again #797
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
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
testing wanted
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!797
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:perf/vk-written-ssbo-once"
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: medium · Tested on: Windows 11 (the game-free checks; the game A/B is next) · Needs: a game run on NVIDIA, AMD and Intel
Why
A storage buffer a shader writes was noted again at every descriptor build that bound it: a lock and a map lookup for the texture note, ParLock and the pools' lock for the write-back and hazard, and a page stamp that also threw away every thread's kept uniform copies. The culling dispatches bind the same written ranges one after another, and most draws rebuild their descriptors. Found in an audit of the renderer's per-draw path; no issue on the tracker.
What changed
texture_gpu_wrote,gpu_buffer_bind's written path andmemory_stamp_gpueach keep a thread's last notes by range and leave a repeat as it was while nothing their note answers has moved (the recording, the submission, the pools, the mirror's sync, and any generation a reader kept since).WriteMemo,write_memo_keep,write_memo_hit,stamp_fence,StampSeen(gpu/vk/vk_memory.cpp)gpu_wrote_changes,GpuWroteSeenintexture_gpu_wrote(gpu/vk/vk_texture.cpp)RX_VK_WRITTEN_EACH=1row in docs/development.mdtests/test_written_once.py;test_direct_buffer_writesruns the real repeat and each conditionMeasurements
Verdict: not measured yet: the measurements are pending from the RX_VK_BENCH A/B of this PR @
346b7434against main @b9e95173(under way), which will replace this section.Flags and settings
One switch for an A/B.
RX_VK_WRITTEN_EACH=1=1for an A/B or if flicker or cyan shows over compute-written memoryTesting
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 @346b7434; it stands alone on main, on no other PR). The 85 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: 79 passed, 6 failed; each failure (nx2/test_bc_storage_views.py,tests/test_crash_dialog.py,tests/test_oot_state_tap.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 85 checks
nx2/test_bc_storage_views.pynx2/test_import_windows.pynx2/test_texture_init_barrier.pytests/test_3d_view_create_flags.pytests/test_astc_bc_policy.pytests/test_bc_raw_targets.pytests/test_bc_upload_retry.pytests/test_bind_memo.pytests/test_blocks_at_start.pytests/test_capture_copy_helpers.pytests/test_capture_copy_nt.pytests/test_capture_copy_runs.pytests/test_capture_wait_log.pytests/test_check_pr_description.pytests/test_commit_limit.pytests/test_commit_room.pytests/test_compressed_over_rt.pytests/test_crash_dialog.pytests/test_dev_packs.pytests/test_direct_buffer_writes.pytests/test_drawn_page_map.pytests/test_drawn_writeback.pytests/test_dump_readback.pytests/test_evict_reason.pytests/test_frame_trace_waits.pytests/test_hold_gpu.pytests/test_image_view_retry.pytests/test_import_buffer_binding.pytests/test_import_chunk_default.pytests/test_import_span.pytests/test_import_write_watch.pytests/test_inline_write_order.pytests/test_keep_rendered.pytests/test_late_fix_build.pytests/test_late_fix_shaders.pytests/test_linux_pressure.pytests/test_low_vram_texture_mips.pytests/test_mem_trim.pytests/test_met_wait_capture.pytests/test_mirror_budget.pytests/test_mirror_gpu_only.pytests/test_mirror_inherit.pytests/test_mirror_trim.pytests/test_native_astc_texture_count.pytests/test_oot_state_tap.pytests/test_parallel_init_order.pytests/test_parallel_mirror_make.pytests/test_parallel_rb_refresh.pytests/test_pipeline_state_portable.pytests/test_pool_span.pytests/test_quick_pipelines.pytests/test_readback_part.pytests/test_report_words.pytests/test_retired_give_back.pytests/test_sparse_mirror.pytests/test_split_before_draw.pytests/test_split_ub_flush.pytests/test_staging_arena_fallback.pytests/test_submitted_page.pytests/test_target_image_pool.pytests/test_target_overlap.pytests/test_tex_spans_once_a_present.pytests/test_texel_buffer_ownership.pytests/test_texture_budget.pytests/test_texture_layout_sizes.pytests/test_texture_squeeze.pytests/test_texture_staging_publication.pytests/test_threaded_rendering.pytests/test_vertex_bind.pytests/test_vk_occlusion_queries.pytests/test_vk_pgo.pytests/test_vk_range_walk.pytests/test_vram_compact.pytests/test_vram_pressure.pytests/test_vulkan_clear_mip.pytests/test_walk_key.pytests/test_wb_diff_cpu_writes.pytests/test_wb_diff_split.pytests/test_wb_diff_stale_shadow.pytests/test_wb_learn.pytests/test_wb_observation_lifetime.pytests/test_wb_pages.pytests/test_wb_shadow_follows_sync.pytests/test_wb_shadow_remake.pytests/test_written_once.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_WRITTEN_EACH=1: Kokiri Forest and Hyrule Field a few minutes, expecting the same picture (no one-frame flicker, no cyan or stale textures) and the same MB written back (vk: a frame: mirrors) (Test Farm: @Beanstalk any, those scenes with and without RX_VK_WRITTEN_EACH=1)Risks
What could break: A write-back or hazard missed, or a kept uniform copy not refreshed: one-frame flicker or stale data over compute-written memory. Fewer
cap_viewbumps can delay a kept read's refresh of guest memory that an earlier submission's write-back is landing in at that moment; that timing was already not fixed.Turning it off:
RX_VK_WRITTEN_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.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.09c6e45841346b74349aRebased onto main @
b9e95173(now346b7434; stands alone on main, not stacked); the 85 checks that read this diff, not the whole suite: 79 passed, 6 failed, each failure also failing on main @b9e95173in the same checks. Stays WIP: measurements pending from the RX_VK_BENCH A/B. Heads-up: main has moved on since (b8d2b04e); #590'swrote_regions::markintexture_gpu_wrotenow conflicts with this PR's early return there, for the next rebase.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.