Karma Engine
Loading...
Searching...
No Matches
VulkanVertexArray.h
1#pragma once
2
3#include "Karma/Renderer/VertexArray.h"
4#include "vulkan/vulkan.h"
5#include "Platform/Vulkan/VulkanBuffer.h"
6#include "Karma/Renderer/Shader.h"
7#include "Platform/Vulkan/VulkanShader.h"
8
9namespace Karma
10{
11 class KARMA_API VulkanVertexArray : public VertexArray, std::enable_shared_from_this<VulkanVertexArray>
12 {
13 public:
15 virtual ~VulkanVertexArray();
16
17 virtual void Bind() const override;
18 virtual void UnBind() const override {}
19
20 virtual void AddVertexBuffer(const std::shared_ptr<VertexBuffer>& vertexBuffer) override;
21 virtual void SetIndexBuffer(const std::shared_ptr<IndexBuffer>& indexBuffer) override;
22
23 virtual void SetMesh(std::shared_ptr<Mesh> mesh) override;
24
25 virtual void SetMaterial(std::shared_ptr<Material> material) override;
26
27 virtual void SetShader(std::shared_ptr<Shader> shader) override;
28
29 void CreateDescriptorSetLayout();
30 void CreatePipelineLayout();
31 void CreateGraphicsPipeline();
32 void CreateDescriptorPool();
33 void CreateDescriptorSets();
34
35 void CreateExternalViewPort(float startX, float startY, float width, float height);
36
37 //void CreateCommandBuffers();
38
39 void GenerateVulkanVA();
40
41 void RecreateVulkanVA();
42 void CleanupPipeline();
43
44 // Helper functions
45 VkShaderModule CreateShaderModule(const std::vector<uint32_t>& code);
46
47 // Getters
48 VkPipeline GetGraphicsPipeline() const { return m_graphicsPipeline; }
49 VkPipelineLayout GetGraphicsPipelineLayout() const { return m_pipelineLayout; }
50 const std::shared_ptr<VulkanShader>& GetShader() const { return m_Shader; }
51 //const std::vector<VkDescriptorSet>& GetUBDescriptorSets() const { return m_descriptorSets; }
52 const std::shared_ptr<VulkanVertexBuffer>& GetVertexBuffer() const { return m_VertexBuffer; }
53 const std::vector<VkDescriptorSet>& GetDescriptorSets() const { return m_descriptorSets; }
54
55 virtual std::shared_ptr<Material> GetMaterial() const override { return m_Materials.at(0); }
56
57 virtual void UpdateProcessAndSetReadyForSubmission() const override;
58
59 // Overrides
60 virtual const std::vector<std::shared_ptr<VertexBuffer>>& GetVertexBuffers() const override { return m_VertexBuffers; }
61 virtual const VulkanIndexBuffer* GetIndexBuffer() const override { return m_IndexBuffer.get(); }
62
63 private:
64 // May need to consider batching for components of Meshes and Materials
65
66 // Mesh relevant members
67 std::vector<std::shared_ptr<VertexBuffer>> m_VertexBuffers;
68 std::shared_ptr<VulkanVertexBuffer> m_VertexBuffer;
69 std::shared_ptr<VulkanIndexBuffer> m_IndexBuffer;
70
71 // Material relevant members
72 std::vector<std::shared_ptr<Material>> m_Materials;
73 std::vector<std::shared_ptr<VulkanShader>> m_Shaders;
74 std::shared_ptr<VulkanShader> m_Shader;
75
76 VkDevice m_device;
77
78 VkPipelineLayout m_pipelineLayout;
79 VkDescriptorSetLayout m_descriptorSetLayout;
80
81 VkPipeline m_graphicsPipeline;
82 VkDescriptorPool m_descriptorPool;
83 std::vector<VkDescriptorSet> m_descriptorSets;
84
85 VkVertexInputBindingDescription m_bindingDescription{};
86 std::vector<VkVertexInputAttributeDescription> m_attributeDescriptions;
87
88 const VkPhysicalDeviceFeatures& m_SupportedDeviceFeatures;
89
90 VkViewport m_ExternalViewPort;
91 bool m_UseExternalViewPort;
92 };
93
94}
Definition VertexArray.h:13
Definition VulkanBuffer.h:48
Definition VulkanVertexArray.h:12