Author Topic: GLideN64 Android port  (Read 139053 times)

Offline Gonetz

  • Developer
  • long
  • *****
  • Posts: 104
    • View Profile
Re: GLideN64 Android port
« Reply #45 on: April 23, 2015, 11:48:38 PM »
@retroben
I'm planning to move step by step from 3.1 downside to 2.0 Most of my Android devices are ES 2.0
I just need a starting point first - a working version, which I can test and debug. For my current code 3.1 is the shortest way to get working Android build.

@littleguy, thanks in advance! I'll wait for your results. So far I'll switch back to PC version issues.

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: GLideN64 Android port
« Reply #46 on: April 24, 2015, 07:04:03 AM »
@Gonetz
I took a look last night and I don't foresee any issues getting your plugin into the Android app.  The patch you sent and the android makefile are both very helpful and should make it very easy for me to translate into the latest Alpha releases.  I can do all the legwork of modifying the UI, so you will only have to drop your source code into the jni directory and press build in Eclipse.

I will be out of town and mostly offline for the next three days, but I can certainly get this set up for you on Monday, if you don't mind waiting.
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline retroben

  • float
  • ****
  • Posts: 432
    • View Profile
Re: GLideN64 Android port
« Reply #47 on: April 24, 2015, 09:48:06 AM »
Okay,good. :)

@littleguy: Don't get crushed by an evil moon while you're gone.  :D

Offline Gonetz

  • Developer
  • long
  • *****
  • Posts: 104
    • View Profile
Re: GLideN64 Android port
« Reply #48 on: April 25, 2015, 01:32:05 AM »
@littleguy - Monday is perfectly fine for me, thanks in advance! I'll use that time to fix some stuff in the code before PC release.

Regarding my old patch to emulator's UI: it was done for settings, which plugin used year ago. Current set of settings is a bit different, see Config.h in my code.

On the first step I'll need support for settings from sections "generalEmulation" and "frameBufferEmulation".
Sections "video" and "texture" are under question.
As I remember, screen size is loaded from general emulator's settings.  multisampling is for GLES31 devices and can be ignored for now. Anisotropy has no support in GLES. "bilinearMode" option is useful, but not must. "maxBytes" option defines how much of video memory plugin can take for textures. I think, that option should not be user-defined on Android. I believe that we can ask Android OS about available video memory and provide the plugin with that information. As a temporal solution I can just hardcode it for some reasonable value.

Offline retroben

  • float
  • ****
  • Posts: 432
    • View Profile
Re: GLideN64 Android port
« Reply #49 on: April 25, 2015, 02:01:34 AM »
But multisampling is also featured in the Rice plugin and works on my device that's stuck on GLES2.
It makes many things look much crisper with almost no performance impact.
Edit: To add,I am on Jellybean 4.2.2 with this feature in Rice fully functional to 16.

One drawback of multisampling is the use of CountPerOp drastically increasing and increased strain to the 1500 VI Refresh Rate limit causing dropped fps when in certain parts/viewpoints of a game.
« Last Edit: April 25, 2015, 02:59:31 AM by retroben »

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: GLideN64 Android port
« Reply #50 on: April 27, 2015, 09:13:23 AM »
@Gonetz
I started a branch for you to start integrating your plugin.  I left you a bunch of comments on GitHub, feel free to reply inline or here if you have any questions or comments.
https://github.com/mupen64plus-ae/mupen64plus-ae/commits/gliden64-integration

For now I have just included the bare minimum mods to allow you to build and test.  I will start exposing your config settings in the android front-end once you are able to build and run the branch.

I haven't actually confirmed the build process yet.  Looks like I will need to obtain the GLESv3 headers and binaries somewhere.  Perhaps the Tegra Android Development Pack?
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline xperia64

  • Moderator
  • double
  • *****
  • Posts: 591
    • View Profile
    • My Apps
Re: GLideN64 Android port
« Reply #51 on: April 27, 2015, 12:09:53 PM »
android-18 has the gles3 headers. I assume the project target api level must be set to at least 18.
https://android.googlesource.com/platform/development/+/master/ndk/platforms/android-18/include/GLES3/gl3.h

Offline Gillou68310

  • Developer
  • long
  • *****
  • Posts: 112
    • View Profile
Re: GLideN64 Android port
« Reply #52 on: April 27, 2015, 11:16:23 PM »
@Gonetz could you re-upload your code please? I didn't get time to download it before the weekend :)

Offline Gonetz

  • Developer
  • long
  • *****
  • Posts: 104
    • View Profile
Re: GLideN64 Android port
« Reply #53 on: April 27, 2015, 11:54:56 PM »
@littleguy - thanks a lot!
I'm currently overbusy with PC release preparation - need to polish some stuff before release for remaining few days.
I'll try to check your work in parallel and ask questions in case of troubles.

Latest Android NDK contains GL headers for GLES3.1

