Skip to content
Draft
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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2016eba00f043842122d7aecb9410cf9371a7693
2e6a5441ad057039d002e6e35ebc6f1d7bd9a7d0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d5fc862f0eba62565dee5b8e511544573c281ec1
d26e5744eeccf6b7d4d214f2b555886a04b62012
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5aeae791eead9c6c47670c0886d77b1b185947fd
63ed92b780a5b172c911866b85816734982eb131
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f090d130b1b02def937f26cc62c38ef429ed7b52
8fc4f7410f7ff1ebea0d604f69d13531814650ca
21 changes: 17 additions & 4 deletions app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
Expand Down Expand Up @@ -809,11 +810,23 @@ public static String getClientClasspath(String version) {
}
public static String generateLaunchClasspath(JMinecraftVersionList.Version info, String actualname) {
StringBuilder launchClasspath = new StringBuilder(); //versnDir + "/" + version + "/" + version + ".jar:";
String lwjgl3Folder = new File(Tools.DIR_GAME_HOME, "lwjgl3").getAbsolutePath();
String lwjgl3File = lwjgl3Folder + "/lwjgl-glfw-classes.jar";
String lwjglxFile = lwjgl3Folder + "/lwjglx-classes.jar";
File lwjgl3Folder = new File(Tools.DIR_GAME_HOME, "lwjgl3");
String lwjgl3Merged = lwjgl3Folder.getAbsolutePath() + "/lwjgl-glfw-classes.jar";
String lwjglxFile = lwjgl3Folder + "/lwjgl-lwjglx.jar";

launchClasspath.append(lwjgl3Merged).append(":");

File[] lwjglModules = lwjgl3Folder.listFiles(pathname ->
pathname.getName().endsWith(".jar") &&
// Exclude our two special jars which goes first and last
!pathname.getName().endsWith("glfw-classes.jar") &&
!pathname.getName().endsWith("lwjglx.jar"));

if (lwjglModules != null) {
for (File lwjglModule : lwjglModules)
launchClasspath.append(lwjglModule.getAbsolutePath()).append(":");
} else Log.e("generateLaunchClasspath", "lwjgl modules are missing from components!");

launchClasspath.append(lwjgl3File).append(":");
launchClasspath.append(getLibClasspath(info)).append(":");
launchClasspath.append(getClientClasspath(actualname));
if (!isLwjgl3) launchClasspath.append(":").append(lwjglxFile);
Expand Down
3 changes: 2 additions & 1 deletion app_pojavlauncher/src/main/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ LOCAL_SRC_FILES := \
jre_launcher.c \
utils.c \
stdio_is.c \
driver_helper/nsbypass.c
driver_helper/nsbypass.c \
glfw_vulkan_bridge.c

ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
LOCAL_CFLAGS += -DADRENO_POSSIBLE
Expand Down
117 changes: 117 additions & 0 deletions app_pojavlauncher/src/main/jni/glfw_vulkan_bridge.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#include <jni.h>
#include <assert.h>
#include <dlfcn.h>

#include <stdbool.h>

#include <vulkan/vulkan.h>
#include <vulkan/vulkan_android.h>
#include <pthread.h>
#include <stdlib.h>
#include "log.h"
#include "environ/environ.h"

// This means that the function is an external API and that it will be used
#define EXTERNAL_API __attribute__((used))

typedef struct VulkanFuncs {
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
} VulkanFuncs;

static VulkanFuncs g_vulkanFuncs = {0};
static void* g_vulkanLib = NULL;

static bool loadVulkanLib() {
g_vulkanLib = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
if (!g_vulkanLib) {
LOGE("Using Vulkan is only possible on Android 7 and above!");
return false;
}
return true;
}

static VulkanFuncs* initVulkanFuncs(VkInstance instance) {
if (!loadVulkanLib()) abort();

if (!g_vulkanFuncs.vkGetInstanceProcAddr)
g_vulkanFuncs.vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(g_vulkanLib, "vkGetInstanceProcAddr");
if (!g_vulkanFuncs.vkGetInstanceProcAddr) {
LOGE("Failed to dlsym vkGetInstanceProcAddr from libvulkan.so");
abort();
}

if (!g_vulkanFuncs.vkCreateAndroidSurfaceKHR && g_vulkanFuncs.vkGetInstanceProcAddr)
g_vulkanFuncs.vkCreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)g_vulkanFuncs.vkGetInstanceProcAddr(instance, "vkCreateAndroidSurfaceKHR");

if (!g_vulkanFuncs.vkCreateAndroidSurfaceKHR) {
LOGE("Failed to vkGetInstanceProcAddr vkCreateAndroidSurfaceKHR");
abort();
}

return &g_vulkanFuncs;
}


#define GLFW_TRUE 1
#define GLFW_FALSE 0

EXTERNAL_API void pojavInitVulkanLoader(long loader){}

EXTERNAL_API int pojavVulkanSupported() {
if (!loadVulkanLib()) return GLFW_FALSE;
return GLFW_TRUE;
}

EXTERNAL_API const char** pojavGetRequiredInstanceExtensions(uint32_t* count) {
assert(count != NULL);
*count = 0;

static const char* extensions[] = {
"VK_KHR_surface",
"VK_KHR_android_surface"
};

*count = 2; // Because there's two extensions.
return extensions;
}

EXTERNAL_API void* pojavGetInstanceProcAddress(VkInstance instance, const char* procname){
VulkanFuncs* funcs = initVulkanFuncs(instance);
return funcs->vkGetInstanceProcAddr(instance, procname);
}

