Karma Engine
Loading...
Searching...
No Matches
VulkanRendererAPI.h
1#pragma once
2
3#include "krpch.h"
4
5#include "Karma/Renderer/RendererAPI.h"
6#include "vulkan/vulkan.h"
7
8namespace Karma
9{
10 class VulkanVertexArray;
11 class KARMA_API VulkanRendererAPI : public RendererAPI
12 {
13 public:
15 virtual ~VulkanRendererAPI();
16 virtual void SetClearColor(const glm::vec4& color) override;
17 virtual void Clear() override;
18
19 virtual void BeginScene() override;
20 virtual void DrawIndexed(std::shared_ptr<VertexArray> vertexArray) override;
21 virtual void EndScene() override;
22
23 void AllocateCommandBuffers();
24 void RecordCommandBuffers(VkCommandBuffer commandBuffer, uint32_t imageIndex);
25 void SubmitCommandBuffers();
26 void CreateSynchronicity();
27 void ClearVulkanRendererAPI();
28 void RemoveSynchronicity();
29 void RecreateCommandBuffersPipelineSwapchain();
30 void RecreateCommandBuffersAndSwapChain();
31
32 // Getters. Depending on detailed implementation of other API (such as OpenGL), we may promote the getter to abstract
33 const std::vector<VkCommandBuffer>& GetCommandBuffers() const { return m_commandBuffers; }
34 const int& GetMaxFramesInFlight() const { return MAX_FRAMES_IN_FLIGHT; }
35 const std::vector<VkFence>& GetFences() const { return m_InFlightFences; }
36 const std::vector<VkSemaphore>& GetImageAvailableSemaphores() const { return m_ImageAvailableSemaphores; }
37 const std::vector<VkSemaphore> GetRenderFinishedSemaphore() const { return m_RenderFinishedSemaphores; }
38
39 private:
40 size_t m_CurrentFrame = 0;
41
42 std::vector<VkCommandBuffer> m_commandBuffers;
43 std::vector<std::shared_ptr<VulkanVertexArray>> m_VulkaVertexArrays;
44
45 std::vector<VkSemaphore> m_ImageAvailableSemaphores;
46 std::vector<VkSemaphore> m_RenderFinishedSemaphores;
47 std::vector<VkFence> m_InFlightFences;
48
49 // Number of images (to work upon (CPU side) whilst an image is being rendered (GPU side processing)) + 1
50 // Clearly, MAX_FRAMES_IN_FLIGHT shouldn't exceed m_SwapChainImages.size()
51 const int MAX_FRAMES_IN_FLIGHT = 2;
52
53 bool m_bAllocateCommandBuffers;
54 };
55}
Definition RendererAPI.h:11
Definition VulkanRendererAPI.h:12