Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add a switch between different render backends #59

Closed
artdeell opened this issue Apr 4, 2020 · 373 comments
Closed

Feature request: Add a switch between different render backends #59

artdeell opened this issue Apr 4, 2020 · 373 comments

Comments

@artdeell
Copy link
Member

artdeell commented Apr 4, 2020

I have an idea: because ~40% of Android 7 devices are supplied with Vulkan drivers, and in some cases Vulkan will be more performant than OpenGL ES, you would try to create a switch, that will change wrappers:
Current GL4ES or
Zink (as Mesa driver) or
Software rasterizer (if your device is Core i9-9900k witk VGA 256-color GPU and Android-x86)

I can try to help you with adding Mesa(for Zink) natively to your project, but i don't know how to implement a switch.

If you're heard about Mesa only as a software rasterizer, you can read the Mesa's wiki.

Zink is an efficent Vulkan-to-GL wrapper written in a form of Mesa driver. It emulates OpenGL 3(!), and knows how to convert shaders. Zhuowei Zhang already tested it with Boardwalk,
but that version was never released.

@khanhduytran0
Copy link
Member

khanhduytran0 commented Apr 4, 2020

Software rasterizer (if your device is Core i9-9900k witk VGA 256-color GPU and Android-x86).

No, i only have Core I5 8250U (1.6ghz, laptop), and 4gb ram so this is why I dual-boot instead of install emulator.

I had take a read at Zink but don't know how to create a switch, or set LD_LIBRARY_PATH???
LWJGL load only libgl04es.so so if libzinkgl.so or something LWJGL can't find, so need to create 2 different liblwjgl.so

@artdeell
Copy link
Member Author

artdeell commented Apr 5, 2020

And switch between them.

@artdeell
Copy link
Member Author

artdeell commented Apr 5, 2020

Hm. I have a better solution. gl4es generates LibGL.a and Zink generates LibGL.a, so we need to (for example):

  1. Read a text file with library name
  2. Load that library

In C++ you somehow can load libraries dynamically, so this will be a solution.

@khanhduytran0
Copy link
Member

Harder than you think, I must add a custom SurfaceView and some JNI Bindings for Vulkan, need some modify in LWJGL to toggle dlopen() between two different path/name...

@artdeell
Copy link
Member Author

artdeell commented Apr 5, 2020

Do not use Zink because it's a part of Mesa driver, that can't be embedded into a standalone app.
If you're lazy, you can just have two separate releases: Vulkan release and OGLES release.

Also, take a look at this https://github.com/p3/regal
It's compartible with OpenGL 4!

It's pretty old (last commits made 5 years ago), but it's natively compartible with Android(not as Mesa, which is compartible only with Android-x86)

@khanhduytran0
Copy link
Member

Look at the answer of your question
zhuowei/Boardwalk#363 (comment)

Edit: there's also Regal, which definitely won't work for Minecraft 1.14 and below (no display list support), but might work for 1.15.x and above. I'd try that as well.'

But i will try it.

@artdeell
Copy link
Member Author

artdeell commented Apr 5, 2020

Display list is used in 1.14 to make use unable to exit from the startup process.
Let's hope it will work for 1.11 and older.

@artdeell
Copy link
Member Author

artdeell commented Apr 5, 2020

Software rasterizer (if your device is Core i9-9900k witk VGA 256-color GPU and Android-x86).

No, i only have Core I5 8250U (1.6ghz, laptop), and 4gb ram so this is why I dual-boot instead of install emulator.

I had take a read at Zink but don't know how to create a switch, or set LD_LIBRARY_PATH???
LWJGL load only libgl04es.so so if libzinkgl.so or something LWJGL can't find, so need to create 2 different liblwjgl.so

I mean: if end user have a very fast CPU and poor GPU, swrast will be a pretty good solution.

@khanhduytran0
Copy link
Member

Looks like I have swrast in this video https://youtu.be/LjcD8rK5ic0
It run on Linux Deploy in framebuffer mode, and have natively OpenGL (and ES) without GL4ES.
It's slow because I install it in slow sdcard, and my CPU is Snapdragom 410, Adreno 306

After that I install using stable GL4ES and XSDL Xserver (unfortunately, 100% lost image) and the tar.gz i provided is unstable GL4ES

Before I noticed something like swrart-dri.so or something not found when trying to run glxgears....

@khanhduytran0
Copy link
Member

