| 1 | #ifndef _GRAPHICS_PIPELINE_VULKAN_H
|
|---|
| 2 | #define _GRAPHICS_PIPELINE_VULKAN_H
|
|---|
| 3 |
|
|---|
| 4 | #include "graphics-pipeline.hpp"
|
|---|
| 5 |
|
|---|
| 6 | #include <vector>
|
|---|
| 7 |
|
|---|
| 8 | #include <vulkan/vulkan.h>
|
|---|
| 9 |
|
|---|
| 10 | // TODO: Maybe change the name of this struct so I can call the list something other than descriptorInfoList
|
|---|
| 11 | struct DescriptorInfo {
|
|---|
| 12 | VkDescriptorType type;
|
|---|
| 13 | VkShaderStageFlags stageFlags;
|
|---|
| 14 |
|
|---|
| 15 | // Only one of the below properties should be set
|
|---|
| 16 | vector<VkDescriptorBufferInfo>* bufferDataList;
|
|---|
| 17 | VkDescriptorImageInfo* imageData;
|
|---|
| 18 | };
|
|---|
| 19 |
|
|---|
| 20 | class GraphicsPipeline_Vulkan : public GraphicsPipeline {
|
|---|
| 21 | public:
|
|---|
| 22 | GraphicsPipeline_Vulkan(VkDevice device, VkRenderPass renderPass, Viewport viewport, int vertexSize);
|
|---|
| 23 | ~GraphicsPipeline_Vulkan();
|
|---|
| 24 |
|
|---|
| 25 | // Maybe I should rename these to addVertexAttribute (addVaryingAttribute) and addUniformAttribute
|
|---|
| 26 |
|
|---|
| 27 | void addAttribute(VkFormat format, size_t offset);
|
|---|
| 28 |
|
|---|
| 29 | void addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, vector<VkDescriptorBufferInfo>* bufferData);
|
|---|
| 30 | void addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, VkDescriptorImageInfo* imageData);
|
|---|
| 31 |
|
|---|
| 32 | void createPipeline(string vertShaderFile, string fragShaderFile);
|
|---|
| 33 | void createDescriptorSetLayout();
|
|---|
| 34 | void createDescriptorPool(vector<VkImage>& swapChainImages);
|
|---|
| 35 | void createDescriptorSets(vector<VkImage>& swapChainImages);
|
|---|
| 36 |
|
|---|
| 37 | void cleanup();
|
|---|
| 38 | void cleanupBuffers();
|
|---|
| 39 |
|
|---|
| 40 | private:
|
|---|
| 41 | VkShaderModule createShaderModule(const vector<char>& code);
|
|---|
| 42 | vector<char> readFile(const string& filename);
|
|---|
| 43 |
|
|---|
| 44 | VkDevice device;
|
|---|
| 45 | VkRenderPass renderPass;
|
|---|
| 46 |
|
|---|
| 47 | VkPipeline pipeline;
|
|---|
| 48 | VkPipelineLayout pipelineLayout;
|
|---|
| 49 |
|
|---|
| 50 | VkVertexInputBindingDescription bindingDescription;
|
|---|
| 51 |
|
|---|
| 52 | vector<VkVertexInputAttributeDescription> attributeDescriptions;
|
|---|
| 53 | vector<DescriptorInfo> descriptorInfoList;
|
|---|
| 54 |
|
|---|
| 55 | VkDescriptorSetLayout descriptorSetLayout;
|
|---|
| 56 | VkDescriptorPool descriptorPool;
|
|---|
| 57 | vector<VkDescriptorSet> descriptorSets;
|
|---|
| 58 | };
|
|---|
| 59 |
|
|---|
| 60 | #endif // _GRAPHICS_PIPELINE_VULKAN_H
|
|---|