Vulkan-Tutorial.com
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
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.
Executing This Code
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.
Notable Changes From C++
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.
SDL2 Instead of GLFW
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.
No Device layers
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.
Vulkan Portability Subset
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.
Go Embed
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.
Drawing a Triangle
Setup
Base Code
Read the tutorial
Original code
Go code
Instance
Read the tutorial
Original code
Go code
Diff
Validation layers
Read the tutorial
Original code
Go code
Diff
Physical devices and queue families
Read the tutorial
Original code
Go code
Diff
Logical device and queues
Read the tutorial
Original code
Go code
Diff
Presentation
Window surface
Read the tutorial
Original code
Go code
Diffs
Swapchain
Read the tutorial
Original code
Go code
Diffs
Image views
Read the tutorial
Original code
Go code
Diffs
Graphics pipeline basics
Introduction
Read the tutorial
Original code
Go code
Diffs
Shader Modules
Read the tutorial
Original code
Go code
Diffs
Fixed functions
Read the tutorial
Original code
Go code
Diffs
Render passes
Read the tutorial
Original code
Go code
Diffs
Conclusion
Read the tutorial
Original code
Go code
Diffs
Drawing
Framebuffers
Read the tutorial
Original code
Go code
Diffs
Command buffers
Read the tutorial
Original code
Go code
Diffs
Rendering and presentation
Read the tutorial
Original code
Go code
Diffs
Swapchain Recreation
Read the tutorial
Original code
Go code
Diffs
Vertex buffers
(Will cause Validation Layer errors, but that will be fixed in the next chapter)
Read the tutorial
Original code
Go code
Diffs
Vertex buffer creation
Read the tutorial
Original code
Go code
Diffs
Staging buffer
Read the tutorial
Original code
Go code
Diffs
Index buffer
Read the tutorial
Original code
Go code
Diffs
Descriptor layout and buffer
Read the tutorial
Original code
Go code
Diffs
Descriptor pool and sets
Read the tutorial
Original code
Go code
Diffs
Texture mapping
Images
Read the tutorial
Original code
Go code
Diffs
Image view and sampler
Read the tutorial
Original code
Go code
Diffs
Combined image sampler
Read the tutorial
Original code
Go code
Diffs
Depth buffering
Read the tutorial
Original code
Go code
Diffs
Loading models
Read the tutorial
Original code
Go code
Diffs
Generating Mipmaps
Read the tutorial
Original code
Go code
Diffs
Multisampling
Read the tutorial
Original code
Go code
Diffs