Skip to content

Commit

Permalink
Merge pull request #6 from Vera-Firefly/sol_testing
Browse files Browse the repository at this point in the history
Create a dedicated buffter for virgl
  • Loading branch information
SolDev69 authored Jan 14, 2024
2 parents b886c87 + b09840a commit b4d1367
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,6 @@ public static void setJavaEnvironment(Activity activity, String jreHome) throws
if(LOCAL_RENDERER.equals("vulkan_zink_legacy")) {
envMap.put("POJAVEXEC_OSMESA", "libOSMesa_znL.so");
}
if(LOCAL_RENDERER.equals("adrhw_freedreno") || LOCAL_RENDERER.equals("swrast") || LOCAL_RENDERER.equals("virgl")) {
envMap.put("POJAVEXEC_OSMESA", "libOSMesa.so");
}
}
if(LauncherPreferences.PREF_BIG_CORE_AFFINITY) envMap.put("POJAV_BIG_CORE_AFFINITY", "1");
envMap.put("AWTSTUB_WIDTH", Integer.toString(CallbackBridge.windowWidth > 0 ? CallbackBridge.windowWidth : CallbackBridge.physicalWidth));
Expand Down Expand Up @@ -455,19 +452,26 @@ public static String loadGraphicsLibrary(){
String renderLibrary;
switch (LOCAL_RENDERER){
case "opengles2":
renderLibrary = "libgl4es_114.so"; break;
renderLibrary = "libgl4es_114.so";
break;
case "vgpu":
renderLibrary = "libvgpu.so"; break;
renderLibrary = "libvgpu.so";
break;
case "malihw_panfrost":
renderLibrary = "libOSMesa_pan.so"; break;
renderLibrary = "libOSMesa_pan.so";
break;
case "vulkan_zink_legacy":
renderLibrary = "libOSMesa_znL.so"; break;
renderLibrary = "libOSMesa_znL.so";
break;
case "malihw_panfrost-new":
case "vulkan_zink":
case "swrast":
case "virgl":
case "adrhw_freedreno":
renderLibrary = "libOSMesa.so"; break;
renderLibrary = "libOSMesa.so";
break;
case "virgl":
renderLibrary = "libOSMesa_81.so";
break;
case "opengles3_desktopgl_angle_vulkan" : renderLibrary = "libtinywrapper.so"; break;
case "opengles3_desktopgl_angle_vulkan_new" : renderLibrary = "libtinywrapper_new_angle.so"; break;
default:
Expand Down
24 changes: 14 additions & 10 deletions app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//
// Created by maks on 21.09.2022.
// Modifile by Vera-Firefly on 13.01.2024.
//
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include "environ/environ.h"
#include "osmesa_loader.h"
#include "renderer_config.h"

GLboolean (*OSMesaMakeCurrent_p) (OSMesaContext ctx, void *buffer, GLenum type,
GLsizei width, GLsizei height);
Expand All @@ -20,19 +22,21 @@ void (*glReadPixels_p) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum

void dlsym_OSMesa() {
char* main_osm_libname = getenv("POJAVEXEC_OSMESA");
if(main_osm_libname == NULL) main_osm_libname = "libOSMesa.so";
char* main_path = NULL;
char* alt_path = NULL;
if(asprintf(&main_path, "%s/%s", getenv("POJAV_NATIVEDIR"), main_osm_libname) == -1 ||
asprintf(&alt_path, "%s/libOSMesa.so.8", getenv("POJAV_NATIVEDIR")) == -1) {
abort();
if(pojav_environ->config_renderer == RENDERER_VK_ZINK) {
if(main_osm_libname == NULL) main_osm_libname = "libOSMesa.so";
if(asprintf(&main_path, "%s/%s", getenv("POJAV_NATIVEDIR"), main_osm_libname) == -1) {
abort();
}
free(main_path);
} else if(pojav_environ->config_renderer == RENDERER_VIRGL) {
if(asprintf(&main_path, "%s/libOSMesa_81.so", getenv("POJAV_NATIVEDIR")) == -1) {
abort();
}
}
void* dl_handle = NULL;
dl_handle = dlopen(alt_path, RTLD_GLOBAL);
if(dl_handle == NULL) dl_handle = dlopen(main_path, RTLD_GLOBAL);
dl_handle = dlopen(main_path, RTLD_GLOBAL);
if(dl_handle == NULL) abort();
free(main_path);
free(alt_path);
OSMesaMakeCurrent_p = dlsym(dl_handle, "OSMesaMakeCurrent");
OSMesaGetCurrentContext_p = dlsym(dl_handle,"OSMesaGetCurrentContext");
OSMesaCreateContext_p = dlsym(dl_handle, "OSMesaCreateContext");
Expand Down
12 changes: 12 additions & 0 deletions app_pojavlauncher/src/main/jni/ctxbridges/renderer_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Created by Vera-Firefly on 2.12.2023.
// Definitions specific to the renderer
//


#define RENDERER_GL4ES 1
#define RENDERER_VK_ZINK 2
#define RENDERER_VIRGL 3
#define RENDERER_VULKAN 4
#define RENDERER_VK_WARLIP 5
#define RENDERER_VK_ZINK_PREF 6
Loading

0 comments on commit b4d1367

Please sign in to comment.