KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
VulkanVertexArray.h
Go to the documentation of this file.
1
10#pragma once
11
13#include "vulkan/vulkan.h"
17
18namespace Karma
19{
33 class KARMA_API VulkanVertexArray : public VertexArray, std::enable_shared_from_this<VulkanVertexArray>
34 {
35 public:
42
52 virtual ~VulkanVertexArray();
53
54 virtual void Bind() const override;
55 virtual void UnBind() const override {}
56
58
66 virtual void AddVertexBuffer(const std::shared_ptr<VertexBuffer>& vertexBuffer) override;
67
76 virtual void SetIndexBuffer(const std::shared_ptr<IndexBuffer>& indexBuffer) override;
77
86 virtual void SetShader(std::shared_ptr<Shader> shader) override;
87
89
98 virtual void SetMesh(std::shared_ptr<Mesh> mesh) override;
99
107 virtual void SetMaterial(std::shared_ptr<Material> material) override;
108
115 void CreateDescriptorSetLayout();
116
123 void CreatePipelineLayout();
124
131 void CreateGraphicsPipeline();
132
144 void CreateKarmaGuiGraphicsPipeline(VkRenderPass renderPassKG, float windowKGWidth, float windowKGHeight);
145
152 void CreateDescriptorPool();
153
163 void CreateDescriptorSets();
164
179 void GenerateVulkanVA();
180
189 void RecreateVulkanVA();
190
197 void CleanupPipeline();
198
204 void CleanupKarmaGuiGraphicsPipeline();
205
225 VkShaderModule CreateShaderModule(const std::vector<uint32_t>& code);
226
227 // Getters
228 VkPipeline GetGraphicsPipeline() const { return m_graphicsPipeline; }
229 VkPipeline GetKarmaGuiGraphicsPipeline() const { return m_graphicsPipelineKGWindow; }
230 VkPipelineLayout GetGraphicsPipelineLayout() const { return m_pipelineLayout; }
231 const std::shared_ptr<VulkanShader>& GetShader() const { return m_Shader; }
232 //const std::vector<VkDescriptorSet>& GetUBDescriptorSets() const { return m_descriptorSets; }
233 const std::shared_ptr<VulkanVertexBuffer>& GetVertexBuffer() const { return m_VertexBuffer; }
234 const std::vector<VkDescriptorSet>& GetDescriptorSets() const { return m_descriptorSets; }
235
236 virtual std::shared_ptr<Material> GetMaterial() const override { return m_Materials.at(0); }
237
238 virtual void UpdateProcessAndSetReadyForSubmission() const override;
239
241
242 virtual const std::vector<std::shared_ptr<VertexBuffer>>& GetVertexBuffers() const override { return m_VertexBuffers; }
243 virtual const VulkanIndexBuffer* GetIndexBuffer() const override { return m_IndexBuffer.get(); }
244
246 private:
247 // May need to consider batching for components of Meshes and Materials
248
249 // Mesh relevant members
250 std::vector<std::shared_ptr<VertexBuffer>> m_VertexBuffers;
251 std::shared_ptr<VulkanVertexBuffer> m_VertexBuffer;
252 std::shared_ptr<VulkanIndexBuffer> m_IndexBuffer;
253
254 // Material relevant members
255 std::vector<std::shared_ptr<Material>> m_Materials;
256 std::vector<std::shared_ptr<VulkanShader>> m_Shaders;
257 std::shared_ptr<VulkanShader> m_Shader;
258
259 VkDevice m_device;
260
261 VkPipelineLayout m_pipelineLayout;
262 VkDescriptorSetLayout m_descriptorSetLayout;
263
264 VkPipeline m_graphicsPipeline;
265 VkPipeline m_graphicsPipelineKGWindow;
266 VkDescriptorPool m_descriptorPool;
267 std::vector<VkDescriptorSet> m_descriptorSets;
268
269 VkVertexInputBindingDescription m_bindingDescription{};
270 std::vector<VkVertexInputAttributeDescription> m_attributeDescriptions;
271
272 const VkPhysicalDeviceFeatures& m_SupportedDeviceFeatures;
273 };
274
275}
#define KARMA_API
Defining Karma's API macro for storage class information.
Definition Core.h:41
This file contains the Shader class.
This file contains the VertexArray class.
This file contains VulkanVertex/Index/ImageBuffer classes.
This file contains VulkanShader class which contains Vulkan specific implementation of Shader class.
A class, comprising of Mesh and Material substances along with relevant setup, for a renderable unit.
Definition VertexArray.h:25
VulkanVertexArray()
A constructor.
Definition VulkanVertexArray.cpp:8
virtual void Bind() const override
For binding OpenGL vertex array object.
Definition VulkanVertexArray.cpp:19
virtual void UnBind() const override
Undo what Bind does.
Definition VulkanVertexArray.h:55
virtual std::shared_ptr< Material > GetMaterial() const override
Getter function for material.
Definition VulkanVertexArray.h:236