Memory

class lluvia.core.Memory
__init__()

Initialize self. See help(type(self)) for accurate signature.

createBuffer(self, uint64_t size, usageFlags=[BufferUsageFlagBits.StorageBuffer, BufferUsageFlagBits.TransferSrc, BufferUsageFlagBits.TransferDst])

Creates a new buffer allocated into this memory.

Parameters
  • size (uint64_t greater than zero.) – The size of the buffer in bytes.

  • usageFlags (BufferUsageFlagBits or list of BufferUsageFlagBits.) –

    Defaults to:
    [BufferUsageFlagBits.StorageBuffer,

    BufferUsageFlagBits.TransferSrc, BufferUsageFlagBits.TransferDst]

    Usage flags for this buffer. It must be a combination of the values defined in lluvia.BufferUsageFlagBits:

    • IndexBuffer

    • IndirectBuffer

    • StorageBuffer

    • StorageTexelBuffer

    • TransferDst

    • TransferSrc

    • UniformBuffer

    • UniformTexelBuffer

    • VertexBuffer

Returns

buf

Return type

lluvia.Buffer object.

createBufferFromHost(self, ndarray arr, usageFlags=[BufferUsageFlagBits.StorageBuffer, BufferUsageFlagBits.TransferSrc, BufferUsageFlagBits.TransferDst])

Creates a buffer from a numpy array.

Parameters
  • arr (np.ndarray.) – Numpy array from which the buffer will be created from. The content of the array will be copied into the buffer.

  • usageFlags (BufferUsageFlagBits or list of BufferUsageFlagBits.) –

    Defaults to:
    [BufferUsageFlagBits.StorageBuffer,

    BufferUsageFlagBits.TransferSrc, BufferUsageFlagBits.TransferDst]

    Usage flags for this buffer. It must be a combination of the values defined in lluvia.BufferUsageFlagBits:

    • IndexBuffer

    • IndirectBuffer

    • StorageBuffer

    • StorageTexelBuffer

    • TransferDst

    • TransferSrc

    • UniformBuffer

    • UniformTexelBuffer

    • VertexBuffer

Returns

buffer – Buffer object with the same content as the input array parameter.

Return type

Buffer.

createBufferLike(self, other, usageFlags=[BufferUsageFlagBits.StorageBuffer, BufferUsageFlagBits.TransferSrc, BufferUsageFlagBits.TransferDst])

Creates a Buffer with the same size in bytes as the other parameter

The memory allocated to this buffer is not filled with any value at the moment of creation.

Parameters
  • other (Numpy ndarray or lluvia Buffer or Image.) –

  • usageFlags (BufferUsageFlagBits or list of BufferUsageFlagBits.) –

    Defaults to:
    [BufferUsageFlagBits.StorageBuffer,

    BufferUsageFlagBits.TransferSrc, BufferUsageFlagBits.TransferDst]

    Usage flags for this buffer. It must be a combination of the values defined in lluvia.BufferUsageFlagBits:

    • IndexBuffer

    • IndirectBuffer

    • StorageBuffer

    • StorageTexelBuffer

    • TransferDst

    • TransferSrc

    • UniformBuffer

    • UniformTexelBuffer

    • VertexBuffer

Returns

buf

Return type

lluvia.Buffer object.

createImage(self, shape, ChannelType channelType=ChannelType.Uint8, usageFlags=[ImageUsageFlagBits.Storage, ImageUsageFlagBits.Sampled, ImageUsageFlagBits.TransferSrc, ImageUsageFlagBits.TransferDst])

Creates a new image allocated in this memory.

Parameters
  • shape (list or tuple of length 1, 2, 3 or 4.) –

    Shape of the image (depth, height , width, channels). Each dimension must be greater than zero. The number of channels must in the range [1, 4]. If one or more dimensions are missing, they are set to 1 by default.

    The shape is interpreted as follows:

    if len(shape) is 1:

    depth = 1 height = 1 width = shape[0] channels = 1

    elif len(shape) is 2:

    depth = 1 height = shape[0] width = shape[1] channels = 1

    elif len(shape) is 3:

    depth = 1 height = shape[0] width = shape[1] channels = shape[2]

    else:

    depth = shape[0] height = shape[1] width = shape[2] channels = shape[3]

  • channelType (ll.ChannelType. Defaults to ll.ChannelType.Uint8.) – Channel type.

  • usageFlags (ImageUsageFlagBits or list of ImageUsageFlagBits.) –

    Defaults to [‘Storage’, ‘Sampled’, ‘TransferSrc’, ‘TransferDst’]. Image usage flags. It must be a combination of th strings defined in lluvia.ImageUsageFlags:

    • TransferSrc

    • TransferDst

    • Sampled

    • Storage

    • ColorAttachment

    • DepthStencilAttachment

    • TransientAttachment

    • InputAttachment

Returns

image

Return type

new Image object.

:raises ValueError : if the number of dimensions is not in [1, 2, 3, 4] or: if any parameter is not within its required range.

createImageFromHost(self, ndarray arr, usageFlags=[ImageUsageFlagBits.Storage, ImageUsageFlagBits.Sampled, ImageUsageFlagBits.TransferSrc, ImageUsageFlagBits.TransferDst])

Creates a lluvia.Image object from a Numpy array.

The numpy array can have between 1 and 4 dimensions. Images can be 1D, 2D or 3D and can have up to 4 color channels. The width, height, depth and channels of the image are resolved as follows.

if arr.ndim is 1: create a 1D image if arr.ndim is 2: create a 2D image with one color channel. if arr.ndim is 3: create a 2D image with the number of channels

given by the length of the third dimension.

if arr.ndim is 4: create a 3D image with the number of channels

given by the length of the fourth dimension.

Notice that for creating 1D images with several color channels, one needs to specify the 4 dimensions [length, 1, 1, channels].

The image’s channel type is deduced from arr.dtype.

Parameters
  • arr (Numpy array.) –

  • usageFlags (string or list of strings.) –

    Defaults to [‘Storage’, ‘Sampled’, ‘TransferSrc’, ‘TransferDst’]. Image usage flags. It must be a combination of th strings defined in lluvia.ImageUsageFlags:

    • TransferSrc

    • TransferDst

    • Sampled

    • Storage

    • ColorAttachment

    • DepthStencilAttachment

    • TransientAttachment

    • InputAttachment

Returns

img – A new Image object.

Return type

lluvia.Image

:raises ValueError : if the number of dimensions is not in [1, 2, 3, 4] or: if arr.dtype is incompatible with image ChannelType. :raises RuntimeError : if the image cannot be created from this memory.:

isMappable
isPageMappable(self, uint64_t page)

Determines if page is currently available to be mapped.

This test checks if page is available to be mapped to host-memory by a given objects such as a Buffer.

Parameters

page (uint64_t) – Page number.

Returns

Return type

True if page is mappable, False otherwise

memoryFlags
pageCount
pageSize
session