From 165dcc325fac87ec6e6660fce1fc76b723ce6ae1 Mon Sep 17 00:00:00 2001 From: Alexander Gauggel <agauggel@uni-koblenz.de> Date: Thu, 30 Sep 2021 11:35:15 +0200 Subject: [PATCH] [#96] Add doxygen comments to PushConstants --- include/vkcv/PushConstants.hpp | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/include/vkcv/PushConstants.hpp b/include/vkcv/PushConstants.hpp index d974fbe6..986de552 100644 --- a/include/vkcv/PushConstants.hpp +++ b/include/vkcv/PushConstants.hpp @@ -28,25 +28,44 @@ namespace vkcv { PushConstants& operator=(const PushConstants& other) = default; PushConstants& operator=(PushConstants&& other) = default; + /** + * @return The size of the data that is bound per drawcall in bytes + */ [[nodiscard]] size_t getSizePerDrawcall() const { return m_sizePerDrawcall; } + /** + * @return The size of the total data stored for push constants in bytes + */ [[nodiscard]] size_t getFullSize() const { return m_data.size(); } + /** + * @return The number of drawcalls that data is stored for + */ [[nodiscard]] size_t getDrawcallCount() const { return (m_data.size() / m_sizePerDrawcall); } + /** + * @brief Clear the drawcall data + */ void clear() { m_data.clear(); } + /** + * @brief Append data for a single drawcall + * + * @tparam T Type of data to append, must match the size of the #PushConstants per drawcall size + * @param value Data to append + * @return If operation was successfull + */ template<typename T = uint8_t> bool appendDrawcall(const T& value) { if (sizeof(T) != m_sizePerDrawcall) { @@ -61,24 +80,49 @@ namespace vkcv { return true; } + /** + * @brief Get the data for a single drawcall as reference + * + * @tparam T Type of data to return + * @param index Index of the drawcall data to return + * @return Drawcall data + */ template<typename T = uint8_t> T& getDrawcall(size_t index) { const size_t offset = (index * m_sizePerDrawcall); return *reinterpret_cast<T*>(m_data.data() + offset); } + /** + * @brief Get the data for a single drawcall as const reference + * + * @tparam T Type of data to return + * @param index Index of the drawcall data to return + * @return Drawcall data + */ template<typename T = uint8_t> const T& getDrawcall(size_t index) const { const size_t offset = (index * m_sizePerDrawcall); return *reinterpret_cast<const T*>(m_data.data() + offset); } + /** + * @brief Get the data for a single drawcall as a void pointer + * + * @param index Index of the drawcall data to return + * @return Drawcall data + */ [[nodiscard]] const void* getDrawcallData(size_t index) const { const size_t offset = (index * m_sizePerDrawcall); return reinterpret_cast<const void*>(m_data.data() + offset); } + /** + * @return Raw pointer to the entire drawcall data array, + * might be nullptr if data is empty, + * pointer might be invalidated by clearing or adding data + */ [[nodiscard]] const void* getData() const { if (m_data.empty()) { -- GitLab