Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
VulkanBuffer.hpp
1/*
2Copyright (C) 2017-2019,2021,2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGAMES_VULKANBUFFER_HPP
17#define AEONGAMES_VULKANBUFFER_HPP
18#include <vulkan/vulkan.h>
19#include "aeongames/Buffer.hpp"
20
21namespace AeonGames
22{
23 class VulkanRenderer;
25 class VulkanBuffer : public Buffer
26 {
27 public:
29 VulkanBuffer ( const VulkanRenderer& aVulkanRenderer );
31 VulkanBuffer ( const VulkanRenderer& aVulkanRenderer, const VkDeviceSize aSize, const VkBufferUsageFlags aUsage, const VkMemoryPropertyFlags aProperties, const void *aData = nullptr );
35 VulkanBuffer ( const VulkanBuffer& aBuffer ) = delete;
37 VulkanBuffer& operator= ( const VulkanBuffer& aBuffer ) = delete;
42 void Initialize ( const VkDeviceSize aSize, const VkBufferUsageFlags aUsage, const VkMemoryPropertyFlags aProperties, const void *aData = nullptr );
44 void Finalize();
46 const VkBuffer& GetBuffer() const;
49 void WriteMemory ( const size_t aOffset, const size_t aSize, const void *aData = nullptr ) const final;
50 void* Map ( const size_t aOffset, size_t aSize ) const final;
51 void Unmap() const final;
52 size_t GetSize() const final;
54 private:
55 void Initialize ( const void *aData );
56 const VulkanRenderer& mVulkanRenderer;
57 VkBuffer mBuffer{ VK_NULL_HANDLE };
58 VkDeviceMemory mDeviceMemory{ VK_NULL_HANDLE };
59 VkDeviceSize mSize{};
60 VkBufferUsageFlags mUsage{};
61 VkMemoryPropertyFlags mProperties{};
62 };
63}
64#endif
Abstract interface for GPU/memory buffer operations.
Definition Buffer.hpp:24
VulkanBuffer & operator=(const VulkanBuffer &aBuffer)=delete
Assignment operator due to rule of zero/three/five.
VulkanBuffer(const VulkanBuffer &aBuffer)=delete
Copy constructor.
size_t GetSize() const final
Get the total size of the buffer in bytes.
VulkanBuffer(const VulkanRenderer &aVulkanRenderer)
Construct an uninitialized buffer.
void WriteMemory(const size_t aOffset, const size_t aSize, const void *aData=nullptr) const final
Write data into the buffer at a given offset.
void * Map(const size_t aOffset, size_t aSize) const final
Map a region of the buffer into CPU-accessible memory.
void Initialize(const VkDeviceSize aSize, const VkBufferUsageFlags aUsage, const VkMemoryPropertyFlags aProperties, const void *aData=nullptr)
Initialize the buffer with the given size, usage, memory properties, and optional data.
const VkBuffer & GetBuffer() const
Get the underlying Vulkan buffer handle.
void Finalize()
Release the Vulkan buffer and its device memory.
void Unmap() const final
Unmap a previously mapped buffer region.
Vulkan rendering backend implementing the Renderer interface.
<- This is here just for the literals
Definition AABB.hpp:31