Prefer to read without ads? Become a member — from $10/month — and support the work. Already a member? Log in to read ad-free on this device.

10.16 Texturing Quick References

10.16.1 Hardware Capabilities

Hardware Limits

Capability SM 1.x SM 2.x
Maximum width – 1D CUDA array 8192 32768
Maximum width – 1D device memory 227
Maximum width and number of layers – 1D layered texture 8192×512 16384×2048
Maximum extents for 2D texture 65536×32768
Maximum extents and number of layers – 2D layered texture

8192×

8192×

512

16384×

16384×

2048

Maximum extents – 3D CUDA array 2048×2048×2048
Maximum extents for a 2D surface n/a 8192×8192

Queries – Driver API

Most of the hardware limits listed above can be queried by calling cuDeviceGetAttribute() with the following values.

Attribute CUdevice_attribute value
Maximum width – 1D CUDA array CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH
Maximum width of 1D layered texture CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH
Maximum number of layers of 1D layered texture CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS
Maximum width of 2D texture CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH
Maximum height of 2D texture CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT
Maximum width of 2D layered texture CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH
Maximum height of 2D layered texture CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT
Maximum number of layers of 2D layered texture CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS
Maximum width – 3D CUDA array CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH
Maximum height – 3D CUDA array CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT
Maximum depth – 3D CUDA array CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH

Queries – CUDA Runtime

The following members of cudaDeviceProp contain hardware limits as listed below.

Capability cudaDeviceProp member
Maximum width – 1D CUDA array int maxTexture1D;
Maximum width and number of layers – 1D layered texture int maxTextureLayered[2];
Maximum extents for 2D texture int maxTexture2D[2];
Maximum extents and number of layers – 2D layered texture int maxTextureLayered[2];
Maximum extents – 3D CUDA array int maxTexture3D[3];

10.16.2 CUDA Runtime

A texture object is created with cudaCreateTextureObject() from a cudaResourceDesc whose resType is given below, together with a cudaTextureDesc; it is released with cudaDestroyTextureObject().

1D Textures

Operation Device Memory CUDA Arrays
Allocate with… cudaMalloc() cudaMallocArray()
Free with… cudaFree() cudaFreeArray()
Resource type… cudaResourceTypeLinear cudaResourceTypeArray
Texture with… tex1Dfetch()<T>() tex1D()<T>()

2D Textures

Operation Device Memory CUDA Arrays
Allocate with… cudaMallocPitch() cudaMalloc2DArray()*
Free with… cudaFree() cudaFreeArray()
Resource type… cudaResourceTypePitch2D cudaResourceTypeArray
Texture with… tex2D()<T>() tex2D()<T>()

* if surface load/store is desired, specify the cudaArraySurfaceLoadStore flag.

3D Textures

Operation Device Memory CUDA Arrays
Allocate with… (not supported) cudaMalloc3DArray()
Free with… cudaFreeArray()
Resource type… cudaResourceTypeArray
Texture with… tex3D()<T>()

1D Layered Textures

Operation Device Memory CUDA Arrays
Allocate with… (not supported) cudaMalloc2DArray()- specify cudaArrayLayered.
Free with… cudaFreeArray()
Resource type… cudaResourceTypeArray
Texture with… tex1DLayered<T>()

2D Layered Textures

Operation Device Memory CUDA Arrays
Allocate with… (not supported) cudaMalloc3DArray()- specify cudaArrayLayered.
Free with… cudaFreeArray()
Resource type… cudaResourceTypeArray
Texture with… tex2DLayered<T>()