Plasma Engine  2.0
Loading...
Searching...
No Matches
BufferVulkan.h
1
2#pragma once
3
4#include <RendererFoundation/Resources/Buffer.h>
5
6#include <RendererVulkan/Device/DeviceVulkan.h>
7
8#include <vulkan/vulkan.hpp>
9
10class PL_RENDERERVULKAN_DLL plGALBufferVulkan : public plGALBuffer
11{
12public:
13 void DiscardBuffer() const;
14 PL_ALWAYS_INLINE vk::Buffer GetVkBuffer() const;
15 const vk::DescriptorBufferInfo& GetBufferInfo() const;
16
17 PL_ALWAYS_INLINE vk::IndexType GetIndexType() const;
18 PL_ALWAYS_INLINE plVulkanAllocation GetAllocation() const;
19 PL_ALWAYS_INLINE const plVulkanAllocationInfo& GetAllocationInfo() const;
20 PL_ALWAYS_INLINE vk::PipelineStageFlags GetUsedByPipelineStage() const;
21 PL_ALWAYS_INLINE vk::AccessFlags GetAccessMask() const;
22 static vk::DeviceSize GetAlignment(const plGALDeviceVulkan* pDevice, vk::BufferUsageFlags usage);
23
24protected:
26 {
27 vk::Buffer m_buffer;
28 plVulkanAllocation m_alloc;
29 mutable plUInt64 m_currentFrame = 0;
30 };
31
32 friend class plGALDeviceVulkan;
33 friend class plMemoryUtils;
34
35 plGALBufferVulkan(const plGALBufferCreationDescription& Description, bool bCPU = false);
36
37 virtual ~plGALBufferVulkan();
38
39 virtual plResult InitPlatform(plGALDevice* pDevice, plArrayPtr<const plUInt8> pInitialData) override;
40 virtual plResult DeInitPlatform(plGALDevice* pDevice) override;
41 virtual void SetDebugNamePlatform(const char* szName) const override;
42 void CreateBuffer() const;
43
44 mutable BufferVulkan m_currentBuffer;
45 mutable vk::DescriptorBufferInfo m_resourceBufferInfo;
46 mutable plDeque<BufferVulkan> m_usedBuffers;
47 mutable plVulkanAllocationInfo m_allocInfo;
48
49 // Data for memory barriers and access
50 vk::PipelineStageFlags m_stages = {};
51 vk::AccessFlags m_access = {};
52 vk::IndexType m_indexType = vk::IndexType::eUint16; // Only applicable for index buffers
53 vk::BufferUsageFlags m_usage = {};
54 vk::DeviceSize m_size = 0;
55
56 plGALDeviceVulkan* m_pDeviceVulkan = nullptr;
57 vk::Device m_device;
58
59 bool m_bCPU = false;
60 mutable plString m_sDebugName;
61};
62
63#include <RendererVulkan/Resources/Implementation/BufferVulkan_inl.h>
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition Deque.h:270
Definition Buffer.h:8
Definition BufferVulkan.h:11
The plRenderDevice class is the primary interface for interactions with rendering APIs It contains a ...
Definition Device.h:19
The Vulkan device implementation of the graphics abstraction layer.
Definition DeviceVulkan.h:58
This class provides functions to work on raw memory.
Definition MemoryUtils.h:26
Definition Descriptors.h:169
Definition BufferVulkan.h:26
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Subset of VmaAllocationInfo. Duplicated for abstraction purposes.
Definition MemoryAllocatorVulkan.h:78