[Release] SDL2 with screen rotation

Talking about OS and emulation core development
PaulF8080
Posts: 71
Joined: Fri Feb 14, 2020 9:40 am
languages_spoken: english
ODROIDs: go, go advance, xu4
Has thanked: 0
Been thanked: 9 times
Contact:

Re: [Release] SDL2 with screen rotation

Post by PaulF8080 »

crashoverride wrote: โ†‘
Wed Apr 22, 2020 1:55 pm
PaulF8080 wrote: โ†‘
Wed Apr 22, 2020 12:22 pm
What do mean by "provide rotation transparently"? Do you swap X and Y widths?
It means the display is rotated 90 degrees (portrait to landscape) without any modifications to programs using SDL. The X and Y widths are swapped to reflect this.
Thanks. I think I get it now. I'm learning a lot. The /dev/dri/card0 is totally new to me. The /dev/fb0 doesn't do rotation anymore via /sys/class/graphics/fb0/rotate.

I ordered touch screen for my Raspberry Pi with the same resolution. I'm hoping it will be easier for me to do SDL2 migration on the old PI which I'm comfortable with.

escalade
Posts: 287
Joined: Thu Mar 14, 2019 8:34 pm
languages_spoken: english and norwegian
Has thanked: 16 times
Been thanked: 136 times
Contact:

Re: [Release] SDL2 with screen rotation

Post by escalade »

Did anyone manage to rebase on latest git? I tried but failed :) The current code is getting a bit long in the tooth.
Maintainer of RetroELEC (XU4 / OGA / x86_64)

AreaScout
Posts: 1795
Joined: Sun Jul 07, 2013 3:05 am
languages_spoken: german, english
ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
N1, Go, VU5A, Show2, CloudShell2,
H2, N2, VU7A, VuShell, Go2, C4
Has thanked: 120 times
Been thanked: 372 times
Contact:

Re: [Release] SDL2 with screen rotation

