1
0
Fork 0
Univerxel/src/client/render/vk/PhysicalDeviceInfo.hpp

39 lines
1.4 KiB
C++

#pragma once
#include "forward.hpp"
#include "../../../core/utils/logger.hpp"
#include <vector>
#include <optional>
struct GLFWwindow;
namespace render::vk {
struct SwapChainSupportDetails {
VkSurfaceCapabilitiesKHR capabilities;
std::vector<VkSurfaceFormatKHR> formats;
std::vector<VkPresentModeKHR> presentModes;
static SwapChainSupportDetails Query(VkPhysicalDevice, VkSurfaceKHR);
bool isValid() const { return !formats.empty() && !presentModes.empty(); }
};
struct QueueFamilyIndices {
std::optional<uint32_t> graphicsFamily;
std::optional<uint32_t> presentFamily;
std::optional<uint32_t> transferFamily;
static QueueFamilyIndices Query(VkPhysicalDevice, VkSurfaceKHR);
bool isComplete() const { return graphicsFamily.has_value() && presentFamily.has_value(); }
bool isOptimal() const { return isComplete() && transferFamily.has_value(); }
};
struct PhysicalDeviceInfo {
PhysicalDeviceInfo() {}
PhysicalDeviceInfo(GLFWwindow *window, VkPhysicalDevice device, VkSurfaceKHR surface):
window(window), device(device), surface(surface),
swapDetails(SwapChainSupportDetails::Query(device, surface)), queueIndices(QueueFamilyIndices::Query(device, surface)) { }
VkSurfaceFormatKHR getFormat() const;
GLFWwindow *window;
VkPhysicalDevice device = VK_NULL_HANDLE;
VkSurfaceKHR surface;
SwapChainSupportDetails swapDetails;
QueueFamilyIndices queueIndices;
};
}