Repository navigation
nvn/vulkan: upload CPU-backed write-back render targets before LOAD_OP_LOAD (#296, #438) - #461
Conversation
|
Thanks, this is a great find. The root cause matches what we see: at level 0, I'd like to merge the #296 fix, but on its own. The PR is +1932 lines, and only about 200 of the ~440 runtime lines are the fix itself (the rest is the 1486-line mock test). Could you split it?
On testing: the A/B with raycasts is convincing, but it was done on a v0.4.3 diagnostic build. On this commit, the #296 route itself wasn't run, only fps and errors were checked. Once it's split and rebased onto current main (it merges cleanly onto 6113c61), I'll run the Little Twin River / Dueling Peaks route here on the Adreno 830 for 60+ min, and check #168 (leaves) and the terrain height tiles (8053dc8) against 0.4.5. A run of the same route on your Mali would be very welcome. |
0230d2f to
6f83821
Compare
…30 A/B + clock check, and 11-scene audit [skip ci]
|
Thanks for the detailed review. I have split and rebased
|
|
Thanks, this is exactly the split I asked for, and the extra pieces (the full-clear skip, |
6f83821 to
7077d56
Compare
|
Rebased cleanly onto current Re-verified after the rebase:
Noted on the |
…mamcjr#436/mamcjr#475 updated [skip ci]
|
Thanks! Tested here on the POCO F7 Ultra (Adreno 830, Turnip): a 16-scene benchmark tour across the map (16 loads) on main and on 7077d56 merged onto main gave the same results - every scene ran in both (one scene fails the harness check the same way in both), equal GPU times, no errors, normal images. Merging. |
mamcjr#480 starter-scene heights
Summary
Fixes #296 (also reported in #438) — resolves the underwater walking bug where Link falls through rivers and walks on the riverbed while water remains visually rendered above.
Following review feedback, this branch is narrowed strictly to the
#296/#438write-back render-target upload path (nonvn.h/objects.c/tegra.cchanges):LOAD_OP_LOAD(vk_tex_upload_for_load):0is bound without a whole-targetLOAD_OP_CLEAR(begin_pass(), or self-sampled inresolve_feedback()beforerenderer_mark_gpu_owned(t)),vk_tex_upload_for_load(t)callsupload_texture_impl(t, b, true).!b->uploaded) uploads vias->uploadbeforevk_submit_extra's existing barrier; previously sampled targets whose guest CPU pages changed while!gpu_owned(full_wgen/mainhash_full/watch_full) re-upload synchronously ons->mainaftervk_end_pass()with scopedVkImageMemoryBarrier2barriers, bypassing thechecked_frame/8-frame stagger / sparse sampling throttles.snap_okreuse on Turnip in-place feedback, invalidates snapshot caches only on non-in-place uploads, and removes staleNvnTexture *snapshot entries viavk_alias_texture_destroyed()/vk_alias_reset().undiscard()indestroy_image()and re-uploads inupload_texture_impl()sotex_discarded_bytesdecrements accurately with zero drift.Root Cause (#296 / #438)
NVNtexturedescriptors vianvnTextureInitializewithout callingnvnTextureFinalize. Clipmap passes keeptile=6/7pinned (owners > 0) whiletile=0..5drop toowners = 0and can be evicted (texture_release).64x64NVN 0x2awater height clipmap tile first as a level-0 render target (LOAD_OP_LOAD) to draw a partial border strip before any pass samples it.begin_pass()uploaded initial CPU contents only forlv > 0(vk_tex_upload_for_mips) while markingrenderer_mark_gpu_owned(t), leaving the untouched interior zeroed in the freshVkImage.wb_apply()atvk_end_pass()then wrote those zeros back over the guest clipmap tile, which cascading clipmap passes propagated intotile=6/7until Havok heightfield queries returnedhit = 0.Testing & Validation (rebased onto
main26da3fa, commit7077d56)SM-X730):tools/test_rt_load_upload.c:13/13PASS (0Vulkan sync hazards) — covers#296partialLOAD_OP_LOADwrite-back, full- vs partial-areaLOAD_OP_CLEAR, intra-submissionV1 -> V2upload ons->main(with page tracking on/off), stagger bypass, open-passresolve_feedback(), Turnip in-place + pointer-reuse cleanup, andundiscard()tex_discarded_bytesaccounting.main6113c61):10/13FAIL (rc=1).7/7suites intools/test_android_runtime.ps1(test_kernel_affinity,test_bc_shadow,test_buffer_copy,test_rt_load_upload,test_nvn_lifetime,test_object_cache,test_benchmark_trace):PASS(rc=0).test_vulkan_compat.py(16checks),test_vulkan_startup.py(33checks), and./gradlew :app:assembleDebug(JDK 17):PASS.SM-X730,Mali-G925-Immortalis MC12,LARECOMP_NATIVE=1, Dueling Peaks Stable):#461(6f83821, identical runtime logic before rebase onto26da3fa):93write-backs logged (64x64 f0x2a,64x64 f0x25,192x192 f0x6,1x1 f0x25/2e,85x20/120x23 f0x1),fbcopy 540 (breaks 0),30.0 fps(max 35ms),0errors. (Controlled#296underwater route telemetry earlier also verified24/24river raycastshit=1vs17/17hit=0without the fix.)