Skip to content
Snippets Groups Projects
Commit d15f3c38 authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#96] Document Buffer.hpp

parent f892820c
No related branches found
No related tags found
1 merge request!97Resolve "Dokumentation vervollständigen"
Pipeline #27501 passed
...@@ -18,44 +18,82 @@ namespace vkcv { ...@@ -18,44 +18,82 @@ namespace vkcv {
// explicit destruction of default constructor // explicit destruction of default constructor
Buffer<T>() = delete; Buffer<T>() = delete;
/**
* @return The #BufferHandle to be used with the #Core
*/
[[nodiscard]] [[nodiscard]]
const BufferHandle& getHandle() const { const BufferHandle& getHandle() const {
return m_handle; return m_handle;
} }
/**
* @return The #BufferType of the #Buffer
*/
[[nodiscard]] [[nodiscard]]
BufferType getType() const { BufferType getType() const {
return m_type; return m_type;
}; };
/**
* @return The number of objects of type T the #Buffer holds
*/
[[nodiscard]] [[nodiscard]]
size_t getCount() const { size_t getCount() const {
return m_count; return m_count;
} }
/**
* @return The size of the #Buffer in bytes
*/
[[nodiscard]] [[nodiscard]]
size_t getSize() const { size_t getSize() const {
return m_count * sizeof(T); return m_count * sizeof(T);
} }
/**
* @return The vulkan handle of the #Buffer to be used for manual vulkan commands
*/
[[nodiscard]] [[nodiscard]]
const vk::Buffer getVulkanHandle() const { const vk::Buffer getVulkanHandle() const {
return m_manager->getBuffer(m_handle); return m_manager->getBuffer(m_handle);
} }
/**
* Fill the #Buffer with data of type T
*
* @param data Pointer to the array of object type T
* @param count The number of objects to copy from the data array
* @param offset The offset into the #Buffer where the data is copied into
*/
void fill(const T* data, size_t count = 0, size_t offset = 0) { void fill(const T* data, size_t count = 0, size_t offset = 0) {
m_manager->fillBuffer(m_handle, data, count * sizeof(T), offset * sizeof(T)); m_manager->fillBuffer(m_handle, data, count * sizeof(T), offset * sizeof(T));
} }
/**
* Fill the #Buffer with data from a vector of type T
*
* @param vector Vector of type T to be copied into the #Buffer
* @param offset The offset into the #Buffer where the data is copied into
*/
void fill(const std::vector<T>& vector, size_t offset = 0) { void fill(const std::vector<T>& vector, size_t offset = 0) {
fill( static_cast<const T*>(vector.data()), static_cast<size_t>(vector.size()), offset); fill( static_cast<const T*>(vector.data()), static_cast<size_t>(vector.size()), offset);
} }
/**
* Maps memory to the #Buffer and returns it
*
* @param offset Offset of mapping in objects of type T
* @param count Count of objects of type T that are mapped
* @return Pointer to mapped memory as type T
*/
[[nodiscard]] [[nodiscard]]
T* map(size_t offset = 0, size_t count = 0) { T* map(size_t offset = 0, size_t count = 0) {
return reinterpret_cast<T*>(m_manager->mapBuffer(m_handle, offset * sizeof(T), count * sizeof(T))); return reinterpret_cast<T*>(m_manager->mapBuffer(m_handle, offset * sizeof(T), count * sizeof(T)));
} }
/**
* Unmap the #Buffer, invalidates the pointer obtained by map()
*/
void unmap() { void unmap() {
m_manager->unmapBuffer(m_handle); m_manager->unmapBuffer(m_handle);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment