Texture Object Management
- Provided by: nvidia-cuda-dev (Version: 7.5.18-0ubuntu1)
- Source: nvidia-cuda-toolkit
- Report a bug
\brief texture object management functions of the CUDA runtime API (cuda_runtime_api.h)
This section describes the low level texture object management functions of the CUDA runtime 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 cudaResourceDesc structure is defined as:
struct cudaResourceDesc {
enum cudaResourceType resType;
union {
struct {
cudaArray_t array;
} array;
struct {
cudaMipmappedArray_t mipmap;
} mipmap;
struct {
void *devPtr;
struct cudaChannelFormatDesc desc;
size_t sizeInBytes;
} linear;
struct {
void *devPtr;
struct cudaChannelFormatDesc desc;
size_t width;
size_t height;
size_t pitchInBytes;
} pitch2D;
} res;
};
where:
enum cudaResourceType {
cudaResourceTypeArray = 0x00,
cudaResourceTypeMipmappedArray = 0x01,
cudaResourceTypeLinear = 0x02,
cudaResourceTypePitch2D = 0x03
};
.RS 4 If cudaResourceDesc::resType is set to
cudaResourceTypeArray, cudaResourceDesc::res::array::array must be
set to a valid CUDA array handle.
.RS 4 If cudaResourceDesc::resType is set to
cudaResourceTypeMipmappedArray, cudaResourceDesc::res::mipmap::mipmap
must be set to a valid CUDA mipmapped array handle and
cudaTextureDesc::normalizedCoords must be set to true.
.RS 4 If cudaResourceDesc::resType is set to
cudaResourceTypeLinear, cudaResourceDesc::res::linear::devPtr must be
set to a valid device pointer, that is aligned to
cudaDeviceProp::textureAlignment. cudaResourceDesc::res::linear::desc
describes the format and the number of components per array element.
cudaResourceDesc::res::linear::sizeInBytes specifies the size of the array
in bytes. The total number of elements in the linear address range cannot
exceed cudaDeviceProp::maxTexture1DLinear. The number of elements is
computed as (sizeInBytes / sizeof(desc)).
.RS 4 If cudaResourceDesc::resType is set to
cudaResourceTypePitch2D, cudaResourceDesc::res::pitch2D::devPtr must
be set to a valid device pointer, that is aligned to
cudaDeviceProp::textureAlignment.
cudaResourceDesc::res::pitch2D::desc describes the format and the number of
components per array element. cudaResourceDesc::res::pitch2D::width and
cudaResourceDesc::res::pitch2D::height specify the width and height of the
array in elements, and cannot exceed
cudaDeviceProp::maxTexture2DLinear[0] and
cudaDeviceProp::maxTexture2DLinear[1] respectively.
cudaResourceDesc::res::pitch2D::pitchInBytes specifies the pitch between two
rows in bytes and has to be aligned to
cudaDeviceProp::texturePitchAlignment. Pitch cannot exceed
cudaDeviceProp::maxTexture2DLinear[2].
The cudaTextureDesc struct is defined as
struct cudaTextureDesc {
enum cudaTextureAddressMode addressMode[3];
enum cudaTextureFilterMode filterMode;
enum cudaTextureReadMode readMode;
int sRGB;
int normalizedCoords;
unsigned int maxAnisotropy;
enum cudaTextureFilterMode mipmapFilterMode;
float mipmapLevelBias;
float minMipmapLevelClamp;
float maxMipmapLevelClamp;
};
where
enum cudaTextureAddressMode {
cudaAddressModeWrap = 0,
cudaAddressModeClamp = 1,
cudaAddressModeMirror = 2,
cudaAddressModeBorder = 3
};
This is ignored if cudaResourceDesc::resType is
cudaResourceTypeLinear. Also, if
cudaTextureDesc::normalizedCoords is set to zero,
cudaAddressModeWrap and cudaAddressModeMirror won't be
supported and will be switched to cudaAddressModeClamp.
enum cudaTextureFilterMode {
cudaFilterModePoint = 0,
cudaFilterModeLinear = 1
};
This is ignored if cudaResourceDesc::resType is
cudaResourceTypeLinear.
enum cudaTextureReadMode {
cudaReadModeElementType = 0,
cudaReadModeNormalizedFloat = 1
};
Note that this applies only to 8-bit and 16-bit integer formats. 32-bit
integer format would not be promoted, regardless of whether or not this
cudaTextureDesc::readMode is set cudaReadModeNormalizedFloat
is specified.
The cudaResourceViewDesc struct is defined as
struct cudaResourceViewDesc {
enum cudaResourceViewFormat format;
size_t width;
size_t height;
size_t depth;
unsigned int firstMipmapLevel;
unsigned int lastMipmapLevel;
unsigned int firstLayer;
unsigned int lastLayer;
};
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 specified, cudaErrorInvalidValue 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.