Skip to content

unitycoder/vulkan-triangle-modern

 
 

Repository files navigation

The meme is dead

Render a vulkan triangle in ~380 lines of code! (~370 without the shader code)

Highlights

  • Vulkan hpp headers included as a c++ module (c++20 required)
  • Dynamic rendering (VK_KHR_dynamic_rendering)
  • Shader objects (VK_EXT_shader_object)
  • Bindless rendering using buffer references (VK_EXT_buffer_device_address)
  • (Resizable) BAR for device local buffer access
  • Deferred swapchain image allocation (VK_EXT_swapchain_maintenance1)
  • Straightforward swapchain sync (VK_EXT_swapchain_maintenance1)
  • Slang used for shader code
  • Modular code
  • SDL3 for window handling

How to build (on windows)

Use CMake for project configuration. The included make.bat script can be used for this. The Vulkan SDK is not required to run this code. Only for validation layers a Vulkan SDK installation is necessary.

Please clone this repository with submodule!

Notes

  • Only works with NVIDIA and RADV driver, as others still need to implement VK_EXT_swapchain_maintenance1 aka VK_KHR_swapchain_maintenance1
  • eDeferredMemoryAllocationEXT can crash the app when apps like RiverTuner are running in the back (deactivated, see line #107)
  • Visual Studio (Code) still has problems with module syntax highlighting, installing ReSharper or switching the module import to #include <vulkan/vulkan_raii.hpp> fixes this
  • Linux should work (LLVM version >= 18.0.0 + Ninja build version >= 1.11)
  • On MacOS use a newer LLVM/Clang version from brew and install the Vulkan SDK

About

Vulkan triangle in ~380 lines of code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 72.9%
  • CMake 11.8%
  • C 9.4%
  • Makefile 2.8%
  • Batchfile 1.8%
  • Slang 1.3%