15 #include <vsg/core/Array.h>
16 #include <vsg/vk/Device.h>
30 DeviceMemory(
Device* device,
const VkMemoryRequirements& memRequirements, VkMemoryPropertyFlags properties,
void* pNextAllocInfo =
nullptr);
32 operator VkDeviceMemory()
const {
return _deviceMemory; }
33 VkDeviceMemory vk()
const {
return _deviceMemory; }
35 void copy(VkDeviceSize offset, VkDeviceSize size,
const void* src_data);
36 void copy(VkDeviceSize offset,
const Data* data);
39 VkResult
map(VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags,
void** ppData);
42 const VkMemoryRequirements& getMemoryRequirements()
const {
return _memoryRequirements; }
43 const VkMemoryPropertyFlags& getMemoryPropertyFlags()
const {
return _properties; }
45 MemorySlots::OptionalOffset reserve(VkDeviceSize size);
46 void release(VkDeviceSize offset, VkDeviceSize size);
49 VkDeviceSize maximumAvailableSpace()
const;
50 size_t totalAvailableSize()
const;
51 size_t totalReservedSize()
const;
53 Device* getDevice() {
return _device; }
54 const Device* getDevice()
const {
return _device; }
57 virtual ~DeviceMemory();
59 VkDeviceMemory _deviceMemory;
60 VkMemoryRequirements _memoryRequirements;
61 VkMemoryPropertyFlags _properties;
62 ref_ptr<Device> _device;
64 mutable std::mutex _mutex;
65 MemorySlots _memorySlots;
73 using value_type =
typename T::value_type;
75 template<
typename... Args>
78 _deviceMemory(deviceMemory)
81 size_t numElements = (args * ...);
82 _deviceMemory->map(offset, numElements *
sizeof(value_type), flags, &pData);
83 T::assign(args...,
static_cast<value_type*
>(pData));
86 template<
typename... Args>
92 template<
typename... Args>
96 data->properties = properties;
103 _deviceMemory->unmap();
Definition: DeviceMemory.h:28
VkResult map(VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void **ppData)
wrapper of vkMapMemory
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition: Device.h:37
Definition: DeviceMemory.h:71