NDEVR
API Documentation
VulkanBuffer.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Graphics
28File: VulkanBuffer
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "VulkanDefines.h"
34#include "VulkanDevice.h"
35#include <NDEVR/GraphicsBuffer.h>
36#include <NDEVR/TableColumn.h>
37#include <NDEVR/Pointer.h>
38namespace NDEVR
39{
46 {
47 public:
55 VulkanBuffer(const TableColumn& reference_data, const ConstPointer<VulkanDevice>& vulkan_instance);
58 VulkanBuffer(VulkanBuffer&& vulkan_buffer) noexcept;
64 void insertRows(uint04 location, uint04 add_size) final override;
67 void setSize(uint04 buffer_size) final override;
72 void updateRegion(const TableColumn& column, uint04 offset, uint04 size) override;
76 void copyData(const TableColumn& reference_data, bool set_type) override;
78 void cleanup() override;
79
82 VkBuffer getVKBuffer() const;
86 VkVertexInputBindingDescription getBindingDescription(uint04 number) const;
90 VkFormat getFormat(uint01 vertex_index) const;
93 VkFormat getFormat() const;
100 void copyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, uint04 src_start, uint04 dst_start, uint04 size);
110 static VkBuffer CreateVKBuffer(VkDeviceSize& allocation_size, const VulkanDevice& device, VkDeviceSize size, VkDeviceSize object_size, uint04 usage, uint04 properties, VkDeviceMemory& bufferMemory);
114 void copyData(const VulkanBuffer& reference_data, bool set_type);
116 virtual void setDefaultValueFrom(const TableColumn&) override {}
117 public:
123 static uint04 FindMemoryType(const VulkanDevice& device, uint04 typeFilter, uint04 properties);
124 private:
125 uint04 getFlags() const;
126 void getFromVideoCard(bool copy_existing) override;
127 void sendToVideoCard(bool copy_existing) override;
128 void* mapMemory(size_t offset, size_t size) const override;
129 void unmapMemory(size_t offset, size_t size) const override;
130 private:
132 VkDeviceMemory m_device_memory;
133 VkBuffer m_vertex_buffer;
134 };
135}
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition Pointer.hpp:276
GraphicsBuffer(const StringView &label)
Constructs a graphics buffer with the given label.
uint04 size() const final override
Returns the number of rows in this column.
The core String View class for the NDEVR API.
Definition StringView.h:58
A virtual storage type that is used with Table class to store data where the actual mechanism for sto...
Definition TableColumn.h:86
const String & label() const
Returns the label (name) of this column.
void sendToVideoCard(bool copy_existing) override
Sends buffer data from CPU memory to the video card.
VulkanBuffer(VulkanBuffer &&vulkan_buffer) noexcept
Move constructor.
static uint04 FindMemoryType(const VulkanDevice &device, uint04 typeFilter, uint04 properties)
Finds a suitable memory type index on the device.
void cleanup() override
Releases all Vulkan resources held by this buffer.
void insertRows(uint04 location, uint04 add_size) final override
Inserts empty rows into the buffer at the given location.
virtual void setDefaultValueFrom(const TableColumn &) override
Sets the default value from a table column (no-op for Vulkan buffers).
void copyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, uint04 src_start, uint04 dst_start, uint04 size)
Copies data between two Vulkan buffers using a transfer command.
void getFromVideoCard(bool copy_existing) override
Retrieves buffer data from the video card into CPU memory.
void * mapMemory(size_t offset, size_t size) const override
Maps a region of GPU memory for CPU access.
~VulkanBuffer()
Destructor.
VkVertexInputBindingDescription getBindingDescription(uint04 number) const
Returns the vertex input binding description for this buffer.
VulkanBuffer(const StringView &label, const ConstPointer< VulkanDevice > &vulkan_instance)
Constructs a named Vulkan buffer.
static VkBuffer CreateVKBuffer(VkDeviceSize &allocation_size, const VulkanDevice &device, VkDeviceSize size, VkDeviceSize object_size, uint04 usage, uint04 properties, VkDeviceMemory &bufferMemory)
Creates a new Vulkan buffer with the given properties.
VkFormat getFormat(uint01 vertex_index) const
Returns the Vulkan format for a specific vertex attribute index.
void updateRegion(const TableColumn &column, uint04 offset, uint04 size) override
Updates a region of the GPU buffer from a table column.
void copyData(const VulkanBuffer &reference_data, bool set_type)
Copies data from another VulkanBuffer.
VkBuffer getVKBuffer() const
Returns the underlying Vulkan buffer handle.
void copyData(const TableColumn &reference_data, bool set_type) override
Copies all data from a table column into this buffer.
VkFormat getFormat() const
Returns the overall Vulkan format for this buffer.
VulkanBuffer(const TableColumn &reference_data, const ConstPointer< VulkanDevice > &vulkan_instance)
Constructs a Vulkan buffer from existing table column data.
void setSize(uint04 buffer_size) final override
Sets the total size of the buffer in number of elements.
void unmapMemory(size_t offset, size_t size) const override
Unmaps a previously mapped memory region.
A GraphicsDevice for managing Vulkan limitations and actions.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...