mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-21 09:01:56 -07:00
Merge Zink renderer to upstream (#1585)
* OSMesa EGLBridge * It renders a gray screen with Zink! * Image * Added missing file: gl/glext.h * Added jniLibs/arm64-v8a/libOSMesa_8.so * Load built-in libOSMesa when dev lib not available * Added jniLibs/x86_64/libOSMesa_8.so * Start trying to use Android's internal APIs to manage framebuffers * Automatic stride to un-broke the image * DMA * Update lwjgl3 version * Update LauncherPreferences.java Temporary force set, to fix #1121 * Remove ndk.abiFilters * Re-add ndk.abiFilters but for 64bit archs only * Fixed x86_64 libOSMesa_8.so * Fix buffer size * [WIP] Force enable VK ext for GL 3.0 * WIP force ext * Attempt get Zink GL 3.0 by force enable some exts * Just missing ;; * Mesa3D: set OpenGL version to 4.6 * Added Zink to renderer list * Fixed the renderer check * Maybe correct the switch between gl4es and zink * Update JREUtils.java fixes from https://github.com/sp614x/optifine/issues/420 * also set glsl version * [NOT TESTED] (DO NOT TRY DEVS ONLY) upstream mesa to staging mesa branch * upstream mesa once again * Revert "upstream mesa once again" This reverts commit ccb0f429b707c6fed1376809bb978e7eb8230222. * add arm32 * Enable building for arm32 * Attempt fix auto change to libname libOSMesa * Attempt fix (2/2)? * Added missed `break`, should fix gl4es crashes * Update JREUtils.java * Support OpenJDK 17 runtime environment (internal) * Update JREUtils.java * [zink] use RGBA instead of RGB Some mobile GPUs does not support RGB format, so switching to RGBA is necessary. However, native window is set to RGBX to ignore alpha channel. * Move jreReleaseList to here * Update BaseMainActivity.java * Fixes (#1525) * import java.util.Map * fix: String cannot be converted to boolean * Fixes * Put readJREReleaseProperties to try catch * Remove loading libtinyiconv.so (statically linked) * lets do this * upsteam to the staging branch of 21.0 * [zink] exports OpenGL 4.6 again Limit OpenGL version does nothing other than deny the game to use it, so limiting is probably useless. Also, this is a lie that user see "export OpenGL 4.6" in renderer list but see "OpenGL 3.2" when enter game. Therefore, change back to OpenGL 4.6. * New string: mcn_check_fail_vulkan_support * [not yet finish] error if GPU doesn’t have Vulkan * [not yet finished] error if vulkan is unsupported * Additional checks for Vulkan support state * Changes about gl4es renderers * Define new renderer: opengles2_5 g4es 1.1.4 Also, change how gl4es renderers works * Filter out "_5" * Don’t allow custom OpenGL libname from jvm args * Update strings.xml * Update headings_array.xml * Update headings_array.xml * Update strings.xml * Unreachable code * Enable build for 32-bit x86 (zink not added!) * Changes from upstream and security changes (#1575) * import java.util.Map * fix: String cannot be converted to boolean * Fixes * Put readJREReleaseProperties to try catch * Attempt to redirect signal handler to JVM * @artdeell: missed \n in printf * Missed include errno.h * Comment out last changes * try and optimise gl4es with flags * corect format * dont shrink textures * does notting * Fix issue #1199 * Filter out Session ID on new log pipe * int index * Debug: print all env vars to latestlog.txt Co-authored-by: artdeell Co-authored-by: rhjdvsgsgks Co-authored-by: LegacyGamerHD Co-authored-by: Boulay Mathias
This commit is contained in:
parent
76b185e3b5
commit
4a90c8f124
17 changed files with 16217 additions and 177 deletions
|
|
@ -1 +1 @@
|
|||
20210131
|
||||
20210328
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package net.kdt.pojavlaunch;
|
|||
|
||||
import android.app.*;
|
||||
import android.content.*;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.*;
|
||||
import android.os.*;
|
||||
import android.util.*;
|
||||
|
|
@ -65,6 +66,7 @@ public class BaseMainActivity extends LoggableActivity {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
private MinecraftGLView minecraftGLView;
|
||||
private int guiScale;
|
||||
private DisplayMetrics displayMetrics;
|
||||
|
|
@ -893,6 +895,10 @@ public class BaseMainActivity extends LoggableActivity {
|
|||
*/
|
||||
|
||||
appendlnToLog("--------- beggining with launcher debug");
|
||||
appendlnToLog("Info: Launcher version: " + BuildConfig.VERSION_NAME);
|
||||
if (LauncherPreferences.PREF_RENDERER.equals("vulkan_zink")) {
|
||||
checkVulkanZinkIsSupported();
|
||||
}
|
||||
checkLWJGL3Installed();
|
||||
|
||||
jreReleaseList = JREUtils.readJREReleaseProperties();
|
||||
|
|
@ -954,6 +960,16 @@ public class BaseMainActivity extends LoggableActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private void checkVulkanZinkIsSupported() {
|
||||
if (Tools.CURRENT_ARCHITECTURE.equals("x86")
|
||||
|| Build.VERSION.SDK_INT < 25
|
||||
|| !getPackageManager().hasSystemFeature(PackageManager.FEATURE_VULKAN_HARDWARE_LEVEL)
|
||||
|| !getPackageManager().hasSystemFeature(PackageManager.FEATURE_VULKAN_HARDWARE_VERSION)) {
|
||||
appendlnToLog("Error: Vulkan Zink renderer is not supported!");
|
||||
throw new RuntimeException(getString(R.string. mcn_check_fail_vulkan_support));
|
||||
}
|
||||
}
|
||||
|
||||
public void printStream(InputStream stream) {
|
||||
try {
|
||||
BufferedReader buffStream = new BufferedReader(new InputStreamReader(stream));
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import androidx.appcompat.app.*;
|
|||
import android.util.*;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
public class FatalErrorActivity extends BaseActivity
|
||||
public class FatalErrorActivity extends AppCompatActivity
|
||||
{
|
||||
public static void showError(Context ctx, String savePath, boolean storageAllow, /* boolean isFatalErr, */ Throwable th) {
|
||||
Intent ferrorIntent = new Intent(ctx, FatalErrorActivity.class);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ public class PojavApplication extends Application
|
|||
crashStream.append(" - Device: " + Build.PRODUCT + " " + Build.MODEL + "\n");
|
||||
crashStream.append(" - Android version: " + Build.VERSION.RELEASE + "\n");
|
||||
crashStream.append(" - Crash stack trace:\n");
|
||||
crashStream.append(" - Launcher version: " + BuildConfig.VERSION_NAME + "\n");
|
||||
crashStream.append(Log.getStackTraceString(th));
|
||||
crashStream.close();
|
||||
} catch (Throwable th2) {
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ public final class Tools
|
|||
// javaArgList.add("-Dorg.lwjgl.libname=liblwjgl3.so");
|
||||
// javaArgList.add("-Dorg.lwjgl.system.jemalloc.libname=libjemalloc.so");
|
||||
|
||||
overrideableArgList.add("-Dorg.lwjgl.opengl.libname=libgl4es_114.so");
|
||||
overrideableArgList.add("-Dorg.lwjgl.opengl.libname=" + LauncherPreferences.PREF_CUSTOM_OPENGL_LIBNAME);
|
||||
// overrideableArgList.add("-Dorg.lwjgl.opengl.libname=libgl4es_115.so");
|
||||
|
||||
// javaArgList.add("-Dorg.lwjgl.opengl.libname=libRegal.so");
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ public class LauncherPreferences
|
|||
String DEFAULT_JAVA_ARGS =
|
||||
"-Xms" + (androidHeap > 800 ? 800 : androidHeap) + "m " +
|
||||
// (32bit) More than 800mb may make JVM not allocateable and crash
|
||||
"-Xmx" + (doubleAndroidHeap > 800 ? 800 : doubleAndroidHeap) + "m"; /* "m " +
|
||||
|
||||
"-Xmx" + (doubleAndroidHeap > 800 ? 800 : doubleAndroidHeap) + "m";
|
||||
/* "m " +
|
||||
"-XX:+UseG1GC " +
|
||||
"-XX:+ParallelRefProcEnabled " +
|
||||
"-XX:MaxGCPauseMillis=200 " +
|
||||
|
|
@ -82,10 +82,27 @@ public class LauncherPreferences
|
|||
DEFAULT_PREF.edit().putString("javaArgs", DEFAULT_JAVA_ARGS).commit();
|
||||
}
|
||||
|
||||
switch (PREF_RENDERER) {
|
||||
case "opengles2":
|
||||
case "opengles2_5":
|
||||
PREF_CUSTOM_OPENGL_LIBNAME = "libgl4es_114.so";
|
||||
break;
|
||||
case "opengles3":
|
||||
PREF_CUSTOM_OPENGL_LIBNAME = "libgl4es_115.so";
|
||||
break;
|
||||
case "vulkan_zink":
|
||||
PREF_CUSTOM_OPENGL_LIBNAME = "libOSMesa_8.so";
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Undefined renderer: " + PREF_RENDERER);
|
||||
}
|
||||
|
||||
String argLwjglLibname = "-Dorg.lwjgl.opengl.libname=";
|
||||
for (String arg : PREF_CUSTOM_JAVA_ARGS.split(" ")) {
|
||||
if (arg.startsWith(argLwjglLibname)) {
|
||||
PREF_CUSTOM_OPENGL_LIBNAME = arg.substring(argLwjglLibname.length());
|
||||
// purge arg
|
||||
DEFAULT_PREF.edit().putString("javaArgs",
|
||||
PREF_CUSTOM_JAVA_ARGS.replace(arg, "")).commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ public class JREUtils
|
|||
return ret;
|
||||
}
|
||||
public static void initJavaRuntime() {
|
||||
dlopen(findInLdLibPath("libtinyiconv.so"));
|
||||
dlopen(findInLdLibPath("libjli.so"));
|
||||
dlopen(findInLdLibPath("libjvm.so"));
|
||||
dlopen(findInLdLibPath("libverify.so"));
|
||||
|
|
@ -221,6 +220,13 @@ public class JREUtils
|
|||
envMap.put("LIBGL_NOTEXMAT", "1");
|
||||
|
||||
envMap.put("MESA_GLSL_CACHE_DIR", ctx.getCacheDir().getAbsolutePath());
|
||||
envMap.put("MESA_GL_VERSION_OVERRIDE", "4.6");
|
||||
envMap.put("MESA_GLSL_VERSION_OVERRIDE", "460");
|
||||
envMap.put("force_glsl_extensions_warn", "true");
|
||||
envMap.put("allow_higher_compat_version", "true");
|
||||
envMap.put("allow_glsl_extension_directive_midshader", "true");
|
||||
envMap.put("MESA_LOADER_DRIVER_OVERRIDE", "zink");
|
||||
|
||||
envMap.put("LD_LIBRARY_PATH", LD_LIBRARY_PATH);
|
||||
envMap.put("PATH", Tools.DIR_HOME_JRE + "/bin:" + Os.getenv("PATH"));
|
||||
|
||||
|
|
@ -228,6 +234,8 @@ public class JREUtils
|
|||
envMap.put("REGAL_GL_RENDERER", "Regal");
|
||||
envMap.put("REGAL_GL_VERSION", "4.5");
|
||||
|
||||
envMap.put("POJAV_RENDERER", LauncherPreferences.PREF_RENDERER);
|
||||
|
||||
envMap.put("AWTSTUB_WIDTH", Integer.toString(CallbackBridge.windowWidth > 0 ? CallbackBridge.windowWidth : CallbackBridge.physicalWidth));
|
||||
envMap.put("AWTSTUB_HEIGHT", Integer.toString(CallbackBridge.windowHeight > 0 ? CallbackBridge.windowHeight : CallbackBridge.physicalHeight));
|
||||
|
||||
|
|
@ -245,11 +253,12 @@ public class JREUtils
|
|||
if(!envMap.containsKey("LIBGL_ES")) {
|
||||
int glesMajor = getDetectedVersion();
|
||||
Log.i("glesDetect","GLES version detected: "+glesMajor);
|
||||
|
||||
if (glesMajor < 3) {
|
||||
//fallback to 2 since it's the minimum for the entire app
|
||||
envMap.put("LIBGL_ES","2");
|
||||
} else if (LauncherPreferences.PREF_RENDERER.startsWith("opengles")) {
|
||||
envMap.put("LIBGL_ES", LauncherPreferences.PREF_RENDERER.replace("opengles", ""));
|
||||
envMap.put("LIBGL_ES", LauncherPreferences.PREF_RENDERER.replace("opengles", "").replace("_5", ""));
|
||||
} else {
|
||||
// TODO if can: other backends such as Vulkan.
|
||||
// Sure, they should provide GLES 3 support.
|
||||
|
|
@ -257,6 +266,7 @@ public class JREUtils
|
|||
}
|
||||
}
|
||||
for (Map.Entry<String, String> env : envMap.entrySet()) {
|
||||
ctx.appendlnToLog("Added custom env: " + env.getKey() + "=" + env.getValue());
|
||||
Os.setenv(env.getKey(), env.getValue(), true);
|
||||
}
|
||||
|
||||
|
|
|
|||
2102
app_pojavlauncher/src/main/jni/GL/gl.h
Normal file
2102
app_pojavlauncher/src/main/jni/GL/gl.h
Normal file
File diff suppressed because it is too large
Load diff
12832
app_pojavlauncher/src/main/jni/GL/glext.h
Normal file
12832
app_pojavlauncher/src/main/jni/GL/glext.h
Normal file
File diff suppressed because it is too large
Load diff
332
app_pojavlauncher/src/main/jni/GL/osmesa.h
Normal file
332
app_pojavlauncher/src/main/jni/GL/osmesa.h
Normal file
|
|
@ -0,0 +1,332 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Mesa Off-Screen rendering interface.
|
||||
*
|
||||
* This is an operating system and window system independent interface to
|
||||
* Mesa which allows one to render images into a client-supplied buffer in
|
||||
* main memory. Such images may manipulated or saved in whatever way the
|
||||
* client wants.
|
||||
*
|
||||
* These are the API functions:
|
||||
* OSMesaCreateContext - create a new Off-Screen Mesa rendering context
|
||||
* OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer
|
||||
* and make the specified context the current one.
|
||||
* OSMesaDestroyContext - destroy an OSMesaContext
|
||||
* OSMesaGetCurrentContext - return thread's current context ID
|
||||
* OSMesaPixelStore - controls how pixels are stored in image buffer
|
||||
* OSMesaGetIntegerv - return OSMesa state parameters
|
||||
*
|
||||
*
|
||||
* The limits on the width and height of an image buffer can be retrieved
|
||||
* via OSMesaGetIntegerv(OSMESA_MAX_WIDTH/OSMESA_MAX_HEIGHT).
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OSMESA_H
|
||||
#define OSMESA_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
|
||||
#define OSMESA_MAJOR_VERSION 11
|
||||
#define OSMESA_MINOR_VERSION 2
|
||||
#define OSMESA_PATCH_VERSION 0
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Values for the format parameter of OSMesaCreateContext()
|
||||
* New in version 2.0.
|
||||
*/
|
||||
#define OSMESA_COLOR_INDEX GL_COLOR_INDEX
|
||||
#define OSMESA_RGBA GL_RGBA
|
||||
#define OSMESA_BGRA 0x1
|
||||
#define OSMESA_ARGB 0x2
|
||||
#define OSMESA_RGB GL_RGB
|
||||
#define OSMESA_BGR 0x4
|
||||
#define OSMESA_RGB_565 0x5
|
||||
|
||||
|
||||
/*
|
||||
* OSMesaPixelStore() parameters:
|
||||
* New in version 2.0.
|
||||
*/
|
||||
#define OSMESA_ROW_LENGTH 0x10
|
||||
#define OSMESA_Y_UP 0x11
|
||||
|
||||
|
||||
/*
|
||||
* Accepted by OSMesaGetIntegerv:
|
||||
*/
|
||||
#define OSMESA_WIDTH 0x20
|
||||
#define OSMESA_HEIGHT 0x21
|
||||
#define OSMESA_FORMAT 0x22
|
||||
#define OSMESA_TYPE 0x23
|
||||
#define OSMESA_MAX_WIDTH 0x24 /* new in 4.0 */
|
||||
#define OSMESA_MAX_HEIGHT 0x25 /* new in 4.0 */
|
||||
|
||||
/*
|
||||
* Accepted in OSMesaCreateContextAttrib's attribute list.
|
||||
*/
|
||||
#define OSMESA_DEPTH_BITS 0x30
|
||||
#define OSMESA_STENCIL_BITS 0x31
|
||||
#define OSMESA_ACCUM_BITS 0x32
|
||||
#define OSMESA_PROFILE 0x33
|
||||
#define OSMESA_CORE_PROFILE 0x34
|
||||
#define OSMESA_COMPAT_PROFILE 0x35
|
||||
#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
|
||||
#define OSMESA_CONTEXT_MINOR_VERSION 0x37
|
||||
|
||||
|
||||
typedef struct osmesa_context *OSMesaContext;
|
||||
|
||||
|
||||
/*
|
||||
* Create an Off-Screen Mesa rendering context. The only attribute needed is
|
||||
* an RGBA vs Color-Index mode flag.
|
||||
*
|
||||
* Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
|
||||
* OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
|
||||
* sharelist - specifies another OSMesaContext with which to share
|
||||
* display lists. NULL indicates no sharing.
|
||||
* Return: an OSMesaContext or 0 if error
|
||||
*/
|
||||
GLAPI OSMesaContext GLAPIENTRY
|
||||
OSMesaCreateContext( GLenum format, OSMesaContext sharelist );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Create an Off-Screen Mesa rendering context and specify desired
|
||||
* size of depth buffer, stencil buffer and accumulation buffer.
|
||||
* If you specify zero for depthBits, stencilBits, accumBits you
|
||||
* can save some memory.
|
||||
*
|
||||
* New in Mesa 3.5
|
||||
*/
|
||||
GLAPI OSMesaContext GLAPIENTRY
|
||||
OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
|
||||
GLint accumBits, OSMesaContext sharelist);
|
||||
|
||||
|
||||
/*
|
||||
* Create an Off-Screen Mesa rendering context with attribute list.
|
||||
* The list is composed of (attribute, value) pairs and terminated with
|
||||
* attribute==0. Supported Attributes:
|
||||
*
|
||||
* Attributes Values
|
||||
* --------------------------------------------------------------------------
|
||||
* OSMESA_FORMAT OSMESA_RGBA*, OSMESA_BGRA, OSMESA_ARGB, etc.
|
||||
* OSMESA_DEPTH_BITS 0*, 16, 24, 32
|
||||
* OSMESA_STENCIL_BITS 0*, 8
|
||||
* OSMESA_ACCUM_BITS 0*, 16
|
||||
* OSMESA_PROFILE OSMESA_COMPAT_PROFILE*, OSMESA_CORE_PROFILE
|
||||
* OSMESA_CONTEXT_MAJOR_VERSION 1*, 2, 3
|
||||
* OSMESA_CONTEXT_MINOR_VERSION 0+
|
||||
*
|
||||
* Note: * = default value
|
||||
*
|
||||
* We return a context version >= what's specified by OSMESA_CONTEXT_MAJOR/
|
||||
* MINOR_VERSION for the given profile. For example, if you request a GL 1.4
|
||||
* compat profile, you might get a GL 3.0 compat profile.
|
||||
* Otherwise, null is returned if the version/profile is not supported.
|
||||
*
|
||||
* New in Mesa 11.2
|
||||
*/
|
||||
GLAPI OSMesaContext GLAPIENTRY
|
||||
OSMesaCreateContextAttribs( const int *attribList, OSMesaContext sharelist );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Destroy an Off-Screen Mesa rendering context.
|
||||
*
|
||||
* Input: ctx - the context to destroy
|
||||
*/
|
||||
GLAPI void GLAPIENTRY
|
||||
OSMesaDestroyContext( OSMesaContext ctx );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Bind an OSMesaContext to an image buffer. The image buffer is just a
|
||||
* block of memory which the client provides. Its size must be at least
|
||||
* as large as width*height*sizeof(type). Its address should be a multiple
|
||||
* of 4 if using RGBA mode.
|
||||
*
|
||||
* Image data is stored in the order of glDrawPixels: row-major order
|
||||
* with the lower-left image pixel stored in the first array position
|
||||
* (ie. bottom-to-top).
|
||||
*
|
||||
* Since the only type initially supported is GL_UNSIGNED_BYTE, if the
|
||||
* context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
|
||||
* value. If the context is in color indexed mode, each pixel will be
|
||||
* stored as a 1-byte value.
|
||||
*
|
||||
* If the context's viewport hasn't been initialized yet, it will now be
|
||||
* initialized to (0,0,width,height).
|
||||
*
|
||||
* Input: ctx - the rendering context
|
||||
* buffer - the image buffer memory
|
||||
* type - data type for pixel components, only GL_UNSIGNED_BYTE
|
||||
* supported now
|
||||
* width, height - size of image buffer in pixels, at least 1
|
||||
* Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
|
||||
* invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
|
||||
* width>internal limit or height>internal limit.
|
||||
*/
|
||||
GLAPI GLboolean GLAPIENTRY
|
||||
OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,
|
||||
GLsizei width, GLsizei height );
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Return the current Off-Screen Mesa rendering context handle.
|
||||
*/
|
||||
GLAPI OSMesaContext GLAPIENTRY
|
||||
OSMesaGetCurrentContext( void );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Set pixel store/packing parameters for the current context.
|
||||
* This is similar to glPixelStore.
|
||||
* Input: pname - OSMESA_ROW_LENGTH
|
||||
* specify actual pixels per row in image buffer
|
||||
* 0 = same as image width (default)
|
||||
* OSMESA_Y_UP
|
||||
* zero = Y coordinates increase downward
|
||||
* non-zero = Y coordinates increase upward (default)
|
||||
* value - the value for the parameter pname
|
||||
*
|
||||
* New in version 2.0.
|
||||
*/
|
||||
GLAPI void GLAPIENTRY
|
||||
OSMesaPixelStore( GLint pname, GLint value );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Return an integer value like glGetIntegerv.
|
||||
* Input: pname -
|
||||
* OSMESA_WIDTH return current image width
|
||||
* OSMESA_HEIGHT return current image height
|
||||
* OSMESA_FORMAT return image format
|
||||
* OSMESA_TYPE return color component data type
|
||||
* OSMESA_ROW_LENGTH return row length in pixels
|
||||
* OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
|
||||
* value - pointer to integer in which to return result.
|
||||
*/
|
||||
GLAPI void GLAPIENTRY
|
||||
OSMesaGetIntegerv( GLint pname, GLint *value );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Return the depth buffer associated with an OSMesa context.
|
||||
* Input: c - the OSMesa context
|
||||
* Output: width, height - size of buffer in pixels
|
||||
* bytesPerValue - bytes per depth value (2 or 4)
|
||||
* buffer - pointer to depth buffer values
|
||||
* Return: GL_TRUE or GL_FALSE to indicate success or failure.
|
||||
*
|
||||
* New in Mesa 2.4.
|
||||
*/
|
||||
GLAPI GLboolean GLAPIENTRY
|
||||
OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height,
|
||||
GLint *bytesPerValue, void **buffer );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Return the color buffer associated with an OSMesa context.
|
||||
* Input: c - the OSMesa context
|
||||
* Output: width, height - size of buffer in pixels
|
||||
* format - buffer format (OSMESA_FORMAT)
|
||||
* buffer - pointer to depth buffer values
|
||||
* Return: GL_TRUE or GL_FALSE to indicate success or failure.
|
||||
*
|
||||
* New in Mesa 3.3.
|
||||
*/
|
||||
GLAPI GLboolean GLAPIENTRY
|
||||
OSMesaGetColorBuffer( OSMesaContext c, GLint *width, GLint *height,
|
||||
GLint *format, void **buffer );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This typedef is new in Mesa 6.3.
|
||||
*/
|
||||
typedef void (*OSMESAproc)();
|
||||
|
||||
|
||||
/*
|
||||
* Return pointer to the named function.
|
||||
* New in Mesa 4.1
|
||||
* Return OSMESAproc in 6.3.
|
||||
*/
|
||||
GLAPI OSMESAproc GLAPIENTRY
|
||||
OSMesaGetProcAddress( const char *funcName );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enable/disable color clamping, off by default.
|
||||
* New in Mesa 6.4.2
|
||||
*/
|
||||
GLAPI void GLAPIENTRY
|
||||
OSMesaColorClamp(GLboolean enable);
|
||||
|
||||
|
||||
/**
|
||||
* Enable/disable Gallium post-process filters.
|
||||
* This should be called after a context is created, but before it is
|
||||
* made current for the first time. After a context has been made
|
||||
* current, this function has no effect.
|
||||
* If the enable_value param is zero, the filter is disabled. Otherwise
|
||||
* the filter is enabled, and the value may control the filter's quality.
|
||||
* New in Mesa 10.0
|
||||
*/
|
||||
GLAPI void GLAPIENTRY
|
||||
OSMesaPostprocess(OSMesaContext osmesa, const char *filter,
|
||||
unsigned enable_value);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -9,6 +10,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <GL/osmesa.h>
|
||||
|
||||
#ifdef GLES_TEST
|
||||
#include <GLES2/gl2.h>
|
||||
|
|
@ -16,11 +18,568 @@
|
|||
|
||||
#include <android/native_window.h>
|
||||
#include <android/native_window_jni.h>
|
||||
|
||||
#include <android/rect.h>
|
||||
#include <string.h>
|
||||
#include "utils.h"
|
||||
// region OSMESA internals
|
||||
|
||||
struct pipe_screen;
|
||||
|
||||
//only get what we need to access/modify
|
||||
struct st_manager
|
||||
{
|
||||
struct pipe_screen *screen;
|
||||
};
|
||||
struct st_context_iface
|
||||
{
|
||||
void *st_context_private;
|
||||
};
|
||||
struct zink_device_info
|
||||
{
|
||||
bool have_EXT_conditional_rendering;
|
||||
bool have_EXT_transform_feedback;
|
||||
};
|
||||
struct zink_screen
|
||||
{
|
||||
struct zink_device_info info;
|
||||
};
|
||||
|
||||
enum st_attachment_type {
|
||||
ST_ATTACHMENT_FRONT_LEFT,
|
||||
ST_ATTACHMENT_BACK_LEFT,
|
||||
ST_ATTACHMENT_FRONT_RIGHT,
|
||||
ST_ATTACHMENT_BACK_RIGHT,
|
||||
ST_ATTACHMENT_DEPTH_STENCIL,
|
||||
ST_ATTACHMENT_ACCUM,
|
||||
ST_ATTACHMENT_SAMPLE,
|
||||
|
||||
ST_ATTACHMENT_COUNT,
|
||||
ST_ATTACHMENT_INVALID = -1
|
||||
};
|
||||
enum pipe_format {
|
||||
PIPE_FORMAT_NONE,
|
||||
PIPE_FORMAT_B8G8R8A8_UNORM,
|
||||
PIPE_FORMAT_B8G8R8X8_UNORM,
|
||||
PIPE_FORMAT_A8R8G8B8_UNORM,
|
||||
PIPE_FORMAT_X8R8G8B8_UNORM,
|
||||
PIPE_FORMAT_B5G5R5A1_UNORM,
|
||||
PIPE_FORMAT_R4G4B4A4_UNORM,
|
||||
PIPE_FORMAT_B4G4R4A4_UNORM,
|
||||
PIPE_FORMAT_R5G6B5_UNORM,
|
||||
PIPE_FORMAT_B5G6R5_UNORM,
|
||||
PIPE_FORMAT_R10G10B10A2_UNORM,
|
||||
PIPE_FORMAT_L8_UNORM, /**< ubyte luminance */
|
||||
PIPE_FORMAT_A8_UNORM, /**< ubyte alpha */
|
||||
PIPE_FORMAT_I8_UNORM, /**< ubyte intensity */
|
||||
PIPE_FORMAT_L8A8_UNORM, /**< ubyte alpha, luminance */
|
||||
PIPE_FORMAT_L16_UNORM, /**< ushort luminance */
|
||||
PIPE_FORMAT_UYVY,
|
||||
PIPE_FORMAT_YUYV,
|
||||
PIPE_FORMAT_Z16_UNORM,
|
||||
PIPE_FORMAT_Z16_UNORM_S8_UINT,
|
||||
PIPE_FORMAT_Z32_UNORM,
|
||||
PIPE_FORMAT_Z32_FLOAT,
|
||||
PIPE_FORMAT_Z24_UNORM_S8_UINT,
|
||||
PIPE_FORMAT_S8_UINT_Z24_UNORM,
|
||||
PIPE_FORMAT_Z24X8_UNORM,
|
||||
PIPE_FORMAT_X8Z24_UNORM,
|
||||
PIPE_FORMAT_S8_UINT, /**< ubyte stencil */
|
||||
PIPE_FORMAT_R64_FLOAT,
|
||||
PIPE_FORMAT_R64G64_FLOAT,
|
||||
PIPE_FORMAT_R64G64B64_FLOAT,
|
||||
PIPE_FORMAT_R64G64B64A64_FLOAT,
|
||||
PIPE_FORMAT_R32_FLOAT,
|
||||
PIPE_FORMAT_R32G32_FLOAT,
|
||||
PIPE_FORMAT_R32G32B32_FLOAT,
|
||||
PIPE_FORMAT_R32G32B32A32_FLOAT,
|
||||
PIPE_FORMAT_R32_UNORM,
|
||||
PIPE_FORMAT_R32G32_UNORM,
|
||||
PIPE_FORMAT_R32G32B32_UNORM,
|
||||
PIPE_FORMAT_R32G32B32A32_UNORM,
|
||||
PIPE_FORMAT_R32_USCALED,
|
||||
PIPE_FORMAT_R32G32_USCALED,
|
||||
PIPE_FORMAT_R32G32B32_USCALED,
|
||||
PIPE_FORMAT_R32G32B32A32_USCALED,
|
||||
PIPE_FORMAT_R32_SNORM,
|
||||
PIPE_FORMAT_R32G32_SNORM,
|
||||
PIPE_FORMAT_R32G32B32_SNORM,
|
||||
PIPE_FORMAT_R32G32B32A32_SNORM,
|
||||
PIPE_FORMAT_R32_SSCALED,
|
||||
PIPE_FORMAT_R32G32_SSCALED,
|
||||
PIPE_FORMAT_R32G32B32_SSCALED,
|
||||
PIPE_FORMAT_R32G32B32A32_SSCALED,
|
||||
PIPE_FORMAT_R16_UNORM,
|
||||
PIPE_FORMAT_R16G16_UNORM,
|
||||
PIPE_FORMAT_R16G16B16_UNORM,
|
||||
PIPE_FORMAT_R16G16B16A16_UNORM,
|
||||
PIPE_FORMAT_R16_USCALED,
|
||||
PIPE_FORMAT_R16G16_USCALED,
|
||||
PIPE_FORMAT_R16G16B16_USCALED,
|
||||
PIPE_FORMAT_R16G16B16A16_USCALED,
|
||||
PIPE_FORMAT_R16_SNORM,
|
||||
PIPE_FORMAT_R16G16_SNORM,
|
||||
PIPE_FORMAT_R16G16B16_SNORM,
|
||||
PIPE_FORMAT_R16G16B16A16_SNORM,
|
||||
PIPE_FORMAT_R16_SSCALED,
|
||||
PIPE_FORMAT_R16G16_SSCALED,
|
||||
PIPE_FORMAT_R16G16B16_SSCALED,
|
||||
PIPE_FORMAT_R16G16B16A16_SSCALED,
|
||||
PIPE_FORMAT_R8_UNORM,
|
||||
PIPE_FORMAT_R8G8_UNORM,
|
||||
PIPE_FORMAT_R8G8B8_UNORM,
|
||||
PIPE_FORMAT_B8G8R8_UNORM,
|
||||
PIPE_FORMAT_R8G8B8A8_UNORM,
|
||||
PIPE_FORMAT_X8B8G8R8_UNORM,
|
||||
PIPE_FORMAT_R8_USCALED,
|
||||
PIPE_FORMAT_R8G8_USCALED,
|
||||
PIPE_FORMAT_R8G8B8_USCALED,
|
||||
PIPE_FORMAT_B8G8R8_USCALED,
|
||||
PIPE_FORMAT_R8G8B8A8_USCALED,
|
||||
PIPE_FORMAT_B8G8R8A8_USCALED,
|
||||
PIPE_FORMAT_A8B8G8R8_USCALED,
|
||||
PIPE_FORMAT_R8_SNORM,
|
||||
PIPE_FORMAT_R8G8_SNORM,
|
||||
PIPE_FORMAT_R8G8B8_SNORM,
|
||||
PIPE_FORMAT_B8G8R8_SNORM,
|
||||
PIPE_FORMAT_R8G8B8A8_SNORM,
|
||||
PIPE_FORMAT_B8G8R8A8_SNORM,
|
||||
PIPE_FORMAT_R8_SSCALED,
|
||||
PIPE_FORMAT_R8G8_SSCALED,
|
||||
PIPE_FORMAT_R8G8B8_SSCALED,
|
||||
PIPE_FORMAT_B8G8R8_SSCALED,
|
||||
PIPE_FORMAT_R8G8B8A8_SSCALED,
|
||||
PIPE_FORMAT_B8G8R8A8_SSCALED,
|
||||
PIPE_FORMAT_A8B8G8R8_SSCALED,
|
||||
PIPE_FORMAT_R32_FIXED,
|
||||
PIPE_FORMAT_R32G32_FIXED,
|
||||
PIPE_FORMAT_R32G32B32_FIXED,
|
||||
PIPE_FORMAT_R32G32B32A32_FIXED,
|
||||
PIPE_FORMAT_R16_FLOAT,
|
||||
PIPE_FORMAT_R16G16_FLOAT,
|
||||
PIPE_FORMAT_R16G16B16_FLOAT,
|
||||
PIPE_FORMAT_R16G16B16A16_FLOAT,
|
||||
|
||||
/* sRGB formats */
|
||||
PIPE_FORMAT_L8_SRGB,
|
||||
PIPE_FORMAT_R8_SRGB,
|
||||
PIPE_FORMAT_L8A8_SRGB,
|
||||
PIPE_FORMAT_R8G8_SRGB,
|
||||
PIPE_FORMAT_R8G8B8_SRGB,
|
||||
PIPE_FORMAT_B8G8R8_SRGB,
|
||||
PIPE_FORMAT_A8B8G8R8_SRGB,
|
||||
PIPE_FORMAT_X8B8G8R8_SRGB,
|
||||
PIPE_FORMAT_B8G8R8A8_SRGB,
|
||||
PIPE_FORMAT_B8G8R8X8_SRGB,
|
||||
PIPE_FORMAT_A8R8G8B8_SRGB,
|
||||
PIPE_FORMAT_X8R8G8B8_SRGB,
|
||||
PIPE_FORMAT_R8G8B8A8_SRGB,
|
||||
|
||||
/* compressed formats */
|
||||
PIPE_FORMAT_DXT1_RGB,
|
||||
PIPE_FORMAT_DXT1_RGBA,
|
||||
PIPE_FORMAT_DXT3_RGBA,
|
||||
PIPE_FORMAT_DXT5_RGBA,
|
||||
|
||||
/* sRGB, compressed */
|
||||
PIPE_FORMAT_DXT1_SRGB,
|
||||
PIPE_FORMAT_DXT1_SRGBA,
|
||||
PIPE_FORMAT_DXT3_SRGBA,
|
||||
PIPE_FORMAT_DXT5_SRGBA,
|
||||
|
||||
/* rgtc compressed */
|
||||
PIPE_FORMAT_RGTC1_UNORM,
|
||||
PIPE_FORMAT_RGTC1_SNORM,
|
||||
PIPE_FORMAT_RGTC2_UNORM,
|
||||
PIPE_FORMAT_RGTC2_SNORM,
|
||||
|
||||
PIPE_FORMAT_R8G8_B8G8_UNORM,
|
||||
PIPE_FORMAT_G8R8_G8B8_UNORM,
|
||||
|
||||
/* mixed formats */
|
||||
PIPE_FORMAT_R8SG8SB8UX8U_NORM,
|
||||
PIPE_FORMAT_R5SG5SB6U_NORM,
|
||||
|
||||
/* TODO: re-order these */
|
||||
PIPE_FORMAT_A8B8G8R8_UNORM,
|
||||
PIPE_FORMAT_B5G5R5X1_UNORM,
|
||||
PIPE_FORMAT_R10G10B10A2_USCALED,
|
||||
PIPE_FORMAT_R11G11B10_FLOAT,
|
||||
PIPE_FORMAT_R9G9B9E5_FLOAT,
|
||||
PIPE_FORMAT_Z32_FLOAT_S8X24_UINT,
|
||||
PIPE_FORMAT_R1_UNORM,
|
||||
PIPE_FORMAT_R10G10B10X2_USCALED,
|
||||
PIPE_FORMAT_R10G10B10X2_SNORM,
|
||||
PIPE_FORMAT_L4A4_UNORM,
|
||||
PIPE_FORMAT_A2R10G10B10_UNORM,
|
||||
PIPE_FORMAT_A2B10G10R10_UNORM,
|
||||
PIPE_FORMAT_B10G10R10A2_UNORM,
|
||||
PIPE_FORMAT_R10SG10SB10SA2U_NORM,
|
||||
PIPE_FORMAT_R8G8Bx_SNORM,
|
||||
PIPE_FORMAT_R8G8B8X8_UNORM,
|
||||
PIPE_FORMAT_B4G4R4X4_UNORM,
|
||||
|
||||
/* some stencil samplers formats */
|
||||
PIPE_FORMAT_X24S8_UINT,
|
||||
PIPE_FORMAT_S8X24_UINT,
|
||||
PIPE_FORMAT_X32_S8X24_UINT,
|
||||
|
||||
PIPE_FORMAT_R3G3B2_UNORM,
|
||||
PIPE_FORMAT_B2G3R3_UNORM,
|
||||
PIPE_FORMAT_L16A16_UNORM,
|
||||
PIPE_FORMAT_A16_UNORM,
|
||||
PIPE_FORMAT_I16_UNORM,
|
||||
|
||||
PIPE_FORMAT_LATC1_UNORM,
|
||||
PIPE_FORMAT_LATC1_SNORM,
|
||||
PIPE_FORMAT_LATC2_UNORM,
|
||||
PIPE_FORMAT_LATC2_SNORM,
|
||||
|
||||
PIPE_FORMAT_A8_SNORM,
|
||||
PIPE_FORMAT_L8_SNORM,
|
||||
PIPE_FORMAT_L8A8_SNORM,
|
||||
PIPE_FORMAT_I8_SNORM,
|
||||
PIPE_FORMAT_A16_SNORM,
|
||||
PIPE_FORMAT_L16_SNORM,
|
||||
PIPE_FORMAT_L16A16_SNORM,
|
||||
PIPE_FORMAT_I16_SNORM,
|
||||
|
||||
PIPE_FORMAT_A16_FLOAT,
|
||||
PIPE_FORMAT_L16_FLOAT,
|
||||
PIPE_FORMAT_L16A16_FLOAT,
|
||||
PIPE_FORMAT_I16_FLOAT,
|
||||
PIPE_FORMAT_A32_FLOAT,
|
||||
PIPE_FORMAT_L32_FLOAT,
|
||||
PIPE_FORMAT_L32A32_FLOAT,
|
||||
PIPE_FORMAT_I32_FLOAT,
|
||||
|
||||
PIPE_FORMAT_YV12,
|
||||
PIPE_FORMAT_YV16,
|
||||
PIPE_FORMAT_IYUV, /**< aka I420 */
|
||||
PIPE_FORMAT_NV12,
|
||||
PIPE_FORMAT_NV21,
|
||||
|
||||
/* PIPE_FORMAT_Y8_U8_V8_420_UNORM = IYUV */
|
||||
/* PIPE_FORMAT_Y8_U8V8_420_UNORM = NV12 */
|
||||
PIPE_FORMAT_Y8_U8_V8_422_UNORM,
|
||||
PIPE_FORMAT_Y8_U8V8_422_UNORM,
|
||||
PIPE_FORMAT_Y8_U8_V8_444_UNORM,
|
||||
|
||||
PIPE_FORMAT_Y16_U16_V16_420_UNORM,
|
||||
/* PIPE_FORMAT_Y16_U16V16_420_UNORM */
|
||||
PIPE_FORMAT_Y16_U16_V16_422_UNORM,
|
||||
PIPE_FORMAT_Y16_U16V16_422_UNORM,
|
||||
PIPE_FORMAT_Y16_U16_V16_444_UNORM,
|
||||
|
||||
PIPE_FORMAT_A4R4_UNORM,
|
||||
PIPE_FORMAT_R4A4_UNORM,
|
||||
PIPE_FORMAT_R8A8_UNORM,
|
||||
PIPE_FORMAT_A8R8_UNORM,
|
||||
|
||||
PIPE_FORMAT_R10G10B10A2_SSCALED,
|
||||
PIPE_FORMAT_R10G10B10A2_SNORM,
|
||||
|
||||
PIPE_FORMAT_B10G10R10A2_USCALED,
|
||||
PIPE_FORMAT_B10G10R10A2_SSCALED,
|
||||
PIPE_FORMAT_B10G10R10A2_SNORM,
|
||||
|
||||
PIPE_FORMAT_R8_UINT,
|
||||
PIPE_FORMAT_R8G8_UINT,
|
||||
PIPE_FORMAT_R8G8B8_UINT,
|
||||
PIPE_FORMAT_R8G8B8A8_UINT,
|
||||
|
||||
PIPE_FORMAT_R8_SINT,
|
||||
PIPE_FORMAT_R8G8_SINT,
|
||||
PIPE_FORMAT_R8G8B8_SINT,
|
||||
PIPE_FORMAT_R8G8B8A8_SINT,
|
||||
|
||||
PIPE_FORMAT_R16_UINT,
|
||||
PIPE_FORMAT_R16G16_UINT,
|
||||
PIPE_FORMAT_R16G16B16_UINT,
|
||||
PIPE_FORMAT_R16G16B16A16_UINT,
|
||||
|
||||
PIPE_FORMAT_R16_SINT,
|
||||
PIPE_FORMAT_R16G16_SINT,
|
||||
PIPE_FORMAT_R16G16B16_SINT,
|
||||
PIPE_FORMAT_R16G16B16A16_SINT,
|
||||
|
||||
PIPE_FORMAT_R32_UINT,
|
||||
PIPE_FORMAT_R32G32_UINT,
|
||||
PIPE_FORMAT_R32G32B32_UINT,
|
||||
PIPE_FORMAT_R32G32B32A32_UINT,
|
||||
|
||||
PIPE_FORMAT_R32_SINT,
|
||||
PIPE_FORMAT_R32G32_SINT,
|
||||
PIPE_FORMAT_R32G32B32_SINT,
|
||||
PIPE_FORMAT_R32G32B32A32_SINT,
|
||||
|
||||
PIPE_FORMAT_R64_UINT,
|
||||
PIPE_FORMAT_R64_SINT,
|
||||
|
||||
PIPE_FORMAT_A8_UINT,
|
||||
PIPE_FORMAT_I8_UINT,
|
||||
PIPE_FORMAT_L8_UINT,
|
||||
PIPE_FORMAT_L8A8_UINT,
|
||||
|
||||
PIPE_FORMAT_A8_SINT,
|
||||
PIPE_FORMAT_I8_SINT,
|
||||
PIPE_FORMAT_L8_SINT,
|
||||
PIPE_FORMAT_L8A8_SINT,
|
||||
|
||||
PIPE_FORMAT_A16_UINT,
|
||||
PIPE_FORMAT_I16_UINT,
|
||||
PIPE_FORMAT_L16_UINT,
|
||||
PIPE_FORMAT_L16A16_UINT,
|
||||
|
||||
PIPE_FORMAT_A16_SINT,
|
||||
PIPE_FORMAT_I16_SINT,
|
||||
PIPE_FORMAT_L16_SINT,
|
||||
PIPE_FORMAT_L16A16_SINT,
|
||||
|
||||
PIPE_FORMAT_A32_UINT,
|
||||
PIPE_FORMAT_I32_UINT,
|
||||
PIPE_FORMAT_L32_UINT,
|
||||
PIPE_FORMAT_L32A32_UINT,
|
||||
|
||||
PIPE_FORMAT_A32_SINT,
|
||||
PIPE_FORMAT_I32_SINT,
|
||||
PIPE_FORMAT_L32_SINT,
|
||||
PIPE_FORMAT_L32A32_SINT,
|
||||
|
||||
PIPE_FORMAT_B8G8R8_UINT,
|
||||
PIPE_FORMAT_B8G8R8A8_UINT,
|
||||
|
||||
PIPE_FORMAT_B8G8R8_SINT,
|
||||
PIPE_FORMAT_B8G8R8A8_SINT,
|
||||
|
||||
PIPE_FORMAT_A8R8G8B8_UINT,
|
||||
PIPE_FORMAT_A8B8G8R8_UINT,
|
||||
PIPE_FORMAT_A2R10G10B10_UINT,
|
||||
PIPE_FORMAT_A2B10G10R10_UINT,
|
||||
PIPE_FORMAT_B10G10R10A2_UINT,
|
||||
PIPE_FORMAT_B10G10R10A2_SINT,
|
||||
PIPE_FORMAT_R5G6B5_UINT,
|
||||
PIPE_FORMAT_B5G6R5_UINT,
|
||||
PIPE_FORMAT_R5G5B5A1_UINT,
|
||||
PIPE_FORMAT_B5G5R5A1_UINT,
|
||||
PIPE_FORMAT_A1R5G5B5_UINT,
|
||||
PIPE_FORMAT_A1B5G5R5_UINT,
|
||||
PIPE_FORMAT_R4G4B4A4_UINT,
|
||||
PIPE_FORMAT_B4G4R4A4_UINT,
|
||||
PIPE_FORMAT_A4R4G4B4_UINT,
|
||||
PIPE_FORMAT_A4B4G4R4_UINT,
|
||||
PIPE_FORMAT_R3G3B2_UINT,
|
||||
PIPE_FORMAT_B2G3R3_UINT,
|
||||
|
||||
PIPE_FORMAT_ETC1_RGB8,
|
||||
|
||||
PIPE_FORMAT_R8G8_R8B8_UNORM,
|
||||
PIPE_FORMAT_G8R8_B8R8_UNORM,
|
||||
|
||||
PIPE_FORMAT_R8G8B8X8_SNORM,
|
||||
PIPE_FORMAT_R8G8B8X8_SRGB,
|
||||
PIPE_FORMAT_R8G8B8X8_UINT,
|
||||
PIPE_FORMAT_R8G8B8X8_SINT,
|
||||
PIPE_FORMAT_B10G10R10X2_UNORM,
|
||||
PIPE_FORMAT_R16G16B16X16_UNORM,
|
||||
PIPE_FORMAT_R16G16B16X16_SNORM,
|
||||
PIPE_FORMAT_R16G16B16X16_FLOAT,
|
||||
PIPE_FORMAT_R16G16B16X16_UINT,
|
||||
PIPE_FORMAT_R16G16B16X16_SINT,
|
||||
PIPE_FORMAT_R32G32B32X32_FLOAT,
|
||||
PIPE_FORMAT_R32G32B32X32_UINT,
|
||||
PIPE_FORMAT_R32G32B32X32_SINT,
|
||||
|
||||
PIPE_FORMAT_R8A8_SNORM,
|
||||
PIPE_FORMAT_R16A16_UNORM,
|
||||
PIPE_FORMAT_R16A16_SNORM,
|
||||
PIPE_FORMAT_R16A16_FLOAT,
|
||||
PIPE_FORMAT_R32A32_FLOAT,
|
||||
PIPE_FORMAT_R8A8_UINT,
|
||||
PIPE_FORMAT_R8A8_SINT,
|
||||
PIPE_FORMAT_R16A16_UINT,
|
||||
PIPE_FORMAT_R16A16_SINT,
|
||||
PIPE_FORMAT_R32A32_UINT,
|
||||
PIPE_FORMAT_R32A32_SINT,
|
||||
PIPE_FORMAT_R10G10B10A2_UINT,
|
||||
PIPE_FORMAT_R10G10B10A2_SINT,
|
||||
|
||||
PIPE_FORMAT_B5G6R5_SRGB,
|
||||
|
||||
PIPE_FORMAT_BPTC_RGBA_UNORM,
|
||||
PIPE_FORMAT_BPTC_SRGBA,
|
||||
PIPE_FORMAT_BPTC_RGB_FLOAT,
|
||||
PIPE_FORMAT_BPTC_RGB_UFLOAT,
|
||||
|
||||
PIPE_FORMAT_G8R8_UNORM,
|
||||
PIPE_FORMAT_G8R8_SNORM,
|
||||
PIPE_FORMAT_G16R16_UNORM,
|
||||
PIPE_FORMAT_G16R16_SNORM,
|
||||
|
||||
PIPE_FORMAT_A8B8G8R8_SNORM,
|
||||
PIPE_FORMAT_X8B8G8R8_SNORM,
|
||||
|
||||
PIPE_FORMAT_ETC2_RGB8,
|
||||
PIPE_FORMAT_ETC2_SRGB8,
|
||||
PIPE_FORMAT_ETC2_RGB8A1,
|
||||
PIPE_FORMAT_ETC2_SRGB8A1,
|
||||
PIPE_FORMAT_ETC2_RGBA8,
|
||||
PIPE_FORMAT_ETC2_SRGBA8,
|
||||
PIPE_FORMAT_ETC2_R11_UNORM,
|
||||
PIPE_FORMAT_ETC2_R11_SNORM,
|
||||
PIPE_FORMAT_ETC2_RG11_UNORM,
|
||||
PIPE_FORMAT_ETC2_RG11_SNORM,
|
||||
|
||||
PIPE_FORMAT_ASTC_4x4,
|
||||
PIPE_FORMAT_ASTC_5x4,
|
||||
PIPE_FORMAT_ASTC_5x5,
|
||||
PIPE_FORMAT_ASTC_6x5,
|
||||
PIPE_FORMAT_ASTC_6x6,
|
||||
PIPE_FORMAT_ASTC_8x5,
|
||||
PIPE_FORMAT_ASTC_8x6,
|
||||
PIPE_FORMAT_ASTC_8x8,
|
||||
PIPE_FORMAT_ASTC_10x5,
|
||||
PIPE_FORMAT_ASTC_10x6,
|
||||
PIPE_FORMAT_ASTC_10x8,
|
||||
PIPE_FORMAT_ASTC_10x10,
|
||||
PIPE_FORMAT_ASTC_12x10,
|
||||
PIPE_FORMAT_ASTC_12x12,
|
||||
|
||||
PIPE_FORMAT_ASTC_4x4_SRGB,
|
||||
PIPE_FORMAT_ASTC_5x4_SRGB,
|
||||
PIPE_FORMAT_ASTC_5x5_SRGB,
|
||||
PIPE_FORMAT_ASTC_6x5_SRGB,
|
||||
PIPE_FORMAT_ASTC_6x6_SRGB,
|
||||
PIPE_FORMAT_ASTC_8x5_SRGB,
|
||||
PIPE_FORMAT_ASTC_8x6_SRGB,
|
||||
PIPE_FORMAT_ASTC_8x8_SRGB,
|
||||
PIPE_FORMAT_ASTC_10x5_SRGB,
|
||||
PIPE_FORMAT_ASTC_10x6_SRGB,
|
||||
PIPE_FORMAT_ASTC_10x8_SRGB,
|
||||
PIPE_FORMAT_ASTC_10x10_SRGB,
|
||||
PIPE_FORMAT_ASTC_12x10_SRGB,
|
||||
PIPE_FORMAT_ASTC_12x12_SRGB,
|
||||
|
||||
PIPE_FORMAT_ASTC_3x3x3,
|
||||
PIPE_FORMAT_ASTC_4x3x3,
|
||||
PIPE_FORMAT_ASTC_4x4x3,
|
||||
PIPE_FORMAT_ASTC_4x4x4,
|
||||
PIPE_FORMAT_ASTC_5x4x4,
|
||||
PIPE_FORMAT_ASTC_5x5x4,
|
||||
PIPE_FORMAT_ASTC_5x5x5,
|
||||
PIPE_FORMAT_ASTC_6x5x5,
|
||||
PIPE_FORMAT_ASTC_6x6x5,
|
||||
PIPE_FORMAT_ASTC_6x6x6,
|
||||
|
||||
PIPE_FORMAT_ASTC_3x3x3_SRGB,
|
||||
PIPE_FORMAT_ASTC_4x3x3_SRGB,
|
||||
PIPE_FORMAT_ASTC_4x4x3_SRGB,
|
||||
PIPE_FORMAT_ASTC_4x4x4_SRGB,
|
||||
PIPE_FORMAT_ASTC_5x4x4_SRGB,
|
||||
PIPE_FORMAT_ASTC_5x5x4_SRGB,
|
||||
PIPE_FORMAT_ASTC_5x5x5_SRGB,
|
||||
PIPE_FORMAT_ASTC_6x5x5_SRGB,
|
||||
PIPE_FORMAT_ASTC_6x6x5_SRGB,
|
||||
PIPE_FORMAT_ASTC_6x6x6_SRGB,
|
||||
|
||||
PIPE_FORMAT_FXT1_RGB,
|
||||
PIPE_FORMAT_FXT1_RGBA,
|
||||
|
||||
PIPE_FORMAT_P010,
|
||||
PIPE_FORMAT_P012,
|
||||
PIPE_FORMAT_P016,
|
||||
|
||||
PIPE_FORMAT_R10G10B10X2_UNORM,
|
||||
PIPE_FORMAT_A1R5G5B5_UNORM,
|
||||
PIPE_FORMAT_A1B5G5R5_UNORM,
|
||||
PIPE_FORMAT_X1B5G5R5_UNORM,
|
||||
PIPE_FORMAT_R5G5B5A1_UNORM,
|
||||
PIPE_FORMAT_A4R4G4B4_UNORM,
|
||||
PIPE_FORMAT_A4B4G4R4_UNORM,
|
||||
|
||||
PIPE_FORMAT_G8R8_SINT,
|
||||
PIPE_FORMAT_A8B8G8R8_SINT,
|
||||
PIPE_FORMAT_X8B8G8R8_SINT,
|
||||
|
||||
PIPE_FORMAT_ATC_RGB,
|
||||
PIPE_FORMAT_ATC_RGBA_EXPLICIT,
|
||||
PIPE_FORMAT_ATC_RGBA_INTERPOLATED,
|
||||
|
||||
PIPE_FORMAT_Z24_UNORM_S8_UINT_AS_R8G8B8A8,
|
||||
|
||||
PIPE_FORMAT_AYUV,
|
||||
PIPE_FORMAT_XYUV,
|
||||
|
||||
PIPE_FORMAT_R8_G8B8_420_UNORM,
|
||||
|
||||
PIPE_FORMAT_COUNT
|
||||
};
|
||||
|
||||
struct st_visual
|
||||
{
|
||||
bool no_config;
|
||||
|
||||
/**
|
||||
* Available buffers. Bitfield of ST_ATTACHMENT_*_MASK bits.
|
||||
*/
|
||||
unsigned buffer_mask;
|
||||
|
||||
/**
|
||||
* Buffer formats. The formats are always set even when the buffer is
|
||||
* not available.
|
||||
*/
|
||||
enum pipe_format color_format;
|
||||
enum pipe_format depth_stencil_format;
|
||||
enum pipe_format accum_format;
|
||||
unsigned samples;
|
||||
|
||||
/**
|
||||
* Desired render buffer.
|
||||
*/
|
||||
enum st_attachment_type render_buffer;
|
||||
};
|
||||
typedef struct osmesa_buffer
|
||||
{
|
||||
struct st_framebuffer_iface *stfb;
|
||||
struct st_visual visual;
|
||||
unsigned width, height;
|
||||
|
||||
struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
|
||||
|
||||
void *map;
|
||||
|
||||
struct osmesa_buffer *next; /**< next in linked list */
|
||||
};
|
||||
|
||||
|
||||
typedef struct osmesa_context
|
||||
{
|
||||
struct st_context_iface *stctx;
|
||||
|
||||
bool ever_used; /*< Has this context ever been current? */
|
||||
|
||||
struct osmesa_buffer *current_buffer;
|
||||
|
||||
/* Storage for depth/stencil, if the user has requested access. The backing
|
||||
* driver always has its own storage for the actual depth/stencil, which we
|
||||
* have to transfer in and out.
|
||||
*/
|
||||
void *zs;
|
||||
unsigned zs_stride;
|
||||
|
||||
enum pipe_format depth_stencil_format, accum_format;
|
||||
|
||||
GLenum format; /*< User-specified context format */
|
||||
GLenum type; /*< Buffer's data type */
|
||||
GLint user_row_length; /*< user-specified number of pixels per row */
|
||||
GLboolean y_up; /*< TRUE -> Y increases upward */
|
||||
/*< FALSE -> Y increases downward */
|
||||
|
||||
/** Which postprocessing filters are enabled. */
|
||||
//safe to remove
|
||||
};
|
||||
// endregion OSMESA internals
|
||||
struct PotatoBridge {
|
||||
/* ANativeWindow */ void* androidWindow;
|
||||
/*ANativeWindow */ void* androidWindow;
|
||||
|
||||
/* EGLContext */ void* eglContextOld;
|
||||
/* EGLContext */ void* eglContext;
|
||||
|
|
@ -31,21 +590,36 @@ struct PotatoBridge {
|
|||
void* eglSurfaceDraw;
|
||||
*/
|
||||
};
|
||||
struct PotatoBridge potatoBridge;
|
||||
EGLConfig config;
|
||||
struct PotatoBridge potatoBridge;
|
||||
GLboolean (*OSMesaMakeCurrent_p) (OSMesaContext ctx, void *buffer, GLenum type,
|
||||
GLsizei width, GLsizei height);
|
||||
OSMesaContext (*OSMesaGetCurrentContext_p) (void);
|
||||
OSMesaContext (*OSMesaCreateContext_p) (GLenum format, OSMesaContext sharelist);
|
||||
void (*OSMesaDestroyContext_p) (OSMesaContext ctx);
|
||||
void (*OSMesaPixelStore_p) ( GLint pname, GLint value );
|
||||
GLubyte* (*glGetString_p) (GLenum name);
|
||||
void (*glFinish_p) (void);
|
||||
void (*glClearColor_p) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
||||
void (*glClear_p) (GLbitfield mask);
|
||||
|
||||
typedef jint RegalMakeCurrent_func(EGLContext context);
|
||||
#define RENDERER_GL4ES 1
|
||||
#define RENDERER_VK_ZINK 2
|
||||
|
||||
int config_renderer;
|
||||
|
||||
// Called from JNI_OnLoad of liblwjgl_opengl
|
||||
void pojav_openGLOnLoad() {
|
||||
|
||||
}
|
||||
void pojav_openGLOnUnload() {
|
||||
|
||||
}
|
||||
void* gbuffer;
|
||||
|
||||
void terminateEgl() {
|
||||
printf("EGLBridge: Terminating\n");
|
||||
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES: {
|
||||
eglMakeCurrent(potatoBridge.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglDestroySurface(potatoBridge.eglDisplay, potatoBridge.eglSurface);
|
||||
eglDestroyContext(potatoBridge.eglDisplay, potatoBridge.eglContext);
|
||||
|
|
@ -55,6 +629,12 @@ void terminateEgl() {
|
|||
potatoBridge.eglContext = EGL_NO_CONTEXT;
|
||||
potatoBridge.eglDisplay = EGL_NO_DISPLAY;
|
||||
potatoBridge.eglSurface = EGL_NO_SURFACE;
|
||||
} break;
|
||||
|
||||
case RENDERER_VK_ZINK: {
|
||||
// Nothing to do here
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_utils_JREUtils_setupBridgeWindow(JNIEnv* env, jclass clazz, jobject surface) {
|
||||
|
|
@ -62,10 +642,27 @@ JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_utils_JREUtils_setupBridgeWindow
|
|||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglGetCurrentContext(JNIEnv* env, jclass clazz) {
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES:
|
||||
return (jlong) eglGetCurrentContext();
|
||||
|
||||
case RENDERER_VK_ZINK:
|
||||
return (jlong) OSMesaGetCurrentContext_p();
|
||||
|
||||
default: return (jlong) 0;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglInit(JNIEnv* env, jclass clazz) {
|
||||
ANativeWindow_acquire(potatoBridge.androidWindow);
|
||||
savedWidth = ANativeWindow_getWidth(potatoBridge.androidWindow);
|
||||
savedHeight = ANativeWindow_getHeight(potatoBridge.androidWindow);
|
||||
ANativeWindow_setBuffersGeometry(potatoBridge.androidWindow,savedWidth,savedHeight,AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM);
|
||||
|
||||
const char *renderer = getenv("POJAV_RENDERER");
|
||||
if (strncmp("opengles", renderer, 8) == 0) {
|
||||
config_renderer = RENDERER_GL4ES;
|
||||
|
||||
if (potatoBridge.eglDisplay == NULL || potatoBridge.eglDisplay == EGL_NO_DISPLAY) {
|
||||
potatoBridge.eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (potatoBridge.eglDisplay == EGL_NO_DISPLAY) {
|
||||
|
|
@ -128,7 +725,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglInit(JNIEnv* env, j
|
|||
assert(val & EGL_WINDOW_BIT);
|
||||
}
|
||||
|
||||
|
||||
printf("EGLBridge: Initialized!\n");
|
||||
printf("EGLBridge: ThreadID=%d\n", gettid());
|
||||
printf("EGLBridge: EGLDisplay=%p, EGLSurface=%p\n",
|
||||
|
|
@ -137,10 +733,94 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglInit(JNIEnv* env, j
|
|||
potatoBridge.eglSurface
|
||||
);
|
||||
return JNI_TRUE;
|
||||
} else if (strcmp(renderer, "vulkan_zink") == 0) {
|
||||
config_renderer = RENDERER_VK_ZINK;
|
||||
|
||||
setenv("GALLIUM_DRIVER","zink",1);
|
||||
void* dl_handle = dlopen("libOSMesa.so.8",RTLD_NOLOAD|RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
|
||||
if (!dl_handle) {
|
||||
dl_handle = dlopen("libOSMesa_8.so",RTLD_NOLOAD|RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
|
||||
printf("OSMDroid: using built-in libOSMesa_8.so\n");
|
||||
} else {
|
||||
printf("OSMDroid: using developer libOSMesa.so.8 instead of built-in\n");
|
||||
}
|
||||
|
||||
if(dl_handle == NULL) {
|
||||
printf("OSMDroid: unable to load: %s\n",dlerror());
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
OSMesaMakeCurrent_p = dlsym(dl_handle,"OSMesaMakeCurrent");
|
||||
OSMesaGetCurrentContext_p = dlsym(dl_handle,"OSMesaGetCurrentContext");
|
||||
OSMesaCreateContext_p = dlsym(dl_handle, "OSMesaCreateContext");
|
||||
OSMesaDestroyContext_p = dlsym(dl_handle, "OSMesaDestroyContext");
|
||||
OSMesaPixelStore_p = dlsym(dl_handle,"OSMesaPixelStore");
|
||||
glGetString_p = dlsym(dl_handle,"glGetString");
|
||||
glClearColor_p = dlsym(dl_handle, "glClearColor");
|
||||
glClear_p = dlsym(dl_handle,"glClear");
|
||||
glFinish_p = dlsym(dl_handle,"glFinish");
|
||||
|
||||
if(OSMesaCreateContext_p == NULL) {
|
||||
printf("OSMDroid: %s\n",dlerror());
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
printf("OSMDroid: width=%i;height=%i, reserving %i bytes for frame buffer\n", savedWidth, savedHeight,
|
||||
savedWidth * 4 * savedHeight);
|
||||
gbuffer = malloc(savedWidth * 4 * savedHeight+1);
|
||||
if (gbuffer) {
|
||||
printf("OSMDroid: created frame buffer\n");
|
||||
return JNI_TRUE;
|
||||
} else {
|
||||
printf("OSMDroid: can't generate frame buffer\n");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return JNI_FALSE;
|
||||
}
|
||||
ANativeWindow_Buffer buf;
|
||||
int32_t stride;
|
||||
bool stopSwapBuffers;
|
||||
void flipFrame() {
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES: {
|
||||
if (!eglSwapBuffers(potatoBridge.eglDisplay, eglGetCurrentSurface(EGL_DRAW))) {
|
||||
if (eglGetError() == EGL_BAD_SURFACE) {
|
||||
stopSwapBuffers = true;
|
||||
closeGLFWWindow();
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
case RENDERER_VK_ZINK: {
|
||||
((struct osmesa_context)*OSMesaGetCurrentContext_p())
|
||||
.current_buffer->map = buf.bits;
|
||||
glFinish_p();
|
||||
ANativeWindow_unlockAndPost(potatoBridge.androidWindow);
|
||||
ANativeWindow_lock(potatoBridge.androidWindow,&buf,NULL);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglSwapBuffers(JNIEnv *env, jclass clazz) {
|
||||
if (stopSwapBuffers) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
flipFrame();
|
||||
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
bool locked = false;
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglMakeCurrent(JNIEnv* env, jclass clazz, jlong window) {
|
||||
//if(OSMesaGetCurrentContext_p() != NULL) {
|
||||
// printf("OSMDroid: skipped context reset\n");
|
||||
// return JNI_TRUE;
|
||||
//}
|
||||
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES: {
|
||||
EGLContext *currCtx = eglGetCurrentContext();
|
||||
printf("EGLBridge: Comparing: thr=%d, this=%p, curr=%p\n", gettid(), window, currCtx);
|
||||
if (currCtx == NULL || window == 0) {
|
||||
|
|
@ -187,16 +867,56 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglMakeCurrent(JNIEnv*
|
|||
// (*env)->ThrowNew(env,(*env)->FindClass(env,"java/lang/Exception"),"Trace exception");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
case RENDERER_VK_ZINK: {
|
||||
printf("OSMDroid: making current\n");
|
||||
OSMesaMakeCurrent_p((OSMesaContext)window,gbuffer,GL_UNSIGNED_BYTE,savedWidth,savedHeight);
|
||||
ANativeWindow_lock(potatoBridge.androidWindow,&buf,NULL);
|
||||
OSMesaPixelStore_p(OSMESA_ROW_LENGTH,buf.stride);
|
||||
stride = buf.stride;
|
||||
//ANativeWindow_unlockAndPost(potatoBridge.androidWindow);
|
||||
|
||||
if (getenv("ZINK_FORCEGL") == "1") {
|
||||
printf("OSMDroid: Forcing enable Vulkan extensions for Zink\n");
|
||||
struct zink_screen *zscreen = ((struct st_manager*)((OSMesaContext)window)->stctx->st_context_private)->screen;
|
||||
|
||||
// OpenGL 3.0
|
||||
zscreen->info.have_EXT_transform_feedback = true;
|
||||
zscreen->info.have_EXT_conditional_rendering = true;
|
||||
// zscreen->info.feats.features.independentBlend = true;
|
||||
}
|
||||
|
||||
OSMesaPixelStore_p(OSMESA_Y_UP,0);
|
||||
printf("OSMDroid: vendor: %s\n",glGetString_p(GL_VENDOR));
|
||||
printf("OSMDroid: renderer: %s\n",glGetString_p(GL_RENDERER));
|
||||
glClear_p(GL_COLOR_BUFFER_BIT);
|
||||
glClearColor_p(0.4f, 0.4f, 0.4f, 1.0f);
|
||||
flipFrame();
|
||||
return JNI_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_lwjgl_glfw_GLFW_nativeEglDetachOnCurrentThread(JNIEnv *env, jclass clazz) {
|
||||
//Obstruct the context on the current thread
|
||||
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES: {
|
||||
eglMakeCurrent(potatoBridge.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
} break;
|
||||
|
||||
case RENDERER_VK_ZINK: {
|
||||
// Nothing to do here
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_org_lwjgl_glfw_GLFW_nativeEglCreateContext(JNIEnv *env, jclass clazz, jlong contextSrc) {
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES: {
|
||||
const EGLint ctx_attribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, atoi(getenv("LIBGL_ES")),
|
||||
EGL_NONE
|
||||
|
|
@ -208,6 +928,15 @@ Java_org_lwjgl_glfw_GLFW_nativeEglCreateContext(JNIEnv *env, jclass clazz, jlong
|
|||
printf("EGLBridge: Created CTX pointer = %p\n",ctx);
|
||||
//(*env)->ThrowNew(env,(*env)->FindClass(env,"java/lang/Exception"),"Trace exception");
|
||||
return (long)ctx;
|
||||
}
|
||||
|
||||
case RENDERER_VK_ZINK: {
|
||||
printf("OSMDroid: generating context\n");
|
||||
void* ctx = OSMesaCreateContext_p(OSMESA_RGBA,contextSrc);
|
||||
printf("OSMDroid: context=%p",ctx);
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglTerminate(JNIEnv* env, jclass clazz) {
|
||||
|
|
@ -216,29 +945,35 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglTerminate(JNIEnv* e
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL_nativeRegalMakeCurrent(JNIEnv *env, jclass clazz) {
|
||||
printf("Regal: making current");
|
||||
/*printf("Regal: making current");
|
||||
|
||||
RegalMakeCurrent_func *RegalMakeCurrent = (RegalMakeCurrent_func *) dlsym(RTLD_DEFAULT, "RegalMakeCurrent");
|
||||
RegalMakeCurrent(potatoBridge.eglContext);
|
||||
RegalMakeCurrent(potatoBridge.eglContext);*/
|
||||
|
||||
printf("regal removed\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
bool stopSwapBuffers;
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglSwapBuffers(JNIEnv *env, jclass clazz) {
|
||||
if (stopSwapBuffers) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
jboolean result = (jboolean) eglSwapBuffers(potatoBridge.eglDisplay, eglGetCurrentSurface(EGL_DRAW));
|
||||
if (!result) {
|
||||
if (eglGetError() == EGL_BAD_SURFACE) {
|
||||
stopSwapBuffers = true;
|
||||
closeGLFWWindow();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_org_lwjgl_opengl_GL_getGraphicsBufferAddr(JNIEnv *env, jobject thiz) {
|
||||
return &gbuffer;
|
||||
}
|
||||
JNIEXPORT jintArray JNICALL
|
||||
Java_org_lwjgl_opengl_GL_getNativeWidthHeight(JNIEnv *env, jobject thiz) {
|
||||
jintArray ret = (*env)->NewIntArray(env,2);
|
||||
jint arr[] = {savedWidth, savedHeight};
|
||||
(*env)->SetIntArrayRegion(env,ret,0,2,arr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_GLFW_nativeEglSwapInterval(JNIEnv *env, jclass clazz, jint interval) {
|
||||
switch (config_renderer) {
|
||||
case RENDERER_GL4ES: {
|
||||
return eglSwapInterval(potatoBridge.eglDisplay, interval);
|
||||
} break;
|
||||
|
||||
case RENDERER_VK_ZINK: {
|
||||
printf("eglSwapInterval: NOT IMPLEMENTED YET!\n");
|
||||
// Nothing to do here
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/libOSMesa_8.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/arm64-v8a/libOSMesa_8.so
Normal file
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/armeabi-v7a/libOSMesa_8.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/armeabi-v7a/libOSMesa_8.so
Normal file
Binary file not shown.
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/libOSMesa_8.so
Normal file
BIN
app_pojavlauncher/src/main/jniLibs/x86_64/libOSMesa_8.so
Normal file
Binary file not shown.
|
|
@ -8,12 +8,16 @@
|
|||
</string-array>
|
||||
|
||||
<string-array name="renderer">
|
||||
<item name="2">@string/mcl_setting_renderer_gles2</item>
|
||||
<item name="3">@string/mcl_setting_renderer_gles3</item>
|
||||
<item name="2">@string/mcl_setting_renderer_gles2_4</item>
|
||||
<item name="3">@string/mcl_setting_renderer_gles2_5</item>
|
||||
<item name="3">@string/mcl_setting_renderer_gles3_5</item>
|
||||
<item name="4">@string/mcl_setting_renderer_vulkan_zink</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="renderer_values">
|
||||
<item>opengles2</item>
|
||||
<item>opengles3</item>
|
||||
<item>opengles2</item> <!-- gl4es 1.1.4 with OpenGL ES 2 -->
|
||||
<item>opengles2_5</item> <!-- gl4es 1.1.5 with OpenGL ES 2 -->
|
||||
<item>opengles3</item> <!-- gl4es 1.1.5 with OpenGL ES 3 -->
|
||||
<item>vulkan_zink</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -99,8 +99,10 @@
|
|||
<string name="mcl_setting_category_general">General settings</string>
|
||||
<string name="mcl_setting_category_scaling">Scaling settings</string>
|
||||
<string name="mcl_setting_category_renderer">Renderer</string>
|
||||
<string name="mcl_setting_renderer_gles2">OpenGL ES 2</string>
|
||||
<string name="mcl_setting_renderer_gles3">OpenGL ES 3</string>
|
||||
<string name="mcl_setting_renderer_gles2_4">gl4es 1.1.4 (OpenGL ES 2): exports OpenGL 2.1</string>
|
||||
<string name="mcl_setting_renderer_gles2_5">gl4es 1.1.5 (OpenGL ES 2): exports OpenGL 2.1</string>
|
||||
<string name="mcl_setting_renderer_gles3_5">gl4es 1.1.5 (OpenGL ES 3): exports OpenGL 2.1 + partial 3.2 (no 1.17 supported yet)</string>
|
||||
<string name="mcl_setting_renderer_vulkan_zink">zink (Vulkan): exports OpenGL 4.6</string>
|
||||
<string name="mcl_setting_category_veroption">Version type will be in version list</string>
|
||||
<string name="mcl_setting_veroption_release">Release</string>
|
||||
<string name="mcl_setting_veroption_snapshot">Snapshot</string>
|
||||
|
|
@ -121,30 +123,13 @@
|
|||
<string name="global_error_field_empty">This field can\'t be empty</string>
|
||||
<string name="global_waiting">Wait</string>
|
||||
|
||||
<!--
|
||||
<string name="mcl_about">
|
||||
%1$s BETA (Minecraft Java launcher for Android), version " + PathTools.usingVerName + "\n" +
|
||||
" - by Khanh Duy Tran (based from \"Boardwalk\" app)\n" +
|
||||
"Using libraries:\n" +
|
||||
" • LWJGL " + org.lwjgl.Sys.getVersion() + "\n" +
|
||||
//" • Boardwalk memory manager (not used now).\n" +
|
||||
" • gl4es: OpenGL for OpenGL ES devices by lunixbochs and ptitSeb.\n" +
|
||||
" • OpenJDK" +
|
||||
"\n" +
|
||||
"* Notes:\n" +
|
||||
" - This app is currently BETA, it will not be stable.\n" +
|
||||
//"* This app will unstable on Android 7.0 or higher devices.\n" +
|
||||
" - This app only use LWJGL2 and don't have a JRE8 desugar, so doesn't support 1.13 or higher versions.\n" +
|
||||
" - This app is not affiliated with Minecraft, Mojang or Microsoft.\n")
|
||||
</string>
|
||||
-->
|
||||
|
||||
<!-- MainActivity: strings -->
|
||||
<string name="mcn_exit_title">Application/Game exited with code %d</string>
|
||||
<string name="mcn_exit_call">Exit</string>
|
||||
<string name="mcn_exit_confirm">Are you sure want to force close?</string>
|
||||
<string name="mcn_check_fail_lwjgl">LWJGL3 was not installed!</string>
|
||||
<string name="mcn_check_fail_incompatiblearch">Architecture %1$s is incompatible with Java Runtime %2$s.</string>
|
||||
<string name="mcn_check_fail_vulkan_support">Vulkan Zink renderer is not supported on this device!</string>
|
||||
|
||||
<!-- MainActivity: Control buttons -->
|
||||
<string name="control_toggle">GUI</string>
|
||||
|
|
|
|||
|
|
@ -330,7 +330,8 @@ public final class GL {
|
|||
public static GLCapabilities createCapabilities() {
|
||||
return createCapabilities(false);
|
||||
}
|
||||
|
||||
private static native long getGraphicsBufferAddr();
|
||||
private static native int[] getNativeWidthHeight();
|
||||
/**
|
||||
* Creates a new {@link GLCapabilities} instance for the OpenGL context that is current in the current thread.
|
||||
*
|
||||
|
|
@ -345,12 +346,6 @@ public final class GL {
|
|||
*/
|
||||
@SuppressWarnings("AssignmentToMethodParameter")
|
||||
public static GLCapabilities createCapabilities(boolean forwardCompatible) {
|
||||
// This fixed framebuffer issue on 1.13+ 64-bit by another making current
|
||||
GLFW.nativeEglMakeCurrent(GLFW.mainContext);
|
||||
|
||||
if (isUsingRegal /* && Long.parseLong(System.getProperty("glfwstub.internal.glthreadid", "-1")) != Thread.currentThread().getId() */) {
|
||||
nativeRegalMakeCurrent();
|
||||
}
|
||||
// System.setProperty("glfwstub.internal.glthreadid", Long.toString(Thread.currentThread().getId()));
|
||||
|
||||
FunctionProvider functionProvider = GL.functionProvider;
|
||||
|
|
@ -361,6 +356,17 @@ public final class GL {
|
|||
GLCapabilities caps = null;
|
||||
|
||||
try {
|
||||
if (System.getenv("POJAV_RENDERER").startsWith("opengles")) {
|
||||
// This fixed framebuffer issue on 1.13+ 64-bit by another making current
|
||||
GLFW.nativeEglMakeCurrent(GLFW.mainContext);
|
||||
if (isUsingRegal /* && Long.parseLong(System.getProperty("glfwstub.internal.glthreadid", "-1")) != Thread.currentThread().getId() */) {
|
||||
nativeRegalMakeCurrent();
|
||||
}
|
||||
} else if (System.getenv("POJAV_RENDERER").equals("vulkan_zink")) {
|
||||
int[] dims = getNativeWidthHeight();
|
||||
callJPI(GLFW.glfwGetCurrentContext(),getGraphicsBufferAddr(),GL_UNSIGNED_BYTE,dims[0],dims[1],functionProvider.getFunctionAddress("OSMesaMakeCurrent"));
|
||||
}
|
||||
|
||||
// We don't have a current ContextCapabilities when this method is called
|
||||
// so we have to use the native bindings directly.
|
||||
long GetError = functionProvider.getFunctionAddress("glGetError");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue