Hymn to Beauty
C++ 3D Engine
VulkanBuffer.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "../Interface/Buffer.hpp"
4
5#include <vulkan/vulkan.h>
6
7namespace Video {
8
9class RawBuffer;
10class VulkanRenderer;
11
13class VulkanBuffer : public Buffer {
14 public:
16
21
23 ~VulkanBuffer() final;
24
25 void Reset(BufferUsage bufferUsage, const BufferAllocation& allocation) final;
26 unsigned int GetSize() const final;
27
29
32 VkBuffer GetBuffer() const;
33
35
38 uint32_t GetOffset() const;
39
41
44 VkPipelineStageFlags GetReadMask() const;
45
47
50 void SetReadMaskStage(VkPipelineStageFlags pipelineStage);
51
53 void ClearReadMask();
54
56
59 VkPipelineStageFlags GetLastWriteStage() const;
60
62
65 void SetLastWriteStage(VkPipelineStageFlags pipelineStage);
66
67 private:
68 VulkanBuffer(const VulkanBuffer& other) = delete;
69
70 VkDevice device;
71 VkBuffer buffer;
72 VkDeviceMemory deviceMemory;
73 uint32_t offset;
74 uint32_t size;
75
76 RawBuffer* rawBuffer;
77 bool temporaryAllocation;
78
79 VkPipelineStageFlags readMask;
80 VkPipelineStageFlags lastWrite;
81};
82
83}
A buffer containing GPU accessible data.
Definition: Buffer.hpp:8
BufferUsage
How the buffer is going to be used.
Definition: Buffer.hpp:11
BufferUsage bufferUsage
How the buffer will be used.
Definition: Buffer.hpp:54
A large buffer from which buffers are sub-allocated.
Definition: BufferAllocator.hpp:21
Vulkan implementation of Buffer.
Definition: VulkanBuffer.hpp:13
uint32_t GetOffset() const
Get the offset into the raw buffer.
Definition: VulkanBuffer.cpp:41
void SetLastWriteStage(VkPipelineStageFlags pipelineStage)
Set which pipeline stage last wrote to the buffer.
Definition: VulkanBuffer.cpp:61
void Reset(BufferUsage bufferUsage, const BufferAllocation &allocation) final
Reset the buffer.
Definition: VulkanBuffer.cpp:19
~VulkanBuffer() final
Destructor.
Definition: VulkanBuffer.cpp:13
VkPipelineStageFlags GetReadMask() const
Get which pipeline stages have read the buffer since the last write.
Definition: VulkanBuffer.cpp:45
void SetReadMaskStage(VkPipelineStageFlags pipelineStage)
Set a pipeline stage having read the buffer since the last write.
Definition: VulkanBuffer.cpp:49
VkPipelineStageFlags GetLastWriteStage() const
Get the shader stage which last wrote to the buffer.
Definition: VulkanBuffer.cpp:57
void ClearReadMask()
Clear the read mask.
Definition: VulkanBuffer.cpp:53
VkBuffer GetBuffer() const
Get the internal Vulkan buffer.
Definition: VulkanBuffer.cpp:37
VulkanBuffer(Buffer::BufferUsage bufferUsage, const BufferAllocation &allocation)
Create new Vulkan buffer.
Definition: VulkanBuffer.cpp:9
unsigned int GetSize() const final
Get the size of the buffer.
Definition: VulkanBuffer.cpp:33
Definition: Editor.hpp:18
An allocation.
Definition: BufferAllocator.hpp:36