nngn
Loading...
Searching...
No Matches
nngn::DeviceMemory Class Reference

Manages device memory queries, allocations, and lifetime. More...

#include <memory.h>

Public Types

template<VkMemoryPropertyFlags f>
using find_ret = std::conditional_t< required(f), void, bool >
 
template<VkMemoryPropertyFlags f>
using find_ret = std::conditional_t< required(f), void, bool >
 

Public Member Functions

 DeviceMemory (void)=default
 
 ~DeviceMemory (void)
 
bool init (VkInstance inst, VkPhysicalDevice physical_dev, VkDevice dev)
 
template<VkMemoryPropertyFlags f>
find_ret< ffind_type (std::uint32_t type, std::uint32_t *p) const
 Finds a memory type among those offered by the device.
 
template<VkMemoryPropertyFlags f>
bool alloc (const VkMemoryRequirements *req, VkDeviceMemory *p)
 Allocates device memory from a type that fulfills req.
 
template<VkMemoryPropertyFlags f>
bool alloc (const VkMemoryRequirements *req, MemoryAllocation *alloc, VkDeviceMemory *mem, VkDeviceSize *offset)
 Allocates device memory from a type that fulfills req.
 
template<VkMemoryPropertyFlags f>
bool alloc (VkBuffer buf, VkDeviceMemory *p)
 Allocates device memory from a type for a given buffer.
 
template<VkMemoryPropertyFlags f>
bool alloc (VkBuffer b, MemoryAllocation *alloc, VkDeviceMemory *mem, VkDeviceSize *offset)
 Allocates device memory from a type that fulfills req.
 
template<VkMemoryPropertyFlags f>
bool alloc (VkImage img, VkDeviceMemory *p)
 Allocates device memory from a type for a given image.
 
template<VkMemoryPropertyFlags f>
bool alloc (VkImage img, MemoryAllocation *alloc, VkDeviceMemory *mem, VkDeviceSize *offset)
 Allocates device memory from a type for a given image.
 
void dealloc (VkDeviceMemory mem)
 Deallocates a block of device memory.
 
void dealloc (MemoryAllocation alloc)
 Deallocates a block of memory from an allocation pool (if necessary).
 
 DeviceMemory (void)=default
 
 ~DeviceMemory (void)
 
bool init (VkInstance inst, VkPhysicalDevice physical_dev, VkDevice dev)
 
template<VkMemoryPropertyFlags f>
find_ret< ffind_type (std::uint32_t type, std::uint32_t *p) const
 Finds a memory type among those offered by the device.
 
template<VkMemoryPropertyFlags f>
bool alloc (const VkMemoryRequirements *req, VkDeviceMemory *p)
 Allocates device memory from a type that fulfills req.
 
template<VkMemoryPropertyFlags f>
bool alloc (const VkMemoryRequirements *req, MemoryAllocation *alloc, VkDeviceMemory *mem, VkDeviceSize *offset)
 Allocates device memory from a type that fulfills req.
 
template<VkMemoryPropertyFlags f>
bool alloc (VkBuffer buf, VkDeviceMemory *p)
 Allocates device memory from a type for a given buffer.
 
template<VkMemoryPropertyFlags f>
bool alloc (VkBuffer b, MemoryAllocation *alloc, VkDeviceMemory *mem, VkDeviceSize *offset)
 Allocates device memory from a type that fulfills req.
 
template<VkMemoryPropertyFlags f>
bool alloc (VkImage img, VkDeviceMemory *p)
 Allocates device memory from a type for a given image.
 
template<VkMemoryPropertyFlags f>
bool alloc (VkImage img, MemoryAllocation *alloc, VkDeviceMemory *mem, VkDeviceSize *offset)
 Allocates device memory from a type for a given image.
 
void dealloc (VkDeviceMemory mem)
 Deallocates a block of device memory.
 
void dealloc (MemoryAllocation alloc)
 Deallocates a block of memory from an allocation pool (if necessary).
 
template<VkMemoryPropertyFlags f>
auto find_type (std::uint32_t type, std::uint32_t *p) const -> find_ret< f >
 

Static Public Member Functions

