{"id":47872,"date":"2019-09-03T06:00:47","date_gmt":"2019-09-03T10:00:47","guid":{"rendered":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=47872"},"modified":"2019-08-30T10:58:09","modified_gmt":"2019-08-30T14:58:09","slug":"this-dumb-industry-vulkan","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=47872","title":{"rendered":"This Dumb Industry: What is Vulkan?"},"content":{"rendered":"<p>Here is the first video in the This Dumb Industry series. As I mentioned before, these videos begin as articles and are then turned into videos. I think this works better than going the other way. This ought to read like a slightly informal variant of my old columns. Or you could just watch <a href=\"https:\/\/youtu.be\/8Ov_qN2Oub0\">the video<\/a>. Whatever works for you.<\/p>\n<p>Like I mentioned on the last video, I have a Patreon reward tier for people who want their names in the credits. These videos are often produced a week or so ahead of time, so if you signed up in the last 7 days or so then your name probably won&#8217;t show up yet.\u00a0 I just wanted to make it clear that I didn&#8217;t forget you, we&#8217;re just dealing with normal video-production lag times. If you&#8217;re signed up now then you should show up in the next vid.<\/p>\n<p>One final note is that this is obviously a shorter and less detailed version of <a href=\"?p=35550\">an article I wrote back in 2016<\/a>. I wanted to start off this series with something familiar and easy before we try to tackle more challenging topics.<\/p>\n<p>Anyway, on to the article:<\/p>\n<p><!--more--><\/p>\n<h3>What is Vulkan?<\/h3>\n<p><table class='nomargin' cellspacing='0' width='100%' cellpadding='0' align='center' border='0'><tr><td><iframe loading=\"lazy\" width=\"1024\" height=\"576\" src=\"https:\/\/www.youtube.com\/embed\/8Ov_qN2Oub0\" frameborder=\"0\" allowfullscreen class=\"embed\"><\/iframe><br\/><small><a href='http:\/\/www.youtube.com\/watch?v=8Ov_qN2Oub0'>Link (YouTube)<\/a><\/small><\/td><\/tr><\/table><\/p>\n<p>We meet again, The Internet. Today I want to talk to you about Vulcan. Not <a href=\"https:\/\/en.wikipedia.org\/wiki\/Vulcan_(mythology)\">this vulcan<\/a>. Not <a href=\"https:\/\/en.wikipedia.org\/wiki\/Vulcan_(Star_Trek)\">this Vulcan<\/a>. Not <a href=\"https:\/\/en.wikipedia.org\/wiki\/Vulcan_statue\">this Vulcan<\/a>. Not even <a href=\"https:\/\/en.wikipedia.org\/wiki\/Black_Vulcan\">this vulcan<\/a>. I&#8217;m talking about <a href=\"https:\/\/en.wikipedia.org\/wiki\/Vulkan_(API)\">this Vulkan<\/a>. With a K for some reason.<\/p>\n<p>Maybe you&#8217;ve seen this logo in a splash screen somewhere or maybe you&#8217;ve seen Vulkan in <a href=\"https:\/\/www.nomanssky.com\/2019\/04\/vulkan-update\/\">gaming news<\/a> and wondered what the deal is. Isn&#8217;t it supposed to make games faster somehow? Is this thing a new <a href=\"https:\/\/www.ogre3d.org\/\">graphics engine<\/a>? Is it a <a href=\"https:\/\/unity.com\/\">game engine like Unity<\/a>? Is it <a href=\"https:\/\/www.havok.com\/\">middleware<\/a>?<\/p>\n<p>No. It&#8217;s not any of those things. Vulkan is a replacement for OpenGL. So now I need to explain what OpenGL is. And to explain that, we need to talk about&#8230;<\/p>\n<h3>Standards<\/h3>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/stock_outlet.jpg' width=100% alt='' title=''\/><\/div><div class='mouseover-alt'><\/div><\/p>\n<p>Standards are important for getting disparate systems to interoperate. Let&#8217;s say there&#8217;s a power plant out there generating electricity for us. And let&#8217;s also say that you&#8217;ve got some sort of electrical gizmo that you want to use. You can&#8217;t just wire your gizmo directly into the power grid because that would kill your gizmo, and probably you. So we have some standards for how to step down power from the grid to make it suitable for residential use. On the other side we have standards for gizmos, telling them how to accept residential power. The humble household electrical outlet is where these two sets of standards meet.<\/p>\n<p>This means that it doesn&#8217;t matter what the power plant looks like, how many there are, or how they work. It doesn&#8217;t matter how large or small the gizmo is or how much power it needs. Each system can follow their half of the standards and the two can meet in the middle.<\/p>\n<p>To get a feel for what it&#8217;s like in a world without standards, think back to the goofy days of the early 90s and how much hassle there was getting games to support your sound card. If you&#8217;re too young to remember those days, I highly recommend the channel <a href=\"https:\/\/www.youtube.com\/user\/phreakindee\">Lazy Game Reviews<\/a>.<\/p>\n<p>In those days, there wasn&#8217;t a single standard for sound cards. Every model was a little different, and programmers had to go out of their way to write code specifically to support all the different species of sound devices. You&#8217;d find games that supported every card except the one you owned, or they only supported a subset of the features. It was a lot more work for the developers and a lot more frustration for the user.<\/p>\n<p>We eventually got that sorted out so now developers don&#8217;t need to care about your specific make and model of card to get sound to come out of the speakers. We have similar standards for graphics, and OpenGL is part of that.<\/p>\n<h3>YTILIBITAPMOC<\/h3>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/tdi_opengl.jpg' width=100% alt='The game talks to OpenGL, which talks to the graphics driver, which talks to the graphics card,  which is connected to the tiny fairies that create the glowing pixel-magic on your monitor.' title='The game talks to OpenGL, which talks to the graphics driver, which talks to the graphics card,  which is connected to the tiny fairies that create the glowing pixel-magic on your monitor.'\/><\/div><div class='mouseover-alt'>The game talks to OpenGL, which talks to the graphics driver, which talks to the graphics card,  which is connected to the tiny fairies that create the glowing pixel-magic on your monitor.<\/div><\/p>\n<p>The game talks to OpenGL, which talks to the graphics driver, which talks to the graphics card, which makes the graphics happen. Obviously it&#8217;s way more complicated than I&#8217;m making it sound. I don&#8217;t want to stop and explain what an API is, or the historical evolution of graphics hardware, or all the crazy extensions that were bolted onto OpenGL at one point. So let&#8217;s just imagine that OpenGL is a magic black box and not worry too much about the details.<\/p>\n<p>The point is that as long as the developer provides the graphics calls to OpenGL in the proper way, and as long as the graphics card manufacturer builds proper drivers, then the two halves of our system can connect to make the graphics happen.<\/p>\n<p>The beauty of OpenGL is that it has always been steadfastly backwards compatible. You could take your code from a late-90s shooter and compile it against the latest version of OpenGL and it has a reasonable chance of working on a modern machine. We don&#8217;t end up with hard walls between the graphics generations like they do in console land, where graphics engines need to be completely rewritten from scratch to work with the new hotness. It doesn&#8217;t matter if you write <a href=\"http:\/\/nehe.gamedev.net\/tutorial\/your_first_polygon\/13002\/\">this code<\/a> in 1998 or 2018, it will still draw a polygon to the screen:<\/p>\n<p>Well, actually, you wouldn&#8217;t want to do things like that today or you&#8217;d be wasting most of the available processing power. What you really want to do is <a href=\"http:\/\/nehe.gamedev.net\/tutorial\/vertex_buffer_objects\/22002\/\">pack a bunch of triangles into a buffer and send them off in batches<\/a>.<\/p>\n<p>Actually, that&#8217;s a horribly outdated way of doing things too. See, you really need to set up some vertex and fragment shaders. Except, not <a href=\"http:\/\/nehe.gamedev.net\/article\/glsl_an_introduction\/25007\/\">like this<\/a> because that&#8217;s a naive way of doing things now, what you really want is to&#8230;<\/p>\n<p>So now we come to the first problem with OpenGL. It&#8217;s got a lot of cruft. Cruft is what programmers call the ugly useless bits leftover from older systems.<\/p>\n<h3>The Tyranny of Cruft<\/h3>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/tdi_intercom.jpg' width=100% alt='The house I grew up in had a giant alcove in the living room that was originally housing for a whole-house intercom system. By the 1980s, all of that had been torn out and someone stuck a mirror in the resulting hole.' title='The house I grew up in had a giant alcove in the living room that was originally housing for a whole-house intercom system. By the 1980s, all of that had been torn out and someone stuck a mirror in the resulting hole.'\/><\/div><div class='mouseover-alt'>The house I grew up in had a giant alcove in the living room that was originally housing for a whole-house intercom system. By the 1980s, all of that had been torn out and someone stuck a mirror in the resulting hole.<\/div><\/p>\n<p>Picture an old house. It was built before electricity was common in homes, so all of the wiring is on the outside of the walls. It has an intercom system from the 1960s that hasn&#8217;t worked since the 1970s. There&#8217;s a satellite dish in the yard that hasn&#8217;t been useful since the 1990s. There are lines going from the old roof antenna to every room in the house, even though that system was long since replaced by cable TV, which was itself long since replaced by internet streaming. It&#8217;s got ancient landline telephones built into the walls of every room, and nobody wants to remove them because that would just expose a big ugly hole that nobody wants to fix.<\/p>\n<p>This metaphorical house has cruft. Lots of effort was spent over the years in an attempt to keep things modern, but when old systems became obsolete they left behind useless infrastructure. This is the downside of backwards compatibility. If you never get rid of anything, then it tends to pile up. As nice as that retro compatibility is, systems that offer it will eventually accumulate a bunch of ugly bits that make it hard to develop and maintain things.<\/p>\n<p>This is where Vulkan comes in. We&#8217;re bulldozing the old house and replacing it with something modern. Hopefully this gives developers the freedom of OpenGL without all the jank.<\/p>\n<p>So that&#8217;s what Vulkan is. It&#8217;s an effort to replace OpenGL so developers have a portable way to talk to modern graphics hardware without decades of accumulated cruft. Now is a good time to do this. Graphics technology has stabilized over the last decade or so. New stuff is still being invented. (Stuff like raytracing, which I&#8217;ll cover in a later video.) But we&#8217;re finally past the chaos of the late 90s and early aughts where you had to throw your game engine away every few years because there&#8217;s a whole new, better way of doing things.<\/p>\n<p>Is there a downside to this? Sort of. We&#8217;re giving up that backwards compatibility I talked about before. Also, Vulkan is a lot more complicated to use than humble OpenGL. It interfaces with the graphics card more directly. It&#8217;s more raw. This means that if you know what you&#8217;re doing, you can make more efficient rendering code. The downside is that Vulkan makes it a bit harder for students, indies, and other assorted bedroom programmers to get started. But I don&#8217;t think that&#8217;s a big deal. The days of loners making their own engines from scratch are mostly over. I fiddled with making a lot of experimental engines years ago, but that kind of work isn&#8217;t really needed these days. Now we have commercial-grade engines like Unity and Unreal, which are available to anyone, basically for free.<\/p>\n<p>So that&#8217;s Vulkan. It won&#8217;t make your life any easier, but it&#8217;s probably making <i>someone&#8217;s<\/i> life easier, and it&#8217;s probably making your PC games just a couple percent faster.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is the first video in the This Dumb Industry series. As I mentioned before, these videos begin as articles and are then turned into videos. I think this works better than going the other way. This ought to read like a slightly informal variant of my old columns. Or you could just watch the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102],"tags":[],"class_list":["post-47872","post","type-post","status-publish","format-standard","hentry","category-weekly-column"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/47872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=47872"}],"version-history":[{"count":10,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/47872\/revisions"}],"predecessor-version":[{"id":47888,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/47872\/revisions\/47888"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=47872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=47872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=47872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}