Skip to content

Commit

Permalink
QuestCraft v5.0.0 - LTS (QuestCraftPlusPlus#27)
Browse files Browse the repository at this point in the history
* No more pbuffers :D

* Update Mesa and OpenComposite

* Potential Q3 support

* Fix QPro, update OC

* Update a ton of stuff. Fix GPU util

* Reenable turbo

* Don't launch until everything finishes downloading

* Update GLFW Name

* Add an error message for if the auth servers can't be reached

* Fix unassigned UUID issue

* Still bugged, but bump Mesa and Freedreno for some 6xx fixes

* Prep Mainline Merge (QuestCraftPlusPlus#26)

* Update devmods.json

* Update fabric api

* Rename GLFW File (QuestCraftPlusPlus#24)

* Remove the forgotten child (QuestCraftPlusPlus#25)

remove 1.19.3

* Update devmods.json

---------

Co-authored-by: The Judge <[email protected]>
Co-authored-by: Cart <[email protected]>

---------
  • Loading branch information
CADIndie authored Nov 24, 2023
1 parent a930fb8 commit 07a13c6
Show file tree
Hide file tree
Showing 25 changed files with 348 additions and 79 deletions.
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ plugins {
}

android {
ndkVersion = "25.2.9519653"
compileSdkVersion = "android-31"
ndkVersion = "26.1.10909125"
compileSdkVersion = "android-32"
defaultConfig {
minSdkVersion(31)
minSdkVersion(32)
}

buildTypes {
Expand Down
3 changes: 1 addition & 2 deletions lib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pojlib.android">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:allowNativeHeapPointerTagging="false">
</application>
<application android:allowNativeHeapPointerTagging="false"/>
</manifest>
Binary file modified lib/src/main/assets/JRE-17.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/src/main/assets/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@ modelPart_right_sleeve:true
modelPart_left_pants_leg:true
modelPart_right_pants_leg:true
modelPart_hat:true
fullscreenResolution:2960x1440@60:24
fullscreenResolution:1920x1080@90:24
9 changes: 7 additions & 2 deletions lib/src/main/java/pojlib/account/MinecraftAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static pojlib.account.Msa.checkMcProfile;

import android.app.Activity;
import android.util.Log;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
Expand Down Expand Up @@ -70,7 +71,11 @@ public static MinecraftAccount load(String path, @Nullable String newToken, @Nul
}

public static String getSkinFaceUrl(MinecraftAccount account) {
return Constants.CRAFATAR_URL + "/avatars/" + account.uuid;
try {
return Constants.CRAFATAR_URL + "/avatars/" + account.uuid;
} catch (NullPointerException e) {
System.out.println("Username not set! Please sign in on PC/Pojav first then try again.");
return null;
}
}

}
1 change: 1 addition & 0 deletions lib/src/main/java/pojlib/api/API_V1.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
public class API_V1 {

public static String msaMessage = "";
public static String model = "Quest";
private static boolean hasQueried = false;
private static JsonObject initialResponse;
public static boolean finishedDownloading = false;
Expand Down
1 change: 1 addition & 0 deletions lib/src/main/java/pojlib/instance/MinecraftInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ public void launchInstance(Activity activity, MinecraftAccount account) {
JREUtils.redirectAndPrintJRELog();
VLoader.setAndroidInitInfo(activity);
VLoader.setEGLGlobal(JREUtils.getEGLContextPtr(), JREUtils.getEGLDisplayPtr(), JREUtils.getEGLConfigPtr());
while(!API_V1.finishedDownloading);
JREUtils.launchJavaVM(activity, generateLaunchArgs(account), versionName);
} catch (Throwable e) {
e.printStackTrace();
Expand Down
12 changes: 6 additions & 6 deletions lib/src/main/java/pojlib/util/JREUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,20 @@ public static void setJavaEnvironment(Activity activity) throws Throwable {
envMap.put("JAVA_HOME", activity.getFilesDir() + "/runtimes/JRE-17");
envMap.put("HOME", Constants.MC_DIR);
envMap.put("TMPDIR", activity.getCacheDir().getAbsolutePath());
envMap.put("LIBGL_MIPMAP", "3");
envMap.put("LIBGL_NOINTOVLHACK", "1");
envMap.put("VR_MODEL", API_V1.model);
envMap.put("MESA_GL_VERSION_OVERRIDE", "4.6");
envMap.put("MESA_GLSL_VERSION_OVERRIDE", "460");
envMap.put("MESA_LOADER_DRIVER_OVERRIDE", "zink");
envMap.put("GALLIUM_DRIVER", "zink");
envMap.put("LIBGL_DEBUG", "verbose");
envMap.put("LIBGL_DRIVERS_PATH", sNativeLibDir);
envMap.put("GALLIUM_THREAD", "0");
envMap.put("MESA_LOG_FILE", Constants.MC_DIR + "/mesa-log.txt");
envMap.put("POJAV_RENDERER", "vulkan_zink");

envMap.put("LD_LIBRARY_PATH", LD_LIBRARY_PATH);
envMap.put("PATH", activity.getFilesDir() + "/runtimes/JRE-17/bin:" + Os.getenv("PATH"));

envMap.put("LIBGL_GLES", "/system/lib64/libGLESv2.so");
envMap.put("LIBGL_EGL", "/system/lib64/libEGL.so");

File customEnvFile = new File(Constants.USER_HOME, "custom_env.txt");
if (customEnvFile.exists() && customEnvFile.isFile()) {
BufferedReader reader = new BufferedReader(new FileReader(customEnvFile));
Expand Down Expand Up @@ -201,7 +201,7 @@ public static int launchJavaVM(final Activity activity, final List<String> JVMAr

userArgs.add("-Dorg.lwjgl.opengl.libname=" + graphicsLib);
userArgs.add("-Dorg.lwjgl.opengles.libname=" + "/system/lib64/libGLESv3.so");
userArgs.add("-Dorg.lwjgl.egl.libname=" + "/system/lib64/libEGL.so");
userArgs.add("-Dorg.lwjgl.egl.libname=" + "/system/lib64/libEGL_dri.so");
userArgs.add("-Dfabric.addMods=" + Constants.MC_DIR + "/mods/" + versionName);

userArgs.addAll(JVMArgs);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/main/java/pojlib/util/LoginHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public static void beginLogin(Activity activity) {
API_V1.profileImage = MinecraftAccount.getSkinFaceUrl(API_V1.currentAcc);
API_V1.profileName = API_V1.currentAcc.username;
} catch (ExecutionException | InterruptedException e) {
API_V1.msaMessage = "Something went wrong! Couldn't reach the Microsoft Auth servers.\n"
+ e.getMessage();
throw new RuntimeException(e);
}
});
Expand Down
Binary file modified lib/src/main/jni/OpenOVR/OCOVR.a
Binary file not shown.
Binary file modified lib/src/main/jni/OpenOVR/libDrvOpenXR.a
Binary file not shown.
Binary file modified lib/src/main/jni/OpenOVR/libOCCore.a
Binary file not shown.
Binary file modified lib/src/main/jni/OpenOVR/libOpenXR.a
Binary file not shown.
28 changes: 23 additions & 5 deletions lib/src/main/jni/adrenotools/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
extern "C" {
#endif

#include <stdbool.h>
#include "priv.h"

/**
Expand All @@ -18,23 +19,40 @@ extern "C" {
* @param customDriverDir The directory to load a custom GPU driver named according to `customDriverName` from. Only used if ADRENOTOOLS_DRIVER_CUSTOM is set in `featureFlags`
* @param customDriverName The soname of the custom driver to load. Only used if ADRENOTOOLS_DRIVER_CUSTOM is set in `featureFlags`
* @param fileRedirectDir The directory which to redirect all file accesses performed by the driver to. Only used if ADRENOTOOLS_DRIVER_FILE_REDIRECT is set in `featureFlags`
* @param userMappingHandle A pointer to a void* which will be set to the mapping handle if ADRENOTOOLS_DRIVER_GPU_MAPPING_IMPORT is set in `featureFlags`
*/
void *adrenotools_open_libvulkan(int dlopenMode, int featureFlags, const char *tmpLibDir, const char *hookLibDir, const char *customDriverDir, const char *customDriverName, const char *fileRedirectDir, struct adrenotools_gpu_mapping *nextGpuMapping);
void *adrenotools_open_libvulkan(int dlopenMode, int featureFlags, const char *tmpLibDir, const char *hookLibDir, const char *customDriverDir, const char *customDriverName, const char *fileRedirectDir, void **userMappingHandle);

/**
* @brief Imports the given CPU mapped memory range into the GSL allocator. The out_mapping should have been passed to adrenotools_open_libvulkan with ADRENOTOOLS_DRIVER_GPU_MAPPING_IMPORT set in `featureFlags`. This should then be followed by a call to vkAllocateMemory with a matching size which will return a VkDeviceMemory view over the input region
* @param outMapping Output mapping pointer, the same as was passed to adrenotools_open_libvulkan
* @brief Imports the given CPU mapped memory range into the GSL allocator. This should then be followed by a call to vkAllocateMemory with a matching size which will return a VkDeviceMemory view over the input region
* @param handle Mapping handle that was returned by adrenotools_open_libvulkan
* @param hostPtr The host pointer to import
* @param size The size of the region to import
* @return True on success
*/
bool adrenotools_import_user_mem(struct adrenotools_gpu_mapping *outMapping, void *hostPtr, uint64_t size);
bool adrenotools_import_user_mem(void *handle, void *hostPtr, uint64_t size);

/**
* @brief Maps GPU memory and imports it into the GSL allocator. This should then be followed by a call to adrenotools_mem_cpu_map to map the memory on the CPU, then finally vkAllocateMemory with a matching size
* @param handle Mapping handle that was returned by adrenotools_open_libvulkan
* @param size Pointer to a variable containing the size of the region to import, will be updated to contain the required size of the region to allocate CPU side
* @return true on success
*/
bool adrenotools_mem_gpu_allocate(void *handle, uint64_t *size);

/**
* @brief Maps the last mapping allocated using adrenotools_mem_gpu_allocate into the given host memory region, such that vkAllocateMemory can then be called
* @param handle Mapping handle that was returned by adrenotools_open_libvulkan
* @param hostPtr A pointer to where the mapping should be mapped
* @param size The size of the mapping. MUST be equal to the size returned by adrenotools_mem_gpu_allocate
*/
bool adrenotools_mem_cpu_map(void *handle, void *hostPtr, uint64_t size);

/**
* @note This function should be called after adrenotools_open_libvulkan and Vulkan driver init to check if the mapping import hook loaded successfully
* @return True if the mapping was successfully imported (or initialization succeeded)
*/
bool adrenotools_validate_gpu_mapping(struct adrenotools_gpu_mapping *mapping);
bool adrenotools_validate_gpu_mapping(void *handle);

/**
* @brief Provides a way to force the GPU to run at the maximum possible clocks (thermal constraints will still be applied)
Expand Down
Binary file modified lib/src/main/jni/adrenotools/libadrenotools.so
Binary file not shown.
51 changes: 35 additions & 16 deletions lib/src/main/jni/egl_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ typedef struct osmesa_context
GLboolean (*OSMesaMakeCurrent_p) (OSMesaContext ctx, void *buffer, GLenum type,
GLsizei width, GLsizei height);
OSMesaContext (*OSMesaGetCurrentContext_p) (void);
OSMesaContext (*OSMesaCreateContext_p) (GLenum format, OSMesaContext sharelist);
OSMesaContext (*OSMesaCreateContextAttribs_p) ( const int *attribList, OSMesaContext sharelist );
GLubyte* (*glGetString_p) (GLenum name);

void* gbuffer;
Expand Down Expand Up @@ -711,44 +711,48 @@ void dlsym_OSMesa() {
void* dl_handle;
dl_handle = dlopen(alt_path, RTLD_NOW);
if(dl_handle == NULL) dl_handle = dlopen(main_path, RTLD_NOW);
if(dl_handle == NULL) abort();
if(dl_handle == NULL) {
printf("Error opening OSMesa! %s\n", dlerror());
abort();
}
OSMesaMakeCurrent_p = dlsym(dl_handle, "OSMesaMakeCurrent");
OSMesaGetCurrentContext_p = dlsym(dl_handle,"OSMesaGetCurrentContext");
OSMesaCreateContext_p = dlsym(dl_handle, "OSMesaCreateContext");
OSMesaCreateContextAttribs_p = dlsym(dl_handle, "OSMesaCreateContextAttribs");
glGetString_p = dlsym(dl_handle,"glGetString");
}

int pojavInit() {
savedWidth = 1080;
savedHeight = 720;
savedWidth = 1920;
savedHeight = 1080;

xrEglInit();
// xrEglInit();

char *natives = getenv("POJAV_NATIVEDIR");
char *gpuStuff = getenv("HOME");
strcat(natives, "/");
char *gpuStuff;
char *nativeDir;
asprintf(&nativeDir, "%s/", getenv("POJAV_NATIVEDIR"));
asprintf(&gpuStuff, "%s/gpustuff", getenv("HOME"));
void *libvulkan = adrenotools_open_libvulkan(RTLD_NOW, ADRENOTOOLS_DRIVER_CUSTOM, NULL,
gpuStuff, natives,
"libvulkan_freedreno.so", NULL, NULL);
gpuStuff, nativeDir,
"libvulkan_freedreno.so", NULL, NULL);
adrenotools_set_turbo(true);
printf("libvulkan: %p\n", libvulkan);
char *vulkanPtrString;

asprintf(&vulkanPtrString, "%p", libvulkan);
printf("%s\n", vulkanPtrString);
setenv("VULKAN_PTR", vulkanPtrString, 1);

setenv("GALLIUM_DRIVER", "zink", 1);
dlsym_OSMesa();

if (OSMesaCreateContext_p == NULL) {
if (OSMesaCreateContextAttribs_p == NULL) {
printf("OSMDroid: %s\n", dlerror());
return 0;
}

printf("OSMDroid: width=%i;height=%i, reserving %i bytes for frame buffer\n", savedWidth,
savedHeight,
savedWidth * 4 * savedHeight);
gbuffer = malloc(savedWidth * 4 * savedHeight + 1);
gbuffer = malloc(savedWidth * 4 * savedHeight);
if (gbuffer) {
printf("OSMDroid: created frame buffer\n");
return 1;
Expand Down Expand Up @@ -809,7 +813,22 @@ Java_org_lwjgl_glfw_GLFW_nativeEglDetachOnCurrentThread(JNIEnv *env, jclass claz

void* pojavCreateContext(void* contextSrc) {
printf("OSMDroid: generating context\n");
void *ctx = OSMesaCreateContext_p(OSMESA_RGBA, contextSrc);

int attribs[100], n = 0;

attribs[n++] = OSMESA_FORMAT;
attribs[n++] = OSMESA_RGBA;
attribs[n++] = OSMESA_DEPTH_BITS;
attribs[n++] = 24;
attribs[n++] = OSMESA_STENCIL_BITS;
attribs[n++] = 8;
attribs[n++] = OSMESA_ACCUM_BITS;
attribs[n++] = 0;
attribs[n++] = OSMESA_PROFILE;
attribs[n++] = OSMESA_CORE_PROFILE;
attribs[n++] = 0;

void *ctx = OSMesaCreateContextAttribs_p(attribs, contextSrc);
printf("OSMDroid: context=%p\n", ctx);
return ctx;
}
Expand All @@ -825,7 +844,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL_nativeRegalMakeCurrent(JNIEnv *e
}
JNIEXPORT JNICALL jlong
Java_org_lwjgl_opengl_GL_getGraphicsBufferAddr(JNIEnv *env, jobject thiz) {
return &gbuffer;
return (jlong) &gbuffer;
}
JNIEXPORT JNICALL jintArray
Java_org_lwjgl_opengl_GL_getNativeWidthHeight(JNIEnv *env, jobject thiz) {
Expand Down
Loading

0 comments on commit 07a13c6

Please sign in to comment.