Vulkan device, loader, memory and swapchain #31

Open
UnflavoredMeson/Primal_Plus_Plus
opened 2026-11-24 20:15:57 +00:00 by UnflavoredMeson · 0 comments
Owner

Why

The second backend starts here: a device, memory and a window to present to, with validation on from the first line.

Decided

  • Vulkan 1.3. Functions are loaded, not linked (Engine/Graphics/Vulkan/VulkanLoader.h): VK_NO_PROTOTYPES, each function a global pointer with its Vulkan name in an X-macro list (global, instance, device), so calls stay ::vkX(...). VK_EXT_debug_utils is loaded only when enabled.
  • VMA for memory (it gets vkGet*ProcAddr and loads its own).
  • Validation in Debug (PRIMAL_VULKAN_VALIDATION=0 turns it off); graphics::validation_stats() counts errors and warnings for tests.
  • An FP16 scRGB swapchain when available; reversed Z.
  • One module per D3D12 module, same names.

Read first

  • LinuxVulkanPort, "Phase 6 – Vulkan backend" (6a-6c) and "Decisions"; UnflavoredMeson/Primal#18.
  • Engine/Graphics/Direct3D12/D3D12Core.cpp, D3D12Surface.cpp on master.

Steps

  • 1. Write the loader and create an instance and device with validation.
  • 2. Add VMA and the surface/swapchain with resize.
  • 3. Clear the screen in the surfaces EngineTest on Linux and Windows.
  • 4. Add validation_stats() and fail a Debug run that reports anything.

Done when

  • The surfaces EngineTest runs on Vulkan on both OSes, validation and sync validation clean; nothing links the Vulkan loader; 0 warnings; tidy 0.

Claude can help with

  • Reading validation messages and finding the spec rule they quote.

Learn

  • Why loading functions yourself avoids the loader's dispatch and the link dependency.
## Why The second backend starts here: a device, memory and a window to present to, with validation on from the first line. ## Decided - Vulkan 1.3. Functions are loaded, not linked (`Engine/Graphics/Vulkan/VulkanLoader.h`): `VK_NO_PROTOTYPES`, each function a global pointer with its Vulkan name in an X-macro list (global, instance, device), so calls stay `::vkX(...)`. VK_EXT_debug_utils is loaded only when enabled. - VMA for memory (it gets `vkGet*ProcAddr` and loads its own). - Validation in Debug (`PRIMAL_VULKAN_VALIDATION=0` turns it off); `graphics::validation_stats()` counts errors and warnings for tests. - An FP16 scRGB swapchain when available; reversed Z. - One module per D3D12 module, same names. ## Read first - [LinuxVulkanPort](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/LinuxVulkanPort), "Phase 6 – Vulkan backend" (6a-6c) and "Decisions"; `UnflavoredMeson/Primal#18`. - `Engine/Graphics/Direct3D12/D3D12Core.cpp`, `D3D12Surface.cpp` on `master`. ## Steps - [ ] 1. Write the loader and create an instance and device with validation. - [ ] 2. Add VMA and the surface/swapchain with resize. - [ ] 3. Clear the screen in the surfaces EngineTest on Linux and Windows. - [ ] 4. Add `validation_stats()` and fail a Debug run that reports anything. ## Done when - [ ] The surfaces EngineTest runs on Vulkan on both OSes, validation and sync validation clean; nothing links the Vulkan loader; 0 warnings; tidy 0. ## Claude can help with - Reading validation messages and finding the spec rule they quote. ## Learn - Why loading functions yourself avoids the loader's dispatch and the link dependency.
Sign in to join this conversation.
No assignees
No project
No milestone
Blocks
#32 Vulkan content, uploads and descriptors
UnflavoredMeson/Primal_Plus_Plus
#70 Verify HDR output on Linux with KDE
UnflavoredMeson/Primal_Plus_Plus
Depends on
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
UnflavoredMeson/Primal_Plus_Plus#31
No description provided.