I accidentally removed sources of my preliminary Android port. Here the update link:
https://drive.google.com/file/d/0B0YqMPjGo3B2R19Oa05wbjA3YjA/view?usp=sharing

Offline Gonetz

  • Developer
  • long
  • *****
  • Posts: 104
    • View Profile
Re: GLideN64 Android port
« Reply #54 on: May 02, 2015, 12:46:20 PM »
Sorry for delay.
Was very busy with plugin Public Release preparations.

I've fetched latest state, switched to gliden64-integration, copied my sources (correct accordingly to the littleguy's instructions) and built the project. Run, select GLideN64 as graphics plugin and start the demo rom. Result is expected:

05-02 23:37:57.738: I/UI-Console(17664): using Video plugin: 'GLideN64' v2.0.0
05-02 23:37:57.738: I/UI-Console(17664): using Audio plugin: 'Mupen64Plus SDL Audio Plugin' v2.0.0
05-02 23:37:57.739: I/UI-Console(17664): using Input plugin: 'Mupen64Plus Android Input Plugin' v1.0.0
05-02 23:37:57.739: I/UI-Console(17664): using RSP plugin: 'Hacktarux/Azimer High-Level Emulation RSP Plugin' v2.0.0
05-02 23:37:57.768: A/libc(17664): Fatal signal 11 (SIGSEGV), code 2, fault addr 0x7e88d61c in tid 17738 (CoreThread)

Is it possible to debug native c++ code using Eclipse (breakpoints, call stack etc) or Log is my only hope?

Offline retroben

  • float
  • ****
  • Posts: 432
    • View Profile
Re: GLideN64 Android port
« Reply #55 on: May 02, 2015, 01:49:25 PM »
A quote of what hunterk said on libretro: "Twinaphex has been backporting a lot of gonetz's work into mupen64plus-libretro's gln64 plugin. It turns out it's not wildly different from gln64, so backporting makes more sense in this case than bringing over the plugin wholescale."

Can this same method be done on Mupen64Plus AE after merging over the original glN64 and cleaning it up?

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: GLideN64 Android port
« Reply #56 on: May 02, 2015, 04:13:11 PM »
@Gonetz No worries, you have done so much already.

Unfortunately I don't have any easy advice about debugging the native code on Android.  I have looked into it in the past and realized there was no "easy button" as far as I could tell.  But there are tools out there like ndk-stack (see the tools directory of mupen64plus-ae) and the tegra android development pack, and I would think someone out there has taken the time to document a good solution.  Most of my personal involvement in the native debugging has been with regards to ae-bridge, mupen64plus-input-android, xperia-touchpad, and a bit of SDL2.  In those cases I gave up and just suffered through using debug statements.  If you find a particularly good link or tutorial, I'd love to know.

@retroben Not sure I understand what you're trying to say.  If you are suggesting that we somehow fork GLideN64, then that is not my interest at all.
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline retroben

  • float
  • ****
  • Posts: 432
    • View Profile
Re: GLideN64 Android port
« Reply #57 on: May 02, 2015, 04:59:50 PM »
What I meant was taking the main original gln64 (first platform or best version/main version GLideN64 was made on) and combining it with the AE version,then implant GLideN64 into that.

Sorry,might be a bad idea,but I don't know much about it on a technological standpoint,and it might end up being too much work. :(

Offline Gillou68310

  • Developer
  • long
  • *****
  • Posts: 112
    • View Profile
Re: GLideN64 Android port
« Reply #58 on: May 03, 2015, 03:06:21 AM »
@Gonetz you can send debug messages to the android log using this function in your code:

Code: [Select]
void DebugMessage(int level, const char *message, ...)
{
  char msgbuf[1024];
  va_list args;

  if (l_DebugCallback == NULL)
      return;

  va_start(args, message);
  vsprintf(msgbuf, message, args);

  (*l_DebugCallback)(l_DebugCallContext, level, msgbuf);

  va_end(args);
}

Pointers to DebugCallback and DebugCallContext are passed through PluginStartup:

Code: [Select]
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context,
                                   void (*DebugCallback)(void *, int, const char *))

You can see the logs directly in the logcat view in eclipse.
From my experience this is the easiest way to debug native code. Setting breakpoints is a nightmare and even if your breakpoint is hit, it's extremely slow.

I'm kind of used to debug native code on android, so if you need help with this don't hesitate to ask ;)

BTW, is your current work on android in sync with Public Release 1?
« Last Edit: May 03, 2015, 04:42:11 AM by Gillou68310 »

Offline Gonetz

  • Developer
  • long
  • *****
  • Posts: 104
    • View Profile
Re: GLideN64 Android port
« Reply #59 on: May 03, 2015, 05:55:17 AM »
Thanks for advice. I'll check NVidia tegra tools.

My current Android port code is right above the master, from which Public Release was built.