This is a go port of the example code at vulkan-tutorial.com, using vkngwrapper as a wrapper library. Each subfolder pertains to a single step of the tutorial, and I have tried to strike a balance between making the tutorial code match the C++ code as closely as possible while still being vaguely idiomatic. You should be able to use the code files here as a reference while working through the vulkan tutorial.
To learn more about vkngwrapper, check out the core repository!
- Rights
- Executing This Code
- Notable Changes From C++
- Drawing a Triangle
- Swapchain Recreation
- Vertex buffers
- Uniform buffers
- Texture mapping
- Depth Buffering
- Loading Models
- Generating Mipmaps
- Multisampling
The vulkan tutorial's source and licensing information can be found at https://github.com/Overv/VulkanTutorial and are licensed under the CC BY-SA 4.0 license or the CC0 1.0 Universal license. The example code in this folder and its subfolders is also licensed under the CC0 1.0 Universal license found here. Code outside this directory may be licensed differently.
Images and meshes in this directory were obtained from the vulkan tutorial and are licensed under the CC BY-SA 4.0 license.
Before this code can be executed, you will need to install the Vulkan SDK for your operating system. Additionally, it may be necessary to download SDL2 using your local package manager. For more information, see go-sdl2 requirements.
In order to best support this code as an idiomatic Golang example, there are a few differences between this code and the default C++ code provided at http://vulkan-tutorial.com/ - they are listed here and reasoning is provided.
This example code uses go-sdl2 as its windowing system, with Surface support provided via integrations/sdl2. The primary reason for this is that go-sdl2's level of support is far, far better than any GLFW wrapper for Go.
Step 2 of the tutorial instructs users to apply a validation layer to both the Vulkan Instance and the Device. However, Device layers were deprecated before Vulkan 1.0 was released, and is not necessary when activating validation behavior. As a result, vkngwrapper does not support Device layers and we do not apply them in this tutorial.
Beginning with Step 4, we activate the VK_KHR_portability_subset
extension
in the logical Device on creation, when it is available. Doing so allows this tutorial to run on hardware
that does not support the full Vulkan spec, such as Mac laptops.
Asset files are loaded from disk using //go:embed. This makes it very easy to package each step's assets with the step itself and load the assets from disk with a minimum of confusion.
(Will cause Validation Layer errors, but that will be fixed in the next chapter)