Chronos 0.0
A advanced 2D rendering and animation system
|
Namespaces | |
namespace | FontStructs |
Classes | |
class | Buffer |
Used to store buffers in GPU. More... | |
class | ColorBuffer |
This is a buffer for storing and updating the color of the shape. More... | |
class | ColoredRectangle |
struct | ColorVertex |
This defines the position of a vertex. Used when we need a colored vertex. Does not support textures. More... | |
class | Device |
This initializes, manages and destroys the logical and physical devices(GPU). More... | |
class | Engine |
struct | FontTypes |
The parameters needed for the font style. More... | |
class | Object |
Abstract class for creating and managing generic graphical objects. More... | |
class | ObjectManager |
struct | PipelineAttributes |
Structure defining attributes required for creating a graphics pipeline. More... | |
struct | QueueFamilyIndices |
This is used to check if a given familty supports graphics and presentation. More... | |
class | SwapChain |
struct | SwapChainSupportDetails |
Contains the fields to the support details of a physical device. More... | |
class | Text |
Class for creating a text object for rendering text. More... | |
struct | TextParams |
Parameters for rendering text. More... | |
class | Texture |
This class holds the Vulkan data and objects needed for a texture. More... | |
class | TexturedRectangle |
struct | TexturedVertex |
This defines the position and texture coordinates of a vertex. Used when we need a textured vertex. More... | |
class | TextureManager |
This is the texture manager for Chronos. It handles creation, modification, updating and desrtuction of textures. More... | |
class | UniformBuffer |
This is a Uniform buffer for storing the uniform variables in the shaders. More... | |
struct | UniformBufferObject |
Uniform struct passed to shader. More... | |
struct | UniformColorBufferObject |
Uniform struct for color passed to shader. More... | |
Enumerations | |
enum | ObjectType { TypeTexturedRectangle , TypeColoredRectangle , TypeText } |
Functions | |
VkCommandBuffer | beginSingleTimeCommands (VkCommandPool commandPool, VkDevice device) |
Begins recording of a command buffer that will be used once. | |
void | endSingleTimeCommands (VkCommandBuffer *commandBuffer, Chronos::Engine::Device device, VkCommandPool commandPool) |
Ends recording of single time command buffer and destroys it. | |
uint32_t | findMemoryType (uint32_t typeFilter, VkMemoryPropertyFlags properties, VkPhysicalDevice physicalDevice) |
Finds suitable memory type for given requrements. | |
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. | |
void | copyBuffer (Chronos::Engine::Device device, VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size, VkCommandPool commandPool) |
Copies data from one buffer to another. | |
QueueFamilyIndices | findQueueFamilies (VkPhysicalDevice device, VkSurfaceKHR surface) |
Gets the indices of the needed queue families. | |
VkCommandPool | createCommandPool (Chronos::Engine::Device device, VkSurfaceKHR surface) |
Creates a command pool for a given device and surface. | |
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. | |
std::vector< VkFramebuffer > | createFramebuffer (Chronos::Engine::Device device, Chronos::Engine::SwapChain swapChain, VkRenderPass renderPass, bool msaa) |
Creates a set of framebuffers for use. | |
std::vector< VkCommandBuffer > | createCommandBuffer (Chronos::Engine::Device device, Chronos::Engine::SwapChain swapChain, VkCommandPool commandPool) |
Creates a set of command buffers for use. | |
Chronos::Engine::FontTypes | getFontType (std::string fontType, int fontSize) |
VkExtent2D | chooseSwapExtent (const VkSurfaceCapabilitiesKHR &capabilities, GLFWwindow *window) |
Gets the maximum extent of the swapchain images(framebuffer size). | |
VkSurfaceFormatKHR | chooseSwapSurfaceFormat (const std::vector< VkSurfaceFormatKHR > &availableFormats) |
Chooses the best present mode among the supported modes. | |
SwapChainSupportDetails | querySwapChainSupport (VkPhysicalDevice device, VkSurfaceKHR surface) |
For a given swapchain mode, it gets the capabilites, formats and present modes. | |
void | createTextureSampler (Chronos::Engine::Device device, VkSampler *textureSampler) |
Creates a VkSampler | |
void | createImage (Chronos::Engine::Device device, uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, VkImage *image, VkDeviceMemory *imageMemory, VkSampleCountFlagBits numSamples) |
For a given image dimensons, it creates a VkImage and. | |
void | transitionImageLayout (VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout, VkCommandPool commandPool, Chronos::Engine::Device device) |
Transiton a VkImage from one layout to another. | |
void | copyBufferToImage (VkBuffer buffer, VkImage image, uint32_t width, uint32_t height, VkCommandPool commandPool, Chronos::Engine::Device device) |
Copy data from a buffer to an image. | |
VkImageView | createImageView (Chronos::Engine::Device device, VkFormat format, VkImage image) |
Create a VkImageView for a given VkImage . | |
Variables | |
const std::vector< const char * > | deviceExtensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME } |
THis contain the device extensions that are needed to be enabled in vulkan. | |
Enumerator | |
---|---|
TypeTexturedRectangle | |
TypeColoredRectangle | |
TypeText |
Definition at line 4 of file objectTypes.hpp.
VkCommandBuffer Chronos::Engine::beginSingleTimeCommands | ( | VkCommandPool | commandPool, |
VkDevice | device | ||
) |
Begins recording of a command buffer that will be used once.
This is used to create a temporary commandBuffer for single use and starts recording. Generally used for transfering data to the GPU. After using the buffer, it must be ended and destroyed using endSingleTimeCommands
.
commandPool | The command pool to create the temporary command buffer on. |
device | The device that has the command pool. |
Definition at line 24 of file helper.cpp.
VkExtent2D Chronos::Engine::chooseSwapExtent | ( | const VkSurfaceCapabilitiesKHR & | capabilities, |
GLFWwindow * | window | ||
) |
Gets the maximum extent of the swapchain images(framebuffer size).
We need to calculate the maximum extent of the swapchain. Preferably we want to support the width and height of the window. However the hardware may not support this. Hence after getting the desired height and and width, we clamp it to the hardware limits.
capabilites | The capabailites of the hardware/surface to display the image(max/min height and width) |
window | The GLFW window instance to be rendered to. This contains the desired height and width. |
Definition at line 41 of file swapchain.cpp.
VkSurfaceFormatKHR Chronos::Engine::chooseSwapSurfaceFormat | ( | const std::vector< VkSurfaceFormatKHR > & | availableFormats | ) |
Chooses the best present mode among the supported modes.
It chooses RGBA format along with SRGB for color space. If such a format is not available then it chooses the first one that is available.
availableFormats | The available formats available to choose from. |
Definition at line 26 of file swapchain.cpp.
void Chronos::Engine::copyBuffer | ( | Chronos::Engine::Device | device, |
VkBuffer | srcBuffer, | ||
VkBuffer | dstBuffer, | ||
VkDeviceSize | size, | ||
VkCommandPool | commandPool | ||
) |
Copies data from one buffer to another.
This is used to transfer data between host and device using staging buffers.
device | The device that has the commandPool. |
srcBuffer | The source buffer to copy from. |
dstBuffer | The destination buffer to copy to. |
size | The size of the buffer to copy. |
commandPool | The command pool to create the temporary command buffer on. |
Definition at line 111 of file helper.cpp.
References beginSingleTimeCommands(), Chronos::Engine::Device::device, and endSingleTimeCommands().
void Chronos::Engine::copyBufferToImage | ( | VkBuffer | buffer, |
VkImage | image, | ||
uint32_t | width, | ||
uint32_t | height, | ||
VkCommandPool | commandPool, | ||
Chronos::Engine::Device | device | ||
) |
Copy data from a buffer to an image.
buffer | The buffer to copy data from. |
image | The image to copy data to. |
width | Width of the image. |
height | Height of the image. |
commandPool | The command pool to create the temporary command buffer from. |
device | The device that has the image. |
Definition at line 234 of file texture.cpp.
References beginSingleTimeCommands(), Chronos::Engine::Device::device, and endSingleTimeCommands().
void Chronos::Engine::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.
This function creates a buffer of given size and usage. It then allocates the needed memory for this by finding the needed memory type using findMemoryType
.
device | The device that has the buffer. |
size | The size of the buffer. |
usage | The usage of the buffer. |
properties | The memory property flags of the buffer. |
buffer | The buffer to create. |
bufferMemory | The associcated memory for the buffer. |
Definition at line 78 of file helper.cpp.
References Chronos::Engine::Device::device, findMemoryType(), and Chronos::Engine::Device::physicalDevice.
std::vector< VkCommandBuffer > Chronos::Engine::createCommandBuffer | ( | Chronos::Engine::Device | device, |
Chronos::Engine::SwapChain | swapChain, | ||
VkCommandPool | commandPool | ||
) |
Creates a set of command buffers for use.
This creates the command buffers for a given swap chain on a given command pool. It creates as many command buffers as there are images in the swap chain.
device | The device that has the command pool. |
swapChain | The swap chain to create the command buffers for. |
commandPool | The command pool to create the command buffers on. |
Definition at line 308 of file helper.cpp.
References Chronos::Engine::Device::device, and Chronos::Engine::SwapChain::swapChainImageViews.
VkCommandPool Chronos::Engine::createCommandPool | ( | Chronos::Engine::Device | device, |
VkSurfaceKHR | surface | ||
) |
Creates a command pool for a given device and surface.
device | The device to create the command pool on. |
surface | The surface to which we are rendering. |
Definition at line 157 of file helper.cpp.
References Chronos::Engine::Device::device, findQueueFamilies(), Chronos::Engine::QueueFamilyIndices::graphicsFamily, and Chronos::Engine::Device::physicalDevice.
std::vector< VkFramebuffer > Chronos::Engine::createFramebuffer | ( | Chronos::Engine::Device | device, |
Chronos::Engine::SwapChain | swapChain, | ||
VkRenderPass | renderPass, | ||
bool | msaa | ||
) |
Creates a set of framebuffers for use.
It creates as many framebuffers as there are images in the swap chain.
device | The device that has the swap chain. |
swapChain | The swap chain to create the framebuffers for. |
renderPass | The render pass that the framebuffers are going to be used for. |
msaa | Whether MSAA is enabled or not. This is to attach the necessary MSAA images to the framebuffer. |
Definition at line 276 of file helper.cpp.
References Chronos::Engine::SwapChain::colorImageView, Chronos::Engine::Device::device, Chronos::Engine::Device::msaaSamples, Chronos::Engine::SwapChain::swapChainExtent, and Chronos::Engine::SwapChain::swapChainImageViews.
void Chronos::Engine::createImage | ( | Chronos::Engine::Device | device, |
uint32_t | width, | ||
uint32_t | height, | ||
VkFormat | format, | ||
VkImageTiling | tiling, | ||
VkImageUsageFlags | usage, | ||
VkMemoryPropertyFlags | properties, | ||
VkImage * | image, | ||
VkDeviceMemory * | imageMemory, | ||
VkSampleCountFlagBits | numSamples | ||
) |
For a given image dimensons, it creates a VkImage
and.
for the image.
device | Sevice to create the image on. |
width | Width of the image. |
height | Height of the image. |
format | Format of the image. More information here. |
tiling | Tiling structure of the image. Options are _IMAGE_TILING_OPTIMAL
VK_IMAGE_TILING_LINEAR |
usage | The usage of the image. Common options are _IMAGE_USAGE_SAMPLED_BIT
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT , _IMAGE_USAGE_INPUT_ATTACHMENT_BIT
_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
|
properties | The properties of the image. Common options are _MEMORY_PROPERTY_DEVICE_LOCAL_BIT
_MEMORY_PROPERTY_HOST_VISIBLE_BIT
_MEMORY_PROPERTY_HOST_COHERENT_BIT
_MEMORY_PROPERTY_HOST_CACHED_BIT
|
image | The image to be created. |
imageMemory | The memory for the image to be created. |
numSamples | The number of samples for the image. Common options are _SAMPLE_COUNT_1_BIT
VK_SAMPLE_COUNT_2_BIT , _SAMPLE_COUNT_4_BIT
VK_SAMPLE_COUNT_8_BIT . Generally VK_SAMPLE_COUNT_1_BIT is used unless the image is used with MSAA. |
Definition at line 42 of file texture.cpp.
References Chronos::Engine::Device::device, findMemoryType(), and Chronos::Engine::Device::physicalDevice.
VkImageView Chronos::Engine::createImageView | ( | Chronos::Engine::Device | device, |
VkFormat | format, | ||
VkImage | image | ||
) |
Create a VkImageView
for a given VkImage
.
For each image, we need to create an image view. This is used to specify how the image is to be used.
device | The device that has the image. |
format | The format of the image. |
image | The image to create the image view for. |
Definition at line 255 of file texture.cpp.
References Chronos::Engine::Device::device.
VkRenderPass Chronos::Engine::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.
For a given swap chain, layouts, this creates a render pass. Please carefully read the parameters below before using this function to understand what each parameter does.
During the creation of the render pass, the render pass will transition the image from the initial layout to the final layout. If MSAA is enabled, then the render pass will also transition the image from the final layout to the msaa final layout. The other parameters are also detailed below.
initalLayout | The initial layout of the incoming image. If this from the previous frame(no render pass before it) then this is _IMAGE_LAYOUT_UNDEFINED
_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
finalLayout | The final layout of the outgoing image before MSAA. If this is going to be presented to the screen, then this is _IMAGE_LAYOUT_PRESENT_SRC_KHR
_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL , as then msaaFinalLayout is used for the final layout if this is the final render pass. |
msaaFinalLayout | The final layout of the outgoing image if MSAA is enabled. This is due to the fact that MSAA resolves the image, hence it change the layout of the image. If this is going to be presented to the screen, then this is VK_IMAGE_LAYOUT_PRESENT_SRC_KHR , else it is advised to use VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL . |
msaa | Whether MSAA is enabled or not. |
clearFramebuffer | Whether the framebuffer should be cleared or not. If this is the first render pass, then this should be true. Else it should be false, else the previous contents rendered to the framebuffer from the previous render pass will be cleared. |
dependency | Whether the render pass should wait for other render passes to finish. If there are render passes before this, then this should be true. Else it should be false. |
Definition at line 175 of file helper.cpp.
References Chronos::Engine::Device::device, Chronos::Engine::Device::msaaSamples, and Chronos::Engine::SwapChain::swapChainImageFormat.
void Chronos::Engine::createTextureSampler | ( | Chronos::Engine::Device | device, |
VkSampler * | textureSampler | ||
) |
Creates a VkSampler
device | Device to create the sampler on. |
textureSampler | Sampler to be created. |
Definition at line 278 of file texture.cpp.
References Chronos::Engine::Device::device, and Chronos::Engine::Device::physicalDevice.
void Chronos::Engine::endSingleTimeCommands | ( | VkCommandBuffer * | commandBuffer, |
Chronos::Engine::Device | device, | ||
VkCommandPool | commandPool | ||
) |
Ends recording of single time command buffer and destroys it.
Ends recording of the command buffer and destroys the temporary
created using beginSingleTimeCommands
. Generally used for transfering data.
commandBuffer | The command buffer created by to destroy. |
device | The device that has the command pool. |
commandPool | The command pool that has the command buffer. |
Definition at line 47 of file helper.cpp.
References Chronos::Engine::Device::device, and Chronos::Engine::Device::graphicsQueue.
uint32_t Chronos::Engine::findMemoryType | ( | uint32_t | typeFilter, |
VkMemoryPropertyFlags | properties, | ||
VkPhysicalDevice | physicalDevice | ||
) |
Finds suitable memory type for given requrements.
This is used to find a memory type on the physical device(GPU) that is suitable for the buffer that we are creating. It takes in the
and VkMemoryPropertyFlags
to find such a memory type.
typeFilter | The filter to find the memory type. |
properties | The properties of the memory type. |
physicalDevice | The physical device to find the memory type on. |
Definition at line 63 of file helper.cpp.
Chronos::Engine::QueueFamilyIndices Chronos::Engine::findQueueFamilies | ( | VkPhysicalDevice | device, |
VkSurfaceKHR | surface | ||
) |
Gets the indices of the needed queue families.
It finds the required graphics and presentation queue families on the physical device(GPU). It checks if the given physical device is capable of rendering to the surface that we provide it.
device | The physical device(GPU) to find the queue families on. |
surface | The surface to which we are rendering. |
Definition at line 126 of file helper.cpp.
References Chronos::Engine::QueueFamilyIndices::graphicsFamily, Chronos::Engine::QueueFamilyIndices::isComplete(), and Chronos::Engine::QueueFamilyIndices::presentFamily.
Chronos::Engine::FontTypes Chronos::Engine::getFontType | ( | std::string | fontType, |
int | fontSize | ||
) |
Definition at line 51 of file getFontType.cpp.
References FONT_CASE.
Chronos::Engine::SwapChainSupportDetails Chronos::Engine::querySwapChainSupport | ( | VkPhysicalDevice | device, |
VkSurfaceKHR | surface | ||
) |
For a given swapchain mode, it gets the capabilites, formats and present modes.
For a given device and surface, there are multiple available swapchain modes available for use. This gets those details for further use.
device | The physical device(GPU) on which we are rendering. |
surface | The rendering surface(basically a vulkan window.) |
Definition at line 65 of file swapchain.cpp.
References Chronos::Engine::SwapChainSupportDetails::capabilities, Chronos::Engine::SwapChainSupportDetails::formats, and Chronos::Engine::SwapChainSupportDetails::presentModes.
void Chronos::Engine::transitionImageLayout | ( | VkImage | image, |
VkImageLayout | oldLayout, | ||
VkImageLayout | newLayout, | ||
VkCommandPool | commandPool, | ||
Chronos::Engine::Device | device | ||
) |
Transiton a VkImage
from one layout to another.
Only the following transitions are supported:
VK_IMAGE_LAYOUT_UNDEFINED
to VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
to image | The image to be transitioned. |
oldLayout | The old layout of the image(VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL ). |
newLayout | The new layout of the image(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL or VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL ). |
Definition at line 190 of file texture.cpp.
References beginSingleTimeCommands(), Chronos::Engine::Device::device, and endSingleTimeCommands().
const std::vector<const char*> Chronos::Engine::deviceExtensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME } |
THis contain the device extensions that are needed to be enabled in vulkan.
Definition at line 36 of file device.hpp.