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 aTextureObject(or by retrieving the level’sCUDAArrayand binding it as aSurfaceObject). Destroying theMipmappedArraydestroys all level arrays implicitly, so theCUDAArrayinstances returned byget_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 levelCUDAArrayfromget_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_LDSTso individual levels (obtained viaget_level()) can be bound asSurfaceObjectfor kernel-side writes. Default False.
- Return type:
- get_level(self, level)#
Return a non-owning
CUDAArrayview of the given mip level.- Parameters:
level (int) – Mip level index in
[0, num_levels).- Returns:
A non-owning
CUDAArraywrapping the level’sCUarray. TheMipmappedArrayis kept alive for the lifetime of the returnedCUDAArray; the underlying storage is released only when thisMipmappedArrayis destroyed.- Return type:
Attributes
- device#
The
Devicethis mipmap was allocated on.
- format#
The element
ArrayFormat.
- handle#
The underlying
CUmipmappedArrayas an integer.
- is_surface_load_store#
True if this mipmap (and each of its levels) was created with
CUDA_ARRAY3D_SURFACE_LDSTand can back aSurfaceObject.
- num_channels#
Channels per element (1, 2, or 4).
- num_levels#
Number of mip levels.
- shape#
Base-level (level 0) allocation shape, in elements.