Chronos 0.0
A advanced 2D rendering and animation system
Loading...
Searching...
No Matches
helper.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2024 Rahul Satish Vadhyar
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
21*/
22
23#pragma once
30#include <optional>
31#include "swapchain.hpp"
32namespace Chronos {
33namespace Engine {
34
45 std::optional<uint32_t> graphicsFamily;
46 std::optional<uint32_t> presentFamily;
48 {
49 return graphicsFamily.has_value() && presentFamily.has_value();
50 }
51 };
52
66 VkCommandBuffer beginSingleTimeCommands(
67 VkCommandPool commandPool, VkDevice device);
68
81 void endSingleTimeCommands(VkCommandBuffer* commandBuffer,
82 Chronos::Engine::Device device, VkCommandPool commandPool);
83
97 uint32_t findMemoryType(uint32_t typeFilter,
98 VkMemoryPropertyFlags properties, VkPhysicalDevice physicalDevice);
99
114 void createBuffer(Chronos::Engine::Device device, VkDeviceSize size,
115 VkBufferUsageFlags usage, VkMemoryPropertyFlags properties,
116 VkBuffer* buffer, VkDeviceMemory* bufferMemory);
117
130 void copyBuffer(Chronos::Engine::Device device, VkBuffer srcBuffer,
131 VkBuffer dstBuffer, VkDeviceSize size, VkCommandPool commandPool);
132
143 QueueFamilyIndices findQueueFamilies(
144 VkPhysicalDevice device, VkSurfaceKHR surface);
145
154 VkCommandPool createCommandPool(
155 Chronos::Engine::Device device, VkSurfaceKHR surface);
156
199 VkRenderPass createRenderPass(Chronos::Engine::Device device,
200 Chronos::Engine::SwapChain swapChain, VkImageLayout initalLayout,
201 VkImageLayout finalLayout, VkImageLayout msaaFinalLayout, bool msaa,
202 bool clearFramebuffer, bool dependency);
203
216 std::vector<VkFramebuffer> createFramebuffer(Chronos::Engine::Device device,
217 Chronos::Engine::SwapChain swapChain, VkRenderPass renderPass,
218 bool msaa);
232 std::vector<VkCommandBuffer> createCommandBuffer(
234 VkCommandPool commandPool);
235};
236};
This initializes, manages and destroys the logical and physical devices(GPU).
Definition device.hpp:47
VkCommandBuffer beginSingleTimeCommands(VkCommandPool commandPool, VkDevice device)
Begins recording of a command buffer that will be used once.
Definition helper.cpp:24
std::vector< VkFramebuffer > createFramebuffer(Chronos::Engine::Device device, Chronos::Engine::SwapChain swapChain, VkRenderPass renderPass, bool msaa)
Creates a set of framebuffers for use.
Definition helper.cpp:276
std::vector< VkCommandBuffer > createCommandBuffer(Chronos::Engine::Device device, Chronos::Engine::SwapChain swapChain, VkCommandPool commandPool)
Creates a set of command buffers for use.
Definition helper.cpp:308
void endSingleTimeCommands(VkCommandBuffer *commandBuffer, Chronos::Engine::Device device, VkCommandPool commandPool)
Ends recording of single time command buffer and destroys it.
Definition helper.cpp:47
VkRenderPass createRenderPass(Chronos::Engine::Device device, Chronos::Engine::SwapChain swapChain, VkImageLayout initalLayout, VkImageLayout finalLayout, VkImageLayout msaaFinalLayout, bool msaa, bool clearFramebuffer, bool dependency)
Creates a render pass.
Definition helper.cpp:175
uint32_t findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties, VkPhysicalDevice physicalDevice)
Finds suitable memory type for given requrements.
Definition helper.cpp:63
QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface)
Gets the indices of the needed queue families.
Definition helper.cpp:126
void createBuffer(Chronos::Engine::Device device, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer *buffer, VkDeviceMemory *bufferMemory)
Creates a buffer of a given size, usage and properties.
Definition helper.cpp:78
void copyBuffer(Chronos::Engine::Device device, VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size, VkCommandPool commandPool)
Copies data from one buffer to another.
Definition helper.cpp:111
VkCommandPool createCommandPool(Chronos::Engine::Device device, VkSurfaceKHR surface)
Creates a command pool for a given device and surface.
Definition helper.cpp:157
This is used to check if a given familty supports graphics and presentation.
Definition helper.hpp:44
std::optional< uint32_t > presentFamily
Definition helper.hpp:46
std::optional< uint32_t > graphicsFamily
Definition helper.hpp:45
Contains the swapChain class along with all the swapChain related functions.