[experimental] SDL2 with Tear-Free Zero-copy Rotation

Talking about OS and emulation core development
Post Reply
JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

[experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

I am developing a backend for SDL2 that allows for display rotation with libmali on fbdev:
https://github.com/JohnnyonFlame/SDL-ge2d/tree/2.0.22

This can be configured via the following environment variables:

Code: Select all

# Setup native display orientation for OGU
export SDL_MALI_ORIENTATION=1
# Setup application orientation (e.g. for "TATE Mode")
export SDL_MALI_ROTATION=0
# Final rotation is 'rotation = (SDL_MALI_ORIENTATION+SDL_MALI_ROTATION) % 4;'
Thanks To:
- pcercuei: For the original triple buffering implementation (ported from SDL1.2).
- 7Ji: For the original SDL2.0.22 fbdev backend.
- shantigilbert: For EmuELEC, being patient, and helping with development/testing.
- ODROID: For the provided development hardware, your support is incredibly welcome.
- crashoverride: For providing the libgou reference library in order to work around platform behavior.
- slaminger: Providing testing and validation of SDL2 under different workloads.
Last edited by JohnnyonFlame on Mon Dec 05, 2022 4:10 am, edited 5 times in total.
These users thanked the author JohnnyonFlame for the post:
tobetter (Sat Sep 03, 2022 11:20 am)

JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

Added support for arbitrary, configurable display rotation:

https://www.youtube.com/watch?v=9rygQApghv8

shanti
Posts: 352
Joined: Fri Feb 15, 2019 3:12 am
languages_spoken: english, spanish
ODROIDs: Odroid N2
Has thanked: 116 times
Been thanked: 142 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by shanti »

JohnnyonFlame wrote:
Sat Sep 03, 2022 4:19 am
- shantigilbert: For EmuELEC, being patient, and helping with development/testing.
Thanks to you!


This is working perfectly on the OGU, SDL is rotating and performance seems to be equal to un-rotated! so amazing job!
These users thanked the author shanti for the post:
JohnnyonFlame (Sat Sep 03, 2022 10:47 am)

crashoverride
Posts: 5860
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 647 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by crashoverride »

Since the original thread of discussion is locked, I will post to this one. The creation of an open source "libgou" was previously discussed. An initial implementation of it has been made and is expected to be released later this week. A modified version of RetroRun will also be provided to illustrate the library's use. The goal of "libgou" is to illustrate driving the pixel pipeline on OGU with GE2D scale/blit.

Slaminger
Posts: 404
Joined: Tue Jul 16, 2019 12:30 am
languages_spoken: English, French
ODROIDs: All of Them
Location: Canada
Has thanked: 32 times
Been thanked: 196 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by Slaminger »

Very nice indeed, seems to be working on my end as well.

crashoverride
Posts: 5860
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 647 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by crashoverride »

crashoverride wrote:
Thu Sep 08, 2022 10:11 am
The creation of an open source "libgou" was previously discussed.
The library is available here:
https://github.com/OtherCrashOverride/libgou.git

A modified version of RetroRun was created to illustrate its use (note the "gou" branch):
https://github.com/OtherCrashOverride/r ... 2/tree/gou

At the time of this writing there an issue that I can not seem to locate with regard to memory corruption in RetroRun. When using the Dreamcast core, it will appear as if a button is always pressed. In other cores, it appears that the exit button is pressed. Since the core SIGSEVs as part of its JIT, it is difficult to debug.
These users thanked the author crashoverride for the post (total 4):
shanti (Tue Sep 13, 2022 1:34 pm) • odroid (Tue Sep 13, 2022 2:17 pm) • JohnnyonFlame (Tue Sep 13, 2022 3:21 pm) • Slaminger (Tue Sep 13, 2022 10:43 pm)

JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

crashoverride wrote:
Tue Sep 13, 2022 1:26 pm
crashoverride wrote:
Thu Sep 08, 2022 10:11 am
The creation of an open source "libgou" was previously discussed.
The library is available here:
https://github.com/OtherCrashOverride/libgou.git

A modified version of RetroRun was created to illustrate its use (note the "gou" branch):
https://github.com/OtherCrashOverride/r ... 2/tree/gou

At the time of this writing there an issue that I can not seem to locate with regard to memory corruption in RetroRun. When using the Dreamcast core, it will appear as if a button is always pressed. In other cores, it appears that the exit button is pressed. Since the core SIGSEVs as part of its JIT, it is difficult to debug.
Thank you.

Right now I'm trying to implement SDL2 via fbdev+ge2d or fbdev+gl, but I am unable to maintain 60fps when VSync is enabled on OGU, with stock unrotated SDL2 fbdev patches, with SDL2+GE2D blitter or SDL2+GL blitter, the only way I've managed to achieve 200fps was with vsync disabled, but the tearing is absurd.

I'll investigate more in the coming days, but is there any known problem with the vop or panel drivers that could cause this? Specially since the SDL2+GL blitter runs perfectly on N2+.

crashoverride
Posts: 5860
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 647 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by crashoverride »

JohnnyonFlame wrote:
Tue Sep 13, 2022 3:25 pm
is there any known problem with the vop or panel drivers that could cause this?
I am not aware of any driver issues that would cause it. The fact that libgou + RetroRun does not experience it also further supports the premise that its not a driver issue.

JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

crashoverride wrote:
Tue Sep 13, 2022 5:51 pm
JohnnyonFlame wrote:
Tue Sep 13, 2022 3:25 pm
is there any known problem with the vop or panel drivers that could cause this?
I am not aware of any driver issues that would cause it. The fact that libgou + RetroRun does not experience it also further supports the premise that its not a driver issue.
The problem is that my implementation works perfectly out of the box, no tearing, 60fps on 1080p when testing on N2+ w/ EmuELEC v4.6, testing on OGU + EmuELEC sees my performance drop to 25 to 40fps with noticeable tearing.

crashoverride
Posts: 5860
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 647 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by crashoverride »

JohnnyonFlame wrote:
Tue Sep 13, 2022 10:11 pm
sees my performance drop to 25 to 40fps with noticeable tearing.
This actually reminded me of an issue I reported early on during OGU development and was the main reason for the GE2D pipeline.
viewtopic.php?p=309112#p309112
These users thanked the author crashoverride for the post:
JohnnyonFlame (Tue Sep 13, 2022 10:28 pm)

crashoverride
Posts: 5860
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 647 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by crashoverride »

Can someone recommend some emulator programs (other than PPSSPP since it wont build) to test SDL with? I need a link to the source code and build instructions.

[edit]
Finally got PPSSPP to build. The "HEAD" as of today contains an error, so I reverted to a previous revision:

Code: Select all

git reset --hard 434fa0f072a7bf6f2e400d78f8ec879d95010c9d

cmake -DUSING_EGL=OFF -DUSING_GLES2=ON -DUSING_FBDEV=ON -DUSE_SYSTEM_LIBPNG=OFF -DUSING_X11_VULKAN=OFF ..

crashoverride
Posts: 5860
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 647 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by crashoverride »

I created a fork of the code mentioned in the first post. This fork uses "libgou". It is available here:
https://github.com/OtherCrashOverride/S ... ee/gou-dev

I have tested with a recent version of PPSSPP (see above post) and achieve 51 FPS at the title screen of "God of War - Ghost of Sparta". Note that the CPU governor must be set to "performance":

Code: Select all

echo "performance" | sudo tee /sys/devices/system/cpu/cpufreq/policy2/scaling_governor
These users thanked the author crashoverride for the post (total 2):
odroid (Thu Oct 20, 2022 3:19 pm) • JohnnyonFlame (Fri Oct 21, 2022 6:17 pm)

JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

crashoverride wrote:
Thu Oct 20, 2022 12:35 pm
I created a fork of the code mentioned in the first post. This fork uses "libgou". It is available here:
https://github.com/OtherCrashOverride/S ... ee/gou-dev

I have tested with a recent version of PPSSPP (see above post) and achieve 51 FPS at the title screen of "God of War - Ghost of Sparta". Note that the CPU governor must be set to "performance":

Code: Select all

echo "performance" | sudo tee /sys/devices/system/cpu/cpufreq/policy2/scaling_governor
Interesting way to incorporate libgou here, as soon as I get some time, I'm testing this more throughly. Thanks.

Slaminger
Posts: 404
Joined: Tue Jul 16, 2019 12:30 am
languages_spoken: English, French
ODROIDs: All of Them
Location: Canada
Has thanked: 32 times
Been thanked: 196 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by Slaminger »

crashoverride wrote:
Wed Oct 19, 2022 9:49 pm
Can someone recommend some emulator programs (other than PPSSPP since it wont build) to test SDL with? I need a link to the source code and build instructions.

[edit]
Finally got PPSSPP to build. The "HEAD" as of today contains an error, so I reverted to a previous revision:

Code: Select all

git reset --hard 434fa0f072a7bf6f2e400d78f8ec879d95010c9d

cmake -DUSING_EGL=OFF -DUSING_GLES2=ON -DUSING_FBDEV=ON -DUSE_SYSTEM_LIBPNG=OFF -DUSING_X11_VULKAN=OFF ..


Amiberry Amiga - https://github.com/BlitterStudio/amiberry

instructions on git

crashoverride
Posts: 5860
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 647 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by crashoverride »

Slaminger wrote:
Wed Oct 26, 2022 11:22 pm
Amiberry Amiga - https://github.com/BlitterStudio/amiberry

instructions on git
It appears to work. I compiled it and it displays a configuration screen. However, I did not actually run an Amiga image.

Slaminger
Posts: 404
Joined: Tue Jul 16, 2019 12:30 am
languages_spoken: English, French
ODROIDs: All of Them
Location: Canada
Has thanked: 32 times
Been thanked: 196 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by Slaminger »

crashoverride wrote:
Thu Oct 27, 2022 6:35 am
Slaminger wrote:
Wed Oct 26, 2022 11:22 pm
Amiberry Amiga - https://github.com/BlitterStudio/amiberry

instructions on git
It appears to work. I compiled it and it displays a configuration screen. However, I did not actually run an Amiga image.
Things are looking good for the OGU. The SDL issues are resolved on my end now as well, and a new image is coming later today. Thanks for the help!

JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

crashoverride wrote:
Thu Oct 20, 2022 12:35 pm
I created a fork of the code mentioned in the first post. This fork uses "libgou". It is available here:
https://github.com/OtherCrashOverride/S ... ee/gou-dev

I have tested with a recent version of PPSSPP (see above post) and achieve 51 FPS at the title screen of "God of War - Ghost of Sparta". Note that the CPU governor must be set to "performance":

Code: Select all

echo "performance" | sudo tee /sys/devices/system/cpu/cpufreq/policy2/scaling_governor
The failure to build PPSSPP from the main branch should be fixed now.

Anyways, tested and proposed fixes/improvements to libgou and libSDL2-gou:

https://github.com/OtherCrashOverride/SDL-ge2d/pull/1
https://github.com/OtherCrashOverride/libgou/pull/1

Usage with ARMHF requires libmali built for it, it would be interesting to get a build of libmali-n2-fbdev and libmali-n2-fbdev-dev with armhf support. In the meantime, I'm testing with the following:

Code: Select all

wget https://github.com/CoreELEC/opengl-meson/raw/aml64_buildroot_master/lib/eabihf/gondul/r12p0/fbdev/libMali.so -O gondul-armhf.so
ln -s gondul-armhf.so libEGL.so
ln -s gondul-armhf.so libEGL.so.1
ln -s gondul-armhf.so libEGL.so.1.0.0
ln -s gondul-armhf.so libGLESv1_CM.so
ln -s gondul-armhf.so libGLESv1_CM.so.1
ln -s gondul-armhf.so libGLESv1_CM.so.1.0.0
ln -s gondul-armhf.so libGLESv2.so
ln -s gondul-armhf.so libGLESv2.so.2
ln -s gondul-armhf.so libGLESv2.so.2.0.0
ln -s gondul-armhf.so libOpenCL.so
These users thanked the author JohnnyonFlame for the post:
odjinan (Sat Dec 03, 2022 4:32 pm)

JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

Okay, I spent some time analyzing how libgou differed from my implementation and managed to find out why I was being unable to work around the vsync bug, the 2.0.22 branch has my implementation, with arbitrary rotation and resolutions among other things.
These users thanked the author JohnnyonFlame for the post:
tobetter (Sun Dec 04, 2022 2:27 am)

crashoverride
Posts: 5860
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 647 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by crashoverride »

JohnnyonFlame wrote:
Fri Dec 02, 2022 12:25 pm
Anyways, tested and proposed fixes/improvements to libgou and libSDL2-gou:
I will need to wait until the "staging" changes are finalized before consideration.

The proposed libgou changes appear to be SDL specific:
1) The link to EGL/GLES2 is correct as it requires the libraries to function. I did not encounter any issue with this during my testing.
2) The GE2D headers are taken directly from the kernel source code. If/when the kernel is updated, this file will be replaced with the version current at the time and require changes to be reapplied.

[edit]
3) Since there is no official 32bit libmali.so, I can not provide support for a 32bit environment until such time.

User avatar
odroid
Site Admin
Posts: 42194
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3619 times
Been thanked: 2005 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by odroid »

Amlogic distributed 32bit and 64bit Mali blobs.
As far as I know, CoreELEC(EmuELEC too) have used a 32bit Mali blob for playing Netflix on Kodi because Widevyne library is 32bit only.

crashoverride
Posts: 5860
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 647 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by crashoverride »

odroid wrote:
Wed Dec 07, 2022 8:11 pm
Amlogic distributed 32bit and 64bit Mali blobs.
If someone can provide me with a link to a 32bit libmali.so, I will begin testing and validation of it to ensure it works properly with the current kernel driver.

User avatar
rooted
Posts: 10575
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 818 times
Been thanked: 725 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by rooted »

I just checked libMali.so on CoreELEC and it's definitely 32bit (after finding the actual file)

Code: Select all

CoreELEC:/ # file /usr/lib/libMali.so
/usr/lib/libMali.so: symbolic link to /var/lib/libMali.so
CoreELEC:/ # file /var/lib/libMali.so
/var/lib/libMali.so: symbolic link to /usr/lib/libMali.gondul.so
CoreELEC:/ # file /usr/lib/libMali.gondul.so
/usr/lib/libMali.gondul.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=bf5d6bac00662caa6ae1212bcf1a8d36f3797b6b, stripped

trngaje
Posts: 39
Joined: Tue Mar 10, 2020 8:38 pm
languages_spoken: english
ODROIDs: odroid go advance
Has thanked: 0
Been thanked: 1 time
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by trngaje »

crashoverride wrote:
Thu Oct 20, 2022 12:35 pm
I created a fork of the code mentioned in the first post. This fork uses "libgou". It is available here:
https://github.com/OtherCrashOverride/S ... ee/gou-dev

I have tested with a recent version of PPSSPP (see above post) and achieve 51 FPS at the title screen of "God of War - Ghost of Sparta". Note that the CPU governor must be set to "performance":

Code: Select all

echo "performance" | sudo tee /sys/devices/system/cpu/cpufreq/policy2/scaling_governor
"Segmentation fault" always occurs when all applications using sdl2 exit. The problem only occurs in applications that use "https://github.com/OtherCrashOverride/SDL-ge2d".
If I use another SDL2, it will not fail.

crashoverride
Posts: 5860
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 647 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by crashoverride »

trngaje wrote:
Sat Dec 10, 2022 2:09 pm
"Segmentation fault" always occurs when all applications using sdl2 exit.
This is a known issue. Because it only happens when the program is ending anyway, it was considered a low priority issue. The priority for the SDL2+libgou fork was to get it out to developers as quickly as possible. It was only validated to ensure correct display operation. Other issues are left to anyone wishing to maintain it.

JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

trngaje wrote:
Sat Dec 10, 2022 2:09 pm
crashoverride wrote:
Thu Oct 20, 2022 12:35 pm
I created a fork of the code mentioned in the first post. This fork uses "libgou". It is available here:
https://github.com/OtherCrashOverride/S ... ee/gou-dev

I have tested with a recent version of PPSSPP (see above post) and achieve 51 FPS at the title screen of "God of War - Ghost of Sparta". Note that the CPU governor must be set to "performance":

Code: Select all

echo "performance" | sudo tee /sys/devices/system/cpu/cpufreq/policy2/scaling_governor
"Segmentation fault" always occurs when all applications using sdl2 exit. The problem only occurs in applications that use "https://github.com/OtherCrashOverride/SDL-ge2d".
If I use another SDL2, it will not fail.
Try the 2.0.22 branch from my repository, it's the one currently deployed on the latest RetroArena builds, and seems to be performing pretty decently.

JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

I PRd the necessary changes to GL4ES upstream to make it compliant with the SDL2 setup.

To use this, build with "-DEGL_WRAPPER=ON -DGLX_STUBS=ON -DNOX11=ON" and setup as:

Code: Select all

# libGL.so.1 and libEGL.so.1 are both GL4ES libraries.
export SDL_VIDEO_GL_DRIVER=$LIBDIR/native/libGL.so.1
export SDL_VIDEO_EGL_DRIVER=$LIBDIR/native/libEGL.so.1
export LIBGL_ES=2
export LIBGL_GL=21
export LIBGL_FB=1
# Uncomment to force some games with statically compiled SDL2 to use the system SDL2, e.g. Chowdren based titles (Iconoclasts, Freedom Planet, etc)
# export SDL_DYNAMIC_API="libSDL2-2.0.so.0"
Image
These users thanked the author JohnnyonFlame for the post:
odroid (Sun Dec 18, 2022 10:15 am)

JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

Another port tested, fixed & validated. Had a tiny problem with UNORM8 texture param causing the ASTC-encoded textures to fail upload.
Image
These users thanked the author JohnnyonFlame for the post:
odjinan (Sun Dec 18, 2022 9:50 pm)

chn
Posts: 8
Joined: Tue May 19, 2020 6:41 pm
languages_spoken: english,german,chinese
ODROIDs: Odroid-Go Ultra
Location: Germany
Has thanked: 0
Been thanked: 5 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by chn »

Thanks for your work guys. I have successfully built SDL2 on my OGU according to the instructions here:

https://github.com/JohnnyonFlame/SDL-ge2d/issues/1

Here's a little script I wrote which automatically does that job:

https://github.com/chn-dev/SDL2-ogu/blo ... ld_sdl2.sh

My little test program is also available here:

https://github.com/chn-dev/SDL2-ogu/blo ... lloworld.c

It all compiles and runs. But it seems I'm suffering from this vsync problem. While the same test program's animation is very smooth on my Windows PC, the frame rate is really choppy on my OGU. It doesn't matter if I use crashoverride's or JohnnyonFlame's fork of SDL2. Before I start the test program, I do "sudo systemctl stop emulationstation" so that it doesn't interfere.
I see something about vsync has been mentioned in this thread already. Did I miss something..?

What I'd like to do when I get this all working is to create something like an SDK bundle for people to download and install on their Ubuntu Linux PC so they could cross-compile their own homebrew software for the OGU very easily.
These users thanked the author chn for the post:
odjinan (Wed Dec 21, 2022 1:22 am)

crashoverride
Posts: 5860
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 647 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by crashoverride »

chn wrote:
Tue Dec 20, 2022 11:50 pm
Did I miss something..?
It could be an installation issue. The reference image uses multi-arch compliant library directory names. This influences the order in which directories are searched. If the Ubuntu provided SDL2 libraries were not manually removed / deleted, they are likely still being used. Ensure all SDL package libraries are removed and run "sudo ldconfig" to update the linker cache.

JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

chn wrote:
Tue Dec 20, 2022 11:50 pm
Thanks for your work guys. I have successfully built SDL2 on my OGU according to the instructions here:

https://github.com/JohnnyonFlame/SDL-ge2d/issues/1

Here's a little script I wrote which automatically does that job:

https://github.com/chn-dev/SDL2-ogu/blo ... ld_sdl2.sh

My little test program is also available here:

https://github.com/chn-dev/SDL2-ogu/blo ... lloworld.c

It all compiles and runs. But it seems I'm suffering from this vsync problem. While the same test program's animation is very smooth on my Windows PC, the frame rate is really choppy on my OGU. It doesn't matter if I use crashoverride's or JohnnyonFlame's fork of SDL2. Before I start the test program, I do "sudo systemctl stop emulationstation" so that it doesn't interfere.
I see something about vsync has been mentioned in this thread already. Did I miss something..?

