Lluvia
|
Class to manage allocation of objects into a specific type of memory. More...
#include <Memory.h>
Public Member Functions | |
Memory ()=delete | |
Memory (const Memory &memory)=delete | |
Memory (Memory &&memory)=delete | |
Memory (const std::shared_ptr< ll::vulkan::Device > &device, const ll::VkHeapInfo &heapInfo, const uint64_t pageSize) | |
Constructs a new ll::Memory object. More... | |
~Memory () | |
Memory & | operator= (const Memory &memory)=delete |
Memory & | operator= (Memory &&memory)=delete |
ll::MemoryPropertyFlags | getMemoryPropertyFlags () const noexcept |
Gets the Vulkan memory property flags used to create this memory. More... | |
uint64_t | getPageSize () const noexcept |
Gets the page size. More... | |
uint32_t | getPageCount () const noexcept |
Gets the number of pages used. More... | |
bool | isMappable () const noexcept |
Determines if this memory is mappable to host-visible memory. More... | |
bool | isPageMappable (const uint32_t page) const noexcept |
Determines if a certain memory page is mappable. More... | |
std::shared_ptr< ll::Buffer > | createBuffer (const uint64_t size) |
Creates a buffer. More... | |
std::shared_ptr< ll::Buffer > | createBuffer (const uint64_t size, const ll::BufferUsageFlags usageFlags) |
Creates a new ll::Buffer object. More... | |
std::shared_ptr< ll::Buffer > | createBufferWithUnsafeFlags (const uint64_t size, const uint32_t usageFlags) |
Creates buffer with usage flags passed as integer type. More... | |
std::shared_ptr< ll::Image > | createImage (const ll::ImageDescriptor &descriptor) |
Creates a new ll::Image object. More... | |
std::shared_ptr< ll::ImageView > | createImageView (const ll::ImageDescriptor &imgDescriptor, const ll::ImageViewDescriptor &viewDescriptor) |
Creates an image view. More... | |
Friends | |
class | ll::Buffer |
class | ll::Image |
Class to manage allocation of objects into a specific type of memory.
Objects of this class contain a list of Vulkan memory objects. They are referred as memory page. Within each page, the memory for objects such as ll::Buffer and ll::Image is reserved. Several of such objets can be allocated in the same page. New pages are created on demand and managed by this class.
ll::Memory objects are constructed by calling ll::Session::createMemory on a valid session object.
TODO
|
delete |
|
delete |
|
delete |
ll::Memory::Memory | ( | const std::shared_ptr< ll::vulkan::Device > & | device, |
const ll::VkHeapInfo & | heapInfo, | ||
const uint64_t | pageSize | ||
) |
Constructs a new ll::Memory object.
[in] | session | The session this node was created from. |
[in] | device | The Vulkan device used for the construction. |
[in] | heapInfo | The heap information. |
[in] | pageSize | The page size in bytes. |
ll::Memory::~Memory | ( | ) |
std::shared_ptr<ll::Buffer> ll::Memory::createBuffer | ( | const uint64_t | size | ) |
Creates a buffer.
The created buffer will hold a reference to this memory object, preventing it from destroying before the buffer is deleted.
The usage flags of the buffer will be set to vk::BufferUsageFlagBits::eStorageBuffer | vk::BufferUsageFlagBits::eTransferSrc | vk::BufferUsageFlagBits::eTransferDst
. See https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VkBufferUsageFlagBits.
[in] | size | The size in bytes |
std::shared_ptr<ll::Buffer> ll::Memory::createBuffer | ( | const uint64_t | size, |
const ll::BufferUsageFlags | usageFlags | ||
) |
Creates a new ll::Buffer object.
The created buffer will hold a reference to this memory object, preventing it from destroying before the buffer is deleted.
[in] | size | The size of the buffer in bytes. If size is greater than the page size, a bigger page is created. |
[in] | usageFlags | The usage flags of the buffer. See https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VkBufferUsageFlagBits. |
std::system_error | if the Vulkan memory does not support allocating buffer objects. |
std::shared_ptr<ll::Buffer> ll::Memory::createBufferWithUnsafeFlags | ( | const uint64_t | size, |
const uint32_t | usageFlags | ||
) |
Creates buffer with usage flags passed as integer type.
[in] | size | The size |
[in] | usageFlags | The usage flags |
std::system_error | if the Vulkan memory does not support allocating buffer objects. |
std::shared_ptr<ll::Image> ll::Memory::createImage | ( | const ll::ImageDescriptor & | descriptor | ) |
Creates a new ll::Image object.
The created image will hold a reference to this memory object, preventing it from destroying before the image is deleted.
[in] | descriptor | The image descriptor. |
std::system_error | if the Vulkan memory does not support allocating image objects. |
std::invalid_argument | if the image size in the descriptor is not valid. This happens if the width, height or depth are zero or if the channel count ins not in the rante [1, 4]. |
std::shared_ptr<ll::ImageView> ll::Memory::createImageView | ( | const ll::ImageDescriptor & | imgDescriptor, |
const ll::ImageViewDescriptor & | viewDescriptor | ||
) |
Creates an image view.
This method is equivalent to
[in] | imgDescriptor | The underlying ll::Image descriptor. |
[in] | viewDescriptor | The image view descriptor. |
std::system_error | if the Vulkan memory does not support allocating image objects. |
std::invalid_argument | if the image size in the descriptor is not valid. This happens if the width, height or depth are zero or if the channel count ins not in the rante [1, 4]. |
|
noexcept |
Gets the Vulkan memory property flags used to create this memory.
See https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VkMemoryPropertyFlagBits for more information.
|
noexcept |
Gets the number of pages used.
|
noexcept |
Gets the page size.
|
noexcept |
Determines if this memory is mappable to host-visible memory.
|
noexcept |
Determines if a certain memory page is mappable.
This test checks if page
is available to be mapped to host-memory by a given objects such as a ll::Buffer.
[in] | page | The page index. |
|
friend |
|
friend |