Vulkan tutorial written in Odin.
This repository will follow the structure of the original tutorial. Each commit will correspond to one page or on section of the page for long chapters.
Sometimes an 'extra' commit will be added with some refactoring, commenting or feature.
There are a few more things covered in the more branch.
You need to have a Vulkan SDK and the Odin compiler.
# if you need to recompile the shaders
.\scripts\compile_shaders.ps1
# or ./scripts/compile_shaders.sh on linux
# compile and run the application
odin run .
# or with validation layers
odin run . -define:ENABLE_VALIDATION_LAYERS=trueThis section contains the summary of the project commits. Follow ๐ to go to the related tutorial page and ๐ผ to go to the commit details.
GLFW initialization, window's creation and main loop setup.
Create and destroy the Vulkan instance.
Enable VK_LAYER_KHRONOS_validation validation layer and setup the debug messenger.
Here we make use of Odin's command-line defines to control the activation of the validation layers (see here).
Physical device and queue families selection.
Create the logical device and retrieve a graphics queue.
Create the window surface and retrieve a queue supporting presentation.
Create the swapchain and retriving the swapchain images.
Create the image views for the swapchain images.
Create and compile the vertex and fragment shaders, load them, and the shader modules.
Setup the states of the fixed functions of the graphics pipeline and create the pipeline layout.
Create the render pass describing the attachments to use during rendering.
Finish the graphics pipeline creation.
Create the swapchain framebuffers from the swapchain image views and the render pass.
Create the command buffer and record commands to draw.
Finalize drawing the triangle to the screen!
Improve rendering by allowing overlap between cpu and gpu with multiple frames in flight.
Handle swapchain recreation and window's resize.
There is a bit of factoring around the swapchain creation and its dependencies here.
Resizing detection is also done differently,
glfwSetFramebufferSizeCallbackis not used and we just manually check if the framebuffer was resized withglfwGetFramebufferSize.
Move hardcoded vertices from the vertex shader to the application code and update pipeline's vertex input info.
A new
vertex.odinfile is added to keep things more manageable.
Create the actual vertex buffer and its memory, fill it and bind it before drawing.
Create a buffer whose memory is local to the graphics card and a staging buffer from which data is tranfered.
Render a rectangle without duplicating vertices by using an index buffer.
Update the vertex shader to apply a transformation and render it with a perspective camera. Also create the descriptor set layout, the buffers used to send data to the shader and update it each frame.
Create the descriptor set pool and sets, update them to point at the proper buffers and bind them before rendering.
Load an image file and upload its data to the GPU.
Create the image view and sampler and enable anisotropic filtering.
Update the descriptor sets, Vertex structure and shaders to use the loaded image as a texture for the displayed rectangle.
Render overlapping geometry, create a depth texture and set up depth testing.
6.0: Obj file loader ๐ผ
This is not part of the original Vulkan tutorial!
Implement a simple (and most likely incomplete) loader for .obj files in preparation for the next chapter. It overlaps a little with the next chapter though as it already merges duplicate vertices and invert the texture coordinates y axis.
This is a very simple loader, it might not work for other more complicated loader. Also it only outputs positions and texture coordinate since we won't use normals.
Load an .obj model and render it.
Since we don't use the vertex color anymore I just remove them altogether.
The tutorial already mentions it but the model doesn't play nicely with backface culling so I disabled it.
Generate mipmaps for the model texture and update sampler to make use of the new mip levels.
Model rotation is now controlled with the right and left keys.
Add MSAA support.
Extra.2: Cleanup and refactoring ๐ผ
This is not part of the original Vulkan tutorial!
Clean up the code, refactor to avoid passing to many things around all the time, make to code more "Odin-like" by applying idioms from the language.
