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
6 changes: 3 additions & 3 deletions ltw/src/main/tinywrapper/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ LOCAL_SRC_FILES := glsl_optimizer/src/code/ir_print_glsl_visitor.cpp \
glsl_optimizer/src/mesa/main/errors.c \
glsl_optimizer/src/mesa/main/extensions_table.c \
glsl_optimizer/src/mesa/main/imports.c \
glsl_optimizer/src/mesa/program/symbol_table.c \
glsl_optimizer/src/mesa/program/prog_parameter.c \
glsl_optimizer/src/program/symbol_table.c \
glsl_optimizer/src/program/prog_parameter.c \
glsl_optimizer/src/compiler/glsl/gl_nir_link_uniform_initializers.c \
glsl_optimizer/src/compiler/glsl/gl_nir_lower_packed_varyings.c \
glsl_optimizer/src/compiler/glsl/gl_nir_opt_dead_builtin_varyings.c \
Expand Down Expand Up @@ -414,5 +414,5 @@ LOCAL_STATIC_LIBRARIES := glsl_optimizer
LOCAL_LDFLAGS := -ffunction-sections -fdata-sections -Wl,--version-script=$(LOCAL_PATH)/version.script
# Comment for debugging
LOCAL_LDFLAGS += -flto -Wl,--gc-sections
LOCAL_LDLIBS := -llog
LOCAL_LDLIBS := -llog -ldl
include $(BUILD_SHARED_LIBRARY)
28 changes: 21 additions & 7 deletions ltw/src/main/tinywrapper/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ INTERNAL eglMustCastToProperFunctionPointerType (*host_eglGetProcAddress)(const
INTERNAL es3_functions_t es3_functions;

static void error_sysegl() {
printf("LTWInit: Failed to load system EGL: %s\n", dlerror());
printf("LTWInit: Failed to load EGL: %s\n", dlerror());
abort();
}

Expand All @@ -39,16 +39,30 @@ static void init_es3_proc() {
}

__attribute__((constructor, used)) void proc_init(){
// ANGLE-first strategy for Vulkan rendering
const char* angleEglPath = "libEGL_angle.so";
const char* systemEglPath = "libEGL.so";
const char* eglPath = getenv("LIBGL_EGL") != NULL ? getenv("LIBGL_EGL") : systemEglPath;
const char* eglPath = NULL;

// Priority 1: Environment override (testing only)
if(getenv("LIBGL_EGL") != NULL) {
eglPath = getenv("LIBGL_EGL");
printf("LTWInit: Using LIBGL_EGL override: %s\n", eglPath);
}
// Priority 2: ANGLE (LD_LIBRARY_PATH must be set by launcher)
else {
eglPath = angleEglPath;
}

int flags = RTLD_LAZY | RTLD_LOCAL;
void* eglHandle = dlopen(eglPath, flags);
if(eglHandle == NULL){
printf("LTWInit: failed loading custom libEGL, using default\n");
eglHandle = dlopen(systemEglPath, flags);
if(eglHandle == NULL)
error_sysegl();

if(eglHandle == NULL) {
printf("LTWInit: FATAL - Failed to load %s: %s\n", eglPath, dlerror());
printf("LTWInit: Ensure launcher called setLdLibraryPath(nativedir) before loading LTW\n");
error_sysegl();
}

host_eglGetProcAddress = dlsym(eglHandle, "eglGetProcAddress");
if(host_eglGetProcAddress == NULL) error_sysegl();
init_egl();
Expand Down