#282
Vulkan: rewrite fragment shuffles before inlining on drivers without fragment subgroups (Adreno 650 follow-up, #243)
Shared code: this changes the Vulkan engine (dm/gfx/vulkan/engine), which Android and HarmonyOS both run (iOS does not use it). Only drivers without fragment-stage subgroups behave differently: the order of two load-time rewrites, and the inlining default on Qualcomm. Elsewhere nothing changes. Tested on Android only (Redmi K50 Ultra, Adreno 730, with the switch that fakes such a driver).
Follow-up to #280 for #243, from @kieusonlam's test on a real Adreno 650 (Retroid Pocket 5, stock driver, stages=0x20) in #243. Neither gfx-inline setting boots there:
gfx-inline=1: helpers are inlined before the quad rewrite. The shuffles then sit in the entry function under divergent control flow, the quad pass rewrites none of them (calls=0 ... skip_control_flow=1..3), and the capability check aborts again.gfx-inline=0: the fragment fix works, but the fluid compute shader098a126f92bf533acrashes the driver's compiler (libllvm-qgl.so, addr 0x48). That's the same crash inlining fixes on the Adreno 750 family, and inlined it compiles.
Change
front_rewrites(xbg_game.cpp): on drivers without fragment subgroups, the quad rewrite and clean-up run before the inlining. Fragment shaders come out free of subgroup instructions whatevergfx-inlinesays, and the inlining then has nothing left to do for them. With fragment subgroups the order stays as it was. Both loaders use it, so the warm-up hands over the same modules.xbg_adreno_inline_default(xbg_adreno_policy.h): inlining is on by default for the Adreno 750–799 family as before, and for Qualcomm drivers without fragment subgroups. Other vendors (Maleoon, Mali, Xclipse) are unchanged. The markergfx-inlinestill wins.
Tests
dm/gfx/vulkan/engine/tests/adreno_policy_test.cpppasses with 7 new cases for the inlining default: 750 on; 650 or 730 without fragment subgroups on; 650 or 730 with them off; Mali and Xclipse off.- Offline, the Adreno 650 chain over all 6,931 shaders of the import pack, with the engine's own rewrite code and
spirv-optfor the inlining step (the same three passes): fragment shaders get relaxed quad + clean-up, then inlining; compute shaders get inlining, then warp32, then tidy. 0 shaders fail the capability check. No fragment shader still needs inlining after the clean-up. All 187 modules with subgroup use passspirv-val --target-env vulkan1.1, including the 5 compute shaders that are inlined and then go through warp32 (a combination no device ran by default before). - Redmi K50 Ultra (Adreno 730), debug APK and pack from this branch, camp, 3D scale held at 0.75, fixed seed:
- With
gfx-no-fragment-subgroups= 1, inlining comes on by default (inlined at load=1). No abort. 17 fragment shaders were rewritten before inlining (calls_rewritten> 0,stripped=4), and none of them was inlined.098a126f92bf533aand6a7a308d61928982were inlined, then warp32. Warm-up 392 built, 0 failed, 178 hits, 0 pipelines created during play, GPU 14.34 ms. - With the switch off:
inlined at load=0as before, same warm-up figures, GPU 14.38 ms. - The screenshots of the two runs differ only in animated content (0.35% of pixels by more than 24/255).
- With
- Full build: debug APK built in docker (NDK 29), no warnings.
Not covered
- No Adreno 650 here; @kieusonlam, could you try this branch on the RP5 with no
gfx-inlinemarker and nospv-override? Build both the APK and the import pack from this branch (the app accepts only a pack made from the same code), copy the newandroidfolder to the device, and let the app import it again. - Shaft455's Adreno 650 (driver
0x801f6000, #155) reported098afailing withVK_ERROR_UNKNOWNeven when inlined offline, so some 650 drivers may still lose the fluid effect (garbled smoke and fire). That would be a separate change.
🤖 Generated with Claude Code
Activity
0No activity yet.