Switch to Vulkan-Hpp dynamic dispatch loader #79

Open
opened 2026-10-04 23:18:17 -07:00 by burkkyy · 0 comments
Owner

Not urgent. Volk isn't needed, because Vulkan-Hpp's dynamic dispatcher covers the same ground.

Current state

We use static dispatch: we link Vulkan::Vulkan and call through the loader's trampolines. Debug-utils extension functions are fetched by hand with vkGetInstanceProcAddr in:

  • engine/src/vulkan/instance.cpp (create/destroy debug messenger)
  • engine/src/vulkan/device.cpp (same wrappers, duplicated)
  • engine/src/vulkan/debug_label.cpp (vkCmdBeginDebugUtilsLabelEXT / vkCmdEndDebugUtilsLabelEXT)

Proposal

Define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 and initialize the default dispatcher:

VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE  // in one .cpp

VULKAN_HPP_DEFAULT_DISPATCHER.init();          // before instance creation
VULKAN_HPP_DEFAULT_DISPATCHER.init(instance);  // after instance creation
VULKAN_HPP_DEFAULT_DISPATCHER.init(device);    // after device creation

Benefits

  • Removes the manual vkGetInstanceProcAddr wrappers. Extension functions get called directly, e.g. instance.createDebugUtilsMessengerEXT(...) and cmd.beginDebugUtilsLabelEXT(...).
  • Device-level calls skip the loader trampoline. This is a minor speedup.
  • Optional: drop the link-time dependency on libvulkan.

Work required

  • VMA: enable VMA_DYNAMIC_VULKAN_FUNCTIONS and pass vkGetInstanceProcAddr/vkGetDeviceProcAddr through VmaVulkanFunctions.
  • ImGui Vulkan backend: load its functions with ImGui_ImplVulkan_LoadFunctions (or define IMGUI_IMPL_VULKAN_NO_PROTOTYPES).
  • Convert any remaining raw C vk* calls to Vulkan-Hpp, or route them through the dispatcher.
Not urgent. Volk isn't needed, because Vulkan-Hpp's dynamic dispatcher covers the same ground. ## Current state We use static dispatch: we link `Vulkan::Vulkan` and call through the loader's trampolines. Debug-utils extension functions are fetched by hand with `vkGetInstanceProcAddr` in: - `engine/src/vulkan/instance.cpp` (create/destroy debug messenger) - `engine/src/vulkan/device.cpp` (same wrappers, duplicated) - `engine/src/vulkan/debug_label.cpp` (`vkCmdBeginDebugUtilsLabelEXT` / `vkCmdEndDebugUtilsLabelEXT`) ## Proposal Define `VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1` and initialize the default dispatcher: ```cpp VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE // in one .cpp VULKAN_HPP_DEFAULT_DISPATCHER.init(); // before instance creation VULKAN_HPP_DEFAULT_DISPATCHER.init(instance); // after instance creation VULKAN_HPP_DEFAULT_DISPATCHER.init(device); // after device creation ``` ## Benefits - Removes the manual `vkGetInstanceProcAddr` wrappers. Extension functions get called directly, e.g. `instance.createDebugUtilsMessengerEXT(...)` and `cmd.beginDebugUtilsLabelEXT(...)`. - Device-level calls skip the loader trampoline. This is a minor speedup. - Optional: drop the link-time dependency on `libvulkan`. ## Work required - VMA: enable `VMA_DYNAMIC_VULKAN_FUNCTIONS` and pass `vkGetInstanceProcAddr`/`vkGetDeviceProcAddr` through `VmaVulkanFunctions`. - ImGui Vulkan backend: load its functions with `ImGui_ImplVulkan_LoadFunctions` (or define `IMGUI_IMPL_VULKAN_NO_PROTOTYPES`). - Convert any remaining raw C `vk*` calls to Vulkan-Hpp, or route them through the dispatcher.
burkkyy added the enhancement label 2026-10-04 23:18:17 -07:00
burkkyy added this to the sophia project 2026-10-04 23:18:26 -07:00
Sign in to join this conversation.