melonDS-emu / melonDS

DS emulator, sorta
https://melonds.kuribo64.net
GNU General Public License v3.0
3.19k stars 527 forks source link

macOS #807

Closed CatsLover2006 closed 3 years ago

CatsLover2006 commented 3 years ago

Need I say more? If need be I can help test builds (I own a MacBook)

nadiaholmquist commented 3 years ago

https://github.com/Arisotura/melonDS/pull/771

RayyanAnsari commented 3 years ago

https://github.com/Arisotura/melonDS/runs/1367458542 @CatsLover2006 could you test Opengl?

CatsLover2006 commented 3 years ago

I can. I'm installing libslurp as I type this.

CatsLover2006 commented 3 years ago

I haven't tested DSi functionality, but this works. OpenGL works (in the firmware, at least). One issue: keyboard input doesn't work. Touch works fine, though. I don't know what causes that keyboard issue, but I'll look into using a controller when I can access one a fair bit later.

RSDuck commented 3 years ago

keyboard input doesn't work

did you bind keys?

CatsLover2006 commented 3 years ago

I tried but it wouldn't bind any keys.

RSDuck commented 3 years ago

ah ok

CatsLover2006 commented 3 years ago

Also one other thing to note: when using OpenGL 3D content doesn't show up. No triangles are rendered. 2D content works fine. That said, the software renderer has no issues handling this and I don't loose frames even though I'm on the second least powered system the latest version of macOS can run on (the least powerful is the same just without hyperthreading). (I spoke too soon with the no loosing frames comment)

RayyanAnsari commented 3 years ago

Could you post the logs from the Terminal with OpenGL?

CatsLover2006 commented 3 years ago

I used Mario Kart DS, best example. In the menus:

melonDS 0.9 http://melonds.kuribo64.net/ Audio output frequency: 48000 Hz OpenGL: renderer: Intel HD Graphics 4000 OpenGL Engine OpenGL: version: 4.1 INTEL-14.7.8 ARM9 BIOS loaded ARM7 BIOS loaded Resetting JIT block cache... done resetting jit mem done resetting jit mem MAC: 00:16:56:83:31:F9 FW: WIFI CRC16 = GOOD FW: AP1 CRC16 = GOOD FW: AP2 CRC16 = GOOD FW: AP3 CRC16 = GOOD FW: USER0 CRC16 = GOOD FW: USER1 CRC16 = GOOD Game code: AMCE ROM CRC32: 49E436D8 ROM entry: 02000000 00000005 !! bad ROM size 25562150 (expected 33554432) rounded to 33554432 Cart ID: 00001FC2 Re-encrypting cart secure area ARM9: offset=00004000 entry=02000800 RAM=02000000 size=000E7534 ARM7: offset=00141600 entry=02380000 RAM=02380000 size=000289A4 remapping SWRAM Secure area decryption OK remapping DTCM 3000000 3004000 ffffffff ffffffff Game is now booting Save file: /Users/chancelp/Google Drive/Roms/Mario Kart DS.sav remapping DTCM ffffffff ffffffff 3000000 3004000 PU: region 0 = 04000033 : enabled, 04000000-08000000 PU: region 1 = 0200002D : enabled, 02000000-02800000 PU: region 2 = 027E0021 : enabled, 027E0000-02800000 PU: region 3 = 08000035 : enabled, 08000000-10000000 PU: region 4 = 027E001B : enabled, 027E0000-027E4000 PU: region 5 = 0100002F : enabled, 01000000-02000000 PU: region 6 = FFFF001D : enabled, FFFF0000-FFFF8000 PU: region 7 = 027FF017 : enabled, 027FF000-02800000 remapping DTCM 27e0000 27e4000 ffffffff ffffffff PU: region 1 = 0200002B : enabled, 02000000-02400000 PU: region 2 = 023E0021 : enabled, 023E0000-02400000 unknown ARM9 IO write32 04001060 00000000 01FFFE54 unknown ARM9 IO write32 04001064 00000000 01FFFE54 unknown ARM9 IO write32 04001068 00000000 01FFFE54 WIFI OFF

When selecting a player, the character doesn't appear on the top screen. Switching to software renderer and back, I get these lines:

OpenGL: renderer: Intel HD Graphics 4000 OpenGL Engine OpenGL: version: 4.1 INTEL-14.7.8 QThread::start: Thread termination error (No such process)

I'm thinking that last line is the culprit.

RayyanAnsari commented 3 years ago

Does it crash when you do it?

CatsLover2006 commented 3 years ago

It doesn't. I don't know why.

RayyanAnsari commented 3 years ago

I think it should happen. https://github.com/Arisotura/melonDS/blob/master/src/GPU3D_Soft.cpp#L74 https://github.com/Arisotura/melonDS/blob/master/src/frontend/qt_sdl/Platform.cpp#L200

I'm not exactly sure about why OpenGL seems to have the issues, will need more testing.

CatsLover2006 commented 3 years ago

It should crash?

RayyanAnsari commented 3 years ago

Nope, it's just that that happens when you close melonDS. I looked into it a bit more and it says that when a thread is terminated (which I'm pretty sure should happen because the SW renderer thread is terminated when switching to OpenGL) that usually happens.

CatsLover2006 commented 3 years ago

Also one other thing to note: the app crashes when I launch a game with the JIT on. Honestly, with the amount of CPU is most computers now, I think that it's somewhat unnecessary on Macs (I have no performance issues without it on this Mac and again it's the second least powerful that can run the latest version of macOS), leaving it off by default and calling it an "experimental feature" on Mac is probably all that needs to be done.

