|
| | VulkanUniformBuffer (std::vector< ShaderDataType > dataTypes, uint32_t bindingPointIndex) |
| | Constructor for Vulkan buffer. Calls VulkanUniformBuffer::BufferCreation().
|
| virtual | ~VulkanUniformBuffer () |
| | Destructor. For freeing up UBO resources, use VulkanUniformBuffer::ClearBuffer().
|
| void | CreateBuffer (VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer &buffer, VkDeviceMemory &bufferMemory) |
| | Creates Vulkan buffer (VKbuffer) for ubo use and allocates device memory appropriately.
|
| uint32_t | FindMemoryType (uint32_t typeFilter, VkMemoryPropertyFlags properties) |
| | Finds appropriate memory type with demanded properties. Basically a loop is run from counter i = 0 to VkPhysicalDeviceMemoryProperties.memoryTypeCount (number of valid elements in the memoryTypes array) and memoryType[i] is queried for appropriate properties. On condition satisfaction, counter i is returned.
|
| const std::vector< VkBuffer > & | GetUniformBuffers () const |
| | Getter for the uniform buffers.
|
| void | ClearBuffer () |
| | Frees up the resources by destroying the buffer object(s) and clearing memory.
|
| void | BufferCreation () |
| | Based on MAX_FRAMES_IN_FLIGHT (number of images (to work upon (CPU side) whilst an image is being rendered (GPU side processing)) + 1), uniform buffers are created with appropriate buffer size.
|
| void | UploadUniformBuffer (size_t frameIndex) override |
| | Uploads (copies) the data from buffer memory (m_UniformBuffersMemory) to host-accessible (CPU) pointer, m_UniformList, to the beginning of the mapped range.
|
| | UniformBufferObject (std::vector< ShaderDataType > dataTypes, uint32_t bindingPointIndex) |
| | An agnostic constructor provided for precomputation of offset and buffer size.
|
| virtual | ~UniformBufferObject ()=default |
| | Pure virtual destructor and sub class should have appropriate implementation.
|
| template<typename... T> |
| void | UpdateUniforms (T &&... uniforms) |
| | Set the m_UniformList with latest supplied uniforms.
|
|
uint32_t | GetBufferSize () const |
|
const std::vector< UBODataPointer > & | GetUniformList () const |
|
const std::vector< ShaderDataType > & | GetUniformDataType () const |
|
const std::vector< uint32_t > & | GetAlignedOffsets () const |
|
const std::vector< uint32_t > & | GetUniformSize () const |
|
uint32_t | GetBindingPointIndex () const |
The actual uniform buffer class with implemented function using Vulkan API.
- Since
- Karma 1.0.0
| void Karma::VulkanUniformBuffer::UploadUniformBuffer |
( |
size_t | frameIndex | ) |
|
|
overridevirtual |
Uploads (copies) the data from buffer memory (m_UniformBuffersMemory) to host-accessible (CPU) pointer, m_UniformList, to the beginning of the mapped range.
Basically copies the data from CPU side (uniforms) to GPU side (m_UniformBuffersMemory).
In summary, the process of updating uniform buffers in Vulkan involves the following steps:
- Uniform data is first stored in a CPU-side structure representing the uniform buffer object.
- The memory of the uniform buffer (a VkBuffer) is created with CPU-visible properties and mapped to a CPU pointer.
- The updateUniformBuffer function copies the CPU-side data (like transformation matrices) into the mapped GPU buffer memory via a memcpy call.
- This allows the GPU to read the fresh uniform data every frame during rendering without needing to re-record command buffers.
- Parameters
-
| frameIndex | The m_CurrentFrame index representing index of MAX_FRAMES_IN_FLIGHT (number of images (to work upon (CPU side) whilst an image is being rendered (GPU side processing)) + 1) |
- See also
- VulkanRendererAPI::SubmitCommandBuffers()
- Since
- Karma 1.0.0
Implements Karma::UniformBufferObject.