Hid Vulkan helper structs

This commit is contained in:
Pasha Bibko
2025-11-17 15:14:09 +00:00
parent cfce4b3069
commit c3924b05c1
4 changed files with 30 additions and 27 deletions

1
.idea/editor.xml generated
View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="BackendCodeEditorSettings"> <component name="BackendCodeEditorSettings">
<option name="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=6EF66A4B_002D3E31_002D529B_002D8F75_002D540403659512_002Fd_003Asrc_002Fd_003Amanagers_002Fd_003Avulkan_002Ff_003AVulkanManagerRender_002Ecpp/@EntryIndexedValue" value="ForceIncluded" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CDeclarationWithImplicitIntType/@EntryIndexedValue" value="WARNING" type="string" /> <option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CDeclarationWithImplicitIntType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" /> <option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConstevalIfIsAlwaysConstant/@EntryIndexedValue" value="WARNING" type="string" /> <option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConstevalIfIsAlwaysConstant/@EntryIndexedValue" value="WARNING" type="string" />

View File

@@ -4,28 +4,6 @@
namespace PB::Renderer namespace PB::Renderer
{ {
struct QueueFamilyIndices
{
static constexpr uint32_t UNDEFINED_UINT32_VALUE = 0xFFFFFFFF;
uint32_t graphicsFamily = UNDEFINED_UINT32_VALUE;
uint32_t presentFamily = UNDEFINED_UINT32_VALUE;
[[nodiscard]] bool Complete() const
{
return
graphicsFamily != UNDEFINED_UINT32_VALUE &&
presentFamily != UNDEFINED_UINT32_VALUE;
}
};
struct SwapChainSupportDetails
{
VkSurfaceCapabilitiesKHR capabilities;
std::vector<VkSurfaceFormatKHR> formats;
std::vector<VkPresentModeKHR> presentModes;
};
class VulkanManager class VulkanManager
{ {
public: public:
@@ -111,6 +89,30 @@ namespace PB::Renderer
static bool RenderPass(GLFWwindow* window); static bool RenderPass(GLFWwindow* window);
private: private:
// === Internal helper structs === //
struct QueueFamilyIndices
{
static constexpr uint32_t UNDEFINED_UINT32_VALUE = 0xFFFFFFFF;
uint32_t graphicsFamily = UNDEFINED_UINT32_VALUE;
uint32_t presentFamily = UNDEFINED_UINT32_VALUE;
[[nodiscard]] bool Complete() const
{
return
graphicsFamily != UNDEFINED_UINT32_VALUE &&
presentFamily != UNDEFINED_UINT32_VALUE;
}
};
struct SwapChainSupportDetails
{
VkSurfaceCapabilitiesKHR capabilities;
std::vector<VkSurfaceFormatKHR> formats;
std::vector<VkPresentModeKHR> presentModes;
};
// === Vulkan init helpers === // // === Vulkan init helpers === //
static bool IsDeviceSuitable(const VkPhysicalDevice& device); static bool IsDeviceSuitable(const VkPhysicalDevice& device);

View File

@@ -6,7 +6,7 @@ namespace PB::Renderer
VkSurfaceKHR VulkanManager::s_Surface = VK_NULL_HANDLE; VkSurfaceKHR VulkanManager::s_Surface = VK_NULL_HANDLE;
VkPhysicalDevice VulkanManager::s_PhysicalDevice = VK_NULL_HANDLE; VkPhysicalDevice VulkanManager::s_PhysicalDevice = VK_NULL_HANDLE;
QueueFamilyIndices VulkanManager::s_QueueIndices; VulkanManager::QueueFamilyIndices VulkanManager::s_QueueIndices;
VkDevice VulkanManager::s_Device = VK_NULL_HANDLE; VkDevice VulkanManager::s_Device = VK_NULL_HANDLE;
@@ -195,7 +195,7 @@ namespace PB::Renderer
return indices.Complete() && swapChainAdequate && discreteGPU; return indices.Complete() && swapChainAdequate && discreteGPU;
} }
QueueFamilyIndices VulkanManager::FindQueueFamilies(const VkPhysicalDevice& device) VulkanManager::QueueFamilyIndices VulkanManager::FindQueueFamilies(const VkPhysicalDevice& device)
{ {
QueueFamilyIndices indices; QueueFamilyIndices indices;
@@ -361,7 +361,7 @@ namespace PB::Renderer
return true; return true;
} }
SwapChainSupportDetails VulkanManager::QuerySwapChainSupport() VulkanManager::SwapChainSupportDetails VulkanManager::QuerySwapChainSupport()
{ {
SwapChainSupportDetails details; SwapChainSupportDetails details;
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(s_PhysicalDevice, s_Surface, &details.capabilities); vkGetPhysicalDeviceSurfaceCapabilitiesKHR(s_PhysicalDevice, s_Surface, &details.capabilities);

View File

@@ -45,7 +45,7 @@ namespace PB::Renderer
void VulkanManager::CleanupSwapChain() void VulkanManager::CleanupSwapChain()
{ {
for (const VkFramebuffer framebuffer : s_Framebuffers) for (const VkFramebuffer& framebuffer : s_Framebuffers)
{ {
vkDestroyFramebuffer(s_Device, framebuffer, nullptr); vkDestroyFramebuffer(s_Device, framebuffer, nullptr);
} }
@@ -56,7 +56,7 @@ namespace PB::Renderer
vkDestroyPipelineLayout(s_Device, s_PipelineLayout, nullptr); vkDestroyPipelineLayout(s_Device, s_PipelineLayout, nullptr);
vkDestroyRenderPass(s_Device, s_RenderPass, nullptr); vkDestroyRenderPass(s_Device, s_RenderPass, nullptr);
for (const VkImageView view : s_SwapChainImageViews) for (const VkImageView& view : s_SwapChainImageViews)
{ {
vkDestroyImageView(s_Device, view, nullptr); vkDestroyImageView(s_Device, view, nullptr);
} }