Skip to content

Commit

Permalink
New[renderer]: Start work on Panfrost
Browse files Browse the repository at this point in the history
TODO:
- Detect renderer compatibility
- Investigate the massive slowdown (seems to be due to texture upload locking up the game thread, idk)
- Test on more devices
  • Loading branch information
artdeell committed Nov 19, 2023
1 parent 26f86f6 commit 78f39e1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ public static void setJavaEnvironment(Activity activity, String jreHome) throws
envMap.put("LIBGL_ES", "3");
envMap.put("POJAVEXEC_EGL","libEGL_angle.so"); // Use ANGLE EGL
}
if(LOCAL_RENDERER.equals("malihw_panfrost")) {
envMap.put("POJAVEXEC_OSMESA", "libOSMesa_pan.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 @@ -450,6 +453,7 @@ public static String loadGraphicsLibrary(){
case "opengles3":
renderLibrary = "libgl4es_114.so"; break;
case "vulkan_zink": renderLibrary = "libOSMesa.so"; break;
case "malihw_panfrost": renderLibrary = "libOSMesa_pan.so"; break;
case "opengles3_desktopgl_angle_vulkan" : renderLibrary = "libtinywrapper.so"; break;
default:
Log.w("RENDER_LIBRARY", "No renderer selected, defaulting to opengles2");
Expand Down
6 changes: 5 additions & 1 deletion app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ void (*glClear_p) (GLbitfield mask);
void (*glReadPixels_p) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * data);

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/libOSMesa.so", getenv("POJAV_NATIVEDIR")) == -1 ||
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();
}
void* dl_handle = NULL;
dl_handle = dlopen(alt_path, RTLD_GLOBAL);
if(dl_handle == NULL) 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
5 changes: 5 additions & 0 deletions app_pojavlauncher/src/main/jni/egl_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ int pojavInitOpenGL() {
load_vulkan();
setenv("GALLIUM_DRIVER","zink",1);
set_osm_bridge_tbl();
} else if (strcmp(renderer, "malihw_panfrost") == 0) {
pojav_environ->config_renderer = RENDERER_VK_ZINK;
setenv("GALLIUM_DRIVER", "panfrost", 1);
setenv("PAN_DEBUG","gofaster",1);
set_osm_bridge_tbl();
}
if(br_init()) {
br_setup_window();
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions app_pojavlauncher/src/main/res/values/headings_array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<item name="1">@string/mcl_setting_renderer_gles2_4</item>
<item name="2">@string/mcl_setting_renderer_vulkan_zink</item>
<item name="3">@string/mcl_setting_renderer_angle</item>
<item name="4">@string/mcl_setting_renderer_panfrost</item>
</string-array>

<string-array name="menu_customcontrol">
Expand Down Expand Up @@ -39,6 +40,7 @@
<item>opengles2</item> <!-- gl4es_extra 1.1.4 with OpenGL ES 2/"3" -->
<item>vulkan_zink</item> <!-- virglrenderer with OpenGL ES 3 -->
<item>opengles3_desktopgl_angle_vulkan</item>
<item>malihw_panfrost</item>
</string-array>
<string-array name="download_source_names">
<item>@string/global_default</item>
Expand Down
1 change: 1 addition & 0 deletions app_pojavlauncher/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<string name="mcl_setting_renderer_gles2_4">Holy GL4ES - (all versions, fast)</string>
<string name="mcl_setting_renderer_vulkan_zink">Zink (Vulkan) - (all versions, mid)</string>
<string name="mcl_setting_renderer_angle">ANGLE (Vulkan) - (1.17+ only, mid)</string>
<string name="mcl_setting_renderer_panfrost">Panfrost (Mali) - (all versions, mid)</string>
<string name="mcl_setting_veroption_release">Release</string>
<string name="mcl_setting_veroption_snapshot">Snapshot</string>
<string name="mcl_setting_veroption_oldalpha">Old-alpha</string>
Expand Down

0 comments on commit 78f39e1

Please sign in to comment.