v3dv: quick guide to build and run some demos

Just today it has published a status update of the Vulkan effort for the Raspberry Pi 4, including that we are moving the development of the driver to an open repository. As it is really likely that some people would be interested on testing it, even if it is not complete at all, here you can find a quick guide to compile it, and get some demos running.

Dependencies

So let’s start installing some dependencies. My personal recipe, that I use every time I configure a new machine to work on mesa is the following one (sorry if some extra unneeded dependencies slipped):

sudo apt-get install libxcb-randr0-dev libxrandr-dev \
        libxcb-xinerama0-dev libxinerama-dev libxcursor-dev \
        libxcb-cursor-dev libxkbcommon-dev xutils-dev \
        xutils-dev libpthread-stubs0-dev libpciaccess-dev \
        libffi-dev x11proto-xext-dev libxcb1-dev libxcb-*dev \
        bison flex libssl-dev libgnutls28-dev x11proto-dri2-dev \
        x11proto-dri3-dev libx11-dev libxcb-glx0-dev \
        libx11-xcb-dev libxext-dev libxdamage-dev libxfixes-dev \
        libva-dev x11proto-randr-dev x11proto-present-dev \
        libclc-dev libelf-dev git build-essential mesa-utils \
        libvulkan-dev ninja-build libvulkan1 python-mako \
        libdrm-dev libxshmfence-dev libxxf86vm-dev \
        python3-mako

Most Raspian libraries are recent enough, but they have been updating some of then during the past months, so just in case, don’t forget to update:

$ sudo apt-get update
$ sudo apt-get upgrade

Additionally, you woud need to install meson. Mesa has just recently bumped up the version needed for meson, so Raspbian version is not enough. There is the option to build meson from the tarball (meson-0.52.0 here), but by far, the easier way to get a recent meson version is using pip3:

$ pip3 install meson

2020-07-04 update

It seems that some people had problems if they have installed meson with apt-get on their system, as when building it would try the older meson version first. For those people, they were able to fix that doing this:

$ sudo apt-get remove meson
$ pip3 install --user meson

Download and build v3dv

This is the simpler recipe to build v3dv:

$ git clone https://gitlab.freedesktop.org/apinheiro/mesa.git mesa
$ cd mesa
$ git checkout wip/igalia/v3dv
$ meson --prefix /home/pi/local-install --libdir lib -Dplatforms=x11,drm -Dvulkan-drivers=broadcom -Ddri-drivers= -Dgallium-drivers=v3d,kmsro,vc4 -Dbuildtype=debug _build
$ ninja -C _build
$ ninja -C _build install

This builds and install a debug version of v3dv on a local directory. You could set a release build, or any other directory. The recipe is also building the OpenGL driver, just in case anyone want to compare, but if you are only interested on the vulkan driver, that is not mandatory.

Run some Vulkan demos

Now, the easiest way to ensure that a vulkan program founds the drivers is setting the following envvar:

export VK_ICD_FILENAMES=/home/pi/local-install/share/vulkan/icd.d/broadcom_icd.armv7l.json

That envvar is used by the Vulkan loader (installed as one of the dependencies listed before) to know which library load. This also means that you don’t need to use LD_PRELOAD, LD_LIBRARY_PATH or similar

So what Vulkan programs are working? For example several of the Sascha Willem Vulkan demos. To make things easier to everybody, here another quick recipe of how to get them build:

$ sudo apt-get install libassimp-dev
$ git clone --recursive https://github.com/SaschaWillems/Vulkan.git  sascha-willems
$ cd sascha-willems
$ mkdir build; cd build
$ cmake -DCMAKE_BUILD_TYPE=Debug  ..
$ make
$ cd bin
$ ./gears

If everything went well, doing that would get this familiar image:

If you want to a somewhat more eye candy demo, you would need to download some assets. So:

$ cd ../..
$ python3 download_assets.py
$ cd build/bin
$./scenerendering

