Texture Object Management
- Provided by: nvidia-cuda-dev (Version: 10.1.243-3)
- Source: nvidia-cuda-toolkit
- Report a bug
\brief texture object management functions of the low-level CUDA driver API (cuda.h)
This section describes the texture object management functions of the low-level CUDA driver application programming interface. The texture object API is only supported on devices of compute capability 3.0 or higher.
Creates a texture object and returns it in pTexObject. pResDesc describes the data to texture from. pTexDesc describes how the data should be sampled. pResViewDesc is an optional argument that specifies an alternate format for the data described by pResDesc, and also describes the subresource region to restrict access to when texturing. pResViewDesc can only be specified if the type of resource is a CUDA array or a CUDA mipmapped array.
Texture objects are only supported on devices of compute capability 3.0 or higher. Additionally, a texture object is an opaque value, and, as such, should only be accessed through CUDA API calls.
The CUDA_RESOURCE_DESC structure is defined as:
typedef struct CUDA_RESOURCE_DESC_st
{
CUresourcetype resType;
union {
struct {
CUarray hArray;
} array;
struct {
CUmipmappedArray hMipmappedArray;
} mipmap;
struct {
CUdeviceptr devPtr;
CUarray_format format;
unsigned int numChannels;
size_t sizeInBytes;
} linear;
struct {
CUdeviceptr devPtr;
CUarray_format format;
unsigned int numChannels;
size_t width;
size_t height;
size_t pitchInBytes;
} pitch2D;
} res;
unsigned int flags;
} CUDA_RESOURCE_DESC;
where:
typedef enum CUresourcetype_enum {
CU_RESOURCE_TYPE_ARRAY = 0x00,
CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01,
CU_RESOURCE_TYPE_LINEAR = 0x02,
CU_RESOURCE_TYPE_PITCH2D = 0x03
} CUresourcetype;
.RS 4 If CUDA_RESOURCE_DESC::resType is set to
CU_RESOURCE_TYPE_ARRAY, CUDA_RESOURCE_DESC::res::array::hArray must
be set to a valid CUDA array handle.
.RS 4 If CUDA_RESOURCE_DESC::resType is set to
CU_RESOURCE_TYPE_MIPMAPPED_ARRAY,
CUDA_RESOURCE_DESC::res::mipmap::hMipmappedArray must be set to a valid CUDA
mipmapped array handle.
.RS 4 If CUDA_RESOURCE_DESC::resType is set to
CU_RESOURCE_TYPE_LINEAR, CUDA_RESOURCE_DESC::res::linear::devPtr must
be set to a valid device pointer, that is aligned to
CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT.
CUDA_RESOURCE_DESC::res::linear::format and
CUDA_RESOURCE_DESC::res::linear::numChannels describe the format of each
component and the number of components per array element.
CUDA_RESOURCE_DESC::res::linear::sizeInBytes specifies the size of the array
in bytes. The total number of elements in the linear address range cannot
exceed CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH. The number
of elements is computed as (sizeInBytes / (sizeof(format) * numChannels)).
.RS 4 If CUDA_RESOURCE_DESC::resType is set to
CU_RESOURCE_TYPE_PITCH2D, CUDA_RESOURCE_DESC::res::pitch2D::devPtr
must be set to a valid device pointer, that is aligned to
CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT.
CUDA_RESOURCE_DESC::res::pitch2D::format and
CUDA_RESOURCE_DESC::res::pitch2D::numChannels describe the format of each
component and the number of components per array element.
CUDA_RESOURCE_DESC::res::pitch2D::width and
CUDA_RESOURCE_DESC::res::pitch2D::height specify the width and height of the
array in elements, and cannot exceed
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH and
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT respectively.
CUDA_RESOURCE_DESC::res::pitch2D::pitchInBytes specifies the pitch between
two rows in bytes and has to be aligned to
CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT. Pitch cannot exceed
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH.
The CUDA_TEXTURE_DESC struct is defined as
typedef struct CUDA_TEXTURE_DESC_st {
CUaddress_mode addressMode[3];
CUfilter_mode filterMode;
unsigned int flags;
unsigned int maxAnisotropy;
CUfilter_mode mipmapFilterMode;
float mipmapLevelBias;
float minMipmapLevelClamp;
float maxMipmapLevelClamp;
} CUDA_TEXTURE_DESC;
where
typedef enum CUaddress_mode_enum {
CU_TR_ADDRESS_MODE_WRAP = 0,
CU_TR_ADDRESS_MODE_CLAMP = 1,
CU_TR_ADDRESS_MODE_MIRROR = 2,
CU_TR_ADDRESS_MODE_BORDER = 3
} CUaddress_mode;
This is ignored if CUDA_RESOURCE_DESC::resType is
CU_RESOURCE_TYPE_LINEAR. Also, if the flag,
CU_TRSF_NORMALIZED_COORDINATES is not set, the only supported address
mode is CU_TR_ADDRESS_MODE_CLAMP.
typedef enum CUfilter_mode_enum {
CU_TR_FILTER_MODE_POINT = 0,
CU_TR_FILTER_MODE_LINEAR = 1
} CUfilter_mode;
This is ignored if CUDA_RESOURCE_DESC::resType is
CU_RESOURCE_TYPE_LINEAR.
The CUDA_RESOURCE_VIEW_DESC struct is defined as
typedef struct CUDA_RESOURCE_VIEW_DESC_st
{
CUresourceViewFormat format;
size_t width;
size_t height;
size_t depth;
unsigned int firstMipmapLevel;
unsigned int lastMipmapLevel;
unsigned int firstLayer;
unsigned int lastLayer;
} CUDA_RESOURCE_VIEW_DESC;
where:
Parameters:
Returns:
See also:
Destroys the texture object specified by texObject.
Parameters:
Returns:
See also:
Returns the resource descriptor for the texture object specified by texObject.
Parameters:
Returns:
See also:
Returns the resource view descriptor for the texture object specified by texObject. If no resource view was set for texObject, the CUDA_ERROR_INVALID_VALUE is returned.
Parameters:
Returns:
See also:
Returns the texture descriptor for the texture object specified by texObject.
Parameters:
Returns:
See also:
Generated automatically by Doxygen from the source code.