khanhduytran0 commented Apr 5, 2020

In this, i have both CPU and GPU poor, but also by slow sdcard.
__
How to build Regal for Android??
__
I'm finding some issues for something useful.

@khanhduytran0
Copy link
Member

So I managed to get Regal built for Android using latest Android NDK in Android Studio.
My Android.mk has some modify to fix some errors so if you clone and put in Android Studio you will get error.

I'm built it by go to regal/build/android/Regal and run ndk-build manually from Terminal.

@khanhduytran0
Copy link
Member

khanhduytran0 commented Apr 6, 2020

If you want binary, get at https://drive.google.com/file/d/1LqjLtptw2hw3y_ghygN9l-0Ucb4RjS1C/view?usp=drivesdk

I didin't build for x86-64 because launcher does not have that ABI and takes more times to compile (for each architecture it takes ~20 minutes to complete build).

@khanhduytran0
Copy link
Member


---- Minecraft Crash Report ----
// I just don't know what went wrong :(

Time: 06/04/2020 17:57
Description: Initializing game

java.lang.IllegalStateException: glGetString(GL_EXTENSIONS) returned null - is there a context current?
	at org.lwjgl.opengl.GLContext.getSupportedExtensions(Unknown Source)
	at org.lwjgl.opengl.ContextCapabilities.initAllStubs(Unknown Source)
	at org.lwjgl.opengl.ContextCapabilities.<init>(Unknown Source)
	at org.lwjgl.opengl.GLContext.useContext(Unknown Source)
	at org.lwjgl.opengl.ContextGL.makeCurrent(Unknown Source)
	at org.lwjgl.opengl.DrawableGL.makeCurrent(Unknown Source)
	at org.lwjgl.opengl.Display.makeCurrent(Unknown Source)
	at org.lwjgl.opengl.Display.makeCurrentAndSetSwapInterval(Unknown Source)
	at org.lwjgl.opengl.Display.create(Unknown Source)
	at org.lwjgl.opengl.Display.create(Unknown Source)
	at bao.ag(SourceFile:327)
	at bao.f(SourceFile:713)
	at net.minecraft.client.main.Main.main(SourceFile:148)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at net.kdt.pojavlaunch.MainActivity.runCraft(MainActivity.java:856)
	at net.kdt.pojavlaunch.MainActivity.access$1000080(MainActivity.java)
	at net.kdt.pojavlaunch.MainActivity$100000014$100000013.run(MainActivity.java:600)
	at java.lang.Thread.run(Thread.java:818)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
	at org.lwjgl.opengl.GLContext.getSupportedExtensions(Unknown Source)
	at org.lwjgl.opengl.ContextCapabilities.initAllStubs(Unknown Source)
	at org.lwjgl.opengl.ContextCapabilities.<init>(Unknown Source)
	at org.lwjgl.opengl.GLContext.useContext(Unknown Source)
	at org.lwjgl.opengl.ContextGL.makeCurrent(Unknown Source)
	at org.lwjgl.opengl.DrawableGL.makeCurrent(Unknown Source)
	at org.lwjgl.opengl.Display.makeCurrent(Unknown Source)
	at org.lwjgl.opengl.Display.makeCurrentAndSetSwapInterval(Unknown Source)
	at org.lwjgl.opengl.Display.create(Unknown Source)
	at org.lwjgl.opengl.Display.create(Unknown Source)

-- Initialization --
Details:
Stacktrace:
	at b.a(SourceFile:250)
	at bao.f(SourceFile:716)
	at net.minecraft.client.main.Main.main(SourceFile:148)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at net.kdt.pojavlaunch.MainActivity.runCraft(MainActivity.java:856)
	at net.kdt.pojavlaunch.MainActivity.access$1000080(MainActivity.java)
	at net.kdt.pojavlaunch.MainActivity$100000014$100000013.run(MainActivity.java:600)
	at java.lang.Thread.run(Thread.java:818)