As mentioned, not all the demos works. But a list of some that we tested and seem to work:
* distancefieldfonts
* descriptorsets
* dynamicuniformbuffer
* gears
* gltfscene
* imgui
* indirectdraw
* occlusionquery
* parallaxmapping
* pbrbasic
* pbribl
* pbrtexture
* pushconstants
* scenerendering
* shadowmapping
* shadowmappingcascade
* specializationconstants
* sphericalenvmapping
* stencilbuffer
* textoverlay
* texture
* texture3d
* texturecubemap
* triangle
* vulkanscene

Update : rpiMike on the comments, and some people privately, have pointed some errors on the post. Thanks! And sorry for the inconvenience.

Update 2 : Mike Hooper pointed more issues on gitlab

29 thoughts on “v3dv: quick guide to build and run some demos”

  1. Changed 1st clone to:
    git clone https://gitlab.freedesktop.org/apinheiro/mesa.git mesa

    Changed meson install to, so ‘meson’ worked:
    sudo pip3 install meson

    Now getting:
    meson –prefix /home/pi/local-install –libdir lib -Dplatforms=x11,drm -Dvulkan-drivers=broadcom -Ddri-drivers= -Dgallium-drivers=v3d,kmsro,vc4 -Dbuildtype=debug _build
    The Meson build system
    Version: 0.54.2
    Source dir: /home/pi/mesa
    Build dir: /home/pi/mesa/_build
    Build type: native build
    Program python found: YES (/usr/bin/python)

    meson.build:21:0: ERROR: Options “broadcom” are not in allowed choices: “, auto, amd, intel”

    A full log can be found at /home/pi/mesa/_build/meson-logs/meson-log.txt

    1. Yes, once you get the proper repository cloned, you need to move to the correct branch:
      $ git branch wip/igalia/v3dv

      I have just updated the post. Thanks for reporting, and sorry for the inconvenience.

  2. was interested in trying this on archlinux in my case I tried on manjaro 64bit and I got an error while compiling.

    https://www.pastiebin.com/5ee3c5f20b6bd

    it was pretty far along (977 of 1155 or something)
    hopefully it just means I cloned the git at a bad time?

    hoping to test dolphin emu under vulkan vs gles and compare πŸ™‚

    1. > hopefully it just means I cloned the git at a bad time?

      As I just explained to other developer testing 64bit, for now we are focusing on 32-bit. We would revisit that as the driver gets more mature.

      Having said so, note that the build is failing on gallium utilities that the vulkan driver is using, and not exactly on the main source code of the driver. So I suspect that perhaps you would need some extra options when calling meson.

      > hoping to test dolphin emu under vulkan vs gles and compare

      We have advanced a lot on the past months, but the driver is still on the early stages. In fact I have just skimmed the dolphin code here:

      https://github.com/dolphin-emu/dolphin.git dolphin-emu

      and it uses Vulkan features like compute shaders and texel buffers that v3dv still doesn’t support. So sorry, but such comparison is still not possible.

  3. Hello, thanks for your work!
    Following your instructions, I was able to successfully run everything on OS 32bit.
    In OS 64bit Beta almost everything worked (only one file in share/vulkan/icd.d that generated as aarch64.json instead of armv7l.json), but when trying to run the demos it raises an error VkResult is “ERROR_INITIALIZATION_FAILED” (res == VK_SUCCESS failed) .

    1. Hi, thanks for testing on both 32 and 64 bit. Unfourtunately, the failure on 64 bit is expected. Right now we are focused on getting the vulkan driver working on the 32-bit Raspbian first. We didn’t even start to test on the 64bit Beta. When we got a conformant, or almost 1.0 conformant driver working on 32-bit, we would need to evaluate the priorities about the next thing to work on (there are plenty of options, 64-bit support, work on performance, 1.1, etc)

  4. Git branch doesn’t switch to a branch unless creating a new one. If anybody have problems with switching to a proper branch try typing:
    git switch wip/igalia/v3dv

    1. I just noticed that git that is on my system is a lot more recent that the one available in buster Raspberry Pi OS repository. I discovered that when I tried to build the driver under a fresh install of 32-bit Raspberry Pi OS Lite. “git switch” is available since git 2.23, and the one in the repo at the time of writing is 2.20.1. So if you want to switch to a branch you should type:
      git checkout wip/igalia/v3dv
      When typing “git branch wip/igalia/v3dv” you will create a new local branch and not change the branch to the branch that resides on remote origin, which is what you want.
      Sorry if I confused anybody with my initial comment as this worked because I was at testing suite of RPi repo

  5. Also you may also need to run this as they are dependencies that may not be on your system:
    pip3 install meso
    apt install libxshmfence-dev

  6. Dear Raspberry Pi Team,
    This is wonderful! Please keep up the good work.

    A few comments:

    1) I also had to use
    git clone –single-branch –branch wip/igalia/v3dv https://gitlab.freedesktop.org/apinheiro/mesa.git
    as gaara suggested above. The method in post did not work.

    2) I had to install a few other development packages:
    python3-mako, libdrm-dev, libxshmfence-dev, libxxf86vm-dev, libassimp-dev, and cmake, of course.
    There were a few others, but I cannot remember if they were for something I am writing or just for purposes of this guide.

    Otherwise, beautiful – indeed many Willems tests run.

      1. Note that the people that suggested that option is writing that with double ‘-‘, so:

        $git clone –-single-branch –-branch wip/igalia/v3dv https://gitlab.freedesktop.org/apinheiro/mesa.git

        Having said so, since people pointed me out that my initial recipe has some errors (sorry and thanks!), I have updated the recipe, so C&P from the current state of the post:

        $ git clone https://gitlab.freedesktop.org/apinheiro/mesa.git mesa
        $ cd mesa
        $ git checkout wip/igalia/v3dv

        1. Still not working. πŸ™

          pi@raspberrypi:~/mesa $ meson –prefix /home/pi/local-install –libdir lib -Dplatforms=x11,drm -Dvulkan-drivers=broadcom -Ddri-drivers= -Dgallium-drivers=v3d,kmsro,vc4 -Dbuildtype=debug _build
          The Meson build system
          Version: 0.54.3
          Source dir: /home/pi/mesa
          Build dir: /home/pi/mesa/_build
          Build type: native build
          Program python found: YES (/usr/bin/python)
          Project name: mesa
          Project version: 20.2.0-devel
          C compiler for the host machine: cc (gcc 8.3.0 “cc (Raspbian 8.3.0-6+rpi1) 8.3.0”)
          C linker for the host machine: cc ld.bfd 2.31.1
          C++ compiler for the host machine: c++ (gcc 8.3.0 “c++ (Raspbian 8.3.0-6+rpi1) 8.3.0”)
          C++ linker for the host machine: c++ ld.bfd 2.31.1
          Host machine cpu family: arm
          Host machine cpu: armv7l
          Program python3 found: YES (/usr/bin/python3)

          meson.build:877:2: ERROR: Problem encountered: Python (3.x) mako module >= 0.8.0 required to build mesa.

          A full log can be found at /home/pi/mesa/_build/meson-logs/meson-log.txt

          1. Try to install python3-mako :
            $ sudo apt-get install python3-mako

            Some people before pointed that package is also needed. I have just updated the recipe.

        2. After $ sudo apt-get install python3-mako things worked fine, but when I closed the terminal and tried to run demos later, this error appeared:

          Could not create Vulkan instance :
          ERROR_EXTENSION_NOT_PRESENT

          1. When you opened a new terminal to run the demos, did you remember to export the envvar with the location of the ICD?:

            export VK_ICD_FILENAMES=/home/pi/local-install/share/vulkan/icd.d/broadcom_icd.armv7l.json

  7. Thanks Raspberry Pi Team for this amazing work!

    I sucessfully installed the Vulkan drivers and run most examples. I’m wondering if readless operation will be supported in the future? The `renderheadless` example did not work without a X11 server.

    1. Thanks for the feedback. That is a interesting comment, as I assumed that the renderheadless demo just worked. Didn’t realize that it needed a X11 server. Having said so, we are still missing several 1.0 core features. Our main focus right now is getting Vulkan 1.0 core supported (so getting vk-gl-cts for 1.0 passing). I hope that to be enough to get that test working without X11 server.

  8. I have this issue πŸ™

    meson –prefix /home/pi/local-install –libdir lib -Dplatforms=x11,drm -Dvulkan-drivers=broadcom -Ddri-drivers= -Dgallium-drivers=v3d,kmsro,vc4 -Dbuildtype=debug _build
    The Meson build system
    Version: 0.49.2
    Source dir: /home/pi/src/mesa
    Build dir: /home/pi/src/mesa/_build
    Build type: native build
    Program python found: YES (/usr/bin/python)

    meson.build:21:0: ERROR: Meson version is 0.49.2 but project requires >= 0.52.

    Machine infos: Raspberrypi 4 4GB Ram

    uname -a
    Linux raspberrypi 5.4.47-v7l+ #1322 SMP Wed Jun 17 17:58:52 BST 2020 armv7l GNU/Linux

    cat /etc/os-release
    PRETTY_NAME=”Raspbian GNU/Linux 10 (buster)”
    NAME=”Raspbian GNU/Linux”
    VERSION_ID=”10″
    VERSION=”10 (buster)”
    VERSION_CODENAME=buster
    ID=raspbian
    ID_LIKE=debian
    HOME_URL=”http://www.raspbian.org/”
    SUPPORT_URL=”http://www.raspbian.org/RaspbianForums”
    BUG_REPORT_URL=”http://www.raspbian.org/RaspbianBugs”

    1. “meson.build:21:0: ERROR: Meson version is 0.49.2 but project requires >= 0.52.”

      Please re-read the guide. It clearly points that Mesa recently bumped meson requirement, and that you need to install a newer version of meson.

      1. you true i forgot to mention

        sudo pip3 install meson
        Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
        Requirement already satisfied: meson in /usr/lib/python3/dist-packages (0.49.2)

        i download the meson last sources and

        python3 -m pip install meson
        Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
        Requirement already satisfied: meson in /home/pi/meson-0.52.0 (0.52.0)

        after :
        meson –prefix /home/pi/local-install –libdir lib -Dplatforms=x11,drm -Dvulkan-drivers=broadcom -Ddri-drivers= -Dgallium-drivers=v3d,kmsro,vc4 -Dbuildtype=debug _build
        The Meson build system
        Version: 0.49.2
        Source dir: /home/pi/src/mesa
        Build dir: /home/pi/src/mesa/_build
        Build type: native build
        Program python found: YES (/usr/bin/python)

        meson.build:21:0: ERROR: Meson version is 0.49.2 but project requires >= 0.52.

        A full log can be found at /home/pi/src/mesa/_build/meson-logs/meson-log.txt

        dho!!

        1. FIXED!
          please add this in your guide for other ppl πŸ™‚

          first is need to
          sudo apt remove meson

          after is need to

          pip3 install –user meson
          Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
          Collecting meson
          Downloading https://www.piwheels.org/simple/meson/meson-0.54.3-py3-none-any.whl (643kB)
          100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 645kB 658kB/s
          Installing collected packages: meson
          Successfully installed meson-0.54.3

          tadaaaaa

          meson –version
          0.54.3

          1. > please add this in your guide for other ppl

            Just added a note. Thanks for the feedback.

Leave a Reply

Your email address will not be published. Required fields are marked *