Skip to content

Commit 94bfb2d

Browse files
committed
Extracted "selectDeviceMemoryType" to allow reuse
A typical usage scenario would be the necessity to add structs to the pnext chain of the creatinfo
1 parent 44bccc6 commit 94bfb2d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

modules/magma/DeviceMemory.hpp

+13-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ namespace magma
2323
return DeviceMemory<>(DeviceMemoryDeleter{magma::Device<claws::no_delete>(*this)}, vk::Device::allocateMemory({size, typeIndex}));
2424
}
2525

26-
inline auto impl::Device::selectAndCreateDeviceMemory(vk::PhysicalDevice physicalDevice,
27-
vk::DeviceSize size,
28-
vk::MemoryPropertyFlags memoryFlags,
29-
uint32_t memoryTypeIndexMask) const
26+
inline auto selectDeviceMemoryType(vk::PhysicalDevice physicalDevice,
27+
vk::DeviceSize size,
28+
vk::MemoryPropertyFlags memoryFlags,
29+
uint32_t memoryTypeIndexMask)
3030
{
3131
auto const memProperties(physicalDevice.getMemoryProperties());
3232

@@ -35,8 +35,16 @@ namespace magma
3535
auto const &type(memProperties.memoryTypes[i]);
3636

3737
if (((memoryTypeIndexMask >> i) & 1u) && (type.propertyFlags & memoryFlags) && memProperties.memoryHeaps[type.heapIndex].size >= size)
38-
return createDeviceMemory(size, i);
38+
return i;
3939
}
4040
throw std::runtime_error("Couldn't find proper memory type");
4141
}
42+
43+
inline auto impl::Device::selectAndCreateDeviceMemory(vk::PhysicalDevice physicalDevice,
44+
vk::DeviceSize size,
45+
vk::MemoryPropertyFlags memoryFlags,
46+
uint32_t memoryTypeIndexMask) const
47+
{
48+
return createDeviceMemory(size, selectDeviceMemoryType(physicalDevice, size, memoryFlags, memoryTypeIndexMask));
49+
}
4250
};

0 commit comments

Comments
 (0)