First post, by kjliew
This is a simple patch to enable CPU core dynrec for DOSBox SVN on Apple M1. The solution was extracted from dosbox-staging PR #1031 by @kklobe, simplified to be less intrusive on DOSBox SVN at the expense of disregarding for source portability. It also fixed OpenGL output on Apple M1 but only tested for MacBook Air M1 built-in retina display. It may not work on external display through USB-C or on MacMini M1 when the scaling option can be different. The obsolete SDL1.2 does not seem to provide API for detecting display scaling so the fix uses hardcoded values. It is very simple to remove the OpenGL output fix if it is not required, just ignore the 4-line changes in sdlmain.cpp.
Consider this as a temporary hack for DOSBox SVN, it was deliberately made simple so that it will survive SVN changes until the official upstream solution is presented. The devs really want to take their time.
Performance was great, almost 2X of CPU normal core and almost equivalent to QEMU TCG performance in MDKDOS. However, I think it is not as fast as Dominus's published PCPBENCH scores with Rosetta 2 translated dynamic_x64 but close. I think it is good enough for all high CPU demand DOS4GW games including built-in Munt MT-32 MIDI music. Nowadays, I don't really need DOSBox to run Win9x games anymore. I have yet to check out 3Dfx DOS games. There is still problem to be solved for Glide pass-through to be able to share the same OpenGlide as QEMU, but Voodoo chip emulation should work pretty well with the added performance of CPU core dynrec.
Debugging on macOS M1 is hard. I hate LLDB. 😜
EDIT: Update patch for dpiscale fix v2 to use OpenGL for obtaining DPI scale.