-
Notifications
You must be signed in to change notification settings - Fork 0
/
VulkanRenderer.h
88 lines (67 loc) · 2.17 KB
/
VulkanRenderer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <iostream>
#include <stdexcept>
#include <vector>
#include <set>
#include <algorithm>
#include <array>
#include "Utilities.h"
class VulkanRenderer
{
public:
VulkanRenderer();
int init(GLFWwindow* newWindow);
void cleanup();
~VulkanRenderer();
private:
GLFWwindow* window;
VkInstance instance;
VkDebugUtilsMessengerEXT debugMessenger;
struct {
VkPhysicalDevice physicalDevice;
VkDevice logicalDevice;
} mainDevice;
VkQueue graphicsQueue;
VkQueue presentationQueue;
VkSurfaceKHR surface;
VkSwapchainKHR swapchain;
std::vector<SwapchainImage> swapChainImages;
std::vector<VkFramebuffer> swapChainFramebuffers;
std::vector<VkCommandBuffer> commandBuffers;
VkPipeline graphicsPipeline;
VkPipelineLayout pipelineLayout;
VkRenderPass renderPass;
VkCommandPool graphicsCommandPool;
VkFormat swapChainImageFormat;
VkExtent2D swapChainExtent;
void createInstance();
void setupDebugMessenger();
void createLogicalDevice();
void createSurface();
void createSwapChain();
void createRenderPass();
void createGraphicsPipeline();
void createFramebuffers();
void createCommandPool();
void createCommandBuffers();
void recordCommands();
void getPhysicalDevice();
bool checkValidationLayerSupport(std::vector<const char*>* checkLayers);
bool checkInstanceExtensionSupport(std::vector<const char*>* checkExtensions);
bool checkDeviceExtensionSupport(VkPhysicalDevice device);
bool checkDeviceSuitable(VkPhysicalDevice device);
QueueFamilyIndices getQueueFamilies(VkPhysicalDevice device);
SwapChainDetails getSwapChainDetails(VkPhysicalDevice device);
VkSurfaceFormatKHR chooseBestSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& formats);
VkPresentModeKHR chooseBestPresentationMode(const std::vector<VkPresentModeKHR>& presentationModes);
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& surfaceCapabilities);
VkImageView createImageView(VkImage image, VkFormat format, VkImageAspectFlags aspectFlags);
VkShaderModule createShaderModule(const std::vector<char>& code);
#ifdef NDEBUG
const bool enableValidationLayers = false;
#else
const bool enableValidationLayers = true;
#endif
};