Vulkan Startup Code

I’ve been studying books, code examples, tutorials, and frankly anything I can get my hands on regarding Vulkan. What follows is a bit of what I’ve learned in the process.

The first thing I bumped into is that Vulkan uses different shaders than OpenGL does. Or perhaps more accurately, almost the same shaders, but with restrictions and rules all over, and in a different format. OpenGL uses GLSL (OpenGL Shader Language), a C-like text based language, for shaders. Vulkan uses a compiler that turns GLSL that follows special rules into SPIR-V (Standard Portable Intermediate Representation for Vulkan) which is a binary (byte code) based language. The trick here is learning to understand enough about GLSL and SPIR-V that you can figure out what all the compiler errors you get when trying to compile your shaders mean.

The next thing I figured out is that getting through all the start up code for Vulkan is borderline nightmarish. OpenGL magically hides a lot of things in the drivers. This includes everything from the GLSL compiler and linker to the hidden state that lets the whole thing work with relatively few methods. That means that the start up code for OpenGL is a relatively lean process that involves compiling a couple shaders with the driver and linking them together into a shader program and not too much else. In contrast, to get Vulkan up and running is about a zillion lines of code that involves at least a dozen different types of objects that have to be picked over and assembled together.

I’m working on crafting this Vulkan start up code into my graphics engine. At this point it has been a lot of work and research, which I admit has slowed down my posting here, but I swear I am plugging along and I suspect I have a long way to go still. Please try to bear with me.