{"id":423,"date":"2020-08-31T23:20:09","date_gmt":"2020-09-01T04:20:09","guid":{"rendered":"https:\/\/www.jasonsblog.place\/?p=423"},"modified":"2020-09-02T22:42:26","modified_gmt":"2020-09-03T03:42:26","slug":"trying-to-run-the-godot-engines-vulkan-implementation-on-the-raspberry-pi-4","status":"publish","type":"post","link":"https:\/\/www.jasonsblog.place\/index.php\/2020\/08\/31\/trying-to-run-the-godot-engines-vulkan-implementation-on-the-raspberry-pi-4\/","title":{"rendered":"Trying to Run the Godot Engine&#8217;s Vulkan Implementation on the Raspberry Pi 4"},"content":{"rendered":"\n<p>This may sound nuts, but I tried running the unstable version of the Godot engine (the 4.0 version with the Vulkan renderer) on the Raspberry Pi 4. Why on god&#8217;s green earth would I do that? For one, the <a href=\"https:\/\/www.raspberrypi.org\/blog\/vulkan-update-now-with-added-source-code\/\">Vulkan driver for the Raspberry Pi<\/a> is improving. For another, the Vulkan renderer for the Godot engine is improving, too. How did I do it? What problems did I overcome? was it all worth it? The answers to those questions lies in the next few paragraphs.<\/p>\n\n\n\n<p>To build this monster, I had to first get the Vulkan drivers for the Raspberry Pi. That was fairly easy. Then I had to get a Raspberry Pi that has enough power to actually run a gaming engine. Enter the Raspberry Pi 4 with 8GBs of RAM. This monster looks like it has <em>just <\/em>enough juice to run some of the lower capabilities of the Godot engine. I added a tiny external SSD to this thing, installed Raspberry Pi OS, and I was off to build drivers.<\/p>\n\n\n\n<p>After downloading the Vulkan drivers for the Raspberry Pi, I used the instructions from <a href=\"https:\/\/blogs.igalia.com\/apinheiro\/2020\/06\/v3dv-quick-guide-to-build-and-run-some-demos\/\">this site<\/a> to build them. In the instructions for the drivers, I had to use a more up-to-date version of meson just to build them. I used pip3 to install meson, and used the local version (local to the &#8220;pi&#8221; user, anyway). The following commands were used to build and install the drivers:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">meson --prefix \/home\/pi\/local-install --libdir lib -Dplatforms=x11,drm -Dvulkan-drivers=broadcom -Ddri-drivers= -Dgallium-drivers=v3d,kmsro,vc4 -Dbuildtype=debug _build\nninja -C _build\nninja -C _build install<\/pre>\n\n\n\n<p>With those built, I then built the <a href=\"https:\/\/github.com\/SaschaWillems\/Vulkan\">examples written by Sascha Willems<\/a>. These were used to see how well the Raspberry Pi 4 could perform. They performed surprisingly well, showing demos which could hold at least 30 FPS (though the demo with special lighting ran poorly). Next I tried my hand at building the engine on the Raspberry Pi 4.<\/p>\n\n\n\n<p>I had a bit of a problem with <code>scons<\/code> being out of date, too. So I had to install a newer version of that with <code>pip3<\/code>, too. Then I git cloned the latest version of the engine, and tried building an export template. The following command was used to build it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">scons -j 4 CCFLAGS=\"-I\/home\/pi\/local-install\/include\/\" LDFLAGS=\"-lvorbis\"  tools=no platform=linuxbsd udev=yes use_llvm=yes module_webm_enabled=no target=release_debug<\/pre>\n\n\n\n<p>The part about <code>module_webm_enabled=no<\/code> had to be used because, in the past, I tried building the engine on the Raspberry Pi only to see it fail because it was hung up on a &#8220;libvpx&#8221; error. Also, I used <code>llvm<\/code> and <code>clang<\/code> because the installed version of GCC was too old to build the engine. When the code finished building with this command (it took over an hour). I had an export file. While that was all well and good I&#8217;m sure there are users of the Godot engine who would love to use the editor on the Raspberry Pi. From what I found (when building the editor) it doesn&#8217;t look like that&#8217;s going to happen any time soon.<\/p>\n\n\n\n<p>The editor took a while to build. I found an error with libvorbis not wanting to link with the final executable. It turns out that the engine couldn&#8217;t find the libraries for libvorbis. So I had to specify that as a linker option when I built the editor. The following command was used to build the engine:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cpu_stuff=\"-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mlittle-endian -munaligned-access\"\nscons $delete -j 4 CCFLAGS=\"$cpu_stuff\" LDLIBS=\"-lstdc++\" LINKFLAGS=\"-lvorbis\" \\\ntools=yes platform=linuxbsd target=release_debug udev=yes use_llvm=yes<\/pre>\n\n\n\n<p>After trying a number of times, this command results in a binary for the engine. While it&#8217;s great that the command resulted in a binary, the performance is left lacking. The editor doesn&#8217;t run, instead giving the error:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">godot.linuxbsd.opt.tools.32.llvm: ..\/src\/broadcom\/vulkan\/v3dv_query.c:34: v3dv_CreateQueryPool: Assertion `pCreateInfo-&gt;queryType == VK_QUERY_TYPE_OCCLUSION' failed.<\/pre>\n\n\n\n<p>It looks like the Vulkan renderer still has a long way to go. Nevertheless, it may one day be possible to build and run the Godot engine on a Raspberry Pi. That&#8217;s why I have thrown together a <a href=\"https:\/\/gist.github.com\/Ertain\/2c28766dd7ebfe551ececb9928c873f3\">script<\/a> which will download, build, and install both the Vulkan drivers and the Godot engine. Note that this script hasn&#8217;t been tested, let programmers beware.<\/p>\n\n\n\n<p>Have fun trying to run gaming engines on low-end hardware!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Can a gaming engine be built and ran on the Raspberry Pi 4? Eh, with the Raspberry Pi vulkan drivers and a new rendering engine, it might.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,31],"tags":[180,91,54,49,178],"class_list":["post-423","post","type-post","status-publish","format-standard","hentry","category-fun","category-video-games","tag-bash","tag-godot-engine","tag-programming-languages","tag-raspberry-pi","tag-vulkan"],"_links":{"self":[{"href":"https:\/\/www.jasonsblog.place\/index.php\/wp-json\/wp\/v2\/posts\/423","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jasonsblog.place\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jasonsblog.place\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jasonsblog.place\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jasonsblog.place\/index.php\/wp-json\/wp\/v2\/comments?post=423"}],"version-history":[{"count":9,"href":"https:\/\/www.jasonsblog.place\/index.php\/wp-json\/wp\/v2\/posts\/423\/revisions"}],"predecessor-version":[{"id":433,"href":"https:\/\/www.jasonsblog.place\/index.php\/wp-json\/wp\/v2\/posts\/423\/revisions\/433"}],"wp:attachment":[{"href":"https:\/\/www.jasonsblog.place\/index.php\/wp-json\/wp\/v2\/media?parent=423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jasonsblog.place\/index.php\/wp-json\/wp\/v2\/categories?post=423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jasonsblog.place\/index.php\/wp-json\/wp\/v2\/tags?post=423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}