libretro / virtualjaguar-libretro

Hard fork of Virtual Jaguar (abandoned project) to Libretro
31 stars 34 forks source link

Possible speedups #53

Closed JoeMatt closed 2 years ago

JoeMatt commented 2 years ago

I'm making a PR for some old optimizations I made for an iOS fork.

This PR is more for the devs to test and cherry-pick, I don't expect this code to be "merge quality", but certainly buildable/testable at least.

For instance, probably don't want these hacks that were specific to iOS loading, https://github.com/libretro/virtualjaguar-libretro/pull/53/commits/811e73f8b574ec2b34a69934fa36f66c3202f45b

The blitter really is the slowest part. I wanted to write something with SIMD or better vectorization or improved memcpy or something. That was by far the slowest part when I profiled this pretty heavily a while ago (at least it was excruciatingly slow on ARM without my C struct hacks to help the compiler optimize better.


Update: Forgot to mention I have these macros defined in my build (in XCode) that need to be added to a header or C compile flags

C

#define INLINE=inline 
#define USE_STRUCTS=1

flags

-DINLINE=inline -DUSE_STRUCTS=1 -D__GCCUNIX__  

Inline macro may need to be customized based on arch. Mac OS is using Clang/C99/gnu++11 syntax for inline.

I also have unroll loops aka -qunroll=no but i forget why.

lgtm-com[bot] commented 2 years ago

This pull request fixes 3 alerts when merging 1e881fae65a1f705781c5ed7bd065a5255f8716d into 2069160f316d09a2713286bd9bf4d5c2805bd143 - view on LGTM.com

fixed alerts:

inactive123 commented 2 years ago

Both Wolfenstein 3D and Doom don't start up for me with this PR on Windows 10 (64bit build).

inactive123 commented 2 years ago

I don't understand why audio_batch_cb is commented out too. This means there will be no sound at all in the libretro core.

if this is something you ported from Provenance and did not test in RetroArch with the libretro core, that isn't going to do us much good. We'd need a backport of the changes you made then to the core and to ensure things still work.

inactive123 commented 2 years ago

That being said, there are some good ideas in here.

JoeMatt commented 2 years ago

That being said, there are some good ideas in here.

Thanks!

This was being used in Provenance and we have our own video and audio pipelines.

This PR was never intended for mass consumption but rather for me to get it to work well in Prov and back port to upstream.

But as you know, there really isn't a true upstream (my original work wasn't from retroarch's fork but the original .Zip source).

So any things that don't make sense are due to that history. I later back ported to your fork but a lot of hacks and such for my specific purposes still exist, which is why i wanted to state that in the original description.

I felt bad keeping all these changes to myself after seeing other wanting this core to make progress so as much as I myself hate when people do a dump of code "here's my amazing but difficult to read changes, bye", at the same time, I have very little time to focus on this as much as I would love to so I figured it was better to submit in the present state and hopefully someone else more talented and with the time can take some value from this work.

JoeMatt commented 2 years ago

Both Wolfenstein 3D and Doom don't start up for me with this PR on Windows 10 (64bit build).

I'm shocked this builds on Windows and you got it to load at least!

Some ROMs work better with internal or provided BIOSs and other flags in my experience, you may already probably know that if you're familiar with the issues with this core already.

I think my hacks on the blitter broke the ID Roms though because they were coded better than most and used some hardware hacks for performance so I'm not suprised those are broken. I bet a little debugging and I or someone else could figure out what's wrong there.

This core could use some unit tests to figure out what about the cpu emu is different with my changes but that's probably a stretch at this point.

inactive123 commented 2 years ago

Alright, thanks.

JoeMatt commented 2 years ago

Alright, thanks.

also i'm using pre-processor macros in XCode, -DINLINE=inline -DUSE_STRUCTS=1

JoeMatt commented 2 years ago

I don't understand why audio_batch_cb is commented out too. This means there will be no sound at all in the libretro core.

if this is something you ported from Provenance and did not test in RetroArch with the libretro core, that isn't going to do us much good. We'd need a backport of the changes you made then to the core and to ensure things still work.

Pushed update to un-delete this.

JoeMatt commented 2 years ago

Re-based and force pushed off of upstream b44e2e29128ecb4d97a23f1e7a71fa2327e17ca3

lgtm-com[bot] commented 2 years ago

This pull request fixes 2 alerts when merging ada5c15dfd80619766325c42114d21a9991ffc1a into b44e2e29128ecb4d97a23f1e7a71fa2327e17ca3 - view on LGTM.com

fixed alerts:

JoeMatt commented 2 years ago

Both Wolfenstein 3D and Doom don't start up for me with this PR on Windows 10 (64bit build).

FYI, libretro wiki says Wolf 3D already doesn't boot, https://docs.libretro.com/library/compatibility/jaguar/

Doom needs a hack which I don't have a menu UI for in Prov, not sure if you tested with that in retroarch.

Another issue is that the wiki for retroarch doesn't mention Jaguar BIOS, but it's been known since the old forums on this core's original author that some games only run or run better with the emulation bios or the Atari official bios.

The wiki for Jaguar makes no mention of BIOS so that should probably be amended and the core option for the bios be mentioned.

https://github.com/libretro/virtualjaguar-libretro/blob/b44e2e29128ecb4d97a23f1e7a71fa2327e17ca3/libretro.c#L58

https://atariage.com/forums/topic/76369-jaguar-bios/

JoeMatt commented 2 years ago

Closing for #55 with rebase