Files
face_sdk/vulkan/Application.h
T

82 lines
2.6 KiB
C++

#pragma once
#include "AppBase.h"
class Application : public AppBase
{
public:
void run();
void initVulkan();
void initWindow();
void createSurface();
void mainLoop();
void cleanup();
void createImages();
void createImageViews();
void createFramebuffers();
void createCommandPool();
void createCommandBuffer();
void createLogicalDevice();
void createSwapChain();
void createPipelineLayout();
void createGraphicsPipeline();
void createRenderPass();
void recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex);
void createSyncObjects();
void drawFrame();
void drawLeft();
void drawRight();
bool isInited() { return inited; }
private:
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; // 物理设备
VkDevice device; // 逻辑设备
VkQueue graphicsQueue; // 图形队列
VkSurfaceKHR surface; // 窗口表面
VkSwapchainKHR swapChain; // 交换链
std::vector<VkImage> swapChainImages; // 交换链图像
VkFormat swapChainImageFormat; // 交换链图像格式
VkExtent2D swapChainExtent; // 交换链图像分辨率
std::vector<VkImageView> swapChainImageViews; // 交换链图像视图
VkRenderPass renderPass; // 渲染流程
VkPipelineLayout pipelineLayout; // 管线布局
VkPipeline graphicsPipeline; // 图形管线
std::vector<VkFramebuffer> swapChainFramebuffers; // 帧缓冲区
VkQueue presentQueue; // 呈现队列
VkCommandPool commandPool;
VkCommandBuffer commandBuffers_Left;
VkCommandBuffer commandBuffers_Right;
VkSemaphore imageAvailableSemaphores_Left;
VkSemaphore imageAvailableSemaphores_Right;
VkSemaphore renderFinishedSemaphores_Left;
VkSemaphore renderFinishedSemaphores_Right;
VkFence inFlightFences_Left;
VkFence inFlightFences_Right;
VkFence imagesInFlight_Left = VK_NULL_HANDLE;
VkFence imagesInFlight_Right = VK_NULL_HANDLE;
const bool showDrawDebug = false;
int currentFrame = 0;
bool inited = false;
//MSAA
VkImage colorImage;
VkDeviceMemory colorImageMemory;
VkImageView colorImageView;
void createColorResources();
uint32_t findMemoryType(VkPhysicalDevice physicalDevice, uint32_t typeFilter,
VkMemoryPropertyFlags properties);
};