• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
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

Low framerate on main EmulationStation menu - Pi 4

Scheduled Pinned Locked Moved Help and Support
pi 4estationperformance
136 Posts 16 Posters 28.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.
  • B
    BuZz administrators
    last edited by BuZz 18 Aug 2020, 03:52

    It's primarily a driver/firmware issue or maybe an overlapping issue with SDL2 as the sdl2 Kms driver has some issues. I thought I got some improvements disabling the WSOD / dynamic gpu texture loading code (which does have one bug, in that 0 should be unlimited but isn't). But I'm actually looking into that currently as well as SDL2 due to upstream changes.

    Our sdl2 includes the old driver, but isn't used for ES on the rpi4. As GL contexts don't work on the RPI4 on dispmanx, there wouldn't have been any display at all. They co-exist together in our SDL though.

    Primarily for rpi3 etc. Our sdl2 will work in both old videocore via dispmanx or via kms on a rpi3.

    Newest Mesa doesn't fix the slowdown btw. Before people said switching to the Kms driver sorted it. I can't remember but I'll retest.

    To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

    B 1 Reply Last reply 19 Aug 2020, 05:44 Reply Quote 0
    • B
      bluestang @BuZz
      last edited by 19 Aug 2020, 05:44

      First off I'm sorry for bombarding your PRs with my nonsense. RA made it possible to use the developmental Vulkan driver post v1.8.8 and I was excited to try it out. Just in what I've been able to mess around with, it seems to provide a few improvements.

      @BuZz said in Low framerate on main EmulationStation menu - Pi 4:

      It's primarily a driver/firmware issue or maybe an overlapping issue with SDL2 as the sdl2 Kms driver has some issues. I thought I got some improvements disabling the WSOD / dynamic gpu texture loading code (which does have one bug, in that 0 should be unlimited but isn't). But I'm actually looking into that currently as well as SDL2 due to upstream changes.

      Lowering the resolution to 720p does not exhibit the framerate drop but that is not the ideal solution. Would compiling the latest release of SDL2 with the neon optimizations help?

      Our sdl2 includes the old driver, but isn't used for ES on the rpi4. As GL contexts don't work on the RPI4 on dispmanx, there wouldn't have been any display at all. They co-exist together in our SDL though.

      Primarily for rpi3 etc. Our sdl2 will work in both old videocore via dispmanx or via kms on a rpi3.

      Although the Pi 3 and Pi 4 share the same driver names, which probably leads to more confusion for everyone, they do not follow the same rules when it comes to 3D and video composition.

      Newest Mesa doesn't fix the slowdown btw. Before people said switching to the Kms driver sorted it. I can't remember but I'll retest.

      I can confirm that when KMS was first exposed in the 5.4 kernel it did fix the issue but that was many moons ago. An update at some point led to the regression, but that may have just been luck as the KMS driver was missing functionality and still does.

      S 1 Reply Last reply 20 Aug 2020, 15:12 Reply Quote 0
      • S
        Swampy @bluestang
        last edited by 20 Aug 2020, 15:12

        @bluestang said in Low framerate on main EmulationStation menu - Pi 4:

        I can confirm that when KMS was first exposed in the 5.4 kernel it did fix the issue but that was many moons ago. An update at some point led to the regression, but that may have just been luck as the KMS driver was missing functionality and still does.

        I have had the same experience.

        Linux is like wigwam: no Gates, no Windows and Apache inside.

        1 Reply Last reply Reply Quote 0
        • B
          bluestang
          last edited by 20 Aug 2020, 15:33

          I couldn’t find this issue at first but I did remember reading at some point. Seems relevant to the issues described in this thread.

          https://github.com/raspberrypi/firmware/issues/1154#issuecomment-544428380

          1 Reply Last reply Reply Quote 0
          • G
            GreenHawk84
            last edited by 20 Aug 2020, 15:51

            I am glad there is interest in this, thanks for the updates !

            1 Reply Last reply Reply Quote 0
            • B
              bluestang
              last edited by bluestang 23 Aug 2020, 15:39

              Can anyone with a Pi 3 assist with some info?

              With EmulationStation running, can you open an SSH session and run the following cmds and post the results?

              1. cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
              2. vcgencmd measure_clock v3d
              3. vcgencmd dispmanx_list
              4. tvservice -s

              Appreciate the help.

              M S 2 Replies Last reply 23 Aug 2020, 16:21 Reply Quote 0
              • M
                mitu Global Moderator @bluestang
                last edited by 23 Aug 2020, 16:21

                @bluestang said in Low framerate on main EmulationStation menu - Pi 4:

                cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
                output:

                ondemand
                ondemand
                ondemand
                ondemand
                

                vcgencmd measure_clock v3d
                output:

                frequency(43)=300000000
                

                vcgencmd dispmanx_list
                output:

                display:2 format:RGB565 transform:0 layer:-127 1920x1080 src:0,0,1920,1080 dst:0,0,1920,1080 cost:889 lbm:0
                display:2 format:RGBA32 transform:20000 layer:0 1920x1080 src:0,0,1920,1080 dst:0,0,1920,1080 cost:1156 lbm:0
                display:2 format:UNKNOWN transform:20000 layer:10000 0x0 src:0,0,1920,1080 dst:0,0,1920,1080 cost:0 lbm:0
                display:2 format:UNKNOWN transform:20000 layer:10000 0x0 src:0,0,1920,1080 dst:0,0,1920,1080 cost:0 lbm:0
                display:2 format:UNKNOWN transform:20000 layer:10000 0x0 src:0,0,1920,1080 dst:0,0,1920,1080 cost:0 lbm:0
                

                tvservice -s
                output:

                state 0xa [HDMI CEA (16) RGB lim 16:9], 1920x1080 @ 60.00Hz, progressive
                
                1 Reply Last reply Reply Quote 0
                • S
                  stoo @bluestang
                  last edited by 23 Aug 2020, 17:02

                  @bluestang

                  cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

                  ondemand
                  ondemand
                  ondemand
                  ondemand
                  

                  vcgencmd measure_clock v3d

                  frequency(43)=250000000
                  

                  vcgencmd dispmanx_list

                  display:2 format:XRGB8888 transform:0 layer:-127 src:0,0,1920,1080 dst:0,0,1920,1080 cost:1156 lbm:0
                  display:2 format:UNKNOWN transform:20000 layer:10000 src:0,0,1920,1080 dst:0,0,1920,1080 cost:0 lbm:0
                  display:2 format:RGBA32 transform:20000 layer:10000 src:0,0,1920,1080 dst:0,0,1920,1080 cost:1156 lbm:0
                  

                  tvservice -s

                  state 0x12000a [HDMI CEA (16) RGB lim 16:9], 1920x1080 @ 60.00Hz, progressive
                  
                  1 Reply Last reply Reply Quote 0
                  • B
                    bluestang
                    last edited by 23 Aug 2020, 19:40

                    Thanks @mitu and @stoo!

                    Well looks like the 30 FPS issue for Pi 4s is related to the clock speed of v3d aka the GPU. The framerate drop is easily reproducible on the larger theme sets. (i.e. Cosmic Rise)

                    During video playback, a stock Pi 4's GPU clock speed will scale to 500 Mhz. On my Pi 4, I have a custom splash screen that plays prior to loading the ES main menu. During that video playback, the frequency reported is 500 Mhz. The GPU can technically be clocked higher with specific command line overclocks but for clarity lets eliminate overclocked use cases.

                    Whatever is telling the scaling governor to downclock the GPU is the cause of the 30 fps issue for Pi 4s. If I go to one of my collection menus where I also have video snaps played back, the GPU will scale its frequency to 500 Mhz, and I do not ever see the 30 FPS issue within those menus. It is only in the Main Menu in my case and I can induce the fps drop by invoking the screensaver where the GPU begins to downclock down to 300 Mhz or lower.

                    This also makes perfect sense that the issue "goes away" if you play a game and come back to the menu...its safe to say that is because the GPU stays scaled to 500 Mhz until the scaling governor downclocks the GPU.

                    I put v3d_freq_min=500 in /boot/config.txt and that has solved the issue for me. My SoC temp stays around 43/44* C and I'm using the Canakit case with a fan.

                    You could also change the scaling_governor to performance as well, but that will also keep the arm frequency to the max clock speed as well.

                    S 1 Reply Last reply 23 Aug 2020, 20:13 Reply Quote 1
                    • S
                      stoo @bluestang
                      last edited by 23 Aug 2020, 20:13

                      @bluestang I'll check your fix out soon.

                      I have no idea about the Pi4 arch, but in my completely ignorant opinion, this sounds like a firmware problem.

                      B 1 Reply Last reply 23 Aug 2020, 20:21 Reply Quote 0
                      • B
                        bluestang @stoo
                        last edited by 23 Aug 2020, 20:21

                        @stoo Yea this could be an issue with how the kernel handles the scaling_governor on the ondemand setting. In fairness though, this could be expected behavior on this setting but I just asked the question on the official forums in the 5.4 Kernel thread.

                        In RetroPie's use case, it would make sense to scale the GPU to its highest allowable setting but that might not be the desired effect for users outside of RetroPie.

                        S D 2 Replies Last reply 23 Aug 2020, 21:01 Reply Quote 0
                        • S
                          stoo @bluestang
                          last edited by stoo 23 Aug 2020, 21:01

                          @bluestang How does it differ from the Pi3? How much does the Pi3 scale the GPU while ES is running?

                          The reason I ask is that while forcing the GPU to remain at 500MHz does indeed make ES much smoother on the Pi4, I can't help wondering whether we're just masking a deeper performance issue with ES...

                          ...or a deeper performance issue somewhere else in the Pi4.

                          B 1 Reply Last reply 23 Aug 2020, 21:34 Reply Quote 0
                          • D
                            dankcushions Global Moderator @bluestang
                            last edited by 23 Aug 2020, 21:02

                            @bluestang said in Low framerate on main EmulationStation menu - Pi 4:

                            In RetroPie's use case, it would make sense to scale the GPU to its highest allowable setting but that might not be the desired effect for users outside of RetroPie.

                            i don't agree. my retropie box spends 99% of it's uptime idling in ES, so I don't want it maxed out at CPU/GPU frequencies when it doesn't need them - that's just wasting power. for portable users on batteries, it's even more important.

                            if the issue is confirmed i guess it's a bug with the governor not correctly evaluating the GPU demand.

                            B 1 Reply Last reply 23 Aug 2020, 21:42 Reply Quote 1
                            • B
                              bluestang @stoo
                              last edited by 23 Aug 2020, 21:34

                              @stoo said in Low framerate on main EmulationStation menu - Pi 4:

                              @bluestang How does it differ from the Pi3? How much does the Pi3 scale the GPU while ES is running?

                              The reason I ask is that while forcing the GPU to remain at 500MHz does indeed make ES much smoother on the Pi4, I can't help wondering whether we're just masking a deeper performance issue with ES.

                              Now you are talking about hardware differences between the Pi 3 and Pi 4. There are a lot of variables involved so it's hard to even begin to go down this road.

                              The Pi 4 is taking a more standard approach to Linux when it comes to software development. What worked on the Pi 0-3 may not work on the Pi 4.

                              1 Reply Last reply Reply Quote 0
                              • S
                                stoo
                                last edited by stoo 23 Aug 2020, 21:39

                                Also, the reason that this issue is so noticable on the Pi4 seems to be a difference in the way they handle framerate drops, compared to the Pi3.

                                On the Pi3 (at least, on my Pi3) if you open the "Start" menu in ES (the Main Menu with Scraper etc.), the framerate will drop to around 50fps. This menu seems to have a fairly heavy performance impact.

                                On the Pi4, opening this menu (and you may have to go into a System and look at a game list to make this happen) causes the framerate to drop to 30fps.

                                In other words:

                                Pi3, when losing v-sync, will drop to whatever framerate it can manage.

                                Pi4, when losing v-sync, will drop to half the refresh-rate.

                                B 1 Reply Last reply 23 Aug 2020, 22:03 Reply Quote 0
                                • B
                                  bluestang @dankcushions
                                  last edited by bluestang 23 Aug 2020, 21:42

                                  @dankcushions said in Low framerate on main EmulationStation menu - Pi 4:

                                  @bluestang said in Low framerate on main EmulationStation menu - Pi 4:

                                  In RetroPie's use case, it would make sense to scale the GPU to its highest allowable setting but that might not be the desired effect for users outside of RetroPie.

                                  i don't agree. my retropie box spends 99% of it's uptime idling in ES, so I don't want it maxed out at CPU/GPU frequencies when it doesn't need them - that's just wasting power. for portable users on batteries, it's even more important.

                                  if the issue is confirmed i guess it's a bug with the governor not correctly evaluating the GPU demand.

                                  And this is the exact reason why I think the ondemand setting may be operating as advertised. No point in wasting cpu/gpu cycles for "low demand" apps.

                                  Without any answers as to why this setting is causing this issue I can speculate all day long but no need to waste anyone's time with that.

                                  1 Reply Last reply Reply Quote 0
                                  • B
                                    bluestang @stoo
                                    last edited by bluestang 23 Aug 2020, 22:03

                                    @stoo I am aware of this too. This is good info for future reference.

                                    @stoo said in Low framerate on main EmulationStation menu - Pi 4:

                                    Also, the reason that this issue is so noticable on the Pi4 seems to be a difference in the way they handle framerate drops, compared to the Pi3.

                                    On the Pi3 (at least, on my Pi3) if you open the "Start" menu in ES (the Main Menu with Scraper etc.), the framerate will drop to around 50fps. This menu seems to have a fairly heavy performance impact.

                                    On the Pi4, opening this menu (and you may have to go into a System and look at a game list to make this happen) causes the framerate to drop to 30fps.

                                    In other words:

                                    Pi3, when losing v-sync, will drop to whatever framerate it can manage.

                                    Pi4, when losing v-sync, will drop to half the refresh-rate.

                                    1 Reply Last reply Reply Quote 0
                                    • F
                                      FrancesKelsey
                                      last edited by 24 Aug 2020, 13:12

                                      you need to change some keys before launching

                                      1 Reply Last reply Reply Quote 0
                                      • B
                                        bluestang
                                        last edited by bluestang 27 Aug 2020, 13:19

                                        The ondemand setting ramps the frequency of the gpu to its default/overlocked setting and then will downclock the gpu when not in use.

                                        It appears that the EmulationStation OpenGL/ES calls do not trigger the gpu to ramp up its frequency therefore the gpu stays downclocked and renders 30 fps when downclocked. If it did, then the gpu would be constantly be at the 500 Mhz default setting. Just as it does for video snap playbacks, and even then after the gpu is no longer being used for video playback the kernel downclocks the gpu again. Or if you play a game from an emulator, the gpu clock rate may temporarily stay at its setting but will eventually downclock.

                                        So there are several options, one of them was already posted earlier as to what can be done to fix this. I'm not sure opening an issue with the RPi team will fix this since the kernel seems to be behaving as expected in the ondemand setting.

                                        The issue for me is trivial and fixable by the setting the v3d minimum frequency. My temps did not increase, in fact the only time when my temps increase to eye popping levels is during code compiles rather than the emulators I normally play.

                                        D S 2 Replies Last reply 27 Aug 2020, 14:38 Reply Quote 1
                                        • D
                                          dankcushions Global Moderator @bluestang
                                          last edited by 27 Aug 2020, 14:38

                                          @bluestang said in Low framerate on main EmulationStation menu - Pi 4:

                                          So there are several options, one of them was already posted earlier as to what can be done to fix this. I'm not sure opening an issue with the RPi team will fix this since the kernel seems to be behaving as expected in the ondemand setting.

                                          i'm not sure i understand this - emulationstation is rendering via the GPU so if it's dropping down to 30fps that implies to me that the demand is not being correctly identified, however i'm not sure how it detects GPU load/demand. i wonder if it's the same using the GLES2 version of ES? https://github.com/RetroPie/EmulationStation/commit/55df3d833235976585d549d0a0548244ab838ebf

                                          in any case, to report it to the firmware we'd need to create a simple example program.

                                          B 1 Reply Last reply 27 Aug 2020, 15:00 Reply Quote 0
                                          104 out of 136
                                          • First post
                                            104/136
                                            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.

                                            This community forum collects and processes your personal information.
                                            consent.not_received