audetto / AppleWin

Apple II emulator for Linux
GNU General Public License v2.0
49 stars 12 forks source link

sa2: very slow on RPi4/Ubuntu22.04 #66

Closed seanshpark closed 2 years ago

seanshpark commented 2 years ago

Hi! I'm a big fan of AppleWin and glad to find this repo to play on Linux :)

I've tried to run this in Ubuntu 22.04 + Raspberry Pi 4 + SDL2. Speed is extremely slow and first thought was it isn't working as expected. I've tried with Qt and seemed working OK.

When I left the emulator running, DOS booted and prompt appeared. So it's about the speed... but why?

This is the log when after several seconds.

IMGUI_VERSION: 1.89 WIP
GL_VENDOR: Broadcom
GL_RENDERER: V3D 4.2
GL_VERSION: OpenGL ES 3.1 Mesa 22.0.5
GL_SHADING_LANGUAGE_VERSION: OpenGL ES GLSL ES 3.10
Default GL swap interval: -1
[DSInit] PC=00000000, WC=00000000, Diff=00000000
Video refresh rate: 0 Hz, inf ms
Global:  total =    8583.48 ms, mean =    8583.48 ms, std =       0.00 ms, n =      1
Frame:   total =    8487.09 ms, mean =       0.06 ms, std =       0.49 ms, n = 154125
Screen:  total =    2321.12 ms, mean =       0.02 ms, std =       0.37 ms, n = 154125
Events:  total =    5797.36 ms, mean =       0.04 ms, std =       0.16 ms, n = 154125
CPU:     total =     237.41 ms, mean =       0.00 ms, std =       0.04 ms, n = 154125
Expected clock: 1020484.45 Hz, 0.70 s
Actual clock:   83466.89 Hz, 8.58 s
seanshpark commented 2 years ago

About the message Video refresh rate: 0 Hz, inf ms. This looked strange.

Anyway found out that from this line in main.cpp

const int should_be_zero = SDL_GetCurrentDisplayMode(0, &current)

current.refresh_rate was 0

I looked in to some SDL codes and some returned 0 and some just returned 60.

I tried with this change

return current.refresh_rate ? current.refresh_rate : 60;

and seem working OK.

The log after DOS boot.

Video refresh rate: 60 Hz, 16.67 ms
Global:  total =    6033.32 ms, mean =    6033.32 ms, std =       0.00 ms, n =      1
Frame:   total =    6032.71 ms, mean =       8.17 ms, std =      10.59 ms, n =    738
Screen:  total =    3818.37 ms, mean =       5.17 ms, std =       6.86 ms, n =    738
Events:  total =     166.90 ms, mean =       0.23 ms, std =       2.62 ms, n =    738
CPU:     total =    2045.89 ms, mean =       2.77 ms, std =       6.84 ms, n =    738
Expected clock: 1020484.45 Hz, 11.04 s
Actual clock:   1866740.08 Hz, 6.03 s

Now the clock is roughly about double.

seanshpark commented 2 years ago

This is after some time

Video refresh rate: 60 Hz, 16.67 ms
Global:  total =  833707.78 ms, mean =  833707.78 ms, std =       0.00 ms, n =      1
Frame:   total =  833653.53 ms, mean =      16.00 ms, std =       4.73 ms, n =  52102
Screen:  total =  713308.81 ms, mean =      13.69 ms, std =       4.38 ms, n =  52102
Events:  total =   12132.54 ms, mean =       0.23 ms, std =       0.32 ms, n =  52102
CPU:     total =  108049.80 ms, mean =       2.07 ms, std =       0.94 ms, n =  52102
Expected clock: 1020484.45 Hz, 875.52 s
Actual clock:   1071665.83 Hz, 833.71 s
audetto commented 2 years ago

I will have to remove the clock info as it does not take into account changes of speed or resets.

audetto commented 2 years ago

Anyway, why don't you test the speed on Ubuntu 22.04.

It all comes down to texture repaint.

sa2 --gl-swap 0 --fixed-speed

Then, once it finishes the DOS boot, look at the FPS on the About dialog and check different window sizes, including maximised and full screen.

seanshpark commented 2 years ago

look at the FPS on the About dialog and check different window sizes, including maximised and full screen.

my default (width=910, height=606) -> 50 ~ 70 maximized (in 1920x1080 res) --> 40 ~ 50 fullscreen (with F6) --> 140 ~ 150

seanshpark commented 2 years ago

thanks! now it works fine :)

audetto commented 2 years ago

Same on bullseye. Which is as fast as it has ever been.

But a few months ago, the situation was a lot worse.

https://forums.raspberrypi.com/viewtopic.php?t=327165