static constexpr bool required (VkMemoryPropertyFlags f)
 Indicates whether a memory type is guaranteed to exist.
 
static constexpr bool required (VkMemoryPropertyFlags f)
 Indicates whether a memory type is guaranteed to exist.
 

Private Member Functions

bool alloc (std::uint32_t type, VkDeviceSize size, VkDeviceMemory *p)
 Shared implementation for all dedicated allocations.
 
bool alloc (std::uint32_t type, const VkMemoryRequirements *req, MemoryAllocation *alloc, VkDeviceMemory *mem, VkDeviceSize *offset)
 Shared implementation for all pooled allocations.
 
bool alloc (std::uint32_t type, VkDeviceSize size, VkDeviceMemory *p)
 Shared implementation for all dedicated allocations.
 
bool alloc (std::uint32_t type, const VkMemoryRequirements *req, MemoryAllocation *alloc, VkDeviceMemory *mem, VkDeviceSize *offset)
 Shared implementation for all pooled allocations.
 

Private Attributes

VkDevice dev = {}
 
void * allocator = {}
 
VkPhysicalDeviceMemoryProperties props = {}
 

Detailed Description

Manages device memory queries, allocations, and lifetime.

Member Typedef Documentation

◆ find_ret [1/2]

template<VkMemoryPropertyFlags f>
using nngn::DeviceMemory::find_ret = std::conditional_t<required(f), void, bool>

◆ find_ret [2/2]

template<VkMemoryPropertyFlags f>
using nngn::DeviceMemory::find_ret = std::conditional_t<required(f), void, bool>

Constructor & Destructor Documentation

◆ DeviceMemory() [1/2]

nngn::DeviceMemory::DeviceMemory ( void  )
default

◆ ~DeviceMemory() [1/2]

nngn::DeviceMemory::~DeviceMemory ( void  )

◆ DeviceMemory() [2/2]

nngn::DeviceMemory::DeviceMemory ( void  )
default

◆ ~DeviceMemory() [2/2]

nngn::DeviceMemory::~DeviceMemory ( void  )

Member Function Documentation