What I'd like to do when I get this all working is to create something like an SDK bundle for people to download and install on their Ubuntu Linux PC so they could cross-compile their own homebrew software for the OGU very easily.
Please use the 2.0.22 branch instead. Should be easier to build and fixes the problem with vsync to boot.

chn
Posts: 8
Joined: Tue May 19, 2020 6:41 pm
languages_spoken: english,german,chinese
ODROIDs: Odroid-Go Ultra
Location: Germany
Has thanked: 0
Been thanked: 5 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by chn »

JohnnyonFlame wrote:
Wed Dec 21, 2022 6:02 pm
chn wrote:
Tue Dec 20, 2022 11:50 pm
Thanks for your work guys. I have successfully built SDL2 on my OGU according to the instructions here:

https://github.com/JohnnyonFlame/SDL-ge2d/issues/1

Here's a little script I wrote which automatically does that job:

https://github.com/chn-dev/SDL2-ogu/blo ... ld_sdl2.sh

My little test program is also available here:

https://github.com/chn-dev/SDL2-ogu/blo ... lloworld.c

It all compiles and runs. But it seems I'm suffering from this vsync problem. While the same test program's animation is very smooth on my Windows PC, the frame rate is really choppy on my OGU. It doesn't matter if I use crashoverride's or JohnnyonFlame's fork of SDL2. Before I start the test program, I do "sudo systemctl stop emulationstation" so that it doesn't interfere.
I see something about vsync has been mentioned in this thread already. Did I miss something..?

What I'd like to do when I get this all working is to create something like an SDK bundle for people to download and install on their Ubuntu Linux PC so they could cross-compile their own homebrew software for the OGU very easily.
Please use the 2.0.22 branch instead. Should be easier to build and fixes the problem with vsync to boot.
Ah, silly me, that's it - thank you!
I've updated build_sdl2.sh to use branch 2.0.22. The result is much, much better. The animation seems to have a frame rate of 60Hz mostly. However, it speeds up sometimes as if the vsync doesnt work reliably and the animation is played as fast as the system can handle. And finally the program crashes with a segmentation fault.

Here's what it looks like:

http://www.chn-dev.net/Private/OGU_SDL2 ... 221221.mp4

Here's the backtrace:

Code: Select all

[Thread 0x7faf8921e0 (LWP 2471) exited]

Thread 1 "helloworld" received signal SIGBUS, Bus error.
0x0000007fb7fb15dc in __aarch64_cas4_acq () from /lib/aarch64-linux-gnu/libpthread.so.0
(gdb) bt
#0  0x0000007fb7fb15dc in __aarch64_cas4_acq () from /lib/aarch64-linux-gnu/libpthread.so.0
#1  0x0000007fb7fa5c34 in __GI___pthread_mutex_lock (mutex=0x55557aa3a9) at pthread_mutex_lock.c:80
#2  0x0000007fb5d4d118 in ?? () from /usr/local/lib/aarch64-linux-gnu/libGLESv2.so
#3  0x00000055555e3c2c in SDL_GL_GetCurrentWindow_REAL ()
#4  0x00000055555e3c2c in SDL_GL_GetCurrentWindow_REAL ()
#5  0x000000555573d670 in ?? ()
And since I'm linking statically, no pre-installed SDL2 libraries are used. Just to be sure, I removed them anyway, even though that prevents EmulationStation from starting up.

Any ideas?

JohnnyonFlame
Posts: 21
Joined: Tue Dec 07, 2021 4:07 am
languages_spoken: english
ODROIDs: N2+, OGA, OGU
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by JohnnyonFlame »

chn wrote:
Wed Dec 21, 2022 8:35 pm
JohnnyonFlame wrote:
Wed Dec 21, 2022 6:02 pm
chn wrote:
Tue Dec 20, 2022 11:50 pm
Thanks for your work guys. I have successfully built SDL2 on my OGU according to the instructions here:

https://github.com/JohnnyonFlame/SDL-ge2d/issues/1

Here's a little script I wrote which automatically does that job:

https://github.com/chn-dev/SDL2-ogu/blo ... ld_sdl2.sh

My little test program is also available here:

