Memory

class lluvia.core.Memory
__init__(*args, **kwargs)
createBuffer(self, uint64_t size, usageFlags=[ll_buffer.BufferUsageFlagBits.StorageBuffer, ll_buffer.BufferUsageFlagBits.TransferSrc, ll_buffer.BufferUsageFlagBits.TransferDst])

Creates a new buffer allocated into this memory.

Parameters

sizeuint64_t greater than zero.

The size of the buffer in bytes.

usageFlagsBufferUsageFlagBits 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 : lluvia.Buffer object.

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

Creates a buffer from a numpy array.

Parameters

arrnp.ndarray.

Numpy array from which the buffer will be created from. The content of the array will be copied into the buffer.

usageFlagsBufferUsageFlagBits 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

bufferBuffer.

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

createBufferLike(self, other, usageFlags=[ll_buffer.BufferUsageFlagBits.StorageBuffer, ll_buffer.BufferUsageFlagBits.TransferSrc, ll_buffer.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.

usageFlagsBufferUsageFlagBits 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 : lluvia.Buffer object.

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

Creates a new image allocated in this memory.

Parameters

shapelist 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]

channelTypell.ChannelType. Defaults to ll.ChannelType.Uint8.

Channel type.

usageFlagsImageUsageFlagBits 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 : new Image object.

Raises

ValueErrorif 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=[ll_image.ImageUsageFlagBits.Storage, ll_image.ImageUsageFlagBits.Sampled, ll_image.ImageUsageFlagBits.TransferSrc, ll_image.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.

usageFlagsstring 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

imglluvia.Image

A new Image object.

Raises

ValueErrorif the number of dimensions is not in [1, 2, 3, 4] or

if arr.dtype is incompatible with image ChannelType.

RuntimeError : if the image cannot be created from this memory.

createImageViewFromHost(self, ndarray arr, usageFlags=[ll_image.ImageUsageFlagBits.Storage, ll_image.ImageUsageFlagBits.Sampled, ll_image.ImageUsageFlagBits.TransferSrc, ll_image.ImageUsageFlagBits.TransferDst], ImageFilterMode filterMode=ll_image.ImageFilterMode.Nearest, ImageAddressMode addressMode=ll_image.ImageAddressMode.ClampToEdge, bool normalizedCoordinates=False, bool sampled=False)

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.

usageFlagsstring 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

filterModestr. Defaults to ‘Nearest’.

Filtering more for reading pixels within a shader. Possible values are defined in lluvia.ImageFilterMode:

  • Nearest

  • Linear

addressModestr. Defaults to ‘Repeat’.

Addressing mode for reading pixels that are outside of the image boundaries. Possible values are defined in lluvia.ImageAddressMode:

  • Repeat

  • MirroredRepeat

  • ClampToEdge

  • ClampToBorder

  • MirrorClampToEdge

normalizedCoordinatesbool. Defaults to False.

Tells whether or not to use normalized coordinates to read pixels within a shader.

sampledbool. Defaults to False.

Tells whether or not to use a sampler object for reading pixels within a shader.

Returns

imglluvia.Image

A new Image object.

Raises

ValueErrorif the number of dimensions is not in [1, 2, 3, 4] or

if arr.dtype is incompatible with image ChannelType.

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

pageuint64_t

Page number.

Returns

True if page is mappable, False otherwise

memoryFlags
pageCount
pageSize
session