BlitterStudio / amiberry

Optimized Amiga emulator for Linux/macOS
https://amiberry.com
GNU General Public License v3.0
664 stars 89 forks source link

Another black screen bug - isolated to bad pixel format #1080

Closed hissingshark closed 1 year ago

hissingshark commented 1 year ago

On Vero4k (AMLogic 905x) Since v3.1 we are getting a black screen during emulation. The GUI is fine. Sound and control inputs continue as normal.

A similar behaviour was encountered on PPSSPP years ago due to bad EGL selection. A workaround was changing the framebuffer mode to 16bit. That works here too. fbset normally shows:

mode "1920x1080" geometry 1920 1080 1920 2160 32 timings 0 0 0 0 0 0 0 rgba 8/16,8/8,8/0,8/24 endmode

That is giving a black screen. But the normal screen is restored if I set 16bit using fbset -fb /dev/fb0 -g 1920 1080 1920 2160 16:

mode "1920x1080" geometry 1920 1080 1920 2160 16 timings 0 0 0 0 0 0 0 rgba 5/11,6/5,5/0,0/0 endmode

The bug is bisected to #fd91c9e which changed osdep/amiberry_gfx.cpp with:

  //display_depth = 16;
  //pixel_format = SDL_PIXELFORMAT_RGB565;
  display_depth = 32;
  pixel_format = SDL_PIXELFORMAT_RGBA32;

If I build Amiberry with pixel format restored to RGB565 it works without the fbset workaround.

I wanted to submit a PR with some sort of detection, but I don't seem to understand the problem. You see, by my interpretation, the offsets of rgba 8/16,8/8,8/0,8/24 would be a mode of SDL_PIXELFORMAT_ARGB32. But if I build with that it doesn't work...

hissingshark commented 1 year ago

Just had a thought - the old working RGB565 didn't reference alpha. I've just tried RGB888 and it works. So alpha seems to be an issue. Not sure why RGB565 works in my 32bit framebuffer though...

midwan commented 1 year ago

@hissingshark Which SDL2 version are you running? Have you tested the latest versions of that, to see if it makes a difference? It seems like an issue between SDL2 and the GPU driver, if you're having issues with the Alpha channel in RGBA32 (which is what Amiberry uses for 32-bit modes).

I went through a lot of tests to determine which mode had the best performance, before setting to this one. So I wouldn't want to change it again in a hurry, until we're sure there's no other way (and only if it doesn't impact performance).

midwan commented 1 year ago

@hissingshark any update on the SDL2 version?

hissingshark commented 1 year ago

Hiya, Sorry, been out of the country.

I've tested on SDL2 builds of 2.0.10 and 2.0.20.

So you're happy RGB888 does not impare performance?

midwan commented 1 year ago

@hissingshark From what I tested, it seems that BGR888 is actually faster than RGB888, but yes, it seems there's no impact in performance when compared to RGBA32 (which is actually BGRA32 on the RPI).