For a long time, I've been teetering on the fence on learning Vulkan because of its steep learning curve. Well, earlier this month I finally decided to take the plunge. This is the first in a series of articles discussing my process of learning Vulkan and my progress along the way.
NOTE: I'll be posting links to a lot of resources at the bottom of this article.
A Brief History
I've been programming against OpenGL and its variants since around 2011 or so. In the last couple of years I've done a lot of programming against WebGL and more recently I've begun experimenting with WebGL2. I also did some DirectX 9, 10 and 11 programming several years ago, but never really went anywhere with it. So, I started this with a familiarity with graphics programming concepts - at least on a high level.
I have a reasonable grasp of C and C++ concepts and feel comfortable enough with it to write an engine with. If you're thinking of jumping into Vulkan, I'd highly recommend having a reasonable comfort level of C and C++ concepts.
I also understand most required math on a high level at least. Granted there are plenty of places where I do fall short on this; my understanding of Quaternions is surface-level at best. So, again I would approach this with a reasonable comfort of vector, matrix and quaternion math - particularly if you are tackling a 3D renderer or engine.
First Things First
Before I can dive into reading Vulkan, I need to gain an understanding of it from a high level. To get started with this, I figured I'd start by following the tutorial at Vulkan Tutorial. This allowed me to get an application running:
The image above details some things that aren't 100%.. shall we say... truthful. The Vulkan Tutorial, while an excellent and highly-recommended resource, leaves out a few things:
- This isn't dynamically lit; it's baked lighting. So it looks cool, but isn't realistic or practical (not that I expected production-ready code from a tutorial. The author even says it isn't production-ready). It basically stops at the point of having a model loaded on-screen and spinning around. No discussions of lighting or shadowing are present.
- The pipeline is setup in such a way where everything is very linear in creation. Loading multiple objects or loading objects dynamically isn't a thing and no in-depth discussion is covered regarding this.
- Other important items, such as how to render to texture and post effects aren't covered.
Again, I wasn't expecting to actually be able to write an engine off of this though. It did, however, give me a working application that I could study and mess with.
The next thing I took a look at was the Vulkan Examples by Sascha Willems. This again, is a great resource. However, I quickly realized upon looking at some of the more complicated examples that I was in over my head and I needed to slow my roll.
A Different Approach
I decided at this point that my approach was all wrong, and I needed to learn this the right way from the ground up. So, I started to research how to learn Vulkan and truly understand it. This presented me with something I hadn't for some reason, even considered. Reading the Vulkan specification.
It's a dry read, I'm not going to lie. I'm only up to section 6, almost to 7. But the information density here is huge. It's honestly really well-written documentation on how things should, can or must behave.
I also found an excellent article on "How to Learn Vulkan" (link) which gave me a lot of resources to look at and a solid place to start. This includes an article (or series of articles, really) I'd not seen or heard of before called "A trip through the graphics pipeline" (link) which goes into detail about how GPUs really work under the hood. While it was written in 2011, it's still largely accurate to the way GPUs and graphics pipelines work today, as well as an occasional dive into the history of it all. At the time of writing I'm most of the way through that series as well and can already confidently say that it's helping solidify some Vulkan concepts in my mind.
So my next goal is to finish reading through all the links which I'll be posting at the bottom of this page before I attempt another Vulkan implementation. I'll likely post a follow-up to this article at that time.
- Vulkan 1.2 Specification: https://www.khronos.org/registry/vulkan/specs/1.2/html
- Vulkan SDK: https://vulkan.lunarg.com/sdk/home
- RenderDoc (for studying and debugging/profiling OpenGL/Vulkan): https://renderdoc.org/
- Some other resources:
- How to Learn Vulkan: https://www.jeremyong.com/c++/vulkan/graphics/rendering/2018/03/26/how-to-learn-vulkan/
- A trip through the graphics pipeline (almost 10 years old but still highly relevant: https://fgiesen.wordpress.com/2011/07/09/a-trip-through-the-graphics-pipeline-2011-index/
- Vulkan in 30 minutes (assumes general familiarity with graphics APIs): https://renderdoc.org/vulkan-in-30-minutes.html
- Vulkan Tutorial - https://vulkan-tutorial.com/
- Vulkan Examples by Sascha Willems: https://github.com/SaschaWillems/Vulkan
- Awesome Vulkan: https://github.com/vinjn/awesome-vulkan
- Vulkan Synchronization primer: https://www.jeremyong.com/c++/graphics/gpu/vulkan/2018/11/22/vulkan-synchronization-primer.html
- Vulkan Subreddit: https://www.reddit.com/r/vulkan