Skurdt / SK.Libretro

Libretro wrapper written in C# with support for the Unity game engine
MIT License
28 stars 13 forks source link

HwRender GLFW implementation does not work on Android #19

Open XenuIsWatching opened 1 year ago

XenuIsWatching commented 1 year ago

GLFW does not have an Android implementation. This makes it so some cores, such as Dolphin, can not run with HW acceleration.

I'm not quite sure how implementation would begin with getting a HW acceleration with OpenGL ES3 with Android NDK would begin

Skurdt commented 1 year ago

I'm using glfw to create an invisible window (and it's gl context), render the output there and do a dumb and slow glCopyPixels call onto an array. This then go to the same unity texture creation path used for non HW accelerated cores. This is done like that only because, on windows, the unity runtime is set (for me) to run on directx. You can very much call that a hack :p

On android, since unity runs on opengl (or variants...) a native plugin may work way better there. (ie. use the existing context and bypass the pixel copy stuff)

Implementing directx, for cores using it, would also probably require a native plugin on windows too.

Phantomxm2021 commented 9 months ago

Any update for this problem?

Skurdt commented 9 months ago

I'm using a very very tiny set of GLFW functions. This is basically to spawn a window and get a dumb opengl framebuffer. Maybe it can be replaced by SDL, which I believe does have a android runtime.

Still, it would be the dumbest way to implement the feature on android, since it only runs on gl and a native plugin would have direct access to the Texture2D, avoiding copying pixels altogether.

Skurdt commented 5 months ago

I swapped to use sdl3 for the opengl window. Obviously the result is exactly the same but it should allow getting it work on platforms where glfw is not supported.

I spent a week trying to get a android version working but unfortunately, the hardware path still doesn't work there. Trying to build a libSDL3.so library was a literal nightmare to figure out, and I'm not even sure it can load as a .so file properly. The current issue seems related to android activity (specifically something about org.libsdl.app.SDLActivity), which I tried researching but I still have no clue what it is exactly and how, or if, the library can be initialized from unity.