From d15f3c38dc595e5facc69f4d547543cf319788a4 Mon Sep 17 00:00:00 2001 From: Alexander Gauggel <agauggel@uni-koblenz.de> Date: Wed, 29 Sep 2021 16:06:04 +0200 Subject: [PATCH] [#96] Document Buffer.hpp --- include/vkcv/Buffer.hpp | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/include/vkcv/Buffer.hpp b/include/vkcv/Buffer.hpp index f5cd183d..b9edc8ff 100644 --- a/include/vkcv/Buffer.hpp +++ b/include/vkcv/Buffer.hpp @@ -18,44 +18,82 @@ namespace vkcv { // explicit destruction of default constructor Buffer<T>() = delete; + /** + * @return The #BufferHandle to be used with the #Core + */ [[nodiscard]] const BufferHandle& getHandle() const { return m_handle; } + /** + * @return The #BufferType of the #Buffer + */ [[nodiscard]] BufferType getType() const { return m_type; }; + /** + * @return The number of objects of type T the #Buffer holds + */ [[nodiscard]] size_t getCount() const { return m_count; } + /** + * @return The size of the #Buffer in bytes + */ [[nodiscard]] size_t getSize() const { return m_count * sizeof(T); } + /** + * @return The vulkan handle of the #Buffer to be used for manual vulkan commands + */ [[nodiscard]] const vk::Buffer getVulkanHandle() const { 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) { 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) { 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]] 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))); } + /** + * Unmap the #Buffer, invalidates the pointer obtained by map() + */ void unmap() { m_manager->unmapBuffer(m_handle); } -- GitLab