perf(vk): use VK_EXT_descriptor_buffer for game shader descriptors #2948
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2948
Loading…
Reference in a new issue
No description provided.
Delete branch "siantm/Longshot:perf/vk-descriptor-buffer"
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
On
main, game draws rebuildVkWriteDescriptorSet/VkDescriptorBufferInfo/VkDescriptorImageInfoarrays in host memory and push them viavkCmdPushDescriptorSetKHR(or allocate per-draw descriptor sets when exceeding push limits) on nearly every draw. That descriptor translation and driver command-serialization overhead runs on every draw in CPU-bound scenes like Castle Town Market.This PR adds a
VK_EXT_descriptor_bufferpath (RX_VK_DESC_BUFFER, default on whenVK_EXT_descriptor_buffer,bufferDeviceAddress, anddescriptorBufferImageLayoutIgnoredare available):RecordingRes::DescBuf): 256 KB chunks keep BAR0 usage modest (~12 MB across 48 slots;221 KBpeak in Market with0made on demand) while skipping per-recordingvkResetDescriptorPooland descriptor set allocations on the descriptor-buffer path.DescWriter::db_shadow): raw hardware descriptors are assembled in cached host memory and copied sequentially into the mapped descriptor buffer via write-combinedmemcpy(zero WC reads), with UBO-only delta updates (update_ubo_descriptors).VkDeviceAddresspropagation: carried throughgpu_buffer_bind, mirror pools, recording streams (RecordingRes::Stream),zero_buffer,miss_buf,SimTurfPrivate, andtexel_buffer_info(avoidingVkBufferViewcreation for texel/image buffers).UbRawCache(2048×4 = 128 KB), 2-waySbRawCache(1024×2 = 64 KB), 2-wayCisRawCache(1024×2 = 64 KB, invalidated on texture/sampler generation changes), and 2-wayDbLayoutCache(512×2 = 16 KB) ingpu/vk/vk_draw.cpp.gpu/vk/vk_recorder.h): by-valuepk_vkCmdSetDescriptorBufferOffsetsEXTfast path for single-set binds (setCount == 1) pluspk_vkCmdBindDescriptorBuffersEXT.Result: +3.27% Avg FPS (
67.01 -> 69.20), +3.69% P50 FPS, +3.89% 1% Low (1000/p99), and +4.83% 0.1% Low (1000/p999) in Castle Town Market, plus +3.44% 1% Low (tail mean) and +12.05% 0.1% Low (1000/p999) in game-thread-limited Kokiri Forest.Read first:
gpu/vk/vk_draw.cpp(RecordingRes::DescBuf,DbLayout,UbRawCache/SbRawCache/CisRawCache,build_descriptors,update_ubo_descriptors,bind_descriptors_db),gpu/vk/vk_main.cpp,gpu/vk/vk_recorder.h.Testing
Tested: Windows 11, NVIDIA GeForce RTX 4060 (driver
621.40, Vulkan 1.4),1280x720, comparingmain @ 4908cc6da(rt-main-4908) against this PR (rt-desc-buf):Parity diffs (excluding version): NONE), improving Market Avg/P50/1%/0.1% FPS and Kokiri Forest 1%/0.1% lows.RX_VK_PROF_FINE=1, Castle Town Market): Confirmedvk: descriptor buffers on (align 0x40, ub 8 sb 16 cis 4 si 4 utb 16 stb 16),bind descriptors 0.23 ms (of it the push call 0.09 ms),desc bufs peak 221 KB (0 made on demand),db sb miss 0.00/draw, anddb cis hit ~96.6%.RX_VK_MEM_CHECK=1, Kokiri Forest):33000 submits: take_open 0, collect_open 0, seq_mismatch 0 (0 of 36729 takes not paired); sync_over_gpu: 0 replaced, 2587 same (0 unbound); CPU reads or writes of one left out: 0 so far; 0.0 draws left out; compiled 0.tests/run_all.py) &mise run lint: 30 targeted checks (test_recorder_sync.py,test_desc_counts.py,test_recording_admission.py,test_draw_stream_visibility.py,test_descriptor_array_census.py,test_draw_binds.py,test_draw_side_effects.py,test_same_bind.py,test_same_draw.py,test_texel_buffer_ownership.py,test_ub_gap.py,test_ub_memo.py,test_ub_threads.py,test_ub_update_batch.py,test_vk_braces.py,test_doc_anchors.py,test_tls_objects.py,test_thinlto_tls.py,test_bind_memo.py,test_direct_buffer_writes.py,test_gpl_cold_library.py,test_gpl_library_cache.py,test_program_stamp_knobs.py,test_dummy_views.py,test_flush_nothing_held.py,test_vram_held_idle.py,test_sim_turf_pools.py,test_device_policy.py,test_vendor_fixes.py,test_desc_clock.py) plustest_recorder_parts.pyandtest_recorder_own_idle.pypassed (0 failed).mise run lintpasses on the branch diff (origin/main..HEAD). Pre-existing failures already onmain @ 4908cc6da(unrelated to this PR):tests/test_switch_table.py(LONGSHOT_LAUNCHER_STARTUPinhost/launcher_startup.h:9),tests/test_log_levels.py(log_tee_write), andtests/test_tex_desc_memo.py(shift_single_wordmissing from test fixture).Still to test:
@Beanstalk amd: run in-game (Market_Child,Kokiri_Forest) withRX_VK_DESC_BUFFERat its default (1) andRX_VK_DESC_BUFFER=0on AMD RDNA (Windows and Linux/RADV, including compute mesh fallback), expecting clean visuals and a frame-time win or parity (@Beanstalk amd).@Beanstalk linux: build on Linux and run fullmise run testand in-game smoke check, expecting all checks and rendering to pass (@Beanstalk linux).Measurements
Verdict: Faster in draw-heavy Castle Town Market (+3.27% Avg FPS, +3.69% P50 FPS, +3.89% 1% Low (
1000/p99), +3.98% 1% Low (tail mean), +4.83% 0.1% Low (1000/p999), -0.47 ms mean frame time) and cleaner frame pacing in game-thread-limited Kokiri Forest (+3.44% 1% Low tail mean, +12.05% 0.1% Low (1000/p999), Avg FPS within spread at-0.67%).RX_VK_DESC_BUFFERships on by default (1) when hardware supportsVK_EXT_descriptor_buffer,bufferDeviceAddress, anddescriptorBufferImageLayoutIgnored.Setup: Windows 11, NVIDIA GeForce RTX 4060 (driver
621.40, Vulkan 1.4);Market_Child(market-entrance) andKokiri_Forest(kokiri-forest),1280x720, uncapped (HOS_FPS_MAX=1000), uncontended 3 interleaved pairs × 30 s each via the job queue (--mode timing), medians reported. Also honors existingRX_VK_PUSH_ALL(default0, as onmain) insidebind_descriptors_db.Castle Town Market (
market-entrance):4908cc6da24f5517171000/p99)1000/p999)main_cpu_msmemsync_msdesc_msKokiri Forest (
kokiri-forest):4908cc6da24f5517171000/p99)1000/p999)desc_msRisks
48 × 256 KB;221 KBpeak in Market) plus ~272 KB ofthread_localraw descriptor caches per recording thread (UbRawCache,SbRawCache,CisRawCache,DbLayoutCache).desc_ms(assembling raw descriptors indb_shadow) in exchange for eliminating per-drawvkCmdPushDescriptorSetKHRdriver command-serialization overhead, yielding a net +3.27% Avg FPS win in draw-heavy Market and +0.20% to +12.05% better lows in Kokiri Forest.VK_EXT_descriptor_buffer,bufferDeviceAddress, anddescriptorBufferImageLayoutIgnored; drivers/GPUs without them fall back automatically to the push-descriptor path.RX_VK_DESC_BUFFER=0restores the previous push-descriptor path immediately without changing saves, shader caches, orlongshot_options.ini.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Windows 11, RTX 4060 (driver 621.40, Vulkan 1.4): uncontended 3-pair x 30s A/B in Castle Town Market (+3.27% Avg FPS, +3.89% 1% Low, +4.83% 0.1% Low) and Kokiri Forest (+12.05% 0.1% Low), Parity diffs: NONE; Kokiri Forest RX_VK_MEM_CHECK=1 (33000 submits, 0 errors, 0 draws left out).
Possibly related, for context:
@review
@beanstalk
Beanstalk test farm · an earlier run: commit
24f5517(the newer results are in a comment below)Commit
24f5517· approved by HumanBean (reviewed) · dashboard⚠️ Note: On hardware without the required descriptor-buffer features, unset and disabled both use the fallback, so their comparison cannot measure the new path; the disabled cell still checks changes shared with the fallback.
⚠️ Note: The farm does not run the requested Linux test suite or directly measure the claimed 0.1% lows; two starts per side and switch value keep the game runs within the time limit.
⚠️ Note: The scenarios exercise normal gameplay but cannot guarantee that the AMD compute-mesh fallback is reached.
Started at 2026-12-01 15:24 UTC.
nvidiawindows+nvidiawindows+amdlinux+radvintelmarket-and-forest· frame time p99 (ms)RX_VK_DESC_BUFFER=RX_VK_DESC_BUFFER=0(reference)nvidiawindows+nvidiawindows+amdlinux+radvintelWhy it failed
nvidia:market-and-forest · RX_VK_DESC_BUFFER= (PR only)screenshot.max_diff:0.7 → 0.2; limit 0.2nvidia:market-and-forest · RX_VK_DESC_BUFFER= (PR only)crash:1 PR run crashednvidia:market-and-forest · RX_VK_DESC_BUFFER=0 (PR only)screenshot.max_diff:0.2 → 0.7; limit 0.2nvidia:market-and-forest · RX_VK_DESC_BUFFER=0 (PR only)market.frametime_1pct_low_ms.max_delta_pct:10.2 → 15.7 (+54.3%); limit 15.0nvidia:market-and-forest · RX_VK_DESC_BUFFER= (PR only)forest.frametime_p99_ms: RX_VK_DESC_BUFFER= vs RX_VK_DESC_BUFFER=0 (PR):6.2 → 8.4 (+33.8%); limit 15.0; the PR's own cells: RX_VK_DESC_BUFFER= against RX_VK_DESC_BUFFER=0 (RX_VK_DESC_BUFFER=0 (PR only))windows+nvidia:market-and-forest · RX_VK_DESC_BUFFER= (PR only)crash:1 PR run crashedwindows+nvidia:market-and-forest · RX_VK_DESC_BUFFER= (PR only)screenshot.max_diff:0.1 → 0.8; limit 0.2windows+nvidia:market-and-forest · RX_VK_DESC_BUFFER= (PR only)market.frametime_p99_ms: RX_VK_DESC_BUFFER= vs RX_VK_DESC_BUFFER=0 (PR):14.0 → 16.9 (+20.5%); limit 15.0; the PR's own cells: RX_VK_DESC_BUFFER= against RX_VK_DESC_BUFFER=0 (RX_VK_DESC_BUFFER=0 (PR only))Couldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.
intel, report 1:Insufficient frame-time evidence for 14 required comparison(s). See rule results.What was tested
What will be tested · AI plan (
gpt-6.1-terra)Compare the pull request with main in Castle Town Market and Kokiri Forest on NVIDIA, AMD and Intel hardware, including Windows AMD and Linux RADV. Each side runs twice with the descriptor-buffer switch unset and twice with it disabled; each visit includes a still image and a 30-second uncapped frame-time measurement after warm-up. The pull request fails on a crash, a substantial image difference, or a frame-time regression over 15%; the enabled-by-default path is also compared with the disabled path on the pull request.
0(PR only).market-entrance(settings vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0; switchesHOS_OUTPUT_RES=1280x720,RX_VK_AUTO_TUNE=0), then teleport to Market, take the picture market to compare with main, measure market for 30 s (after 10 s warm-up), teleport to Kokiri Forest, take the picture forest to compare with main, measure forest for 30 s (after 10 s warm-up); 2 runs on each side for each of 2 cells (2 game starts a run).Measurements on `nvidia`, for the PR description
Verdict: fail on nvidia (2 reports):
market-and-forest screenshot.max_diff;market-and-forest crash;market-and-forest market.frametime_1pct_low_ms.max_delta_pct (+54.3%)failed.Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 4070 Ti SUPER, 621.14.0AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 5070 Ti, 621.40.0AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMScene: market-and-forest, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-and-forest: 2 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)4908cc624f5517RX_VK_DESC_BUFFER= (PR only)· forest · median frame time (ms)RX_VK_DESC_BUFFER= (PR only)· market · median frame time (ms)RX_VK_DESC_BUFFER= (PR only)· forest · frame time (p99) (ms)RX_VK_DESC_BUFFER= (PR only)· market · frame time (p99) (ms)RX_VK_DESC_BUFFER= (PR only)· forest · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER= (PR only)· market · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · median frame time (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · median frame time (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · frame time (p99) (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · frame time (p99) (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · frame time (worst 1%) (ms)Flags and settings
RX_VK_DESC_BUFFER0As Markdown for the PR description:
Measurements on `windows+nvidia`, for the PR description
Verdict: fail on windows+nvidia (2 reports):
market-and-forest crash;market-and-forest screenshot.max_diff;market-and-forest market.frametime_p99_ms: RX_VK_DESC_BUFFER= vs RX_VK_DESC_BUFFER=0 (PR) (+20.5%)failed.Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce GTX 1070, 582.78.0AMD Ryzen 7 9800X3D 8-Core Processor, 64 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 3090, 621.1.0AMD Ryzen 9 5900X 12-Core Processor, 128 GB RAMScene: market-and-forest, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-and-forest: 2 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)4908cc624f5517RX_VK_DESC_BUFFER= (PR only)· forest · median frame time (ms)RX_VK_DESC_BUFFER= (PR only)· market · median frame time (ms)RX_VK_DESC_BUFFER= (PR only)· forest · frame time (p99) (ms)RX_VK_DESC_BUFFER= (PR only)· market · frame time (p99) (ms)RX_VK_DESC_BUFFER= (PR only)· forest · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER= (PR only)· market · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · median frame time (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · median frame time (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · frame time (p99) (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · frame time (p99) (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · frame time (worst 1%) (ms)Flags and settings
RX_VK_DESC_BUFFER0As Markdown for the PR description:
Measurements on `windows+amd`, for the PR description
Verdict: fail on windows+amd (2 reports):
market-and-forest screenshot.max_difffailed.Hardware: 1: windows+amd+amd-proprietary+dgpu
AMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAM; 2: windows+amd+amd-proprietary+igpu+xessAMD Radeon(TM) Graphics, 2.0.279AMD Ryzen 5 5600G with Radeon Graphics, 28 GB RAMScene: market-and-forest, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-and-forest: 2 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)4908cc624f5517RX_VK_DESC_BUFFER= (PR only)· forest · median frame time (ms)RX_VK_DESC_BUFFER= (PR only)· market · median frame time (ms)RX_VK_DESC_BUFFER= (PR only)· forest · frame time (p99) (ms)RX_VK_DESC_BUFFER= (PR only)· market · frame time (p99) (ms)RX_VK_DESC_BUFFER= (PR only)· forest · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER= (PR only)· market · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · median frame time (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · median frame time (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · frame time (p99) (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · frame time (p99) (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · frame time (worst 1%) (ms)Flags and settings
RX_VK_DESC_BUFFER0As Markdown for the PR description:
Measurements on `linux+radv`, for the PR description
Verdict: fail on linux+radv (2 reports):
market-and-forest forest.frametime_p99_ms.max_delta_pct (+264.2%);market-and-forest forest.frametime_1pct_low_ms.max_delta_pct (+132.9%);market-and-forest screenshot.max_difffailed.Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 7900 XTX (RADV NAVI31), 26.3.1AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMScene: market-and-forest, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-and-forest: 2 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)4908cc624f5517RX_VK_DESC_BUFFER= (PR only)· forest · median frame time (ms)RX_VK_DESC_BUFFER= (PR only)· market · median frame time (ms)RX_VK_DESC_BUFFER= (PR only)· forest · frame time (p99) (ms)RX_VK_DESC_BUFFER= (PR only)· market · frame time (p99) (ms)RX_VK_DESC_BUFFER= (PR only)· forest · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER= (PR only)· market · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · median frame time (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · median frame time (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · frame time (p99) (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · frame time (p99) (ms)RX_VK_DESC_BUFFER=0 (PR only)· forest · frame time (worst 1%) (ms)RX_VK_DESC_BUFFER=0 (PR only)· market · frame time (worst 1%) (ms)Flags and settings
RX_VK_DESC_BUFFER0As Markdown for the PR description:
Measurements on `intel`, for the PR description
Verdict: queued on intel (1 report).
Hardware: 1: windows+intel+intel-proprietary+igpu
Intel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMScene: market-and-forest, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-and-forest: 2 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
RX_VK_DESC_BUFFER0As Markdown for the PR description:
The testers' hardware
nvidiaNVIDIA GeForce RTX 4070 Ti SUPER, 621.14.0AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMnvidiaNVIDIA GeForce RTX 5070 Ti, 621.40.0AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMwindows+nvidiaNVIDIA GeForce GTX 1070, 582.78.0AMD Ryzen 7 9800X3D 8-Core Processor, 64 GB RAMwindows+nvidiaNVIDIA GeForce RTX 3090, 621.1.0AMD Ryzen 9 5900X 12-Core Processor, 128 GB RAMwindows+amdAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMwindows+amdAMD Radeon(TM) Graphics, 2.0.279AMD Ryzen 5 5600G with Radeon Graphics, 28 GB RAMlinux+radvAMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAMlinux+radvAMD Radeon RX 7900 XTX (RADV NAVI31), 26.3.1AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMintelIntel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMRecommendation: Request changes. Pipeline-layout handles can be reused after precompilation while the descriptor-layout cache retains their old metadata, causing later shaders to read incorrectly laid-out descriptors. The new path also needs to account for devices that store combined image samplers in separate arrays.
The change replaces per-draw Vulkan descriptor writes for game pipelines with mapped descriptor buffers and thread-local caches. The reported RTX 4060 runs show a Market improvement, at the cost of additional mapped memory and per-thread caches; correctness and performance on other supported hardware remain untested.
Blocking (3): must change before merging.
gpu/vk/vk_draw.cpp:1121: The layout metadata remains keyed by a Vulkan handle after that pipeline layout is destroyed, and emplace does not replace an existing entry when the driver reuses the handle. (more on the line) Do: Remove the metadata and invalidate thread-local cache entries when a layout is destroyed, or associate metadata with the program/layout lifetime without relying on reusable Vulkan handles.gpu/vk/vk_draw.cpp:5005: Combined image sampler descriptors are always written as an interleaved array, without checking combinedImageSamplerDescriptorSingleArray. (more on the line) Do: Handle the separate-array layout using the reported component sizes, or disable the descriptor-buffer path when the property is false.gpu/vk/vk_draw.cpp:4803: The fallback texel descriptors use zero_buffer, but that buffer is created without uniform or storage texel-buffer usage flags. (more on the line) Do: Create a suitable zero texel buffer with both required texel usage flags, or reuse a properly formatted dummy texel buffer for these descriptors.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_main.cpp:1134: The default-on renderer path has not been exercised on the other Tier 1 systems it affects. (more on the line) Do: Run in-game visual and interleaved performance comparisons on the affected Tier 1 systems, including the compute mesh fallback, and report the results.gpu/vk/vk_draw.cpp:793: The change adds mapped descriptor buffers and per-thread caches, but the reported peak ring use is not a before-and-after RAM and VRAM measurement. (more on the line) Do: Measure RAM and VRAM against the base during representative play, including a memory-constrained supported system. (@fixdoes its part first: Reduce initial ring allocation or allocate chunks lazily to shrink the retained memory cost.)@fixcan do L1, L2, L3 and L5.Questions (1) (not confirmed from the code; they don't hold the recommendation)
Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes on the reported Windows RTX 4060 Market run: median average FPS rose from 67.01 to 69.20 across three interleaved 30-second pairs, with the reported 1% low rising from 52.95 to 55.01 FPS. Kokiri Forest results overlap substantially, and the measurements do not establish the default's effect on other supported systems.
Other systems: The path affects graphics, compute and mesh fallback pipelines whenever the extension and required features are present. The supplied runs cover Windows on an NVIDIA RTX 4060; AMD Windows and RADV, NVIDIA Linux, Steam Deck, and the compute fallback still need coverage. Helper pipelines retain their existing descriptor path.
Switches: RX_VK_DESC_BUFFER is added as a kill switch, default on when the feature checks pass; its switches.def row is present. The default has not yet been measured across the supported hardware it can affect.
Reviewed:
24f551717fagainst4908cc6dad: Read the repository rules, PR template, standards, commit message, supplied description, comments and CI status; inspected the diff and surrounding descriptor, recording, texture and device code. The large changed files were inspected in relevant sections rather than read in full; the complete change and all callers were not exhaustively reviewed. No recorded artifacts or generated files were supplied for inspection. ../Tooling/AGENTS.md and docs/review-checklist.md were absent.; nothing run (a code review).Checked and fine:
Testing: No code, tests or project scripts were run, as requested. The author's Windows RTX 4060 in-game runs and game-free checks are reported in the PR; CI is still running.
Overlaps and merge order: Unknown; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -765,4 +790,4 @@std::vector<Stream> streams; // (the first, then the ones made on demand: kept for the slot's next recordings)size_t si = 0; // (the one in use)uint64_t before = 0; // (what the recording used of the streams before this one)uint32_t idle = 0; // (recordings of the slot that stayed in the first stream)L5 (should fix): The change adds mapped descriptor buffers and per-thread caches, but the reported peak ring use is not a before-and-after RAM and VRAM measurement.
When: Players with constrained RAM or VRAM retain descriptor chunks for recording slots and caches for recording threads; the reported 221 KB peak in one recording does not show the total allocation or pressure during play.
Do: Measure RAM and VRAM against the base during representative play, including a memory-constrained supported system.
@ -961,0 +1118,4 @@}}std::lock_guard lk(db_layouts_mu);db_layouts.emplace(layout, std::move(dbl));L1 (blocking): The layout metadata remains keyed by a Vulkan handle after that pipeline layout is destroyed, and emplace does not replace an existing entry when the driver reuses the handle.
When: The compute warm-up destroys p.layout after compiling it. If a later layout receives the same handle, ensure_layout leaves the warm-up layout's size and binding offsets in db_layouts; build_descriptors then writes and binds descriptors using those old offsets, producing incorrect shader inputs or invalid memory accesses.
Do: Remove the metadata and invalidate thread-local cache entries when a layout is destroyed, or associate metadata with the program/layout lifetime without relying on reusable Vulkan handles.
@ -4573,0 +4800,4 @@auto fill_texel = [](VkDescriptorType type, VkDeviceSize sz, uint8_t* dst) {if (!sz || sz > 64) return;VkDescriptorAddressInfoEXT ai{VK_STRUCTURE_TYPE_DESCRIPTOR_ADDRESS_INFO_EXT};ai.address = zero_address;L3 (blocking): The fallback texel descriptors use zero_buffer, but that buffer is created without uniform or storage texel-buffer usage flags.
When: When null descriptors are unavailable and a texel binding cannot be resolved, initialization obtains a texel descriptor for zero_address. That address belongs to a buffer lacking the required texel usage, so the descriptor is invalid and a shader using the fallback can render incorrectly or cause a device error.
Do: Create a suitable zero texel buffer with both required texel usage flags, or reuse a properly formatted dummy texel buffer for these descriptors.
@ -4573,0 +5002,4 @@VkDescriptorGetInfoEXT gi{VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT};gi.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;gi.data.pCombinedImageSampler = ⅈvkGetDescriptorEXT(dev.device, &gi, sz, e.raw);L2 (blocking): Combined image sampler descriptors are always written as an interleaved array, without checking combinedImageSamplerDescriptorSingleArray.
When: On a supporting driver that reports this property as false, an array of combined image samplers has separate image and sampler portions. Writing each combined descriptor at k times combinedImageSamplerDescriptorSize puts the entries in the wrong positions, so shaders sampling an array receive incorrect descriptors.
Do: Handle the separate-array layout using the reported component sizes, or disable the descriptor-buffer path when the property is false.
@ -1114,0 +1131,4 @@dbp.storageTexelBufferDescriptorSize > 0 && dbp.storageTexelBufferDescriptorSize <= 64;const bool fns_ok = vkx::vkGetDescriptorSetLayoutSizeEXT && vkx::vkGetDescriptorSetLayoutBindingOffsetEXT &&vkx::vkGetDescriptorEXT && vkx::vkCmdBindDescriptorBuffersEXT && vkx::vkCmdSetDescriptorBufferOffsetsEXT;if (db_wanted && descriptor_buffer.descriptorBuffer && dev.vk12.bufferDeviceAddress &&L4 (should fix): The default-on renderer path has not been exercised on the other Tier 1 systems it affects.
When: AMD Windows and RADV, NVIDIA Linux and Steam Deck can select this path, but the only reported in-game run is on Windows with an RTX 4060; their rendering and frame-time behavior are unknown.
Do: Run in-game visual and interleaved performance comparisons on the affected Tier 1 systems, including the compute mesh fallback, and report the results.
Addressed the BeanBot review items and Beanstalk Tier-1 findings in
3a1aa3170:vk_draw.cpp,vk_progcache.cpp,vk_internal.h): Addeddb_layout_evict()beforevkDestroyPipelineLayoutinprogram_cache_borrow/program_cache_borrow_all(andturf_population_pipeline), switchedensure_layoutfromemplacetoinsert_or_assign, and added an atomicdb_layout_epochto invalidate thread-localDbLayoutCacheentries on eviction. This prevents stale layout sizes/offsets when drivers reuseVkPipelineLayouthandles after warm-up/precompilation (root cause of the Beanstalk crashes andscreenshot.max_difffailures).vk_main.cpp): Addeddesc_buffer_supported()requiringVkPhysicalDeviceDescriptorBufferPropertiesEXT::combinedImageSamplerDescriptorSingleArray == VK_TRUE, cleanly disablingdev.descriptor_bufferwhen false.vk_draw.cpp): AddedVK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BITtozero_bufferand guardedinit_null_db_descriptors()when!dev.null_descriptor && !zero_address.vk_draw.cpp): TrackedDescWriter::db_gen/db_copy_offso mesh-fallbackCOMPUTE+GRAPHICSbinds share one descriptor copy and never skipGRAPHICSrebinds after UBO delta updates; extendedUbLargeRawCache/SbRawCache/CisRawCacheto 64-byte descriptors (fixing cache bypass on RADV 16B UBO and 64B CIS descriptors); removeddedicated = truefromdb_insert()256 KB ring chunks.switches.def,vk_main.cpp): Beanstalk across 8 Tier-1 systems showedVK_EXT_descriptor_bufferregressed non-ReBAR NVIDIA (GTX 1070 +24%) and RADV (RX 9070 XT +0.6..1.3%,RX 7900 XTX +8.3%), and was flat onRTX 3090/ Windows AMD. ChangedRX_VK_DESC_BUFFERto opt-in (attempt, default off;=1enables when supported), eliminating default memory/perf cost across Tier-1 hardware while keeping the opt-in path fixed and verified (tests/test_vk_desc_buffer.pyunderclang++/g++-Wall -Wextra -Werror, plus live 25 sRX_VK_DESC_BUFFER=1Windows RTX 4060marketrun: 1555 frames,RUN_ERROR=None, 0 crashes).Beanstalk test farm
Commit
3a1aa31· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Recommendation: Request changes. Since
3a1aa3170the descriptor-buffer path is off by default, so players get nothing from it, while the PR still adds about 1,000 lines of a second descriptor path tovk_draw.cpp. The only test of the head is one 25 s smoke run. At24f551717the farm measured regressions and crashes on the hardware where the path turns on. The description still says it ships on, and the branch conflicts withmain.What it does: game draws can write raw descriptors into mapped descriptor-buffer rings (
VK_EXT_descriptor_buffer) instead of pushing them on every draw. This only happens withRX_VK_DESC_BUFFER=1on drivers that have the extension, buffer device address,imageLayoutIgnoredandcombinedImageSamplerDescriptorSingleArray. At the default, the game still uses push descriptors and pools, as onmain.Does it help: No by default (the path is off), and Unproven when switched on. The +3.27% Market average comes from the author's RTX 4060 at
24f551717, not the head. Beanstalk's run of that commit had these results with the path on, againstmain:Commit
3a1aa3170says the crashes and pictures came from the layout-handle bug (BeanBot's L1). Nothing has measured or run the head on the farm yet: its sticky comment says it is "approved by nobody yet".Other systems: When the path is on, it covers every game graphics, compute and mesh-fallback pipeline. When it is off, the default path still changes:
build_descriptorsnow builds the push writes only underneed_writes/sm_mode.gpu_buffer_bindresult carries a device address.zero_buffergains texel and device-address usage on every device.In the farm's
RX_VK_DESC_BUFFER=0cell onnvidia(the push path players get), the picture check failed (0.2 to 0.7 againstmain) and Market's worst 1% was +54%. That was at the old head, but these default-path changes are still in this one. No run shows the default path matchesmainat the head.Switches:
RX_VK_DESC_BUFFER(attempt, default off;=1turns it on where the device supports it). Off is the right default given the farm numbers. But a perf path that players would have to switch on themselves, with no platform measured to gain, isn't a reason to merge it.Reviewed:
3a1aa3170against4908cc6da(its merge base).vk_main.cpp,vk_memory.cpp,vk_progcache.cpp,vk_internal.h,vk_work.h,vk_replay.cpp,vk_loader.handswitches.def.vk_draw.cpp: the layout cache (db_layout_of,ensure_layout,db_layout_evict),bind_descriptors_db,descriptors_disturbed/CmdBound,draw_begin_recording, the zero buffer, and the storage-buffer and texel parts ofbuild_descriptors.UbRawCache/SbRawCache/CisRawCache),update_ubo_descriptors, theuniform_rangechanges,vk_recorder.h,vk_texture.cpp, and the tests (test_vk_desc_buffer.py, recorder and admission tests).Fixed in this review: nothing.
Checked and fine:
desc_buffer_supported()requirescombinedImageSamplerDescriptorSingleArray,imageLayoutIgnored, buffer device address, a power-of-two offset alignment, descriptor sizes of at most 64 bytes and the five entry points.zero_bufferhas both texel usage bits, andquery_buf_addrreturns 0 without buffer device address.ensure_layoutnow usesinsert_or_assignand bumpsdb_layout_epochwhen a handle comes back, so a reused handle gets new offsets and the per-thread caches empty.main(fsr_descriptor_bufferkeeps its value).descriptors_disturbed()andreset_keeping_index()forget the bound descriptor buffer and offsets, anddraw_begin_recordingcallsdescriptors_disturbed(), so a new command buffer binds the buffer again.VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXTis set on every game pipeline path:compute_pipeline_info,gpl_link,build_graphicsand its library parts, andfallback_compute_pipelines.CallKindentries andcall_kind_namesstay in the same order.Blocking
gpu/vk/switches.def:381: there is no measured gain where the path would ship. The fix commit turned it off by default after the farm's regressions, so the PR now carries a second descriptor path, four per-thread caches and a descriptor ring that no player runs by default. Every later change tobuild_descriptorswould have to keep both paths right. The fix: run Beanstalk on3a1aa3170withRX_VK_DESC_BUFFER=1against=0andmain, on the same targets as before. If a platform shows a clean, interleaved win with no crash or picture difference (the RTX 4060 class looked like one), turn it on there only, chosen in the device policy by vendor and driver from those numbers. If none does, close the PR and keep the findings in an issue.The description doesn't match the head:
1)") and Risks ("Allocates ~12 MB ... BAR0") still describe the old default-on behaviour.24f551717.Rewrite it for the opt-in switch, move the farm's results into Measurements (the regressions too), and say what has run at the head (the 25 s
=1smoke run).The branch conflicts with
main: rebase it. Then show the default path is unchanged at the new head, because the farm's=0cell onnvidiafailed the picture check againstmainat the old head (see Other systems). The farm run in point 1 does this if it compares=0againstmain.Suggestions
gpu/vk/vk_draw.cpp:12627(at the head): the compute warm-up (warm_compute) still destroysp.layoutwithoutdb_layout_evict. This is the site BeanBot's L1 named.insert_or_assignkeeps a reused handle correct, but each warmed compute leaves itsDbLayoutindb_layoutsuntil the handle comes back. Calldb_layout_evict(p.layout)there, asprogram_cache_borrownow does.db_layout_evictbumps the global epoch on every eviction. Each recording thread then clears its 16 KBDbLayoutCacheat its next lookup, so a precompile pass that borrows thousands of programs keeps emptying those caches while the game plays. A per-entry generation, or bumping only when the evicted handle was ever looked up, would avoid that.Testing:
24f551717, and a 25 s=1Market smoke run at the head. Game-free checks pass on the author's PC.24f551717: failed on all four targets that finished (crashes, pictures, frame times);intelcouldn't be judged.3a1aa3170, and a default-path check againstmainafter the rebase. These hold the merge.Overlaps and merge order:
RX_VK_DESC_SECTIONS) also changebuild_descriptors/bind_descriptors; #2899 has already merged.build_descriptorswould go last.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.