Turn off the compat layer's image-bounds rewrite in Qualcomm sessions

VK_LAYER_HYBRIS_compat enables a Mali+DXVK workaround by default that
replaces the zero operand of the next OpSelect after any image sample or
fetch. On Adreno it collapses DXVK's comparison selects to constants,
which turned Sparking Zero's main-menu scene red.

(cherry picked from commit 8962b4f6f8c6d46178596dcfb02f98543135744d)
This commit is contained in:
K11MCH1 committed 2026-10-25 02:11:20 +09:00
1 parent d24b824f25
commit d9c84afa8b
3 files changed
+24 -3

No files matched your search

@@ -83,14 +83,20 @@ object QualcommSystemDriver {
"The selected Qualcomm AdrenoTools package is missing or incompatible"
}
val icd = prepare(context)
val dir = icd.parentFile!!
val source = if (id == ID) label() else QualcommDriverPackage.label(context, id)
android.util.Log.i("QualcommSystemDriver", "$source; Android mounts: ${mounts(context, id).joinToString()}")
environment.addAll(listOf(
environment.addAll(sessionEnvironment(icd, id))
}
internal fun sessionEnvironment(icd: File, id: String): List<String> {
val dir = icd.parentFile!!
return listOf(
"VK_DRIVER_FILES=${icd.path}", "VK_ICD_FILENAMES=${icd.path}",
"HYBRIS_ANDROID_SDK_VERSION=${Build.VERSION.SDK_INT}", "HYBRIS_VULKAN_HAL=$HAL",
"HYBRIS_LINKER_DIR=${File(dir, "lib/libhybris/linker").path}",
"HYBRIS_LD_LIBRARY_PATH=/system/lib64:/system_ext/lib64:/vendor/lib64/egl:/vendor/lib64/hw:/vendor/lib64",
// The compat layer's Mali-only image-bounds pass rewrites unrelated OpSelects; DXVK comparisons become constants on Adreno.
"HYBRIS_VULKAN_COMPAT_IMAGE_BOUNDS=0",
"DROIDDECK_SYSTEM_QUALCOMM=1", "BL_GAMESCOPE_BACKEND=sdl",
"DROIDDECK_QUALCOMM_DRIVER=$id",
"BL_GAMESCOPE_BINARY=${File(dir, "bin/gamescope").path}",
@@ -99,7 +105,7 @@ object QualcommSystemDriver {
"VK_LAYER_PATH=${File(dir, "shaders").path}",
"VK_INSTANCE_LAYERS=VK_LAYER_DROIDDECK_qualcomm_shaders",
"PATH=${File(dir, "bin").path}:/usr/local/bin:/usr/bin:/bin",
))
)
}
private fun copyAssets(context: Context, path: String, destination: File) {
@@ -74,6 +74,15 @@ class QualcommDriverPackageTest {
assertEquals("The selected Qualcomm AdrenoTools package is missing or incompatible", error.message)
}
@Test fun qualcommSessionsTurnOffTheCompatLayerImageBoundsRewrite() {
val icd = File(context.filesDir, "qualcomm-system/bridge/icd.json")
val environment = QualcommSystemDriver.sessionEnvironment(icd, runtimeId)
assertTrue("HYBRIS_VULKAN_COMPAT_IMAGE_BOUNDS=0" in environment)
assertEquals(1, environment.count { it.startsWith("HYBRIS_VULKAN_COMPAT_IMAGE_BOUNDS=") })
assertTrue("VK_DRIVER_FILES=${icd.path}" in environment)
assertTrue("DROIDDECK_QUALCOMM_DRIVER=$runtimeId" in environment)
}
@Test fun aPhoneWithoutTheQualcommDriverReportsTheSystemDriverUnavailable() {
assertThrows(QualcommSystemDriver.Unavailable::class.java) { QualcommSystemDriver.prepare(context) }
assertThrows(QualcommSystemDriver.Unavailable::class.java) {
+6
View File
@@ -92,6 +92,12 @@ The Qualcomm HAL has DMA-BUF export but no `VK_EXT_image_drm_format_modifier`, a
Verification on 2026-10-24 used the RedMagic 11 Pro, Adreno 840 and the imported v891.7 driver at 1590x720. `vkcube` (600 frames, uncapped mailbox) went from 131.5 to 198.0 fps; its own CPU time fell from 1.15 s to 0.23 s, Xwayland from 1.64 s to 0.69 s and Gamescope from 6.88 s to 4.00 s. DRAGON BALL: Sparking! ZERO at 60 fps was launched from the same installed APK after a 60-second Steam settle, with only `BL_QUALCOMM_SHM` toggled, and sampled over the same 12-second startup window: Gamescope used 0.35 cores against 0.43 and 0.44 over two shared-memory runs, Xwayland 0.14 against 0.20, and the game 1.28 against 1.21 and 1.22. Average GPU load ranged from 5% to 13% across these runs and does not separate the paths at this phase. The startup logos rendered correctly and the performance overlay hooked DXVK directly. Gamescope's remaining extra cost comes from its SDL backend, the nested-swapchain copy and bridged Vulkan calls. `vkcube` in FIFO mode presented 169.5 fps against a 144 Hz output, so FIFO pacing through this path still needs checking. Native Linux games are not covered by the Proton wrapper.
## Compat-layer image-bounds rewrite
Qualcomm sessions set `HYBRIS_VULKAN_COMPAT_IMAGE_BOUNDS=0`. The bridge's `VK_LAYER_HYBRIS_compat` enables this pass by default, although it ports a Mali+DXVK workaround (Vortek's `removeImageBoundCheck`). After any `OpSampledImage` or `OpImageFetch`, it replaces the zero false operand of the next `OpSelect` with its true operand without checking that the select uses the image result. DXVK writes HLSL comparisons and `step()` as `select(cond, 1.0, 0.0)`, so those collapse to the constant `1.0`.
On RedMagic 11 Pro/Adreno 840 with v891.7, DRAGON BALL: Sparking! ZERO rendered its main-menu scene with a red cast. Replaying the pass over the 479 shaders DXVK compiled up to that menu rewrote 112 of them at 205 selects; 148 of those selects do not depend on any image read. The same scene rendered correctly with only this switch set to `0`, and with every compat shader rewrite disabled. Other compat passes keep their defaults. Evidence is under ignored `build/research/sparking-zero/red2-*`.
## APK packaging
Prepare the normal Linux runtime inputs and all five published add-on packs before compiling. Every APK must support a fresh installation; installed-device runtime reuse is prohibited by `AGENTS.md` and rejected by Gradle.