파일 분리, 셰이더 로드까지 수강.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "glfw/glfw_window.h"
|
||||
#include "precomp.h"
|
||||
|
||||
namespace veng {
|
||||
class Graphics final {
|
||||
@@ -9,9 +10,33 @@ class Graphics final {
|
||||
Graphics(gsl::not_null<Window *> window);
|
||||
~Graphics();
|
||||
|
||||
private:
|
||||
struct QueueFamilyIndices {
|
||||
std::optional<std::uint32_t> graphics_family = std::nullopt;
|
||||
std::optional<std::uint32_t> presentation_family = std::nullopt;
|
||||
|
||||
bool IsValid() const {
|
||||
return graphics_family.has_value() && presentation_family.has_value();
|
||||
}
|
||||
};
|
||||
|
||||
struct SwapChainProperties {
|
||||
VkSurfaceCapabilitiesKHR capabilities;
|
||||
std::vector<VkSurfaceFormatKHR> formats;
|
||||
std::vector<VkPresentModeKHR> present_modes;
|
||||
|
||||
bool IsValid() const { return !formats.empty() && !present_modes.empty(); }
|
||||
};
|
||||
|
||||
void InitializeVulkan();
|
||||
void CreateInstance();
|
||||
void SetupDebugMessenger();
|
||||
void PickPhysicalDevice();
|
||||
void CreateLogicalDeviceAndQueues();
|
||||
void CreateSurface();
|
||||
void CreateSwapChain();
|
||||
void CreateImageViews();
|
||||
void CreateGraphicsPipeline();
|
||||
|
||||
std::vector<gsl::czstring> GetRequiredInstanceExtentions();
|
||||
|
||||
@@ -22,9 +47,48 @@ class Graphics final {
|
||||
static std::vector<VkLayerProperties> GetSupprotedValidationLayers();
|
||||
static bool AreAllLayersSupported(gsl::span<gsl::czstring> extensions);
|
||||
|
||||
VkInstance instance_ = nullptr;
|
||||
QueueFamilyIndices FindQueueFamilies(VkPhysicalDevice device);
|
||||
SwapChainProperties GetSwapChainProperties(VkPhysicalDevice device);
|
||||
bool IsDeviceSuitable(VkPhysicalDevice device);
|
||||
std::vector<VkPhysicalDevice> GetAvailableDevices();
|
||||
bool AreAllDeviceExtensionsSupported(VkPhysicalDevice device);
|
||||
std::vector<VkExtensionProperties> GetDeviceAvailableExtensions(
|
||||
VkPhysicalDevice device);
|
||||
|
||||
VkSurfaceFormatKHR ChooseSwapSurfaceFormat(
|
||||
gsl::span<VkSurfaceFormatKHR> formats);
|
||||
VkPresentModeKHR ChooseSwapPresentMode(
|
||||
gsl::span<VkPresentModeKHR> present_modes);
|
||||
VkExtent2D ChooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities);
|
||||
std::uint32_t ChooseSwapImageCount(const VkSurfaceCapabilitiesKHR& capabilities);
|
||||
|
||||
VkShaderModule CreateShaderModule(gsl::span<std::uint8_t> buffer);
|
||||
|
||||
std::array<gsl::czstring, 1> required_device_extentions_ = {
|
||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME};
|
||||
|
||||
VkInstance instance_ = VK_NULL_HANDLE;
|
||||
VkDebugUtilsMessengerEXT debug_messenger_;
|
||||
|
||||
VkPhysicalDevice physical_device_ = VK_NULL_HANDLE;
|
||||
VkDevice logical_device_ = VK_NULL_HANDLE;
|
||||
VkQueue graphics_queue_ = VK_NULL_HANDLE;
|
||||
VkQueue present_queue_ = VK_NULL_HANDLE;
|
||||
|
||||
VkSurfaceKHR surface_ = VK_NULL_HANDLE;
|
||||
VkSwapchainKHR swap_chain_ = VK_NULL_HANDLE;
|
||||
VkSurfaceFormatKHR surface_format_;
|
||||
VkPresentModeKHR present_mode_;
|
||||
VkExtent2D extent_;
|
||||
std::vector<VkImage> swap_chain_images_;
|
||||
std::vector<VkImageView> swap_chain_image_views_;
|
||||
|
||||
gsl::not_null<Window *> window_;
|
||||
bool validation_enabled_ = false;
|
||||
};
|
||||
|
||||
VkDebugUtilsMessengerCreateInfoEXT GetCreateMessengerInfo();
|
||||
bool IsExtensionSupported(gsl::span<VkExtensionProperties> extensions,
|
||||
gsl::czstring name);
|
||||
|
||||
} // namespace veng
|
||||
|
||||
Reference in New Issue
Block a user