Refactor: Vulkan: Move code from header to compile unit

!139630 requires the implementation to be part of the compile
unit.
This commit is contained in:
Jeroen Bakker
2025-06-03 10:39:47 +02:00
parent 9bbcbd06e8
commit aa8c56935e
2 changed files with 39 additions and 27 deletions

View File

@@ -115,6 +115,42 @@ static bool contains_extension(const vector<VkExtensionProperties> &extension_li
return false;
};
/* -------------------------------------------------------------------- */
/** \name Swapchain resources
* \{ */
void GHOST_SwapchainImage::destroy(VkDevice vk_device)
{
vkDestroySemaphore(vk_device, present_semaphore, nullptr);
present_semaphore = VK_NULL_HANDLE;
vk_image = VK_NULL_HANDLE;
}
void GHOST_FrameDiscard::destroy(VkDevice vk_device)
{
while (!swapchains.empty()) {
VkSwapchainKHR vk_swapchain = swapchains.back();
swapchains.pop_back();
vkDestroySwapchainKHR(vk_device, vk_swapchain, nullptr);
}
while (!semaphores.empty()) {
VkSemaphore vk_semaphore = semaphores.back();
semaphores.pop_back();
vkDestroySemaphore(vk_device, vk_semaphore, nullptr);
}
}
void GHOST_Frame::destroy(VkDevice vk_device)
{
vkDestroyFence(vk_device, submission_fence, nullptr);
submission_fence = VK_NULL_HANDLE;
vkDestroySemaphore(vk_device, acquire_semaphore, nullptr);
acquire_semaphore = VK_NULL_HANDLE;
discard_pile.destroy(vk_device);
}
/* \} */
/* -------------------------------------------------------------------- */
/** \name Vulkan Device
* \{ */

View File

@@ -62,19 +62,7 @@ struct GHOST_FrameDiscard {
std::vector<VkSwapchainKHR> swapchains;
std::vector<VkSemaphore> semaphores;
void destroy(VkDevice vk_device)
{
while (!swapchains.empty()) {
VkSwapchainKHR vk_swapchain = swapchains.back();
swapchains.pop_back();
vkDestroySwapchainKHR(vk_device, vk_swapchain, nullptr);
}
while (!semaphores.empty()) {
VkSemaphore vk_semaphore = semaphores.back();
semaphores.pop_back();
vkDestroySemaphore(vk_device, vk_semaphore, nullptr);
}
}
void destroy(VkDevice vk_device);
};
struct GHOST_SwapchainImage {
@@ -86,12 +74,7 @@ struct GHOST_SwapchainImage {
*/
VkSemaphore present_semaphore = VK_NULL_HANDLE;
void destroy(VkDevice vk_device)
{
vkDestroySemaphore(vk_device, present_semaphore, nullptr);
present_semaphore = VK_NULL_HANDLE;
vk_image = VK_NULL_HANDLE;
}
void destroy(VkDevice vk_device);
};
struct GHOST_Frame {
@@ -105,14 +88,7 @@ struct GHOST_Frame {
GHOST_FrameDiscard discard_pile;
void destroy(VkDevice vk_device)
{
vkDestroyFence(vk_device, submission_fence, nullptr);
submission_fence = VK_NULL_HANDLE;
vkDestroySemaphore(vk_device, acquire_semaphore, nullptr);
acquire_semaphore = VK_NULL_HANDLE;
discard_pile.destroy(vk_device);
}
void destroy(VkDevice vk_device);
};
/**