31 DeviceMemory(
Device* device,
const VkMemoryRequirements& memRequirements, VkMemoryPropertyFlags properties,
void* pNextAllocInfo =
nullptr);
33 operator VkDeviceMemory()
const {
return _deviceMemory; }
34 VkDeviceMemory vk()
const {
return _deviceMemory; }
36 void copy(VkDeviceSize offset, VkDeviceSize size,
const void* src_data);
37 void copy(VkDeviceSize offset,
const Data* data);
40 VkResult
map(VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags,
void** ppData);
43 const VkMemoryRequirements& getMemoryRequirements()
const {
return _memoryRequirements; }
44 const VkMemoryPropertyFlags& getMemoryPropertyFlags()
const {
return _properties; }
46 MemorySlots::OptionalOffset reserve(VkDeviceSize size);
47 void release(VkDeviceSize offset, VkDeviceSize size);
50 VkDeviceSize maximumAvailableSpace()
const;
51 size_t totalAvailableSize()
const;
52 size_t totalReservedSize()
const;
53 size_t totalMemorySize()
const;
55 Device* getDevice() {
return _device; }
56 const Device* getDevice()
const {
return _device; }
59 virtual ~DeviceMemory();
61 VkDeviceMemory _deviceMemory;
62 VkMemoryRequirements _memoryRequirements;
63 VkMemoryPropertyFlags _properties;
64 ref_ptr<Device> _device;
66 mutable std::mutex _mutex;
67 MemorySlots _memorySlots;
78 using value_type =
typename T::value_type;
80 template<
typename... Args>
83 _deviceMemory(deviceMemory)
86 size_t numElements = (args * ...);
87 _deviceMemory->map(offset, numElements *
sizeof(value_type), flags, &pData);
88 T::assign(args...,
static_cast<value_type*
>(pData));
91 template<
typename... Args>
97 template<
typename... Args>
101 data->properties = properties;
108 _deviceMemory->unmap();