Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class MojoExec {
public static native boolean prepareEgl(String eglPath, boolean useBypass, boolean useGles, int glesVersion);
public static native void setDisplayParams(int width, int height, float hz);
public static native void setUseTurnip(boolean enable);
public static native void overrideTurnipLibrary(String turnipLibrary);
public static native void preloadVulkan();
public static native void setNativeLibraryDir(String dir);
}
14 changes: 12 additions & 2 deletions vulkan_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <mojoexec.h>

static bool turnip_enabled = false;
static char* library_override = NULL;

#ifdef ENABLE_TURNIP_LOADER
bool load_turnip_vulkan() {
Expand All @@ -23,9 +24,10 @@ bool load_turnip_vulkan() {
if(!linker_ns_load(mojoexec_native_dir)) return NULL;
void* linkerhook = linker_ns_dlopen("liblinkerhook.so", RTLD_LOCAL | RTLD_NOW);
if(linkerhook == NULL) return NULL;
void* turnip_driver_handle = linker_ns_dlopen("libvulkan_freedreno.so", RTLD_LOCAL | RTLD_NOW);
char* turnip_library = library_override ? library_override : "libvulkan_freedreno.so";
void* turnip_driver_handle = linker_ns_dlopen(turnip_library, RTLD_LOCAL | RTLD_NOW);
if(turnip_driver_handle == NULL) {
printf("MojoExec: Failed to load Turnip!\n%s\n", dlerror());
printf("MojoExec: Failed to load Turnip (%s)!\n%s\n", turnip_library, dlerror());
goto fail_l;
}

Expand Down Expand Up @@ -79,4 +81,12 @@ Java_git_artdeell_mojoexec_MojoExec_preloadVulkan(JNIEnv *env, jclass clazz) {
printf("MojoExec: Failed to preload Turnip!\n");
}
#endif
}

JNIEXPORT void JNICALL
Java_git_artdeell_mojoexec_MojoExec_overrideTurnipLibrary(JNIEnv *env, jclass clazz, jstring turnip_library){
char* c_str = (*env)->GetStringUTF8Chars(env, turnip_library, NULL);
if(!c_str) return;
library_override = strdup(c_str);
(*env)->ReleaseStringUTFChars(env, turnip_library, c_str);
}