RayyanAnsari commented 3 years ago

Try disabling fastmem, that's a known issue and in my to-do list.

CatsLover2006 commented 3 years ago

Fastmem was the issue. Also that QThread error is causing something, it's pretty clear to me now. I got the error without switching.

RayyanAnsari commented 3 years ago

I get the QThread error on Linux whilst switching from SW to OpenGL, and disabling Use seperate thread for the SW renderer. When do you get the error when not doing any of those things?

CatsLover2006 commented 3 years ago

I get the error every now and again when starting the OpenGL thread. Also, I think I found the culprit after I tried building from source code. When I build from source, cmake worked fine but then when I ran make, I got this error message: /Users/chancelp/melonDS/src/OpenGLSupport.h:26:10: fatal error: 'GL/gl.h' file not found This might be the culprit.

RayyanAnsari commented 3 years ago

Don't build from master. Instead build from my PR - https://github.com/WaluigiWare64/melonDS/tree/platform/macos-support Also follow the instructions in the README - https://github.com/WaluigiWare64/melonDS/blob/platform/macos-support/README.md

CatsLover2006 commented 3 years ago

I still get the same GL/gl.h missing error

RayyanAnsari commented 3 years ago

Do you have Homebrew installed, as in the README. Installing Homebrew automatically installs the XCode Command Line Tools, which should have the OpenGL headers.

EDIT - are you sure you did it from my fork? The GL/gl.h error can't even be there as I have a #ifdef to include different header on macOS?

CatsLover2006 commented 3 years ago

I do have Homebrew installed. I'm on macOS Catalina though, so OpenGL is deprecated.

EDIT - I am sure I did it from your fork as I literally copied and pasted the code from the README. I looked at the *.h file and the #ifdef wasn't there.

RayyanAnsari commented 3 years ago

I meant that you have to clone my fork's platform/macos-support branch and build with that.

CatsLover2006 commented 3 years ago

Compiled from source, still nothing. Random question relating to GPU support: would Metal support be possible or no?

RayyanAnsari commented 3 years ago

Maybe, if someone wrote a Metal renderer. Also what is the command you used to clone? As is builds fine on my VM and on the Github Actions CI.

CatsLover2006 commented 3 years ago

I just took the latest code, downloaded as a zip, and overwrote files. It built just fine, but still the same OpenGL error. Sorry for the confusion.

CatsLover2006 commented 3 years ago

Still the OpenGL glitch. IDK what's going on at this point.

RSDuck commented 3 years ago

Random question relating to GPU support: would Metal support be possible or no?

if you mean Vulkan support and MoltenVK maybe some day

CatsLover2006 commented 3 years ago

Metal is for Apple devices (OpenGL is deprecated)

poudink commented 3 years ago

MelonDS appears to have been trying to keep everything cross platform, so a platform-specific Metal renderer would be an odd addition. Vulkan sounds much more likely to me, and I think it'd be a better option as well. Though, even that would be quite a long term inclusion since the OpenGL renderer still has its fair share of issues that need to be addressed first.

CatsLover2006 commented 3 years ago

I’m pretty sure that OpenGL is already gone in iOS.

RSDuck commented 3 years ago

https://apple.stackexchange.com/questions/379326/is-opengl-deprecated-or-removed-in-macos-catalina-10-15

allegedly it's still there on Catalina

RayyanAnsari commented 3 years ago

ANGLE seems to be working on Metal support - https://github.com/google/angle

RayyanAnsari commented 3 years ago

@CatsLover2006 can you try this? The QThread error should be gone.

melonDS.zip

RayyanAnsari commented 3 years ago

@CatsLover2006 could you send a screenshot of Mario Kart DS (since you seem to already have it) in the race?

CatsLover2006 commented 3 years ago

Here's what Mario Kart DS looks like on the character select. Screen Shot 2020-11-16 at 11 52 39 AM And here's what it looks like in-race. Screen Shot 2020-11-16 at 11 53 44 AM Not sure if this also applies, but when I relaunch the app with OpenGL on, the old frame still is present.

CatsLover2006 commented 3 years ago

Debugging idea: wireframe view?

CatsLover2006 commented 3 years ago

I can report that controller inputs work.

CatsLover2006 commented 3 years ago

One other thing: connecting to Wiimmfi results in error code 23917. Not sure if this is related.

CatsLover2006 commented 3 years ago

Random question: 32 bit components in use? If so that's the big issue.

RayyanAnsari commented 3 years ago

@CatsLover2006 thanks for the pictures. It's certainly odd that no 3D is drawn at all. Also Wiimmfi says 23917 is "Wiimmfi access denied". Could you delete the connection and create it again, this time without changing the settings, and then try to get online? If it tells you that the Nintendo WFC has shut down, that means it's connecting to the internet.

CatsLover2006 commented 3 years ago

I know. I think this is an issue with Wiimmfi though, I'm getting this issue with all but my actual 3DS and Wii (including my Wii U's vWii). EDIT: Connection tests return "successful" EDIT 2: Changing settings to default returns WFC shut down

RayyanAnsari commented 3 years ago

Thanks. At least wifi is working :P

RayyanAnsari commented 3 years ago

@CatsLover2006 could you test OpenGL with the latest artifact?

CatsLover2006 commented 3 years ago

OpenGL with latest code is still not working.

RayyanAnsari commented 3 years ago

Did you clone my branch or did you download from artifacts?

CatsLover2006 commented 3 years ago

Where are they? I can't find them.

RayyanAnsari commented 3 years ago

https://github.com/Arisotura/melonDS/pull/771/checks?check_run_id=1426173750