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)
(cherry picked from commit d9c84afa8b)
This commit is contained in:
K11MCH1 authored and The412Banner committed 2026-10-25 23:09:14 +00:00
1 parent 3158933489
commit 8abb0b8e8c
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) {