cuda.core.textures.ResourceDescriptor#

class cuda.core.textures.ResourceDescriptor#

Describes the memory backing a TextureObject.

Construct via the from_* classmethods:

Linear and pitch2D resources cannot back a SurfaceObject — those require an CUDAArray allocated with is_surface_load_store=True.

Methods

__init__(self)#
classmethod from_array(cls, array)#

Build a resource descriptor backed by a CUDAArray.

classmethod from_linear(
cls,
buffer,
*,
format,
num_channels,
size_bytes=None,
)#

Build a resource descriptor for a linear (typed 1D) texture fetch.

Parameters:
  • buffer (Buffer) – Device-memory backing. Must remain alive for the lifetime of any TextureObject built from this descriptor.

  • format (ArrayFormat) – Element format.

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

  • size_bytes (int, optional) – Bytes of buffer to bind. Defaults to buffer.size. Must not exceed it.

Notes

Texture objects built from a linear resource ignore the TextureDescriptor addressing/filtering fields — kernels read through a typed 1D fetch with bounds checking only.

classmethod from_mipmapped_array(cls, mipmapped_array)#

Build a resource descriptor backed by a MipmappedArray.

Suitable for binding to a TextureObject for mipmapped sampling. Not valid as a SurfaceObject backing: surfaces require a single CUDAArray level (obtain via MipmappedArray.get_level()).

classmethod from_pitch2d(
cls,
buffer,
*,
format,
num_channels,
width,
height,
pitch_bytes,
)#

Build a resource descriptor for a row-pitched 2D image.

Parameters:
  • buffer (Buffer) – Device-memory backing. Must remain alive for the lifetime of any TextureObject built from this descriptor.

  • format (ArrayFormat) – Element format.

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

  • width (int) – Image width, in elements.

  • height (int) – Image height, in rows.

  • pitch_bytes (int) – Distance between consecutive rows, in bytes. Must be at least width * format_size * num_channels and meet the driver’s CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT.

Attributes

format#

The element ArrayFormat (None for array-backed).

height#

Pitch2D image height, in rows (None for other kinds).

kind#
num_channels#

Channels per element (None for array-backed).

pitch_bytes#

Pitch2D row pitch, in bytes (None for other kinds).

size_bytes#

Bytes bound for a linear resource (None for other kinds).

source#
width#

Pitch2D image width, in elements (None for other kinds).