-- System Details --
Details:
	Minecraft Version: 1.7.10
	Operating System: Linux (aarch64) version 3.10.49-perf-gf5a4a49
	Java Version: 0, The Android Project
	Java VM Version: Dalvik (LENOVO Lenovo A6010 [Android 21]), The Android Project
	Memory: 1884724 bytes (1 MB) / 52514224 bytes (50 MB) up to 268435456 bytes (256 MB)
	JVM Flags: 0 total; 
	AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	Launched Version: 1.7.10
	LWJGL: 2.9.1
	OpenGL: null GL version null, null
	GL Caps: 
	Is Modded: Definitely; Client brand changed to 'PojavLauncher'
	Type: Client (map_client.txt)
	Resource Packs: []
	Current Language: ~~ERROR~~ NullPointerException: Attempt to invoke virtual method 'brq brr.c()' on a null object reference
	Profiler Position: N/A (disabled)
	Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
	Anisotropic Filtering: Off (1)

@artdeell
Copy link
Member Author

artdeell commented Apr 6, 2020

You need to modify some parameters of Regal. The parameters and its descriptions are on main Regal README.

@artdeell
Copy link
Member Author

artdeell commented Apr 6, 2020

glGetString returns something related to OpenGL string statics, like vendor,version , etc...

@artdeell
Copy link
Member Author

artdeell commented Apr 6, 2020

Can you send me a log? Also, you can try to download AIDA64 and check the Devices and GPU tab (maybe your device is not comparible vith Vulkan?)

@gabbosta
Copy link

gabbosta commented Apr 6, 2020

When will launch the new version of Pojav Launcher

@artdeell
Copy link
Member Author

artdeell commented Apr 6, 2020

Now investigating the issues of Vulkan. Maybe there will be an OpenGL 4 compartiblity!
And after the new pre-release framebuffers, advanced shaders and some high-OpenGL thingies.

@artdeell
Copy link
Member Author

artdeell commented Apr 6, 2020

@khanhduytran0 did you rebuilded native lwjgl and changed all of the includes to Regal's ones?
Maybe the issue is just because of improper linking.

@khanhduytran0
Copy link
Member

i do some quick replace for testing before rebuild everything. seems like Regal need a c++ initialize call.

@khanhduytran0
Copy link
Member

anything I will edit to make it work?

Also might need to port displayList from gl4es to Regal.

@artdeell
Copy link
Member Author

artdeell commented Apr 7, 2020

@khanhduytran0 We need to atleast initialize it correctly

@khanhduytran0
Copy link
Member

khanhduytran0 commented Apr 7, 2020

changed all of the includes to Regal's ones?

https://github.com/p3/regal/blob/master/README.rst

Deployment

  • Most code remains unchanged.
  • Optionally #include <GL/Regal.h>
  • Link with regal32.dlllibRegal.so or libRegal.dylib*

@khanhduytran0
Copy link
Member

last commits made 5 years ago

So Regal developer will not have enough time to implement Vulkan.

@artdeell
Copy link
Member Author

artdeell commented Apr 7, 2020

last commits made 5 years ago

So Regal developer will not have enough time to implement Vulkan.

...when project looks like abandoned.

@artdeell
Copy link
Member Author

@khanhduytran0 can you give me your Regal's project directory?
I wanna try to link Regal and Boardwalk's LWJGL 2

@khanhduytran0
Copy link
Member

Source code?

@artdeell
Copy link
Member Author

In particular, i only need the generated include directory

@khanhduytran0
Copy link
Member

https://github.com/p3/regal/tree/master/include (original)

Why generated?

@artdeell
Copy link
Member Author

Because generated includes are linked with adresses inside .so file

@artdeell
Copy link
Member Author

After change above, I got Minecraft without OpenGL warning!
Screenshot_2020-04-14-12-22-31

On Regal library??

@khanhduytran0
Copy link
Member

