fix(graphics): fall back from unsupported auto display drivers (#2356)

* fix(graphics): fall back from unsupported auto display drivers

* refactor(graphics): drop the unused Auto recommendation lookup

* fix(graphics): repair automatic display fallback build

* test(wayland): keep Vulkan caller harness linkable

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
This commit is contained in:
MaxsTechReviewandKurt Himebauch authored and GitHub committed 2026-11-15 10:13:06 -05:00
1 parent 2e64ae7575
commit 4e3eeea5e2
10 files changed
+57 -3

No files matched your search

@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <android/log.h>
#include <string.h>
#define TAG "DroidDeckWayland"
@@ -45,6 +46,13 @@ int vk_loader_open(const char *driver_path, const char *library_name,
return g_vk.CreateInstance ? 0 : -1;
}
void vk_loader_close(void) {
if (g_handle) dlclose(g_handle);
g_handle = NULL;
g_gip = NULL;
memset(&g_vk, 0, sizeof(g_vk));
}
PFN_vkGetInstanceProcAddr vk_loader_gipa(void) { return g_gip; }
void vk_loader_load_instance(VkInstance instance) {
+2 -1
View File
@@ -6,7 +6,7 @@
#define VK_GLOBAL_FUNCS(X) X(CreateInstance) X(EnumerateInstanceExtensionProperties)
#define VK_INSTANCE_FUNCS(X) \
X(EnumeratePhysicalDevices) X(GetPhysicalDeviceProperties) \
X(DestroyInstance) X(EnumeratePhysicalDevices) X(GetPhysicalDeviceProperties) \
X(GetPhysicalDeviceQueueFamilyProperties) X(GetPhysicalDeviceSurfaceSupportKHR) \
X(GetPhysicalDeviceSurfaceCapabilitiesKHR) X(GetPhysicalDeviceSurfaceFormatsKHR) \
X(CreateAndroidSurfaceKHR) X(DestroySurfaceKHR) X(CreateDevice) \
@@ -43,6 +43,7 @@ extern struct vk_api g_vk;
int vk_loader_open(const char *driver_path, const char *library_name,
const char *native_lib_dir);
void vk_loader_close(void);
void vk_loader_load_instance(VkInstance instance);
void vk_loader_load_device(VkDevice device);
PFN_vkGetInstanceProcAddr vk_loader_gipa(void);
@@ -46,6 +46,7 @@ struct vkp_image {
static ANativeWindow *g_window;
static int g_ahb_import;
static char *g_driver_path, *g_library_name, *g_native_lib_dir;
static int g_allow_driver_fallback;
static int g_dev_state;
static void device_lost(const char *where);
static const char *vk_result_name(VkResult r);
@@ -250,6 +251,8 @@ void vk_present_set_driver(const char *driver_path, const char *library_name,
g_native_lib_dir = native_lib_dir ? strdup(native_lib_dir) : NULL;
}
void vk_present_set_driver_fallback(int allow) { g_allow_driver_fallback = allow; }
static void reset_sync(void) {
VkSemaphoreCreateInfo semci = {.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO};
for (int k = 0; k < MAX_PRESENTS; k++) {
@@ -549,6 +552,18 @@ static int dev_init(void) {
uint32_t npd = 0;
g_vk.EnumeratePhysicalDevices(g_inst, &npd, NULL);
if (!npd) {
if (g_allow_driver_fallback && g_driver_path && g_library_name) {
LOGE("present: display driver exposed no physical devices; retrying the system Vulkan driver");
g_vk.DestroyInstance(g_inst, NULL);
g_inst = VK_NULL_HANDLE;
vk_loader_close();
free(g_driver_path); g_driver_path = NULL;
free(g_library_name); g_library_name = NULL;
g_allow_driver_fallback = 0;
g_colorspace_ext = 0;
g_dev_state = 0;
return dev_init();
}
LOGE("present: no physical devices"); g_dev_state = -1;
set_fault("the display driver exposed no GPU to the app");
return -1;
@@ -7,6 +7,7 @@
void vk_present_set_driver(const char *driver_path, const char *library_name,
const char *native_lib_dir);
void vk_present_set_driver_fallback(int allow);
void vk_present_set_window(ANativeWindow *window);
int vkp_apply_window_request(void);
@@ -254,12 +254,13 @@ static char *dup_jstr(JNIEnv *env, jstring s) {
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeStartWithSurface(
JNIEnv *env, jclass clazz, jobject surface, jstring xdgRuntimeDir,
jstring driverPath, jstring libraryName, jstring nativeLibDir) {
jstring driverPath, jstring libraryName, jstring nativeLibDir, jboolean allowDriverFallback) {
set_runtime_dir(env, xdgRuntimeDir);
char *dp = dup_jstr(env, driverPath);
char *ln = dup_jstr(env, libraryName);
char *nl = dup_jstr(env, nativeLibDir);
vk_present_set_driver(dp, ln, nl);
vk_present_set_driver_fallback(allowDriverFallback == JNI_TRUE);
free(dp); free(ln); free(nl);
if (surface) {
ANativeWindow *win = ANativeWindow_fromSurface(env, surface);
@@ -308,6 +308,12 @@ public final class TurnipDriver {
}
}
if (chosen != null && !chosen.isEmpty()) {
if (SessionPrefs.GPU_DRIVERS_AUTO.equals(SessionPrefs.INSTANCE.gpuDriverMode(context))
&& SessionPrefs.INSTANCE.gpuAutoInstalled(context).contains(chosen)
&& gpuDetector.get().getFamily() == GpuInfo.Family.A7XX_LOW) {
Log.i(TAG, "Auto-selected display driver does not cover Adreno 710/720/722; leaving the display driver to the system");
return null;
}
if (BUNDLED.contains(chosen)) {
Log.i(TAG, "driver pinned by the user: " + chosen);
return chosen;
@@ -344,6 +350,10 @@ public final class TurnipDriver {
Log.i(TAG, "not an Adreno GPU; leaving the display driver to the system");
return null;
}
if (gpu.getFamily() == GpuInfo.Family.A7XX_LOW) {
Log.i(TAG, "no bundled display driver covers Adreno 710/720/722; leaving the display driver to the system");
return null;
}
int model = gpu.getModel();
Log.i(TAG, "gpu model: " + (model == 0 ? "unknown" : model));
return chooseByModel(model, android.os.Build.VERSION.SDK_INT);
@@ -64,6 +64,7 @@ object CompositorHost {
com.droiddeck.launcher.gpu.TpUbwcHint.applyToProcess(context)
WaylandCompositor.nativeStartWithSurface(
surface, xdgRuntimeDir, driverPath, libraryName, nativeLibDir,
SessionPrefs.androidDriver(context).isEmpty(),
)
attached = surface
started = true
@@ -153,7 +153,7 @@ public final class WaylandCompositor {
public static native void nativeStartWithSurface(Surface surface, String xdgRuntimeDir,
String driverPath, String libraryName,
String nativeLibDir);
String nativeLibDir, boolean allowDriverFallback);
public static native void nativeSetSurface(Surface surface);
public static native boolean nativeWaitSurface(int timeoutMs);
@@ -57,7 +57,12 @@ class TurnipDriverAutoTest {
gpu(0, adreno = false) to "system",
gpu(0) to "turnip25.1.0",
gpu(650) to "turnip26.3.0-a6xx",
gpu(710) to "system",
gpu(720) to "system",
gpu(722) to "system",
gpu(730) to "turnip25.1.0",
gpu(740) to "turnip25.1.0",
gpu(750) to "turnip25.1.0",
gpu(850) to "turnip-sdk36",
)) {
var calls = 0
@@ -96,6 +101,17 @@ class TurnipDriverAutoTest {
assertEquals("test-pinned", TurnipDriver(context) { error("manual choice must precede detection") }.install())
}
@Test fun autoInstalledLowSevenDisplayDriverFallsBackToSystem() {
val context = RuntimeEnvironment.getApplication()
val dir = File(context.filesDir, "graphics_driver/test-pinned").apply { mkdirs() }
File(dir, "meta.json").writeText("""{"libraryName":"test.so"}""")
File(dir, "test.so").writeText("")
SessionPrefs.setAndroidDriver(context, "test-pinned")
SessionPrefs.setGpuAutoInstalled(context, setOf("test-pinned"))
assertEquals("system", TurnipDriver(context) { gpu(710) }.autoId())
}
private fun pin(library: String): String {
val context = RuntimeEnvironment.getApplication()
val dir = File(context.filesDir, "graphics_driver/test-pinned").apply { mkdirs() }