Repository navigation
Conversation
|
The deferred clears are careful (applied before every reader, CPU write-back targets excluded, exact matches only), and the measured cycles are a good start. A few correctness gaps first:
Also: it conflicts with main in |
4636313 to
40ccf68
Compare
|
All 5 review points and the merge conflict on
|
…cjr#586 updates, PR mamcjr#582 close, SM-X730 restore [skip ci]
Summary
Reduces redundant tile writebacks, reloads, and command-buffer flushes on ARM Mali proprietary
r49+GPUs (!has_bc && has_astc_ldr && have_driver_props && driverID == VK_DRIVER_ID_ARM_PROPRIETARY && vk_arm_driver_major(driverInfo) >= 49, tested onMali-G925-Immortalis MC12 v1.r49p1-03bet0) via two independently toggleable render-pass optimizations:Deferred full-surface clears &
3 msmid-pass split suppression (LARECOMP_MALI_RP_MERGE_OPT)CMD_CLEAR_COLOR,CMD_CLEAR_DEPTH_STENCIL, andCMD_CLEAR_TEXTUREclears (MaliDeferredClearTable, 64 slots + 64-bit Bloom filter) without splitting an openVkRenderPassunless the cleared subresource conflicts with active pass attachments or draws reading from it (MaliActivePassImgs).VK_ATTACHMENT_LOAD_OP_CLEARwhen the target pass begins (marking those attachments inpass_writtenso subsequent in-place#549reads triggerresolve_feedback()cleanly), and materializes any remaining unconsumed clears cleanly (bracketed byvk_full_barrier(), creating a temporaryVkImageViewfrom the underlying image if the cached view was evicted, and removing records on destroy/replace viavk_mali_rp_forget_image()) before texture/alias reads, buffer copies, compute dispatches, shader dumps,vk_present_now(), andvk_submit_extra().#296unowned write-back safety by verifyingb && b->image && b->gpu_ownedand rejectingwb_eligible,samples > 1,depth > 1, 3D,bc_vf, andastc_bwtargets before mutating backend state.3 mstimer split insplit_long_pass()whenmali_rp_merge_optis active (so large tile-based passes like G-buffer avoid unnecessary store/reload roundtrips), while still honoring an explicitLARECOMP_VK_SPLIT_USenv override and an8192-draw safety cap.VK_ATTACHMENT_STORE_OP_NONElookahead (LARECOMP_MALI_RP_STORE_OPT, requires Vulkan>= 1.3)g_mali_fs_meta) and inspects onlyVK_ATTACHMENT_LOAD_OP_LOADattachments (cand_mask) ahead in the currentCmdRecpass (bounded at2048records, aligning early-stop checks with actualsplit_long_pass/gres_premerge/ non-inline boundaries).VK_ATTACHMENT_STORE_OP_NONE(viavk_mali_choose_store_op) exclusively toVK_ATTACHMENT_LOAD_OP_LOADcolor/depth/stencil attachments proven unwritten in that pass; if a later draw or clear writes to any attachment ing_mali_pass_store_none_mask,st.rt_dirty = truerestarts the render pass cleanly so a fresh look-ahead runs.< r49, desktop (!__ANDROID__), or when disabled (g_vk.mali_rp_merge_opt == false/g_vk.mali_rp_store_opt == false).Gating, Defaults & Rollback Knobs
LARECOMP_MALI_RP_MERGE_OPT(0/1): defaults on only when__ANDROID__ && !has_bc && has_astc_ldr && have_driver_props && driverID == VK_DRIVER_ID_ARM_PROPRIETARY && vk_arm_driver_major(driverInfo) >= 49. SetLARECOMP_MALI_RP_MERGE_OPT=0to disable deferred clears +3 mssplit suppression, or=1to opt in on other!has_bc && has_astc_ldrdrivers.LARECOMP_MALI_RP_STORE_OPT(0/1): defaults on under the same ARM Malir49+gate plusapi >= VK_API_VERSION_1_3. SetLARECOMP_MALI_RP_STORE_OPT=0to keepVK_ATTACHMENT_STORE_OP_STOREeverywhere.Tested vs. Untested Matrix
SM-X730, Android 16 API 36,v1.r49p1-03bet0, Vulkan1.3.278, ClassicVkRenderPass)40ccf68(12/12Bionic units, 3-scene same-frame parity, 31.6-min continuous soak; pre-rebase46363133-arm A/B cycles)ARM Mali r49+ default)has_bc = true) & older Vulkan< 1.3GPUsmerge=0,store=0)!BC && ASTCGPUs (PanVK, PowerVR, Maleoon) & ARM Mali< r49LARECOMP_MALI_RP_*=1overrides)!__ANDROID__)-U__ANDROID__)false)Verification on Rebased Commit
40ccf68(SM-X730,v0.5.1-betaBaseda30d45)1. Startup Capability Proof (
defaults ON— both env vars unset)2. Same-Frame Visual Parity (
2560x1440, bilinear, isolated scratch on40ccf68)Comparison between baseline (
LARECOMP_MALI_RP_MERGE_OPT=0,LARECOMP_MALI_RP_STORE_OPT=0) and defaults ON (both unset) across fixed camera/time-of-day scripted launches:0..255)% <= 4INVARIANT/DEAD VIEW/VUID)dye, static indoor lighting)frame_00784vsframe_00780zora, water/NPC/UI)frame_00784vsframe_00781plat, open grass/cliffs)frame_00780vsframe_00780luma 107.4 vs 127.3, matching natural open-world boot variance); cliffs, pine shadows, shrine gate, and HUD intact.Baseline A | Candidate B | 8x |A-B|)3. 31.6-Minute Continuous Stability Soak (
SM-X730,40ccf68, Defaults ON)Continuous idle-world soak in Zora's Domain (
75%->sgsr12560x1600,30 Hzcap,inplace_reads=1, isolated scratch):1898.8 sgame time (1890.0 spolled at15sintervals,43,714frames), single uninterrupted PID (30163),0crashes,0INVARIANT VIOLATION/DEAD VIEW/VUID-/VK_ERROR/WATCHDOGstalls,29.0 -> 30.4 °Cbattery temp,67/67saves intact afterward.t=300..1890ssteady window):transient ring: initialized once (memory type 0 (device-local host-visible )), flat atring 256 MB in 4fromt~30sthrought=1898.8s(command shadow pages 52,host command chunks 0,gpu mem 1440 MBflat).VmRSS:3897.8 MB(t=300s) ->3923.6 MB(900s) ->3930.4 MB(1500s) ->3934.2 MB(1890s, plateau across final18min).VmSize:45851.0 MB(t=300s) ->45874.1 MB(t=1890s)./proc/30163/maps:8860(t=300s) ->9233(1500s) ->9248(1890s,+15across the final390s/ ~9,100 frames).Pre-Rebase Cycle Benchmark (Earlier Commit
4636313,SM-X730Mali-G925 MC12)Measured at
75%preset (1920x1200 -> SGSR1 2560x1600),30 Hzcap,10ssteady window after warmup:arm0_off:LARECOMP_MALI_RP_MERGE_OPT=0,LARECOMP_MALI_RP_STORE_OPT=0arm1_merge:LARECOMP_MALI_RP_MERGE_OPT=1,LARECOMP_MALI_RP_STORE_OPT=0arm2_both:LARECOMP_MALI_RP_MERGE_OPT=1,LARECOMP_MALI_RP_STORE_OPT=11% lowgpu p50 / p95(ms)rnd p50 / p95(ms)MCyc/framemed / meanFlushes/2s)plateauarm0_off(0/0)28.95 / 34.1019.12 / 21.441143.9 / 1143.933.11 / 33.119949(558)plateauarm1_merge(1/0)27.47 / 33.1418.12 / 21.111118.4 / 1117.230.73 / 30.69(-7.3%)8634(435)plateauarm2_both(1/1)27.52 / 33.2517.02 / 19.751118.0 / 1098.130.77 / 30.22(-8.7%)8556(416)zora-plazaarm0_off(0/0)30.55 / 35.0918.99 / 21.401324.6 / 1322.240.46 / 40.3911318(584)zora-plazaarm1_merge(1/0)29.33 / 34.4718.80 / 21.381325.8 / 1323.038.89 / 38.80(-3.9%)10357(549)zora-plazaarm2_both(1/1)29.21 / 34.7719.31 / 22.011325.8 / 1315.138.73 / 38.42(-4.9%)10187(553)kakariko-dayarm0_off(0/0)30.41 / 34.8721.17 / 23.861325.4 / 1334.440.31 / 40.5810679(595)kakariko-dayarm1_merge(1/0)29.63 / 34.7720.43 / 23.481325.4 / 1310.439.27 / 38.83(-4.3%)9896(491)kakariko-dayarm2_both(1/1)29.80 / 34.9219.36 / 22.201326.1 / 1326.139.52 / 39.52(-2.6%)9987(488)Note on
MCyc/frame: Dimensity DVFS targets ~28–30 ms per 30 Hz frame by stepping clocks down (1326 -> 1144 -> 1118 MHz), soMCyc/frame = gpu_p50_ms * gpu_mhz / 1000tracks true GPU workload reduction across clock steps.Automated Tests (
40ccf68)-std=c11 -Wall -Wextra -Werror -O2 -U__ANDROID__):tools/test_mali_rp_opt.c— PASS.aarch64-linux-android30syntax & link checks (device.c,exec.c,textures.c,tools/test_rt_load_upload.c): PASS (0errors).tools/test_android_runtime.ps1+test_mali_rp_optonSM-X730): 12 / 12 PASS (rc=0,0mock validation hazards) —test_kernel_affinity,test_bc_shadow,test_buffer_copy,test_mali_rp_default,test_mali_rp_opt,test_rt_load_upload(including Case 10mali_rpintegration tests),test_cbwin_snap,test_nvn_lifetime,test_object_cache,test_benchmark_trace,test_bc_parallel,test_motion.