cuda.core.textures.ResourceDescriptor#
- class cuda.core.textures.ResourceDescriptor#
Describes the memory backing a
TextureObject.Construct via the
from_*classmethods:from_array()wraps aCUDAArray(works for bothTextureObjectandSurfaceObject).from_mipmapped_array()wraps aMipmappedArrayfor mipmapped sampling (texture only, not surface).from_linear()wraps aBufferas a typed 1D fetch. Texture objects built from a linear resource do not support filtering, normalized coordinates, or addressing modes.from_pitch2d()wraps aBufferas a row-pitched 2D image. Supports filtering and 2D addressing, but only 2D access.
Linear and pitch2D resources cannot back a
SurfaceObject— those require anCUDAArrayallocated withis_surface_load_store=True.Methods
- __init__(self)#
- 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
TextureObjectbuilt 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
bufferto bind. Defaults tobuffer.size. Must not exceed it.
Notes
Texture objects built from a linear resource ignore the
TextureDescriptoraddressing/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
TextureObjectfor mipmapped sampling. Not valid as aSurfaceObjectbacking: surfaces require a singleCUDAArraylevel (obtain viaMipmappedArray.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
TextureObjectbuilt 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_channelsand meet the driver’sCU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT.
Attributes
- format#
The element
ArrayFormat(Nonefor array-backed).
- height#
Pitch2D image height, in rows (
Nonefor other kinds).
- kind#
- num_channels#
Channels per element (
Nonefor array-backed).
- pitch_bytes#
Pitch2D row pitch, in bytes (
Nonefor other kinds).
- size_bytes#
Bytes bound for a linear resource (
Nonefor other kinds).
- source#
- width#
Pitch2D image width, in elements (
Nonefor other kinds).