KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
VulkanRendererAPI.h
1#pragma once
2
3#include "krpch.h"
4
6#include "vulkan/vulkan.h"
7
8namespace Karma
9{
11 class KARMA_API VulkanRendererAPI : public RendererAPI
12 {
13 public:
14 VulkanRendererAPI();
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
29 void RecordCommandBuffers(VkCommandBuffer commandBuffer, uint32_t imageIndex);
30 void SubmitCommandBuffers();
31 void CreateSynchronicity();
32 void ClearVulkanRendererAPI();
33 void RemoveSynchronicity();
34 void RecreateCommandBuffersPipelineSwapchain();
35 void RecreateCommandBuffersAndSwapChain();
36
37 // Getters. Depending on detailed implementation of other API (such as OpenGL), we may promote the getter to abstract
38 const std::vector<VkCommandBuffer>& GetCommandBuffers() const { return m_commandBuffers; }
39 const int& GetMaxFramesInFlight() const { return MAX_FRAMES_IN_FLIGHT; }
40 const std::vector<VkFence>& GetFences() const { return m_InFlightFences; }
41 const std::vector<VkSemaphore>& GetImageAvailableSemaphores() const { return m_ImageAvailableSemaphores; }
42 const std::vector<VkSemaphore> GetRenderFinishedSemaphore() const { return m_RenderFinishedSemaphores; }
43
44 private:
45 size_t m_CurrentFrame = 0;
46
47 std::vector<VkCommandBuffer> m_commandBuffers;
48 std::vector<std::shared_ptr<VulkanVertexArray>> m_VulkaVertexArrays;
49
50 std::vector<VkSemaphore> m_ImageAvailableSemaphores;
51 std::vector<VkSemaphore> m_RenderFinishedSemaphores;
52 std::vector<VkFence> m_InFlightFences;
53
54 // Number of images (to work upon (CPU side) whilst an image is being rendered (GPU side processing)) + 1
55 // Clearly, MAX_FRAMES_IN_FLIGHT shouldn't exceed m_SwapChainImages.size()
56 const int MAX_FRAMES_IN_FLIGHT = 2;
57
58 bool m_bAllocateCommandBuffers;
59 };
60}
#define KARMA_API
Defining Karma's API macro for storage class information.
Definition Core.h:41
This file contains the class RendererAPI.
An abstract class for a renderer.
Definition RendererAPI.h:23
virtual void DrawIndexed(std::shared_ptr< VertexArray > vertexArray) override
Routine for drawing primitives.
Definition VulkanRendererAPI.cpp:262
virtual void Clear() override
Clear the rendering screen.
Definition VulkanRendererAPI.cpp:32
virtual void SetClearColor(const glm::vec4 &color) override
Set the color to be used for clear (rendering) screen.
Definition VulkanRendererAPI.cpp:27
virtual void EndScene() override
Instructions for end of the scene.
Definition VulkanRendererAPI.cpp:112
void AllocateCommandBuffers()
Allocates resources for command buffers. Command buffers are objects used to record commands which ca...
Definition VulkanRendererAPI.cpp:46
virtual void BeginScene() override
Setting up resources for rendering of a scene.
Definition VulkanRendererAPI.cpp:36
Definition VulkanVertexArray.h:12