No, still gl4es :(

@khanhduytran0
Copy link
Member

Try to FORCE_ES2_CORE_PROFILE and force emulation everything.

@khanhduytran0
Copy link
Member

I force to not execute glOrtho or load together with gl4es and it

Description: Initializing game

org.lwjgl.opengl.OpenGLException: Invalid enum (1280)
	at org.lwjgl.opengl.Util.checkGLError(Unknown Source)
	at org.lwjgl.opengl.DrawableGL.checkGLError(Unknown Source)
	at org.lwjgl.opengl.Display.swapBuffers(Unknown Source)
	at org.lwjgl.opengl.Display.update(Unknown Source)
	at org.lwjgl.opengl.Display.update(Unknown Source)
	at bao.g(SourceFile:869)
	at bao.aj(SourceFile:621)
	at bao.ag(SourceFile:379)
	at bao.f(SourceFile:713)
	at net.minecraft.client.main.Main.main(SourceFile:148)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at net.kdt.pojavlaunch.MainActivity.runCraft(MainActivity.java:970)
	at net.kdt.pojavlaunch.MainActivity.access$1000085(MainActivity.java)
	at net.kdt.pojavlaunch.MainActivity$100000016$100000015.run(MainActivity.java:651)
	at java.lang.Thread.run(Thread.java:818)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
	at org.lwjgl.opengl.Util.checkGLError(Unknown Source)
	at org.lwjgl.opengl.DrawableGL.checkGLError(Unknown Source)
	at org.lwjgl.opengl.Display.swapBuffers(Unknown Source)
	at org.lwjgl.opengl.Display.update(Unknown Source)
	at org.lwjgl.opengl.Display.update(Unknown Source)
	at bao.g(SourceFile:869)
	at bao.aj(SourceFile:621)

@khanhduytran0
Copy link
Member

After many force finally it run with black screen, using Regal together with gl4es.

@artdeell
Copy link
Member Author

After many force finally it run with black screen, using Regal together with gl4es.

It's blackscreening because Regal needs to share context between libraries

@khanhduytran0
Copy link
Member

Also I made LWJGL never getting error by return glGetError as 0 GL_NO_ERROR.

@artdeell
Copy link
Member Author

Also I made LWJGL never getting error by return glGetError as 0 GL_NO_ERROR.

That's not a good way.

@artdeell
Copy link
Member Author

Also I made LWJGL never getting error by return glGetError as 0 GL_NO_ERROR.

That's not a good way.

It's only good for debugging, not for release.

@khanhduytran0
Copy link
Member

I made it for testing what will work, then I will back to getting real state.

@khanhduytran0
Copy link
Member

This is not pushed.

@artdeell
Copy link
Member Author

I got a different error with Regal: Out of memory (1285)

@artdeell
Copy link
Member Author

artdeell commented Apr 16, 2020

Vendor string returning:

OpenGL: The Regal Project GL version 4.2, p3

@artdeell
Copy link
Member Author

I got a different error with Regal: Out of memory (1285)

I just have one question: why out of memory?

@khanhduytran0
Copy link
Member

Try to search an issue with that error, or tracking app memory usage.

@artdeell
Copy link
Member Author

Try to search an issue with that error, or tracking app memory usage.

How can I do that?

@khanhduytran0
Copy link
Member

You could take a look at https://developer.android.com/studio/profile/memory-profiler

@artdeell
Copy link
Member Author

artdeell commented Apr 16, 2020

W/Regal: warning | Regal does not support glGenLists for core or ES2 profiles - skipping.
java.lang.IllegalStateException: glGenLists returned an ID of 0 for a count of 1, GL error (1280): Invalid enum

Bug found. That fu.. freaking display lists.

@khanhduytran0
Copy link
Member

Try disable ES2 profile.

@artdeell
Copy link
Member Author

How can I disable core ES2 profile when the only thing available on Android is core ES2 profile?

@artdeell
Copy link
Member Author

I think we need to stay with GL4ES for the moment, or look for a fork with displayList compartiblity

@khanhduytran0
Copy link
Member

How can I disable core ES2 profile when the only thing available on Android is core ES2 profile?

Hmm... modify MainActivity.java and setEGLContextClientVersion(1);...

@artdeell
Copy link
Member Author

How can I disable core ES2 profile when the only thing available on Android is core ES2 profile?

Hmm... modify MainActivity.java and setEGLContextClientVersion(1);...

The main problem is: Regal attaches directly to OpenGLES .so file so there's no easy way.

@artdeell
Copy link
Member Author

I/Regal: info | Loading OpenGL ES 2.0 from /usr/lib/i386-linux-gnu/mesa-egl/libGLESv2.so.2

@khanhduytran0
Copy link
Member

Look in the log

I/Regal   (32186): info     | REGAL_SYS_ES2             enabled

Find a way to disable it by set property or put in Android.mk.

@artdeell
Copy link
Member Author

I/Regal (32186): info | REGAL_SYS_ES2 enabled

This means we're using OpenGLES v2, not OpenGL etc...
It can't be disabled on Android.

@artdeell
Copy link
Member Author

Also Regal doesn't support any kind of display list emulation. That's bad.

@khanhduytran0
Copy link
Member

Because Regal is unusable so closing.

@BryleHelll
Copy link

fu..... freaking moment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants