37 #ifndef PCL_GPU_UTILS_TEXTURE_BINDER_HPP_
38 #define PCL_GPU_UTILS_TEXTURE_BINDER_HPP_
40 #include <pcl/gpu/utils/safe_call.hpp>
41 #include <pcl/gpu/containers/device_array.h>
50 template<
class T, enum cudaTextureReadMode readMode>
53 cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>();
54 cudaSafeCall( cudaBindTexture2D(0, tex, arr.
ptr(), desc, arr.
cols(), arr.
rows(), arr.
step()) );
57 template<
class T, enum cudaTextureReadMode readMode>
60 cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>();
61 cudaSafeCall( cudaBindTexture(0, tex, arr.
ptr(), desc, arr.
sizeBytes()) );
64 template<
class T, enum cudaTextureReadMode readMode>
67 cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>();
68 cudaSafeCall( cudaBindTexture2D(0, tex, arr.
data, desc, arr.
cols, arr.
rows, arr.
step) );
71 template<
class T, enum cudaTextureReadMode readMode>
74 cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>();
75 cudaSafeCall( cudaBindTexture(0, tex, arr.
data, desc, arr.
size * arr.
elemSize()) );
80 cudaSafeCall( cudaUnbindTexture(texref) );
83 const struct textureReference *texref;
int rows() const
Returns number of rows.
int cols() const
Returns number of elements in each row.
T * ptr(int y=0)
Returns pointer to given row in internal buffer.
T * ptr()
Returns pointer for internal buffer in GPU memory.
std::size_t step() const
Returns stride between two consecutive rows in bytes for internal buffer.
std::size_t sizeBytes() const
TextureBinder(const PtrStepSz< T > &arr, const struct texture< T, 2, readMode > &tex)
TextureBinder(const PtrSz< T > &arr, const struct texture< T, 1, readMode > &tex)
TextureBinder(const DeviceArray2D< T > &arr, const struct texture< T, 2, readMode > &tex)
TextureBinder(const DeviceArray< T > &arr, const struct texture< T, 1, readMode > &tex)
__PCL_GPU_HOST_DEVICE__ std::size_t elemSize() const
std::size_t step
stride between two consecutive rows in bytes.