Post by AreaScout »

    Well, I will have a look on it, but I am on training now, so earliest on weekend


    RG
    These users thanked the author AreaScout for the post:
    escalade (Wed Aug 19, 2020 12:49 pm)

    AreaScout
    Posts: 1795
    Joined: Sun Jul 07, 2013 3:05 am
    languages_spoken: german, english
    ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
    N1, Go, VU5A, Show2, CloudShell2,
    H2, N2, VU7A, VuShell, Go2, C4
    Has thanked: 120 times
    Been thanked: 372 times
    Contact:

    Re: [Release] SDL2 with screen rotation

    Post by AreaScout »


      Oho, I have just take a look on the source code and the kmsdrm backend seems to get a whole rewrite to atomic drm until now it seems that this code is only working on Android devices :o I hope that this will change and linux will also be supported, if not we have to backport drm legacy to SDL2 for versions >= 2.0.13


      https://github.com/bminor/SDL/blob/mast ... les.c#L102

      RG

      escalade
      Posts: 287
      Joined: Thu Mar 14, 2019 8:34 pm
      languages_spoken: english and norwegian
      Has thanked: 16 times
      Been thanked: 136 times
      Contact:

      Re: [Release] SDL2 with screen rotation

      Post by escalade »

      I just compiled latest git for my NUC and it works fine, so the atomic drm rewrite isn't android only. That would be big news if SDL did that :)
      Maintainer of RetroELEC (XU4 / OGA / x86_64)

      AreaScout
      Posts: 1795
      Joined: Sun Jul 07, 2013 3:05 am
      languages_spoken: german, english
      ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
      N1, Go, VU5A, Show2, CloudShell2,
      H2, N2, VU7A, VuShell, Go2, C4
      Has thanked: 120 times
      Been thanked: 372 times
      Contact:

      Re: [Release] SDL2 with screen rotation

      Post by AreaScout »

        Hello escalade


        Then the KMSDRM Video backend is now Mesa only, Mesa also supports Android extensions/functions and I think the Gallium Mesa backend aka Panfrost, Lima and what not must support them too, that means that a lot of proprietary drivers are not supported anymore by this SDL2 video backend including the one from GO2, so we must backport in the future if someone wants a version >=2.0.13


        RG

        escalade
        Posts: 287
        Joined: Thu Mar 14, 2019 8:34 pm
        languages_spoken: english and norwegian
        Has thanked: 16 times
        Been thanked: 136 times
        Contact:

        Re: [Release] SDL2 with screen rotation

        Post by escalade »

        I see, that really sucks. G31 is fully supported by Panfrost AFAIK, too bad we only got a 4.4 kernel to play with.
        Maintainer of RetroELEC (XU4 / OGA / x86_64)

        AreaScout
        Posts: 1795
        Joined: Sun Jul 07, 2013 3:05 am
        languages_spoken: german, english
        ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
        N1, Go, VU5A, Show2, CloudShell2,
        H2, N2, VU7A, VuShell, Go2, C4
        Has thanked: 120 times
        Been thanked: 372 times
        Contact:

        Re: [Release] SDL2 with screen rotation

        Post by AreaScout »

          Yes that's true but sooner or later we will get a newer kernel I hope, it's just sad to see SDL2 KMSDRM not supported anymore with the official RockChip drivers, because the support is fantastic

          edit: It's not a big deal to port the rotation patch to atomic drm for Panfrost if we use a newer kernel, in case Panfrost supports eglDupNativeFenceFDANDROID

          RG

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

          Re: [Release] SDL2 with screen rotation

          Post by crashoverride »

          This is actually a SDL problem. The kernel version and/or proprietary vendor extension (EGL_ANDROID_native_fence_sync) are not required to achieve the goal. As proof, libgo2 does the same thing using a thread with a semaphore.
          https://github.com/OtherCrashOverride/l ... lay.c#L858

          Is there a high profile GO2 application that can only work with a newer version of SDL?

          AreaScout
          Posts: 1795
          Joined: Sun Jul 07, 2013 3:05 am
          languages_spoken: german, english
          ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
          N1, Go, VU5A, Show2, CloudShell2,
          H2, N2, VU7A, VuShell, Go2, C4
          Has thanked: 120 times
          Been thanked: 372 times
          Contact:

          Re: [Release] SDL2 with screen rotation

          Post by AreaScout »

            Of course it is not needed or required, the legacy drm video backend in sdl2 was working great, thought they just changed it to stay on the newest technology
            crashoverride wrote: โ†‘
            Sat Aug 22, 2020 1:31 am
            Is there a high profile GO2 application that can only work with a newer version of SDL?
            I don't think so, maybe the OS itself requires it, if the image builders are want to stay on early releases, but 2.0.13 not even out yet, let's see and wait how this will turn out

            Thanks crash ๐Ÿ‘

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

            Re: [Release] SDL2 with screen rotation

            Post by crashoverride »

            For completeness, I should note the GO2 Kernel does support DRM Atomic Mode Setting. It just is not of any use since there is exactly one mode (320x480@60). The "legacy" API blocks on VSYNC so frame buffer switching is always "atomic".

            AreaScout
            Posts: 1795
            Joined: Sun Jul 07, 2013 3:05 am
            languages_spoken: german, english
            ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
            N1, Go, VU5A, Show2, CloudShell2,
            H2, N2, VU7A, VuShell, Go2, C4
            Has thanked: 120 times
            Been thanked: 372 times
            Contact:

            Re: [Release] SDL2 with screen rotation

            Post by AreaScout »

              The default behavior is to have VSYNC on with the legacy drm backend but if you look on the examples in the test suite of SDL2 it's the other way around

              ./testgles2 runs without VSYNC and ./testgles2 --vsync with, so in general the legacy drm video backend is able to do both

              RG

              escalade
              Posts: 287
              Joined: Thu Mar 14, 2019 8:34 pm
              languages_spoken: english and norwegian
              Has thanked: 16 times
              Been thanked: 136 times
              Contact:

              Re: [Release] SDL2 with screen rotation

              Post by escalade »

              @crashoverride

              Sorry to go a little off topic here, but I've been experimenting with gl4es in hopes of getting OpenGL working in my image but no success as of yet. I can compile it fine and link GL applications to it but I have yet to get it to display anything either on Wayland/Xwayland or through creating the context with SDL2 or RetroArch. I'd appreciate any insight you have on the matter. I've gone through every possible LIBGL_FB options and GBM/EGL/X11 CMake options but no success. I can get glxinfo to work and glxgears creates a window and reports FPS but no visual on the wheels. Here's the gl4es log when trying to start Retroarch with the gl driver:

              http://ix.io/2uSZ

              That's trying to get the KMS context working, seems to be EGL related. When glxgears runs on Weston I believe the log said glamor failed due to lack of wl_drm. I'd love to get it spinning and offer more golden oldies in my images.
              Maintainer of RetroELEC (XU4 / OGA / x86_64)

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

              Re: [Release] SDL2 with screen rotation

              Post by crashoverride »

              escalade wrote: โ†‘
              Sat Aug 22, 2020 9:05 pm
              I'd appreciate any insight you have on the matter.
              For KMS/GBM, you likely need to replace this:
              https://github.com/ptitSeb/gl4es/blob/0 ... ext.c#L196

              With GBM specific initialization like this:
              https://github.com/OtherCrashOverride/l ... 1146-L1167

              [edit]
              It looks like the function "OpenGBMDisplay" is supposed to do exactly that. Make sure its getting compiled:
              https://github.com/ptitSeb/gl4es/blob/f ... gbm.c#L311
              (NO_GBM is not defined)

              [edit2]
              Also, make sure its linking with libmali.so and not MESA libeg/gles.

              escalade
              Posts: 287
              Joined: Thu Mar 14, 2019 8:34 pm
              languages_spoken: english and norwegian
              Has thanked: 16 times
              Been thanked: 136 times
              Contact:

              Re: [Release] SDL2 with screen rotation

              Post by escalade »

              crashoverride wrote: โ†‘
              Sat Aug 22, 2020 1:31 am
              This is actually a SDL problem. The kernel version and/or proprietary vendor extension (EGL_ANDROID_native_fence_sync) are not required to achieve the goal. As proof, libgo2 does the same thing using a thread with a semaphore.
              https://github.com/OtherCrashOverride/l ... lay.c#L858

              Is there a high profile GO2 application that can only work with a newer version of SDL?
              Looks like they have rectified the situation now: https://hg.libsdl.org/SDL/rev/889d85d67a02
              Maintainer of RetroELEC (XU4 / OGA / x86_64)

              AreaScout
              Posts: 1795
              Joined: Sun Jul 07, 2013 3:05 am
              languages_spoken: german, english
              ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
              N1, Go, VU5A, Show2, CloudShell2,
              H2, N2, VU7A, VuShell, Go2, C4
              Has thanked: 120 times
              Been thanked: 372 times
              Contact:

              Re: [Release] SDL2 with screen rotation

              Post by AreaScout »

              escalade wrote: โ†‘
              Thu Sep 17, 2020 8:56 am
              Looks like they have rectified the situation now: https://hg.libsdl.org/SDL/rev/889d85d67a02
              No they don't, it is the eglDupNativeFenceFDANDROID ( https://hg.libsdl.org/SDL/file/ed05d821 ... les.c#l147 ) function they are using which our EGL lib does not support, but this is just a nested function for eglCreateSyncKHR which our driver does support, here is the function implementation commit in Mesa https://lists.freedesktop.org/archives/ ... 11577.html I am not that expert here but if they just cloud implement this function in SDL2 we still would be able to use our proprietary driver !

              edit: uhh, I have run testgles2 from latest SDL2 test suite and at least with software renderer the test does not run :( I don't like this situation, no proprietary driver support under Linux and kmsdrm backend not working with mesa software renderer, I must admit that the situation before the changes was way better !

              RG
              These users thanked the author AreaScout for the post:
              odroid (Mon Oct 19, 2020 9:50 am)

              AreaScout
              Posts: 1795
              Joined: Sun Jul 07, 2013 3:05 am
              languages_spoken: german, english
              ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
              N1, Go, VU5A, Show2, CloudShell2,
              H2, N2, VU7A, VuShell, Go2, C4
              Has thanked: 120 times
              Been thanked: 372 times
              Contact:

              Re: [Release] SDL2 with screen rotation

              Post by AreaScout »

                @all

                The rotation patch for SDL2 has changed slightly to support the new Go Super, credits for the changes goes to team batocera (stride size, seems to need a hardware specific value here) ! :)

                Sources https://github.com/AreaScout/SDL

                RG
                These users thanked the author AreaScout for the post:
                odroid (Wed Dec 30, 2020 9:18 am)

                AreaScout
                Posts: 1795
                Joined: Sun Jul 07, 2013 3:05 am
                languages_spoken: german, english
                ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
                N1, Go, VU5A, Show2, CloudShell2,
                H2, N2, VU7A, VuShell, Go2, C4
                Has thanked: 120 times
                Been thanked: 372 times
                Contact:

                Re: [Release] SDL2 with screen rotation

                Post by AreaScout »

                  @all

                  Happy new Year to all out there !

                  I have uploaded new SDL2 2.0.10 library deb packages for ubuntu with new patch for Go Super applied (they should work also for debian), also a link to the patch used for 2.0.10 and the link for the patch used in 2.0.12

                  RG and have fun
                  These users thanked the author AreaScout for the post:
                  odroid (Mon Jan 04, 2021 9:40 am)

                  fahien
                  Posts: 6
                  Joined: Sun Oct 04, 2020 8:01 am
                  languages_spoken: english
                  ODROIDs: Go, Go2
                  Has thanked: 3 times
                  Been thanked: 5 times
                  Contact:

                  Re: [Release] SDL2 with screen rotation

                  Post by fahien »

                  Hi, I tried your SDL2 repo by following the steps for compiling and installing it, but I am not really convinced of the result.
                  This is what I get by running ./controllermap 0. Any idea what could be the problem?

                  Image

                  AreaScout
                  Posts: 1795
                  Joined: Sun Jul 07, 2013 3:05 am
                  languages_spoken: german, english
                  ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
                  N1, Go, VU5A, Show2, CloudShell2,
                  H2, N2, VU7A, VuShell, Go2, C4
                  Has thanked: 120 times
                  Been thanked: 372 times
                  Contact:

                  Re: [Release] SDL2 with screen rotation

                  Post by AreaScout »

                    Go 2 or Go Super ?

                    fahien
                    Posts: 6
                    Joined: Sun Oct 04, 2020 8:01 am
                    languages_spoken: english
                    ODROIDs: Go, Go2
                    Has thanked: 3 times
                    Been thanked: 5 times
                    Contact:

                    Re: [Release] SDL2 with screen rotation

                    Post by fahien »

                    AreaScout wrote: โ†‘
                    Sat Jan 23, 2021 8:33 pm
                      Go 2 or Go Super ?
                      That is a Go2.

                      AreaScout
                      Posts: 1795
                      Joined: Sun Jul 07, 2013 3:05 am
                      languages_spoken: german, english
                      ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
                      N1, Go, VU5A, Show2, CloudShell2,
                      H2, N2, VU7A, VuShell, Go2, C4
                      Has thanked: 120 times
                      Been thanked: 372 times
                      Contact:

                      Re: [Release] SDL2 with screen rotation

                      Post by AreaScout »

                        I try to build it now on Go2, hold on
                        These users thanked the author AreaScout for the post:
                        fahien (Sat Jan 23, 2021 8:56 pm)

                        AreaScout
                        Posts: 1795
                        Joined: Sun Jul 07, 2013 3:05 am
                        languages_spoken: german, english
                        ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
                        N1, Go, VU5A, Show2, CloudShell2,
                        H2, N2, VU7A, VuShell, Go2, C4
                        Has thanked: 120 times
                        Been thanked: 372 times
                        Contact:

                        Re: [Release] SDL2 with screen rotation

                        Post by AreaScout »

                          Ok my fault, please do this from within the source directory before building

                          Code: Select all

                          wget -O Go2_stride.patch https://pastebin.com/raw/1F0DstUE
                          patch -p1 < Go2_stride.patch
                          
                          build and install and test it

                          @all

                          I have changed the build tutorial to reflect the hardware for the "older" Go2

                          viewtopic.php?p=284753#p284753

                          RG
                          These users thanked the author AreaScout for the post:
                          fahien (Sun Jan 24, 2021 3:03 am)

                          AreaScout
                          Posts: 1795
                          Joined: Sun Jul 07, 2013 3:05 am
                          languages_spoken: german, english
                          ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
                          N1, Go, VU5A, Show2, CloudShell2,
                          H2, N2, VU7A, VuShell, Go2, C4
                          Has thanked: 120 times
                          Been thanked: 372 times
                          Contact:

                          Re: [Release] SDL2 with screen rotation

                          Post by AreaScout »

                            @all

                            I have pushed a new Go2/Super patch on my SDL2 repo, the old one broke the Go2 model, now both Go2 and Super are working

                            You have to re-checkout it because I force pushed to it

                            RG
                            These users thanked the author AreaScout for the post (total 2):
                            fahien (Sun Jan 24, 2021 6:40 am) • odroid (Mon Jan 25, 2021 10:58 am)

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

                            Re: [Release] SDL2 with screen rotation

                            Post by trngaje »

                            AreaScout wrote: โ†‘
                            Wed Dec 30, 2020 4:44 am
                              @all

                              The rotation patch for SDL2 has changed slightly to support the new Go Super, credits for the changes goes to team batocera (stride size, seems to need a hardware specific value here) ! :)

                              Sources https://github.com/AreaScout/SDL

                              RG
                              i compiled this for armhf (32bit), ogs because 32bit sdl2.0 is not include on the ubuntu base image or retroarena .
                              but i coudn't get good working sdl.
                              how can i configure it for armhf before make it? or how can get pre-built sdl2.0 for ogs ?

                              AreaScout
                              Posts: 1795
                              Joined: Sun Jul 07, 2013 3:05 am
                              languages_spoken: german, english
                              ODROIDs: X2, U3, XU3, C2, HiFi Shield, XU4, XU4Q,
                              N1, Go, VU5A, Show2, CloudShell2,
                              H2, N2, VU7A, VuShell, Go2, C4
                              Has thanked: 120 times
                              Been thanked: 372 times
                              Contact:

                              Re: [Release] SDL2 with screen rotation

                              Post by AreaScout »

                                @trngaje

                                Pretty much this viewtopic.php?p=284753#p284753 except all packages for armhf

                                And configure from inside the SDL2 directory

                                Code: Select all

                                mkdir build-armhf && cd $_
                                 
                                TOOLSET=arm-linux-gnueabihf
                                export CC="$TOOLSET-gcc -static-libgcc"
                                export CXX="$TOOLSET-g++ --static-libstdc++"
                                 
                                ../configure --target=$TOOLSET --host=$TOOLSET
                                
                                make -j3
                                sudo make install
                                

                                Christian_Haitian
                                Posts: 66
                                Joined: Sat Nov 10, 2018 10:40 pm
                                languages_spoken: english
                                ODROIDs: Go, Go Advance
                                Has thanked: 28 times
                                Been thanked: 56 times
                                Contact:

                                Re: [Release] SDL2 with screen rotation

                                Post by Christian_Haitian »

                                Thanks to developer by the name of JohnnyonFlame, SDL 2.0.16 is available for use for this chipset. So far, performance seems to be on par or slightly better than 2.0.10. The build recipe I use is in the script below assuming my VM is used.

                                https://github.com/christianhaitian/rk3 ... ts/sdl2.sh
                                Alter for your build environment as you see fit.

                                The patches applied:

                                https://github.com/christianhaitian/rk3 ... t_fd.patch

                                https://raw.githubusercontent.com/chris ... port.patch <--Rotation patch from Batocera

                                1/1/22 update: updated 1st patch to address some potential issues. Thanks to Batocera.
                                These users thanked the author Christian_Haitian for the post (total 5):
                                Baco (Tue Dec 07, 2021 5:36 am) • southoz (Tue Dec 07, 2021 3:27 pm) • JohnnyonFlame (Wed Dec 08, 2021 2:09 am) • shanti (Wed Dec 08, 2021 12:49 pm) • rickyzhang (Tue Feb 08, 2022 6:58 am)
                                A jack of all trades is a master of none, but oftentimes better than a master of one

                                rickyzhang
                                Posts: 70
                                Joined: Thu Feb 28, 2013 1:20 pm
                                languages_spoken: english
                                ODROIDs: u2, xu4
                                Location: Cary, NC
                                Has thanked: 1 time
                                Been thanked: 1 time
                                Contact:

                                Re: [Release] SDL2 with screen rotation

                                Post by rickyzhang »

                                @Christian, Thanks for sharing the patched SDL2. It works like a charm.

                                I wonder if you want to patched its audio and joystick control as well. I used your patched SDL2 and ported Basilisk II Macintosh emulator. But there is no sound nor joystick/buttons control. Do you have any plan to keep doing that?

                                Christian_Haitian
                                Posts: 66
                                Joined: Sat Nov 10, 2018 10:40 pm
                                languages_spoken: english
                                ODROIDs: Go, Go Advance
                                Has thanked: 28 times
                                Been thanked: 56 times
                                Contact:

                                Re: [Release] SDL2 with screen rotation

                                Post by Christian_Haitian »

                                rickyzhang wrote: โ†‘
                                Tue Feb 08, 2022 7:19 am
                                @Christian, Thanks for sharing the patched SDL2. It works like a charm.

                                I wonder if you want to patched its audio and joystick control as well. I used your patched SDL2 and ported Basilisk II Macintosh emulator. But there is no sound nor joystick/buttons control. Do you have any plan to keep doing that?
                                That would be a question for Johnny on what's possible. Does the sound work on the previous 2.10 SDL?
                                A jack of all trades is a master of none, but oftentimes better than a master of one

                                Christian_Haitian
                                Posts: 66
                                Joined: Sat Nov 10, 2018 10:40 pm
                                languages_spoken: english
                                ODROIDs: Go, Go Advance
                                Has thanked: 28 times
                                Been thanked: 56 times
                                Contact:

                                Re: [Release] SDL2 with screen rotation

                                Post by Christian_Haitian »

                                These users thanked the author Christian_Haitian for the post (total 2):
                                southoz (Tue Mar 08, 2022 3:02 pm) • Baco (Fri Mar 18, 2022 12:38 am)
                                A jack of all trades is a master of none, but oftentimes better than a master of one

                                Post Reply

                                Return to โ€œPlatform developmentโ€

                                Who is online

                                Users browsing this forum: No registered users and 2 guests