cuda.core.textures.MipmappedArray#

class cuda.core.textures.MipmappedArray(*args, **kwargs)#

A mipmapped CUDA array for texture/surface access across levels.

Wraps CUmipmappedArray. Each mip level is a distinct, hardware-laid-out allocation accessible only via a TextureObject (or by retrieving the level’s CUDAArray and binding it as a SurfaceObject). Destroying the MipmappedArray destroys all level arrays implicitly, so the CUDAArray instances returned by get_level() are non-owning and hold a strong reference back to their parent.

Construct via from_descriptor().

Methods

__init__(*args, **kwargs)#
close(self)#

Release this object’s reference to the underlying CUmipmappedArray.

Destruction (cuMipmappedArrayDestroy) happens via the handle’s deleter when the last reference is dropped. A level CUDAArray from get_level() holds its own reference to this mipmap’s storage, so it stays valid until both it and this object are released. Idempotent.

classmethod from_descriptor(
cls,
*,
shape,
format,
num_channels,
num_levels,
is_surface_load_store=False,
)#

Allocate a new mipmapped CUDA array.

Parameters:
  • shape (tuple of int) – (width,), (width, height), or (width, height, depth) in elements, for the base (level 0) mip.

  • format (ArrayFormat) – Element format.

  • num_channels (int) – Channels per element. Must be 1, 2, or 4.

  • num_levels (int) – Number of mip levels to allocate; must be >= 1. The driver caps this at the log2 of the largest dimension; passing a larger value yields a driver error.

  • is_surface_load_store (bool) – If True, allocate with CUDA_ARRAY3D_SURFACE_LDST so individual levels (obtained via get_level()) can be bound as SurfaceObject for kernel-side writes. Default False.

Return type:

MipmappedArray

get_level(self, level)#

Return a non-owning CUDAArray view of the given mip level.

Parameters:

level (int) – Mip level index in [0, num_levels).

Returns:

A non-owning CUDAArray wrapping the level’s CUarray. The MipmappedArray is kept alive for the lifetime of the returned CUDAArray; the underlying storage is released only when this MipmappedArray is destroyed.

Return type:

CUDAArray

Attributes

device#

The Device this mipmap was allocated on.

format#

The element ArrayFormat.

handle#

The underlying CUmipmappedArray as an integer.

is_surface_load_store#

True if this mipmap (and each of its levels) was created with CUDA_ARRAY3D_SURFACE_LDST and can back a SurfaceObject.

num_channels#

Channels per element (1, 2, or 4).

num_levels#

Number of mip levels.

shape#

Base-level (level 0) allocation shape, in elements.