<commit_before>/*!
 * \author David
 * \date 22-May-16.
 */

#ifndef RENDERER_GL_UNIFORM_BUFFER_H
#define RENDERER_GL_UNIFORM_BUFFER_H

#include <string>
#include "../../util/vma_usage.hpp"

namespace nova::renderer {
    /*!
     * \brief A nice interface for uniform buffer objects
     *
     * A uniform_buffer has two copies of the buffer: One in device memory and one in host memory. When you update a
     * uniform in the buffer, only the host memory buffer is changed. You must explicitly call .sync() to send the
     * host memory buffer to device memory
     */
    class uniform_buffer {
    public:
        uniform_buffer() = default;

        uniform_buffer(
            std::string name, VkDevice device, VmaAllocator allocator, VkBufferCreateInfo& create_info, uint64_t alignment);

        uniform_buffer(const uniform_buffer& other) = delete;
        uniform_buffer& operator=(const uniform_buffer& other) = delete;

        uniform_buffer(uniform_buffer&& old) noexcept = default;
        uniform_buffer& operator=(uniform_buffer&& old) noexcept = default;

        virtual ~uniform_buffer();

        /*!
         * \brief Provides access to the CPU-side UBO
         *
         * \tparam UboStructType The type of the data in the uniform buffer
         *
         * \return A pointer to the CPU-side UBO
         */
        template <typename UboStructType>
        [[nodiscard]] UboStructType* get_data() {
            return reinterpret_cast<UboStructType*>(cpu_alloc_info.pMappedData);
        };

        [[nodiscard]] VmaAllocation& get_allocation();

        [[nodiscard]] VmaAllocationInfo& get_allocation_info();

        [[nodiscard]] const std::string& get_name() const;

        [[nodiscard]] const VkBuffer& get_vk_buffer() const;

        [[nodiscard]] VkDeviceSize get_size() const;

        [[nodiscard]] VkFence get_dummy_fence() const;

        void record_ubo_upload(VkCommandBuffer cmds);

    protected:
        std::string name;
        uint64_t alignment = 64;

        VmaAllocator allocator = nullptr;

        VkDevice device = nullptr;
        VkBuffer buffer = nullptr;

        VmaAllocation allocation = nullptr;
        VmaAllocationInfo allocation_info = {};

        VkBuffer cpu_buffer = nullptr;
        VmaAllocation cpu_allocation = nullptr;
        VmaAllocationInfo cpu_alloc_info = {};

        VkFence dummy_fence = nullptr;
    };
} // namespace nova::renderer

#endif // RENDERER_GL_UNIFORM_BUFFER_H
<commit_msg>Remove extra semicolons<commit_after>/*!
 * \author David
 * \date 22-May-16.
 */

#ifndef RENDERER_GL_UNIFORM_BUFFER_H
#define RENDERER_GL_UNIFORM_BUFFER_H

#include <string>
#include "../../util/vma_usage.hpp"

namespace nova::renderer {
    /*!
     * \brief A nice interface for uniform buffer objects
     *
     * A uniform_buffer has two copies of the buffer: One in device memory and one in host memory. When you update a
     * uniform in the buffer, only the host memory buffer is changed. You must explicitly call .sync() to send the
     * host memory buffer to device memory
     */
    class uniform_buffer {
    public:
        uniform_buffer() = default;

        uniform_buffer(
            std::string name, VkDevice device, VmaAllocator allocator, VkBufferCreateInfo& create_info, uint64_t alignment);

        uniform_buffer(const uniform_buffer& other) = delete;
        uniform_buffer& operator=(const uniform_buffer& other) = delete;

        uniform_buffer(uniform_buffer&& old) noexcept = default;
        uniform_buffer& operator=(uniform_buffer&& old) noexcept = default;

        virtual ~uniform_buffer();

        /*!
         * \brief Provides access to the CPU-side UBO
         *
         * \tparam UboStructType The type of the data in the uniform buffer
         *
         * \return A pointer to the CPU-side UBO
         */
        template <typename UboStructType>
        [[nodiscard]] UboStructType* get_data() {
            return reinterpret_cast<UboStructType*>(cpu_alloc_info.pMappedData);
        }

        [[nodiscard]] VmaAllocation& get_allocation();

        [[nodiscard]] VmaAllocationInfo& get_allocation_info();

        [[nodiscard]] const std::string& get_name() const;

        [[nodiscard]] const VkBuffer& get_vk_buffer() const;

        [[nodiscard]] VkDeviceSize get_size() const;

        [[nodiscard]] VkFence get_dummy_fence() const;

        void record_ubo_upload(VkCommandBuffer cmds);

    protected:
        std::string name;
        uint64_t alignment = 64;

        VmaAllocator allocator = nullptr;

        VkDevice device = nullptr;
        VkBuffer buffer = nullptr;

        VmaAllocation allocation = nullptr;
        VmaAllocationInfo allocation_info = {};

        VkBuffer cpu_buffer = nullptr;
        VmaAllocation cpu_allocation = nullptr;
        VmaAllocationInfo cpu_alloc_info = {};

        VkFence dummy_fence = nullptr;
    };
} // namespace nova::renderer

#endif // RENDERER_GL_UNIFORM_BUFFER_H

{'fraction_non_alphanumeric': 0.08885754583921016, 'fraction_numerical': 0.004029820672980053, 'mean_word_length': 2.752078609221466, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1074112', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1428, 'n_words': 402}