https://github.com/chn-dev/SDL2-ogu/blo ... lloworld.c

It all compiles and runs. But it seems I'm suffering from this vsync problem. While the same test program's animation is very smooth on my Windows PC, the frame rate is really choppy on my OGU. It doesn't matter if I use crashoverride's or JohnnyonFlame's fork of SDL2. Before I start the test program, I do "sudo systemctl stop emulationstation" so that it doesn't interfere.
I see something about vsync has been mentioned in this thread already. Did I miss something..?

What I'd like to do when I get this all working is to create something like an SDK bundle for people to download and install on their Ubuntu Linux PC so they could cross-compile their own homebrew software for the OGU very easily.
Please use the 2.0.22 branch instead. Should be easier to build and fixes the problem with vsync to boot.
Ah, silly me, that's it - thank you!
I've updated build_sdl2.sh to use branch 2.0.22. The result is much, much better. The animation seems to have a frame rate of 60Hz mostly. However, it speeds up sometimes as if the vsync doesnt work reliably and the animation is played as fast as the system can handle. And finally the program crashes with a segmentation fault.

Here's what it looks like:

http://www.chn-dev.net/Private/OGU_SDL2 ... 221221.mp4

Here's the backtrace:

Code: Select all

[Thread 0x7faf8921e0 (LWP 2471) exited]

Thread 1 "helloworld" received signal SIGBUS, Bus error.
0x0000007fb7fb15dc in __aarch64_cas4_acq () from /lib/aarch64-linux-gnu/libpthread.so.0
(gdb) bt
#0  0x0000007fb7fb15dc in __aarch64_cas4_acq () from /lib/aarch64-linux-gnu/libpthread.so.0
#1  0x0000007fb7fa5c34 in __GI___pthread_mutex_lock (mutex=0x55557aa3a9) at pthread_mutex_lock.c:80
#2  0x0000007fb5d4d118 in ?? () from /usr/local/lib/aarch64-linux-gnu/libGLESv2.so
#3  0x00000055555e3c2c in SDL_GL_GetCurrentWindow_REAL ()
#4  0x00000055555e3c2c in SDL_GL_GetCurrentWindow_REAL ()
#5  0x000000555573d670 in ?? ()
And since I'm linking statically, no pre-installed SDL2 libraries are used. Just to be sure, I removed them anyway, even though that prevents EmulationStation from starting up.

Any ideas?
I'll build and test your code. How long should I wait until the issue presents itself?

chn
Posts: 8
Joined: Tue May 19, 2020 6:41 pm
languages_spoken: english,german,chinese
ODROIDs: Odroid-Go Ultra
Location: Germany
Has thanked: 0
Been thanked: 5 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by chn »

JohnnyonFlame wrote:
Thu Dec 22, 2022 2:55 pm
chn wrote:
Wed Dec 21, 2022 8:35 pm
JohnnyonFlame wrote:
Wed Dec 21, 2022 6:02 pm
chn wrote:
Tue Dec 20, 2022 11:50 pm
Thanks for your work guys. I have successfully built SDL2 on my OGU according to the instructions here:

https://github.com/JohnnyonFlame/SDL-ge2d/issues/1

Here's a little script I wrote which automatically does that job:

https://github.com/chn-dev/SDL2-ogu/blo ... ld_sdl2.sh

My little test program is also available here:

https://github.com/chn-dev/SDL2-ogu/blo ... lloworld.c

It all compiles and runs. But it seems I'm suffering from this vsync problem. While the same test program's animation is very smooth on my Windows PC, the frame rate is really choppy on my OGU. It doesn't matter if I use crashoverride's or JohnnyonFlame's fork of SDL2. Before I start the test program, I do "sudo systemctl stop emulationstation" so that it doesn't interfere.
I see something about vsync has been mentioned in this thread already. Did I miss something..?

What I'd like to do when I get this all working is to create something like an SDK bundle for people to download and install on their Ubuntu Linux PC so they could cross-compile their own homebrew software for the OGU very easily.
Please use the 2.0.22 branch instead. Should be easier to build and fixes the problem with vsync to boot.
Ah, silly me, that's it - thank you!
I've updated build_sdl2.sh to use branch 2.0.22. The result is much, much better. The animation seems to have a frame rate of 60Hz mostly. However, it speeds up sometimes as if the vsync doesnt work reliably and the animation is played as fast as the system can handle. And finally the program crashes with a segmentation fault.

