Repository navigation
vulkan: add submission-scoped cbwin snapshot cache and Mali copy-mode support - #506
Conversation
…, v0.4.7-beta-mali rollout & decal probe
5aec777 to
26c4a5a
Compare
|
Thanks! Two things before merging: it turns the CB window on by default on Mali in copy mode, which the window never ran in before, with only mock tests; and the seqlock that bumps gcopy_gen on every wb_apply/gcopy_retire changes every copy-mode device (more copies, unmeasured). Could you add Mali in-game numbers (LARECOMP_LOG_CBUF_BYTES, fps, the water and terrain checked on 1.9.0), or ship the window default-off? The guest_copy_flush after the buffer-to-buffer copy is a real fix: that part could go in on its own. Also note it conflicts with #508 (now merged) in vk_exec_reset. |
… support Reconciles cbwin (mamcjr#453) with Android gcopy_mode GPUs (ARM Mali), cuts redundant per-draw full-UBO transient copies via a submission-scoped base snapshot cache, isolates async writeback/retire seqlock synchronization via cbwin-private cbwin_retire_{gen,writing,armed} (zero gcopy_gen churn on non-cbwin GPUs), and shrinks per-draw CBP patch uploads with CbpatchDedupe.
26c4a5a to
adbafd6
Compare
|
Rebased onto
|
…amcjr#507 review updates & v0.4.8-beta-mali rollout
|
Thanks for the numbers and the screenshots: −86% to −91% dynamic copies with fps parity on the G925 answers my question, and the extra bookkeeping now stays off on devices without the window. On the POCO (Turnip, placed heap) the default is unchanged: GPU p50 22.5-22.6 ms, as in 0.4.8. Forced on with LARECOMP_CB_WINDOW=1, uploads drop from ~906 to ~91 MB per 2 s and the terrain, grass and water look the same, but GPU p50 goes from 22.6 to 24.0 ms, so keeping it off by default outside Mali copy mode is right. Merged, thanks! |
…rktree cleanup, and PR mamcjr#507 rebase/UI note
…mamcjr#457 merged; how each one landed The status table and the section titles say merged. Sections 3-6 describe the code as it landed instead of the proposal: mamcjr#454 queues the slots on every device (LARECOMP_SLOT_DRAIN=1 waits), with the 60 fps numbers of the merged version; mamcjr#455 says its first version had no effect on Android (SDL lists only the current mode) and the merged one asks Android through JNI, rechecked on 0.4.13 (40 fps on a 120 Hz screen); mamcjr#453 notes the window stays off by default on Adreno and mamcjr#506 took the snapshot cache to Mali.
Summary
Reconciles constant-buffer window (
cbwin, merged upstream in#453) with Androidgcopy_modeGPUs (ARM Mali), cuts redundant per-draw full-UBO transient copies via a submission-scoped base snapshot cache, isolatescbwinasync writeback/retire synchronization so non-cbwindevices incur zero extra atomic/seqlock churn, and shrinks per-drawCBP(cbw_patch) uploads.Key Changes
cbwin_wanted()/cbwin_bind()(runtime/nvn/vulkan/exec.c):cbwin_wanted()ON for!gmem_placed && gcopy_mode && vk_driver_is_mali(), evaluating!gmem_placed && gcopy_mode(memory_order_relaxed) beforevk_driver_is_mali()so Turnip andgmem_placedbuilds short-circuit without probing Mali state (mock_mali_calls == 0); non-Mali/non-Turnip GPUs stay default-off unlessLARECOMP_CB_WINDOW=1.#453behavior:LARECOMP_CBWIN_SNAPSHOT=0orAB("cbsnap") == 1falls back cleanly toguest_copy()ingcopy_mode, or bindsgmem_bufdirectly whengmem_placed.v0.4.8-beta(#508gcopy_dchainmerged):vk_exec_reset()preserves#508'sgwin_mode/dchainresets alongsidecbwin_env,cbwin_snap_env,gmem_placed,cbwin_retire_*, and snapshot/patch caches.runtime/nvn/vulkan/cbwin_snap.h,exec.c):CbwinBaseCache(16-set x 4-way associative, FIFO/RR per set), keyed by(vk_pending_seq() + (cbwin_retire_gen << 40), addr, size, win_lo, win_hi).CMD_UPDATE_UNIFORM_BUFFER(guarded byif (cbwin_wanted())) callscbwin_invalidate_outside()so updates strictly inside[win_lo, win_hi)keep the shared base snapshot while outside or straddling writes invalidate it.cbwinGPUs (cbwin_retire_*): Keeps upstreamgcopy_gen,guest_copy(), andga_load_copy()untouched without seqlock ops; isolateswb_apply()/gcopy_retire()tracking behind#ifdef __ANDROID__cbwin_retire_writing/cbwin_retire_genguarded by relaxedcbwin_retire_armed(armed oncbwin_bind()), plusmemory_order_relaxedongmem_placed/gcopy_modehot reads inubo_direct,cbwin_wanted,cbwin_bind,vcache_lookup,guest_direct,dispatch_compute, anddraw_.CBPpatch-buffer dedupe (CbpatchDedupe,stage_set(),draw_()):cbpatch_active_bytes()(16bytes whenm[0] == 0,16 + min(m[2], 64) * 16bytes otherwise) instead of hashing/copying all1040bytes onup_fixretries or small windows while preserving1040-byteVkDescriptorBufferInfosizing.tools/test_cbwin_snap.c,tools/test_rt_load_upload.c,tools/test_android_runtime.ps1):test_cbwin_snap.cunit tests (hit/miss, inside/outside/straddling/inverted invalidation, epoch invalidation, 4-way collision & in-place overwrite,cbpatch_active_bytesclamping, NULL/bounds checks).test_rt_load_upload.cSection 9 withcbwin_bind,CMD_UPDATE_UNIFORM_BUFFERin/out,CMD_COPY_BUFFER_TO_BUFFER, activecbwin_write_begin/endseqlock, 2-threadpthreadseqlock contention stress (4,000writer iterations,0torn reads),gcopy_retire()cache drop,#453LARECOMP_CBWIN_SNAPSHOT=0&AB("cbsnap")==1, Turnip short-circuit negative control (mock_mali_calls == 0),ok_non_cbwin_zero_churnverifyingwb_apply()+gcopy_retire()perform zero seqlock writes when!cbwin_retire_armed, non-Mali negative control,LARECOMP_CB_WINDOW=0, andvk_exec_reset().Rollback / Zero-Overhead Guarantee
LARECOMP_CB_WINDOW=0reverts Mali to legacy full-UBO copy behavior (patched 0).LARECOMP_CBWIN_SNAPSHOT=0preserves#453uncached copy path.cbwingcopy_modebuilds,!gmem_placed && gcopy_mode/!cbwin_retire_armedshort-circuit cleanly with0gcopy_gen/cbwin_retire_*seqlock churn (ok_non_cbwin_zero_churn,mock_mali_calls == 0).Isolated On-Device Verification (Exact
v0.4.8-betaCommitadbafd6)Environment: Galaxy Tab S11 (
SM-X730), Android 16,Mali-G925-Immortalis MC12(vendor 0x13b5,device 0xd8300010,driver-id 9,v1.r49p1-03bet0.f8a98b506b89b21c80a508d70abfcb3f), BOTW1.9.0, upstream base2b71a10(v0.4.8-beta,#508included), commitadbafd6(debug APK95908e24580c), USB-powered (plugged: 2, no off-charger power claims made).Verbatim
[cbuf]telemetry proof (30 FPS,LARECOMP_LOG_CBUF_BYTES=1, 2s log intervals):plateau(LARECOMP_CB_WINDOW=0):[cbuf] fixed 1152458 x 0.4 KB, dynamic 51371 x 17.6 KB; copied 912.4 MB; in place, patched 0(912.4–912.7 MB/2s)plateau(default ON):[cbuf] fixed 1151312 x 0.4 KB, dynamic 37916 x 1.4 KB; copied 83.7 MB; in place, patched 13320(83.5–83.9 MB/2s, -90.8%)zora-plaza(LARECOMP_CB_WINDOW=0):[cbuf] fixed 1010673 x 0.4 KB, dynamic 51549 x 17.8 KB; copied 962.2 MB; in place, patched 0(961.5–962.2 MB/2s)zora-plaza(default ON):[cbuf] fixed 1013700 x 0.4 KB, dynamic 38266 x 1.8 KB; copied 138.0 MB; in place, patched 13320(136.6–140.6 MB/2s, -85.7%)1. Official 30 FPS
benchmark.cA/B (warmup_s=8,calm_s=3,window_s=10, 301 frames/scene)plateauLARECOMP_CB_WINDOW=0)30.0029.4833.89 ms26.86/32.27 ms17.51/20.75 ms6.48 msplateau30.0029.4433.91 ms27.05/33.61 ms17.87/20.62 ms6.29 mszora-plazaLARECOMP_CB_WINDOW=0)30.0029.4933.88 ms27.50/33.36 ms18.56/21.34 ms5.84 mszora-plaza30.0029.2134.04 ms27.31/33.12 ms18.66/21.19 ms6.02 ms2. Uncapped 60 FPS Steady-Camera
[vk]A/B (LARECOMP_FPS=60, 2s[vk]intervals with0 skipped, compile 0duringS_WARMUP)(Note: upstream
benchmark.c:810exits non-30 FPS targets atS_WINDOW, so these metrics come from steady[vk]2s intervals beforeS_WINDOWexit;#508dispatch chaining is active in both Off and On.)max ms[vk]Upload / 2splateau545.80/45.0630 ms1398.70 MBplateau645.60/45.3333 ms168.70 MBzora-plaza743.50/43.7029 ms1456.60 MBzora-plaza743.40/43.3330 ms264.59 MBVerbatim
[vk]sample (plateau):[vk] t=30.8 frame 1057 48.1 fps max 30ms level - (386733 draws, 0 skipped, 15646 passes, 1652 dispatches (631 chained), 787 flushes, wait 15ms, compile 0 (waited 0ms), fbcopy 970 (read 18340, breaks 0), upload 1491.5MB, ...)[vk] t=30.9 frame 1061 48.1 fps max 25ms level - (386500 draws, 0 skipped, 15495 passes, 1530 dispatches (657 chained), 767 flushes, wait 16ms, compile 0 (waited 0ms), fbcopy 970 (read 18281, breaks 0), upload 176.6MB, ...)Visual Check (
SM-X730: Great Plateau Terrain & Zora's Domain Water withcbwinActive,adbafd6)Additional Unit & Build Verification (
adbafd6)cc -std=c11 -Wall -Wextra -Werror -O2 tools/test_cbwin_snap.c->PASS.NDK 30):test_vulkan_compat.py(16 PASS),test_vulkan_startup.py(33 PASS),test_shader_cache.py(17 PASS),test_soft_linear.py(23 + 3 + 203 PASS).SM-X730,tools/test_android_runtime.ps1):8/8 PASS.:app:assembleDebug --no-daemon->BUILD SUCCESSFUL (13s);-U__ANDROID__has0new diagnostics.Tested vs Untested GPU Matrix
SM-X730,r49p1)v0.4.8-betacommitadbafd6:30 FPSA/B +[cbuf]telemetry +60 FPSsteady[vk]A/B + Plateau & Zora screenshots + 8/8 Bionicgmem_placed) & Qualcomm stockvk_driver_is_mali()(mock_mali_calls == 0) & skipscbwin_retire_*(ok_non_cbwin_zero_churn); preserves#453behavior< r49/ DesktopLARECOMP_CB_WINDOW=0/LARECOMP_CBWIN_SNAPSHOT=0; desktop retains#453behavior