Chapter -1: about this series
What it is
An overview of GPU programming with Vulkan for computational and graphical purposes.
Each chapter contains two parts:
- A concise, high-level overview of the topic at hand, meant to provide a mental model of the API
- A more detailed coverage of the same topic, focusing on how these concepts are concretely implemented in the API
What it is not
- A step-by-step guide to implementing a rendering engine
- A collection of concrete examples
- A guide to the lovely math behind computer graphics
In fact, this series is almost free of code samples, as I feel that these would needlessly bloat the articles: Vulkan is very verbose (reflecting the complexity of modern GPUs), and writing the code is not the hard part. I wanted to leave center stage to conceptual understanding, as opposed to pedestrian implementation concerns. Samples can easily be found online.
Prerequisites
Knowing how to read and program. Some familiarity with linear algebra and the maths being computer graphics, or the willingness to complete from other sources.
Why not read X or Y instead?
I have been working on Batyr on-and-off for the past few years (2% of the time on and the remaining 98% off), and I have had the time to forget everything about Vulkan a few times by now. Getting back in the saddle is unpleasant — most guides are too focused on specific workloads or verbose for my liking (I cannot see how the pieces fit together if everything is spread over 40 different pages), and the doc is too terse (as a good doc should be). This guide aims for a sweet spot. As outlined above, each chapter follows a split structure: the big ideas of a chapter are introduced in isolation before being fleshed out in a second part. This approach brings the following advantages:
- The big ideas are effectively repeated twice (repetitio est mater studiorum[?], as they say, although practice is of course required to truly anchor these ideas).
- The high-level overviews ensure that a quick and easily digestible refresher is always some scrolling away if brain fog starts to settle in.
- More generally, reading only the first part of each chapter is an efficient way of refreshing one's mental model of Vulkan.
A pecularity of this guide is that it introduces Vulkan as a general library for interacting with GPUs (straying away from the usual focus on graphics programming). This offers two key benefits: other Vulkan functionalities are not presented as if they were afterthoughts, and it makes it possible to introduce the API's complexity in a staggered manner. By the time we get to the graphics pipeline, most involved concepts should feel familiar.
With that being said, if you heard good things about X or Y, by all means, do use them! Using a variety of sources is probably the best thing you could do. If no one talked to you about any X nor Y, I listed some personal recommendations below.
Some good alternatives/complementary sources
-
The spec:
the source of
allmost truth. - Vkguide.dev: I did not learn Vulkan using this guide, but I did some skimming and it looks very well put together. I feel like it shares some of the objectives of this guide, but it includes code samples and it is much more verbose (a good or a bad thing, depending on who you ask). Although it focuses on Vulkan 1.3, an older (1.1-based) version of the tutorial is still available (which is relevant for targetting mobile devices, as these do not typically support Vulkan versions past 1.1).
- Vulkan samples: concrete examples for many different scenarios.
- Vulkan-tutorial.com: the classical Vulkan tutorial. A bit outdated and very specific (when I first ran through this tutorial, I ended with a working basic renderer, but no conceptual understanding of the API whatsoever); I feel that it works better as a reference than as a tutorial. Prefer vkguide.
- Vulkan in 30 minutes: a surface-level introduction to Vulkan geared towards D3D11 and OpenGL devs. Not recommended otherwise.
- Comparison of modern graphics APIs: a Rosetta stone for graphics APIs. Not recommended if you do not come from another API.
- Life of a triangle: Nvidia's concise guide to how its rendering pipeline works conceptually. A bit advanced at this stage, but may be very enlightening once you are more familiar with Vulkan (it shows you one of the architectures that Vulkan abstracts on!).
- Learnopengl.com: an OpenGL (not Vulkan) tutorial which gives good intuition of how rendering works and goes much deeper into concrete applications than the typical Vulkan tutorials (at any rate, much deeper than this one). Very good resource for a first foray into computer graphics.
- How do video games graphics work?: a beginner-friendly video on computer graphics.
- How do GPUs work?: a beginner-friendly video on GPU architecture.
- How GPU computing works: a more advanced video on GPU architecture (less fun but quite enlightening).
- Vulkan.org/learn: Vulkan's official list of learning resources for itself.
Caveat
May Will contain mistakes, I am not a pro. Also, this series could do with more
illustrations — right now it is mostly big walls of text (I might come back to fix this at
some point).