|
| 1 | +## About |
| 2 | + |
| 3 | +This tutorial will teach you the basics of using the [Vulkan](https://www.khronos.org/vulkan/) |
| 4 | +graphics and compute API. Vulkan is a new API by the [Khronos group](https://www.khronos.org/) |
| 5 | +(known for OpenGL) that provides a much better abstraction of modern graphics |
| 6 | +cards. This new interface allows you to better describe what your application |
| 7 | +intends to do, which can lead to better performance and less surprising driver |
| 8 | +behavior compared to existing APIs like [OpenGL](https://en.wikipedia.org/wiki/OpenGL) |
| 9 | +and [Direct3D](https://en.wikipedia.org/wiki/Direct3D). The ideas behind Vulkan |
| 10 | +are similar to those of [Direct3D 12](https://en.wikipedia.org/wiki/Direct3D#Direct3D_12) |
| 11 | +and [Metal](https://en.wikipedia.org/wiki/Metal_(API)), but Vulkan has the |
| 12 | +advantage of being fully cross-platform and allows you to develop for Windows, |
| 13 | +Linux and Android at the same time. |
| 14 | + |
| 15 | +However, the price you pay for these benefits is that you have to work with a |
| 16 | +significantly more verbose API. Every detail related to the graphics API needs |
| 17 | +to be set up from scratch by your application, including initial frame buffer |
| 18 | +creation and memory management for objects like buffers and texture images. The |
| 19 | +graphics driver will do a lot less hand holding, which means that you will have |
| 20 | +to do more work in your application to ensure correct behavior. |
| 21 | + |
| 22 | +The takeaway message here is that Vulkan is not for everyone. It is targeted at |
| 23 | +programmers who are enthusiastic about high performance computer graphics, and |
| 24 | +are willing to put some work in. If you are more interested in game development, |
| 25 | +rather than computer graphics, then you may wish to stick to OpenGL or Direct3D, |
| 26 | +which will not be deprecated in favor of Vulkan anytime soon. Another |
| 27 | +alternative is to use an engine like [Unreal Engine](https://en.wikipedia.org/wiki/Unreal_Engine#Unreal_Engine_4) |
| 28 | +or [Unity](https://en.wikipedia.org/wiki/Unity_(game_engine)), which will be |
| 29 | +able to use Vulkan while exposing a much higher level API to you. |
| 30 | + |
| 31 | +With that out of the way, let's cover some prerequisites for following this |
| 32 | +tutorial: |
| 33 | + |
| 34 | +* A graphics card and driver compatible with Vulkan ([NVIDIA](https://developer.nvidia.com/vulkan-driver), [AMD](http://www.amd.com/en-us/innovations/software-technologies/technologies-gaming/vulkan), [Intel](https://software.intel.com/en-us/blogs/2016/03/14/new-intel-vulkan-beta-1540204404-graphics-driver-for-windows-78110-1540)) |
| 35 | +* Experience with C++ (familiarity with RAII, initializer lists) |
| 36 | +* A compiler compatible with C++11 (Visual Studio 2013+, GCC 4.8+) |
| 37 | +* Some existing experience with 3D computer graphics |
| 38 | + |
| 39 | +This tutorial will not assume knowledge of OpenGL or Direct3D concepts, but it |
| 40 | +does require you to know the basics of 3D computer graphics. It will not explain |
| 41 | +the math behind perspective projection, for example. See [this online book](http://opengl.datenwolf.net/gltut/html/index.html) |
| 42 | +for a great introduction of computer graphics concepts. |
| 43 | + |
| 44 | +You can use C instead of C++ if you want, but you will have to use a different |
| 45 | +linear algebra library and you will be on your own in terms of code structuring. |
| 46 | +We will use C++ features like classes and RAII to organize logic and resource |
| 47 | +lifetimes. |
| 48 | + |
| 49 | +## Tutorial structure |
| 50 | + |
| 51 | +We'll start with an overview of how Vulkan works and the work we'll have to do |
| 52 | +to get the first triangle on the screen. The purpose of all the smaller steps |
| 53 | +will make more sense after you've understood their basic role in the whole |
| 54 | +picture. Next, we'll set up the development environment with the [Vulkan SDK](https://lunarg.com/vulkan-sdk/), |
| 55 | +the [GLM library](http://glm.g-truc.net/) for linear algebra operations and |
| 56 | +[GLFW](http://www.glfw.org/) for window creation. The tutorial will cover how |
| 57 | +to set these up on Windows with Visual Studio, and on Ubuntu Linux with GCC. |
| 58 | + |
| 59 | +After that we'll implement all of the basic components of a Vulkan program that |
| 60 | +are necessary to render your first triangle. Each chapter will follow roughly |
| 61 | +the following structure: |
| 62 | + |
| 63 | +* Introduce a new concept and its purpose |
| 64 | +* Use all of the relevant API calls to integrate it into your program |
| 65 | +* Abstract parts of it into helper functions |
| 66 | + |
| 67 | +Although each chapter is written as a follow-up on the previous one, it is also |
| 68 | +possible to read the chapters as standalone articles introducing a certain |
| 69 | +Vulkan feature. That means that the site is also useful as a reference. All of |
| 70 | +the Vulkan functions and types are linked to the specification, so you can click |
| 71 | +them to learn more. Vulkan is a very new API, so there may be some shortcomings |
| 72 | +in the specification itself. You are encouraged to submit feedback to |
| 73 | +[this Khronos repository](https://github.com/KhronosGroup/Vulkan-Docs). |
| 74 | + |
| 75 | +As mentioned before, the Vulkan API has a rather verbose API with many |
| 76 | +parameters to give you maximum control over the graphics hardware. This causes |
| 77 | +basic operations like creating a texture to take a lot of steps that have to be |
| 78 | +repeated every time. Therefore we'll creating our own collection of helper |
| 79 | +functions throughout the tutorial. |
| 80 | + |
| 81 | +Every chapter will also conclude with a link to the full code listing up to that |
| 82 | +point. You can refer to it if you have any doubts about the structure of the |
| 83 | +code, or if you're dealing with a bug and want to compare. All of the code files |
| 84 | +have been tested on graphics cards from multiple vendors to verify correctness. |
| 85 | +Each chapter also has a comment section at the end where you can ask any |
| 86 | +questions that are relevant to the specific subject matter. Please specify your |
| 87 | +platform, driver version, source code, expected behavior and actual behavior to |
| 88 | +help us help you. |
| 89 | + |
| 90 | +This tutorial is intended to be a community effort. Vulkan is still a very new |
| 91 | +API and best practices have not really been established yet. If you have any |
| 92 | +type of feedback on the tutorial and site itself, then please don't hesitate to |
| 93 | +submit an issue or pull request to the [GitHub repository](https://github.com/Overv/VulkanTutorial). |
| 94 | + |
| 95 | +After you've gone through the ritual of drawing your very first Vulkan powered |
| 96 | +triangle onscreen, we'll start expanding the program to include linear |
| 97 | +transformations, textures and 3D models. |
| 98 | + |
| 99 | +If you've played with graphics APIs before, then you'll know that there can be a |
| 100 | +lot of steps until the first geometry shows up on the screen. There are many of |
| 101 | +these initial steps in Vulkan, but you'll see that each of the individual steps |
| 102 | +is easy to understand and does not feel redundant. It's also important to keep |
| 103 | +in mind that once you have that boring looking triangle, drawing fully textured |
| 104 | +3D models does not take that much extra work and each individual step, and each |
| 105 | +step beyond that point is much more rewarding. |
| 106 | + |
| 107 | +Ready to dive into the future of high performance graphics APIs? [Let's go!](!Overview) |
0 commit comments