Here's what it looks like:

http://www.chn-dev.net/Private/OGU_SDL2 ... 221221.mp4

Here's the backtrace:

Code: Select all

[Thread 0x7faf8921e0 (LWP 2471) exited]

Thread 1 "helloworld" received signal SIGBUS, Bus error.
0x0000007fb7fb15dc in __aarch64_cas4_acq () from /lib/aarch64-linux-gnu/libpthread.so.0
(gdb) bt
#0  0x0000007fb7fb15dc in __aarch64_cas4_acq () from /lib/aarch64-linux-gnu/libpthread.so.0
#1  0x0000007fb7fa5c34 in __GI___pthread_mutex_lock (mutex=0x55557aa3a9) at pthread_mutex_lock.c:80
#2  0x0000007fb5d4d118 in ?? () from /usr/local/lib/aarch64-linux-gnu/libGLESv2.so
#3  0x00000055555e3c2c in SDL_GL_GetCurrentWindow_REAL ()
#4  0x00000055555e3c2c in SDL_GL_GetCurrentWindow_REAL ()
#5  0x000000555573d670 in ?? ()
And since I'm linking statically, no pre-installed SDL2 libraries are used. Just to be sure, I removed them anyway, even though that prevents EmulationStation from starting up.

Any ideas?
I'll build and test your code. How long should I wait until the issue presents itself?
It'll often start immediately, sometimes up to about a minute after starting the program.

The last thing I tried was to just add "SDL_Delay(0)" after "SDL_RenderPresent( pRenderer )" to the main loop of my helloworld program. That seems to have fixed the problem - the frame rate seems to be rock-solid. I haven't commited this version yet.

My SDL knowledge is quite dated (from the pre-SDL2 days), so maybe I don't quite know what I'm doing there. I thought SDL_RenderPresent does a vsync and this would automatically cap the frame rate to whatever the LCD's refresh rate is. And I wouldn't expect "SDL_Delay( 0 )" to do anything there.

chn
Posts: 8
Joined: Tue May 19, 2020 6:41 pm
languages_spoken: english,german,chinese
ODROIDs: Odroid-Go Ultra
Location: Germany
Has thanked: 0
Been thanked: 5 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by chn »

I have released a self-contained SDL2 SDK package which allows you to easily compile SDL2 applications on the device itself and to cross-compile them on an Ubuntu Linux PC. This is based on JohnnyonFlame's port.

GitHub: https://github.com/chn-dev/SDL2-ogu/

The pre-compiled package: http://www.chn-dev.net/Content/SDL2-ogu ... 230.tar.gz

An introduction for beginners: http://www.chn-dev.net/index.php?action ... rogramming

I also propose a change to /etc/emulationstation/es_systems.xml which would allow native binary deployment (rather than just game ROMs for emulated systems) on the MicroSD card.

Hopefully this makes homebrew programming for the OGU more popular, overall.
These users thanked the author chn for the post (total 3):
odroid (Sat Dec 31, 2022 11:16 am) • Andyyy (Wed Jan 04, 2023 12:25 am) • mariovirgili (Thu Jan 12, 2023 9:49 pm)

User avatar
mad_ady
Posts: 11942
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4 (HC1, HC2), C1+, C2, C4 (HC4), N1, N2, N2L, H2, H3+, Go, Go Advance, M1, M1S
Location: Bucharest, Romania
Has thanked: 662 times
Been thanked: 1257 times
Contact:

Re: [experimental] SDL2 with Tear-Free Zero-copy Rotation

Post by mad_ady »

@chn that's a nice write-up! It's also a nice way to start native programs via the launcher (I'm not a fan of emulated games either).
What I would change in your tutorial would be using autofs to mount the nfs share on demand. Otherwise, if done via fstab (and at boot), it could lock the boot when there is no network or no nfs server.
These users thanked the author mad_ady for the post:
Andyyy (Wed Jan 04, 2023 12:26 am)

Post Reply

Return to “Platform development”

Who is online

Users browsing this forum: No registered users and 1 guest