RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Add Vulkan Support to RetroPie for Pi 4?

    Scheduled Pinned Locked Moved Ideas and Development
    vulkanpi 4retropie
    97 Posts 13 Posters 23.4k 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.
    • mituM
      mitu Global Moderator @bluestang
      last edited by

      @bluestang said in Add Vulkan Support to RetroPie for Pi 4?:

      However, I applied as best as I could by mangling the setup scripts, the same options for RetroPie but using X11 takes a performance hit.

      How do you measure the performance ?

      As I mentioned earlier, the pure RetroArch build also uses X11 as well but there is no performance hit.

      What do you mean by 'pure RetroArch build' ?

      I can only assume that the performance hit is due to EmulationStation but I know there are some smart people with way more experience than me to figure this out.

      Quite unlikely, EmulationStation does not even run - it's paused - when you start any game/emulator.

      B 2 Replies Last reply Reply Quote 1
      • B
        bluestang @mitu
        last edited by

        @mitu said in [Add Vulkan Support to RetroPie for Pi 4?]

        How do you measure the performance ?

        This is subjective at best but its visibly slower. I encourage anyone that wants to see for themselves to compare for themselves. I created this thread for this discussion exactly to see if anyone was brave enough to try it out and provide some feedback.

        What do you mean by 'pure RetroArch build' ?

        A build of RetroArch without the use of the RetroPie scripts.
        Through my own mangling of the RetroPie setup scripts I built RetroArch with the same configuration. This can be verified with the --features CMD line option.

        Quite unlikely, EmulationStation does not even run - it's paused - when you start any game/emulator.

        As I said, I’m hopeful this thread can serve as a basis for discussion.

        1 Reply Last reply Reply Quote 1
        • B
          bluestang @mitu
          last edited by

          @mitu said in Add Vulkan Support to RetroPie for Pi 4?:

          Update:

          Note to self and double-check driver assignments. If using X11, probably should use X for the input driver too. I had it set to udev and that was causing the slowdown.

          As early as it is, it looks like the Mesa WIP Vulkan driver for the Pi 4 offers comparable performance to the OpenGLES one. Further testing is needed but in my limited sample size, I like what I'm seeing.

          Based on how you develop RA from upstream, I don't see this becoming a part of the RetroPie Setup until the earlies t when 1.9.0 is released if you guys decide to add support for it.

          BuZzB 1 Reply Last reply Reply Quote 1
          • BuZzB
            BuZz administrators @bluestang
            last edited by BuZz

            @bluestang said in Add Vulkan Support to RetroPie for Pi 4?:

            As early as it is, it looks like the Mesa WIP Vulkan driver for the Pi 4 offers comparable performance to the OpenGLES one

            Based on? How are you building against the wip driver? Existing GLSL shader code is working?

            Also we don't run under x11 on the RPI. I'm confused as to what you are suggesting. We are not going to include a WIP driver and build retroarch against it.

            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 3 Replies Last reply Reply Quote 1
            • B
              bluestang @BuZz
              last edited by

              @BuZz said in Add Vulkan Support to RetroPie for Pi 4?:

              Based on? How are you building against the wip driver? Existing GLSL shader code is working?

              Is there a benchmark for RetroPie I can run to show performance metrics?
              The source code for the WIP Vulkan driver was made public last month by the Igalia team. As for shaders, I've done limited testing but the slang shaders seem to work.

              Also we don't run under x11 on the RPI. I'm confused as to what you are suggesting. We are not going to include a WIP driver and build retroarch against it.

              I know, but the Vulkan driver only uses x11 at this current stage. I'm not asking you to package a WIP Vulkan driver, all I'm saying is that it is possible to add support for Vulkan in RetroArch for the Pi 4 - which you currently do not. Anything beyond that is at the discretion of the user.

              BuZzB 1 Reply Last reply Reply Quote 1
              • BuZzB
                BuZz administrators @bluestang
                last edited by BuZz

                @bluestang I'm aware of the progress and code availability. It's just you didnt provide any details as to how you built against the changes, or any tests with emulators that utilise shaders/gl etc.

                If you want to illustrate an improvement you need to provide a lot more information in regards to replicating your findings.

                We are not going to enable vulkan just based on your information so far.

                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 Reply Quote 1
                • B
                  bluestang @BuZz
                  last edited by bluestang

                  @BuZz said in Add Vulkan Support to RetroPie for Pi 4?:

                  @bluestang I'm aware of the progress and code availability. It's just you didnt provide any details as to how you built against the changes, or any tests with emulators that utilise shaders/gl etc.

                  If you want to illustrate an improvement you need to provide a lot more information in regards to replicating your findings.

                  From upstream RetroArch that made Vulkan work - https://github.com/libretro/RetroArch/commit/1fb77c43a365bb1c6d74eccf2e6a4587b4e8c36c

                  I built RetroPie with Vulkan support by just adding the x11 flag to the Pi 4 platform flags in the systems.sh script.

                  I then changed the retroarch.sh to download to the master branch and commented out the 3 patches you have. (this will be no longer needed once you guys align with upstream once they release v1.9.0)

                  I then updated from source to re-compile RetroArch and compiled the Mesa WIP Vulkan driver and that is all that is needed.

                  Also with Vulkan, the glsp shaders are not selectable/visible. However, you can download the Slang shaders and use those but I will admit that I have not really dug into this much at all. I need to understand your patches before I start messing with shaders. I'm just trying to compare apples to apples before I start adding in variables like shaders.

                  We are not going to enable vulkan just based on your information so far.

                  Out of the box, a stock-config Pi 4 supports running from the desktop environment as long as you have a terminal window open. IIRC, it uses EGL and X.

                  It doesn't get any easier than just opening a terminal window and typing emulationstation and hit enter.

                  On a side note, what is the MESA/DRM dependency for? The Pi 4 doesn't seem to use it.

                  BuZzB 1 Reply Last reply Reply Quote 1
                  • BuZzB
                    BuZz administrators
                    last edited by BuZz

                    Our shader config patch will still be needed.

                    I was referring to emulators that use glsl shaders. Eg mupen64plus-next.

                    Mesa-drm module is used for extracting mode info for our sdl2 mode switching. If that's what you're referring to.

                    It might work from the desktop for retroarch, but that's not a supported config on the RPI4.

                    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

                    1 Reply Last reply Reply Quote 1
                    • BuZzB
                      BuZz administrators @bluestang
                      last edited by

                      @bluestang said in Add Vulkan Support to RetroPie for Pi 4?:

                      I then updated from source to re-compile RetroArch and compiled the Mesa WIP Vulkan driver and that is all that is needed

                      This is very vague. Did you build debs, or install to /usr/local or.. if you want any changes considered or for us to test you will need to be more verbose please.

                      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

                      1 Reply Last reply Reply Quote 1
                      • B
                        bluestang @BuZz
                        last edited by

                        @BuZz said in Add Vulkan Support to RetroPie for Pi 4?:

                        Also we don't run under x11 on the RPI. I'm confused as to what you are suggesting. We are not going to include a WIP driver and build retroarch against it.

                        Just out of curiosity, why is x11 not disabled if it is not a supported configuration? Upstream it is left to auto - https://github.com/libretro/RetroArch/blob/master/qb/config.params.sh#L83

                        This is very vague. Did you build debs, or install to /usr/local or.. if you want any changes considered or for us to test you will need to be more verbose please.

                        meson --prefix /usr -Dplatforms=x11,drm -Dvulkan-drivers=broadcom -Ddri-drivers= -Dgallium-drivers=v3d,kmsro,vc4 -Dbuildtype=release build
                        ninja -C build
                        sudo ninja -C build install
                        
                        BuZzB 1 Reply Last reply Reply Quote 1
                        • BuZzB
                          BuZz administrators @bluestang
                          last edited by BuZz

                          @bluestang it was enabled (RPI+Kms only) some time ago in case we needed to use it on a per emulator basis (eg. Due to testing issues outside of X on kms). Originally enabled by another dev but having it enabled doesn't mean we support running on X in general on the RPI. RetroPie isn't just retroarch also.

                          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

                          1 Reply Last reply Reply Quote 1
                          • B
                            bluestang @BuZz
                            last edited by

                            @BuZz said in Add Vulkan Support to RetroPie for Pi 4?:

                            Existing GLSL shader code is working?

                            So the Vulkan driver only sees slang shaders - https://github.com/libretro/slang-shaders (I commented out your existing shader path patch when I compiled RetroArch)

                            I copied the whole repo to the /opt/retropie/confis/all/retroarch/shaders and did not have problems navigating through all the folders that had the *.slangp files and selecting them. Obviously performance will vary on shader complexicity but the crt-pi one works nicely.

                            I also was able to save the shader preset options for game, core, or global and the shaders applied as set. For each type the respective *.slangp file is created.

                            Setting them through the Configuration Editor does not work though. It also appears that both sets of shaders are needed, the glslp ones for the GL driver and slanp for Vulkan.

                            DarksaviorD 1 Reply Last reply Reply Quote 1
                            • DarksaviorD
                              Darksavior @bluestang
                              last edited by

                              @bluestang Last time I checked, the slang version of the crt-pi shader looks nothing like the glsl version, and looks quite ugly.

                              B 2 Replies Last reply Reply Quote 1
                              • B
                                bluestang @Darksavior
                                last edited by

                                @Darksavior I’m sure someone will improve the slang shaders for the pi when the time comes.

                                1 Reply Last reply Reply Quote 1
                                • B
                                  bluestang @Darksavior
                                  last edited by bluestang

                                  @Darksavior I just took a look at the differences between the GLSL vs SLANG pi shaders...

                                  To get the SLANG shader comparable to the GLSL one, you just need to change:

                                  linear_filter0=true in the .slangp file
                                  uncomment #define GAMMA in the .slang file

                                  1 Reply Last reply Reply Quote 3
                                  • B
                                    bluestang
                                    last edited by

                                    @BuZz I haven’t tried your MESA repo in a bit for various extenuating circumstances but the RPi4 Vulkan driver was officially merged upstream today.

                                    It only works on X11, and DRM/KMS support will be added later according to the devs. I believe focus now will be on performance since they implemented 1.0 features with this first release.

                                    I’m sure that the Vulkan driver will makes its way to the Debian maintainers in the near term.

                                    BuZzB 1 Reply Last reply Reply Quote 2
                                    • BuZzB
                                      BuZz administrators @bluestang
                                      last edited by

                                      @bluestang thanks for the info.

                                      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

                                      1 Reply Last reply Reply Quote 1
                                      • B
                                        bluestang
                                        last edited by

                                        @BuZz I made the jump to the 5.9 kernel and KMS video driver for the exact reasons @Brunnis stated.

                                        I modified the sdl2.sh script to install v2.0.12 and I also installed upstream MESA with my own script.

                                        With my MESA script though, I did not have to install libdrm2-.4.102. It installs the needed KMS/V3D/VC4 drivers and dependencies as was provided by the devs that worked the RPi4 Vulkan driver. In addition, I did some digging and I didn't see vc4 changes from 2.4.100 to 2.4.102 in libdrm...for the other Gallium drivers yes, but nothing for the RPi. My RetroPie image is still using libdrm2-4.100 and I'm running the latest of MESA, 5.9 kernel, and sdl2 v2.0.12.

                                        I say all that to say, that your Mesa script could cut down on the dependencies needed if you strictly built the MESA stack for just the RPi drivers. This may be better in the long run since not all the dependencies are needed for the meson builder in upstream MESA. It will also save some space as you only build the Gallium drivers required for RPi - v3d,vc4,kmsro.

                                        I need to try out the latest SDL2 with the atomic stuff but I will get to that at a later date.

                                        BuZzB 1 Reply Last reply Reply Quote 1
                                        • BuZzB
                                          BuZz administrators @bluestang
                                          last edited by BuZz

                                          @bluestang as I have explained before I wanted to minimise my patch set. As this was made for my purposes, I want to build it with everything included as it would be when the Raspbian packages are updated.

                                          I'm not interested in building a minimal Mesa.

                                          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 Reply Quote 1
                                          • B
                                            bluestang @BuZz
                                            last edited by

                                            @buzz @mitu @dankcushions

                                            There was an issue created about a week ago in upstream MESA to get Vulkan running in KMS/DRM. This involved getting the KHR_display extension added to the Pi4 Vulkan code base.

                                            A contributor has done this and I am happy to report that RetroArch now works in KMS/DRM with the Pi4 Vulkan driver. It will be sometime before it gets merged into upstream MESA but it can be tested for now.

                                            I've only tested FBNeo and MAME2K3+ and they work great. I did have to specify 1080p resolution using the retroarch.cfg settings:

                                            video_fullscreen_x = "1920"
                                            video_fullscreen_y = "1080"
                                            

                                            Otherwise, it would default to 4K (my TV) which is a bit too much for the GPU.

                                            I need to recompile 3D emus (i.e. Duckstation) with Vulkan support and do some more testing but I'd figure I'd pass along the news if you want to try it out too.

                                            Some notes about my setup: (4GB Pi4)

                                            • 5.9.3 kernel (32-bit)
                                            • vc4-kms-v3d display driver
                                            • MESA Vulkan build script here - https://pastebin.com/FnwWzbF2
                                            • RetroArch v1.9.0 with Vulkan support enabled
                                            • SDL2 v2.0.12 with Vulkan support enabled
                                            dankcushionsD 1 Reply Last reply Reply Quote 4
                                            • 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.