Vulkan学习笔记7—分层重构

一、Vulkan对象封装 VkContext.h

#pragma once
#define GLFW_INCLUDE_VULKAN
#include 
#include 
#include 
#include 

namespace renderer {
    struct QueueFamilyIndices {
        std::optional graphicsFamily;
        std::optional presentFamily;
        bool sameFamily = false;  // 标记是否为同一队列族

        bool isComplete() { return graphicsFamily.has_value() && presentFamily.has_value(); }
    };

    struct SwapChainSupportDetails {
        VkSurfaceCapabilitiesKHR capabilities;
        std::vector formats;
        std::vector presentModes;
    };

    struct VkContext {
        GLFWwindow* window;
        VkInstance instance;
        VkDebugUtilsMessengerEXT debugMessenger;
        VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
        VkDevice device;
        QueueFamilyIndices queueFamilyIndices;
        VkQueue graphicsQueue;
        VkQueue presentQueue;
        uint32_t currentFrame = 0;
        VkSurfaceKHR surface;
        VkSwapchainKHR swapChain;
        std::vector swapChainImages;
        VkFormat swapChainImageFormat;
        VkExtent2D swapChainExtent;
        std::vector swapChainImageViews;
        VkRenderPass renderPass;
        VkPipelineLayout pipelineLayout;
        VkPipeline graphicsPi

你可能感兴趣的:(学习,笔记,重构)