EXTERNAL_API bool pojavGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, int queuefamily){
return GLFW_TRUE;
}

EXTERNAL_API int pojavCreateWindowSurface(VkInstance instance, void* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface) {
VulkanFuncs* funcs = initVulkanFuncs(instance);
VkAndroidSurfaceCreateInfoKHR createInfo = {0};
createInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
createInfo.window = pojav_environ->pojavWindow;
createInfo.pNext = NULL;
createInfo.flags = 0;

VkResult result = funcs->vkCreateAndroidSurfaceKHR(instance, &createInfo, NULL, surface);
if (result != VK_SUCCESS) {
switch (result) {
case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
LOGE("vkCreateAndroidSurfaceKHR failed! VK_ERROR_NATIVE_WINDOW_IN_USE_KHR");
break;
case VK_ERROR_OUT_OF_HOST_MEMORY:
LOGE("vkCreateAndroidSurfaceKHR failed! VK_ERROR_OUT_OF_HOST_MEMORY");
break;
case VK_ERROR_OUT_OF_DEVICE_MEMORY:
LOGE("vkCreateAndroidSurfaceKHR failed! VK_ERROR_OUT_OF_DEVICE_MEMORY");
break;
case VK_ERROR_UNKNOWN:
LOGE("vkCreateAndroidSurfaceKHR failed! VK_ERROR_UNKNOWN");
break;
case VK_ERROR_VALIDATION_FAILED_EXT:
LOGE("vkCreateAndroidSurfaceKHR failed! VK_ERROR_VALIDATION_FAILED_EXT");
break;
}
}
return result;
}
39 changes: 24 additions & 15 deletions jre_lwjgl3glfw/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ group = 'org.lwjgl.glfw'
configurations.default.setCanBeResolved(true)

jar {
String lwjglxJarName = "lwjgl-lwjglx.jar" // Name of the jar with LWJGLX (LWJGL2 Compatibility) Classes
String lwjglxFinalJarName = "lwjglx-classes.jar" // What lwjglxJarName is renamed to
// Modules to copy over to the components directory instead of patching and merging
String[] excludedModules = ["lwjgl-lwjglx.jar"]

duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveBaseName.set("lwjgl-glfw-classes")
destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/lwjgl3/"))
Expand All @@ -24,34 +25,42 @@ jar {
// Ensure that the core lwjgl jar is processed first so duplicates in META-INF from other classes
// are ignored. This avoids InvalidModuleDescriptorException due to say, using the module-info.class
// from lwjgl-jemalloc.
def files = configurations.default.findAll { it.name != lwjglxJarName }
def coreJar = files.find { it.name == "lwjgl.jar" }
def others = files - coreJar
([coreJar] + others).collect {
def includedModules = configurations.default.findAll { dep ->
!excludedModules.any { it == dep.name }
}
def coreJar = includedModules.find { it.name == "lwjgl.jar" }
println("Merging LWJGL modules in the order: ")
([coreJar] + (includedModules - coreJar)).collect {
println(it.getName())
it.isDirectory() ? it : zipTree(it)
}
}
// Makes the jar reproducible so the version file actually is a version file
preserveFileTimestamps = false
reproducibleFileOrder = true
// Write version file
def versionFile = new File(project(":app_pojavlauncher").projectDir, "src/main/assets/components/lwjgl3/version")
def lwjglxFinalFile = new File(project(":app_pojavlauncher").projectDir, "src/main/assets/components/lwjgl3/" + lwjglxFinalJarName)

def rootProjDir = project(":app_pojavlauncher").projectDir
def versionFile = new File(rootProjDir, "src/main/assets/components/lwjgl3/version")
def jarFile = archiveFile.get().asFile
doLast {
def excludedModulesFileList = excludedModules.collectMany { fileName ->
configurations.default.findAll { it.name == fileName }
}
copy {
// Copy lwjglx to the lwjgl classes dir
from configurations.default.find { it.name == lwjglxJarName }
// Copy excluded modules to the lwjgl classes dir
from excludedModulesFileList
into archiveFile.get().asFile.parentFile
rename lwjglxJarName, lwjglxFinalJarName
}
writeVersionFile([jarFile, lwjglxFinalFile] as File[], versionFile)
writeVersionFile([jarFile] as File[] + excludedModulesFileList, versionFile)
}
// Adds the jank to outputs
outputs.file(versionFile)
outputs.file(lwjglxFinalFile)

outputs.files excludedModules.collect { path -> file(rootProjDir.path + "/src/main/assets/components/lwjgl3/" + path) }
//// Prints out the output.files for troubleshooting
// println "Task outputs:"
// outputs.files.each { file ->
// println " ${file}"
// }
exclude 'net/java/openjdk/cacio/ctc/**'
}

Expand Down
Binary file added jre_lwjgl3glfw/libs/lwjgl-shaderc.jar
Binary file not shown.
Binary file added jre_lwjgl3glfw/libs/lwjgl-spvc.jar
Binary file not shown.
Binary file removed jre_lwjgl3glfw/libs/lwjgl-tinyfd.jar
Binary file not shown.
Binary file added jre_lwjgl3glfw/libs/lwjgl-vma.jar
Binary file not shown.
Binary file added jre_lwjgl3glfw/libs/lwjgl-vulkan.jar
Binary file not shown.
Loading