RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Raspberry Pi 4 - Forced VSYNC?!

    Scheduled Pinned Locked Moved Help and Support
    raspberrypi4sdl2vsync
    14 Posts 2 Posters 2.9k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      FranceMSR
      last edited by FranceMSR

      Hi all, I wrote a porting of M.A.M.E. with the scope of great performance also on Raspberry Pi v1. I'm using SDL2 for the interface with the operating system.

      It works fine but with Raspberry Pi 4 there is a problem. It runs slower than Raspberry Pi 3.

      During my investigation I removed from my code the part that is responsible of adaptive dynamic frameskipping, audio/video synchronization and nominal FPS targeting. In this way the application must be run as fast as it can.

      In this way games run faster, 200 FPS on my laptop, a little slower on Raspberry Pi 3 (but over 100 FPS)... On Raspberry Pi 4 it runs at 60 FPS like an hardware (or software, maybe driver?!?!) performs a VSYNC.

      I can't find a solution, have you any ideas? Is there a way to run glxgears closing EmulationStation?

      RetroPie v4.7.1, fresh install

      1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator
        last edited by

        I remember being a SDL2 issue with its KMS video driver.
        RetroPie ships with 2.0.10, you may try with a newer SDL version (though they may have some quirks with the KMS video driver, that's why they're not yet included).

        F 1 Reply Last reply Reply Quote 0
        • F
          FranceMSR @mitu
          last edited by

          Hi @mitu, thanks for reply.

          I don't understand the point because if there is a bug on SDL 2.0.10 the same behaviour should happens with Raspberry Pi v3. So there is a difference between Raspberry Pi v3 and Raspberry Pi v4 that creates the problem. Video driver? Hardware?

          Anyway I tried with RetroPie 4.7.1 stock (5.4 kernel) and after a full upgrade (so new kernel). After that I changed this option in config.txt

          dtoverlay=vc4-fkms-v3d
          

          so, as I understand, Fake KMS in this

          dtoverlay=vc4-kms-v3d
          

          so Full KMS. The problem persists. I will try to use newer SDL version in order to continue my investigation.

          Maybe there is a wrong interaction between KMS and SDL2 that only appears on Raspberry Pi v4

          mituM 1 Reply Last reply Reply Quote 0
          • mituM
            mitu Global Moderator @FranceMSR
            last edited by

            @francemsr said in Raspberry Pi 4 - Forced VSYNC?!:

            I don't understand the point because if there is a bug on SDL 2.0.10 the same behaviour should happens with Raspberry Pi v3. So there is a difference between Raspberry Pi v3 and Raspberry Pi v4 that creates the problem. Video driver? Hardware?

            The Pi3 (and previous models) has a different video driver in SDL2 - as I said the issue is with the KMS video driver (which is used on the Pi4).

            F 1 Reply Last reply Reply Quote 0
            • F
              FranceMSR @mitu
              last edited by

              @mitu sorry but you wrote "I remember being a SDL2 issue with its KMS video driver." as kind of sort of SDL-ONLY-RELATED internal driver, not Raspberry Pi one :-)

              As I said before, I'll try SDL 2.0.14 and I'll report the result

              mituM 1 Reply Last reply Reply Quote 0
              • mituM
                mitu Global Moderator @FranceMSR
                last edited by

                @francemsr Yes, it's the SDL2 driver, not the Linux kernel or Mesa drivers.

                F 1 Reply Last reply Reply Quote 0
                • F
                  FranceMSR @mitu
                  last edited by

                  @mitu good, thanks.

                  Just for testing purpose: is there a way to use glxgears closing EmulationStation?

                  mituM 1 Reply Last reply Reply Quote 0
                  • mituM
                    mitu Global Moderator @FranceMSR
                    last edited by

                    @francemsr You can install the desktop part as a Port and start it from EmulationStation - https://retropie.org.uk/docs/FAQ/#where-did-the-desktop-go

                    F 1 Reply Last reply Reply Quote 0
                    • F
                      FranceMSR @mitu
                      last edited by

                      @mitu ok, I thought there was a different way instead of pass from Desktop Environment.

                      Thanks for now

                      mituM 1 Reply Last reply Reply Quote 0
                      • mituM
                        mitu Global Moderator @FranceMSR
                        last edited by mitu

                        @francemsr You can instruct the RetroPie launcher (runcommand) to start an emulator/program via xorg by adding XINIT to its command in emulators.cfg - for instance this is how steamlink is started (see here).

                        F 1 Reply Last reply Reply Quote 0
                        • F
                          FranceMSR @mitu
                          last edited by

                          @mitu oh good thing!

                          F 1 Reply Last reply Reply Quote 0
                          • F
                            FranceMSR @FranceMSR
                            last edited by

                            Built SDL2 with --enable-video-kmsdrm parameter, this is the result of pre-build configuration

                            SDL2 Configure Summary:
                            Building Shared Libraries
                            Building Static Libraries
                            Enabled modules : atomic audio video render events joystick haptic sensor power filesystem threads timers file loadso cpuinfo assembly
                            Assembly Math   :
                            Audio drivers   : disk dummy oss alsa(dynamic) sndio(dynamic)
                            Video drivers   : dummy rpi x11(dynamic) kmsdrm(dynamic) opengl opengl_es1 opengl_es2 vulkan
                            X11 libraries   : xcursor xdbe xinerama xinput2 xinput2_multitouch xrandr xscrnsaver xshape xvidmode
                            Input drivers   : linuxev linuxkd
                            Enable virtual joystick APIs : YES
                            Using libsamplerate : YES
                            Using libudev       : YES
                            Using dbus          : YES
                            Using ime           : YES
                            Using ibus          : YES
                            Using fcitx         : YES
                            

                            When Raspberry Pi starts EmulationStation crashes on Creating window... log. Maybe I break something, any idea? This happens both with dtoverlay=vc4-fkms-v3d and dtoverlay=vc4-kms-v3d

                            P.S.: Building without --enable-video-kmsdrm option bring me to console with error related on creation of OpenGL window

                            mituM 1 Reply Last reply Reply Quote 0
                            • mituM
                              mitu Global Moderator @FranceMSR
                              last edited by

                              Try to disable the rpi video driver when configuring SDL2.

                              F 1 Reply Last reply Reply Quote 0
                              • F
                                FranceMSR @mitu
                                last edited by FranceMSR

                                @mitu Built SDL 2.0.14 with

                                --disable-video-rpi --enable-video-kmsdrm
                                

                                The FPS problem still exists with 5.4 kernel, or newer one after full SO upgrade (in this case with fkms or kms), and in this way when emulator is closed EmulationStation is frozen.

                                Anyway I found a solution, if VERTICAL SYNC is enabled also on emulator (I added a command line parameter for this) also Raspberry Pi v4 version is ok.

                                If you don't have any other idea I'll stop the investigation, I don't love VSYNC because if a user has a 50 Hz monitor all games with nominal 60 FPS framerate runs at 50 FPS.

                                Really appreciate your help

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post

                                Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.