{"id":1157,"date":"2023-02-20T11:30:28","date_gmt":"2023-02-20T10:30:28","guid":{"rendered":"https:\/\/blogs.igalia.com\/itoral\/?p=1157"},"modified":"2023-02-28T10:38:02","modified_gmt":"2023-02-28T09:38:02","slug":"supertuxkart-vulkan-vs-opengl-and-zink-status-on-raspberry-pi-4","status":"publish","type":"post","link":"https:\/\/blogs.igalia.com\/itoral\/2023\/02\/20\/supertuxkart-vulkan-vs-opengl-and-zink-status-on-raspberry-pi-4\/","title":{"rendered":"SuperTuxKart Vulkan vs OpenGL and Zink status on Raspberry Pi 4"},"content":{"rendered":"<p><b>SuperTuxKart Vulkan vs OpenGL<\/b><\/p>\n<p>The latest <em>SuperTuxKart<\/em> release comes with an experimental Vulkan renderer and I was eager to check it out on my <em>Raspbery Pi 4<\/em> and see how well it worked.<\/p>\n<p>The short story is that while I have only tested a few tracks it seems to perform really well overall. In my tests, even with a debug build of Mesa I saw the FPS ranging from 60 to 110 depending on the track. I think the game might be able to produce more than 110 fps actually, since various tracks were able to reach exactly 110 fps I think the limiting factor here was the display.<\/p>\n<p>I was then naturally interested in comparing this to the GL renderer and I was a bit surprised to see that, with the same settings, the GL renderer would be somewhere in the 8-20 fps range for the same tracks. The game was clearly hitting a very bad path in the GL driver so I had to fix that before I could make a fair comparison between both.<\/p>\n<p>A perf session quickly pointed me to the issue: Mesa has code to transparently translate vertex attribute formats that are not natively supported to a supported format. While this is great for compatibility it is obviously going to be very slow. In particular, <em>SuperTuxKart<\/em> uses <em>rgba16f<\/em> and <em>rg16f<\/em> with some vertex buffers and Mesa was silently translating these to 32-bit counterparts because the GL driver was not advertising support for the 16-bit variants. The hardware does support 16-bit floating point vertex attributes  though, so this was very easy to <a href=\"https:\/\/gitlab.freedesktop.org\/mesa\/mesa\/-\/merge_requests\/21361\">fix<\/a>.<\/p>\n<p>The Vulkan driver was exposing support for this already, which explains the dramatic difference in performance between both drivers. Indeed, with that change <em>SuperTuxKart<\/em> now plays smooth on OpenGL too, with framerates always above 30 fps and up to 110 fps depending on the track. We should probably have an option in Mesa to make this kind of under-the-hood compatibility translations more obvious to users so we can catch silly issues like this more easily.<\/p>\n<p>With that said, even if GL is now a lot better, Vulkan is still ahead by quite a lot, producing 35-50% better framerate than OpenGL depending on the track, at least for the tracks that don&#8217;t hit the 110 fps mark, which as I said above, looks like it is a display maximum, at least  with my setup.<\/p>\n<p><b>Zink<\/b><\/p>\n<p>During my presentation at <em>XDC<\/em> last year I mentioned <em>Zink<\/em> wasn&#8217;t supported on <em>Raspberry Pi 4<\/em> any more due to feature requirements we could not fulfill.<\/p>\n<p>In the past, <em>Zink<\/em> used to abort when it detected unsupported features, but it seems this policy has been changed and now it simply drops a warning and points to the possibility of incorrect rendering as a result.<\/p>\n<p>Also, I have been talking to <em>zmike<\/em> about one of the features we could not support natively: <em>scalarBlockLayout<\/em>. Particularly, the issue with this is that we can&#8217;t make it work with vectors in all cases and the only alternative for us would be to scalarize everything through a lowering, which would probably have a performance impact. However, <em>zmike<\/em> confirmed that <em>Zink<\/em> is already doing this, so in practice we would not see vector load\/stores from <em>Zink<\/em>, in which case it should work fine .<\/p>\n<p>So with all that in mind, I did give <em>Zink<\/em> a go and indeed, I get the warning that we don&#8217;t support scalar block layouts (and some other feature I don&#8217;t remember now) but otherwise it mostly works. It is not as stable as the native driver and some things that work with the native driver don&#8217;t work with <em>Zink<\/em> at present, some examples I saw include the <em>WebGL Aquarium<\/em> demo in <em>Chromium<\/em> or <em>SuperTuxKart<\/em>.<\/p>\n<p>As far as performance goes, it has been a huge leap from when I tested it maybe 2 years ago. With <em>VkQuake3<\/em>&#8216;s OpenGL renderer performance with <em>Zink<\/em> used to be ~40% of the native OpenGL driver, but is now on par with it, even if not a tiny bit better, so kudos to <em>zmike<\/em> and all the other contributors to <em>Zink<\/em> for all the work they put into this over the last 2 years, it really shows.<\/p>\n<p>With all that said, I didn&#8217;t do too much testing with <em>Zink<\/em> myself so if anyone here decides to give it a more thorough go, please let me know how it went in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SuperTuxKart Vulkan vs OpenGL The latest SuperTuxKart release comes with an experimental Vulkan renderer and I was eager to check it out on my Raspbery Pi 4 and see how well it worked. The short story is that while I have only tested a few tracks it seems to perform really well overall. In my &hellip; <a href=\"https:\/\/blogs.igalia.com\/itoral\/2023\/02\/20\/supertuxkart-vulkan-vs-opengl-and-zink-status-on-raspberry-pi-4\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;SuperTuxKart Vulkan vs OpenGL and Zink status on Raspberry Pi 4&#8221;<\/span><\/a><\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1157","post","type-post","status-publish","format-standard","hentry","category-graphics"],"_links":{"self":[{"href":"https:\/\/blogs.igalia.com\/itoral\/wp-json\/wp\/v2\/posts\/1157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.igalia.com\/itoral\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.igalia.com\/itoral\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/itoral\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/itoral\/wp-json\/wp\/v2\/comments?post=1157"}],"version-history":[{"count":6,"href":"https:\/\/blogs.igalia.com\/itoral\/wp-json\/wp\/v2\/posts\/1157\/revisions"}],"predecessor-version":[{"id":1164,"href":"https:\/\/blogs.igalia.com\/itoral\/wp-json\/wp\/v2\/posts\/1157\/revisions\/1164"}],"wp:attachment":[{"href":"https:\/\/blogs.igalia.com\/itoral\/wp-json\/wp\/v2\/media?parent=1157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.igalia.com\/itoral\/wp-json\/wp\/v2\/categories?post=1157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.igalia.com\/itoral\/wp-json\/wp\/v2\/tags?post=1157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}