◆ alloc() [1/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( const VkMemoryRequirements *  req,
MemoryAllocation alloc,
VkDeviceMemory mem,
VkDeviceSize *  offset 
)

Allocates device memory from a type that fulfills req.

Device memory may come from a pool.

Here is the call graph for this function:

◆ alloc() [2/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( const VkMemoryRequirements *  req,
MemoryAllocation alloc,
VkDeviceMemory mem,
VkDeviceSize *  offset 
)

Allocates device memory from a type that fulfills req.

Device memory may come from a pool.

◆ alloc() [3/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( const VkMemoryRequirements *  req,
VkDeviceMemory p 
)

Allocates device memory from a type that fulfills req.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ alloc() [4/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( const VkMemoryRequirements *  req,
VkDeviceMemory p 
)

Allocates device memory from a type that fulfills req.

◆ alloc() [5/16]

bool nngn::DeviceMemory::alloc ( std::uint32_t  type,
const VkMemoryRequirements *  req,
MemoryAllocation alloc,
VkDeviceMemory mem,
VkDeviceSize *  offset 
)
private

Shared implementation for all pooled allocations.

Here is the call graph for this function:

◆ alloc() [6/16]

bool nngn::DeviceMemory::alloc ( std::uint32_t  type,
const VkMemoryRequirements *  req,
MemoryAllocation alloc,
VkDeviceMemory mem,
VkDeviceSize *  offset 
)
private

Shared implementation for all pooled allocations.

◆ alloc() [7/16]

bool nngn::DeviceMemory::alloc ( std::uint32_t  type,
VkDeviceSize  size,
VkDeviceMemory p 
)
private

Shared implementation for all dedicated allocations.

Here is the call graph for this function:

◆ alloc() [8/16]

bool nngn::DeviceMemory::alloc ( std::uint32_t  type,
VkDeviceSize  size,
VkDeviceMemory p 
)
private

Shared implementation for all dedicated allocations.

◆ alloc() [9/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( VkBuffer  b,
MemoryAllocation alloc,
VkDeviceMemory mem,
VkDeviceSize *  offset 
)

Allocates device memory from a type that fulfills req.

Device memory may come from a pool.

Here is the call graph for this function:

◆ alloc() [10/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( VkBuffer  b,
MemoryAllocation alloc,
VkDeviceMemory mem,
VkDeviceSize *  offset 
)

Allocates device memory from a type that fulfills req.

Device memory may come from a pool.

◆ alloc() [11/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( VkBuffer  buf,
VkDeviceMemory p 
)

Allocates device memory from a type for a given buffer.

◆ alloc() [12/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( VkBuffer  buf,
VkDeviceMemory p 
)

Allocates device memory from a type for a given buffer.

◆ alloc() [13/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( VkImage  img,
MemoryAllocation alloc,
VkDeviceMemory mem,
VkDeviceSize *  offset 
)

Allocates device memory from a type for a given image.

Device memory may come from a pool.

Here is the call graph for this function:

◆ alloc() [14/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( VkImage  img,
MemoryAllocation alloc,
VkDeviceMemory mem,
VkDeviceSize *  offset 
)

Allocates device memory from a type for a given image.

Device memory may come from a pool.

◆ alloc() [15/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( VkImage  img,
VkDeviceMemory p 
)

Allocates device memory from a type for a given image.

◆ alloc() [16/16]

template<VkMemoryPropertyFlags f>
bool nngn::DeviceMemory::alloc ( VkImage  img,
VkDeviceMemory p 
)

Allocates device memory from a type for a given image.

◆ dealloc() [1/4]

void nngn::DeviceMemory::dealloc ( MemoryAllocation  alloc)

Deallocates a block of memory from an allocation pool (if necessary).

Here is the call graph for this function:

◆ dealloc() [2/4]

void nngn::DeviceMemory::dealloc ( MemoryAllocation  alloc)

Deallocates a block of memory from an allocation pool (if necessary).

◆ dealloc() [3/4]

void nngn::DeviceMemory::dealloc ( VkDeviceMemory  mem)

Deallocates a block of device memory.

Here is the caller graph for this function:

◆ dealloc() [4/4]

void nngn::DeviceMemory::dealloc ( VkDeviceMemory  mem)

Deallocates a block of device memory.

◆ find_type() [1/3]

template<VkMemoryPropertyFlags f>
find_ret< f > nngn::DeviceMemory::find_type ( std::uint32_t  type,
std::uint32_t *  p 
) const

Finds a memory type among those offered by the device.

Returns
If f is required, void. Otherwise, returns true if a suitable type was found and written to p.

◆ find_type() [2/3]

template<VkMemoryPropertyFlags f>
find_ret< f > nngn::DeviceMemory::find_type ( std::uint32_t  type,
std::uint32_t *  p 
) const

Finds a memory type among those offered by the device.

Returns
If f is required, void. Otherwise, returns true if a suitable type was found and written to p.

◆ find_type() [3/3]

template<VkMemoryPropertyFlags f>
auto nngn::DeviceMemory::find_type ( std::uint32_t  type,
std::uint32_t *  p 
) const -> find_ret<f>
Here is the call graph for this function:

◆ init() [1/2]

bool nngn::DeviceMemory::init ( VkInstance  inst,
VkPhysicalDevice  physical_dev,
VkDevice  dev 
)
Here is the caller graph for this function:

◆ init() [2/2]

bool nngn::DeviceMemory::init ( VkInstance  inst,
VkPhysicalDevice  physical_dev,
VkDevice  dev 
)

◆ required() [1/2]

constexpr bool nngn::DeviceMemory::required ( VkMemoryPropertyFlags  f)
staticconstexpr

Indicates whether a memory type is guaranteed to exist.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ required() [2/2]

static constexpr bool nngn::DeviceMemory::required ( VkMemoryPropertyFlags  f)
staticconstexpr

Indicates whether a memory type is guaranteed to exist.

Member Data Documentation

◆ allocator

void * nngn::DeviceMemory::allocator = {}
private

◆ dev

VkDevice nngn::DeviceMemory::dev = {}
private

◆ props

VkPhysicalDeviceMemoryProperties nngn::DeviceMemory::props = {}
private

The documentation for this class was generated from the following files: