VulkanContext class

Constructors, destructors, conversion operators

VulkanContext() defaulted
~VulkanContext() defaulted
VulkanContext(const VulkanContext&) deleted

Public functions

auto operator=(const VulkanContext&) -> VulkanContext& deleted
auto Initialize(SDL_Window* window, bool enableValidation = true, PresentPolicy mainPolicy = PresentPolicy::Game) -> bool
Initialize instance -> surface -> device -> swapchain -> command pools.
void Shutdown()
auto RecreateSwapchain(WindowSurface& surface) -> bool
Recreate a window's swapchain after resize. Waits for the device and destroys the old one first.
auto HasArea(const WindowSurface& surface) const -> bool
False while the window has no pixels to draw into (minimised): no swapchain can be made for it.
auto CreateWindowSurface(SDL_Window* window, PresentPolicy policy) -> WindowSurface*
void DestroyWindowSurface(WindowSurface* surface)
Destroy a window's surface and swapchain (waits for the device). Never the main window.
void SetGamePresentMode(GamePresentMode mode)
Game-window presentation; applies to swapchains created or recreated afterwards.
auto GetGamePresentMode() const -> GamePresentMode
auto GetMainSurface() -> WindowSurface&
auto GetMainSurface() const -> const WindowSurface&
auto GetInstance() const -> VkInstance
auto GetPhysicalDevice() const -> VkPhysicalDevice
auto GetDevice() const -> VkDevice
auto GetSurface() const -> VkSurfaceKHR
auto GetQueues() const -> const VulkanQueues&
auto GetSwapchain() const -> const VulkanSwapchain&
The main window's swapchain.
auto GetGraphicsCommandPool() const -> VkCommandPool
auto GetComputeCommandPool() const -> VkCommandPool
auto GetTransferCommandPool() const -> VkCommandPool
auto GetRaiiDevice() const -> const vk::raii::Device&
Returns the owning raii::Device — needed to create vk::raii:: sync objects in VulkRender.
auto HasReBAR() const -> bool
auto SupportsBufferDeviceAddress() const -> bool
auto SupportsShaderObject() const -> bool
auto SupportsMemoryBudget() const -> bool
VK_EXT_memory_budget: the driver reports each heap's usage and budget.
auto SupportsDynamicRendering() const -> bool
auto SupportsTimelineSemaphore() const -> bool
auto SupportsAsyncCompute() const -> bool
auto SupportsAsyncTransfer() const -> bool
auto SupportsHostImageCopy() const -> bool
auto SupportsPushDescriptors() const -> bool
auto SupportsIndexTypeUint8() const -> bool
auto SupportsPresentWait() const -> bool
VK_KHR_present_id + VK_KHR_present_wait: the time a frame actually reached the screen.
auto GetReBarHeapIndex() const -> uint32_t
auto FindSupportedFormat(const std::vector<VkFormat>& candidates, VkImageTiling tiling, VkFormatFeatureFlags features) const -> VkFormat

Function documentation

void VulkanContext::Shutdown()

Explicit teardown — must be called from TrinyxEngine::Shutdown() so that all vkDestroy* calls happen while the validation layer is still alive. raii members would otherwise be destroyed at atexit(), after validation layer statics are gone, causing a dispatch-handle crash.

WindowSurface* VulkanContext::CreateWindowSurface(SDL_Window* window, PresentPolicy policy)

Create a presentation target for another OS window (surface + swapchain), owned by the context. Fails if the graphics queue can't present to it.

VkFormat VulkanContext::FindSupportedFormat(const std::vector<VkFormat>& candidates, VkImageTiling tiling, VkFormatFeatureFlags features) const

Find a supported image format from the candidates list. Used by VulkRender when selecting depth/render-target formats.