texture_binder.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <kfusion/safe_call.hpp>
5 
6 namespace kfusion
7 {
8  namespace cuda
9  {
11  {
12  public:
13  template<class T, enum cudaTextureReadMode readMode>
14  TextureBinder(const DeviceArray2D<T>& arr, const struct texture<T, 2, readMode>& tex) : texref(&tex)
15  {
16  cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>();
17  cudaSafeCall( cudaBindTexture2D(0, tex, arr.ptr(), desc, arr.cols(), arr.rows(), arr.step()) );
18  }
19 
20  template<class T, enum cudaTextureReadMode readMode>
21  TextureBinder(const DeviceArray<T>& arr, const struct texture<T, 1, readMode> &tex) : texref(&tex)
22  {
23  cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>();
24  cudaSafeCall( cudaBindTexture(0, tex, arr.ptr(), desc, arr.sizeBytes()) );
25  }
26 
27  template<class T, enum cudaTextureReadMode readMode>
28  TextureBinder(const PtrStepSz<T>& arr, const struct texture<T, 2, readMode>& tex) : texref(&tex)
29  {
30  cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>();
31  cudaSafeCall( cudaBindTexture2D(0, tex, arr.data, desc, arr.cols, arr.rows, arr.step) );
32  }
33 
34  template<class A, class T, enum cudaTextureReadMode readMode>
35  TextureBinder(const A& arr, const struct texture<T, 2, readMode>& tex, const cudaChannelFormatDesc& desc) : texref(&tex)
36  {
37  cudaSafeCall( cudaBindTexture2D(0, tex, arr.data, desc, arr.cols, arr.rows, arr.step) );
38  }
39 
40  template<class T, enum cudaTextureReadMode readMode>
41  TextureBinder(const PtrSz<T>& arr, const struct texture<T, 1, readMode> &tex) : texref(&tex)
42  {
43  cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>();
44  cudaSafeCall( cudaBindTexture(0, tex, arr.data, desc, arr.size * arr.elemSize()) );
45  }
46 
48  {
49  cudaSafeCall( cudaUnbindTexture(texref) );
50  }
51  private:
52  const struct textureReference *texref;
53  };
54  }
55 
56  namespace device
57  {
59  }
60 }
kfusion::cuda::TextureBinder::texref
const struct textureReference * texref
Definition: texture_binder.hpp:52
kfusion::cuda::TextureBinder::TextureBinder
TextureBinder(const DeviceArray< T > &arr, const struct texture< T, 1, readMode > &tex)
Definition: texture_binder.hpp:21
kfusion::cuda::TextureBinder::TextureBinder
TextureBinder(const A &arr, const struct texture< T, 2, readMode > &tex, const cudaChannelFormatDesc &desc)
Definition: texture_binder.hpp:35
kfusion::cuda::TextureBinder::TextureBinder
TextureBinder(const DeviceArray2D< T > &arr, const struct texture< T, 2, readMode > &tex)
Definition: texture_binder.hpp:14
kfusion::cuda::PtrSz::size
size_t size
Definition: kernel_containers.hpp:37
kfusion::cuda::DeviceArray2D::cols
int cols() const
Returns number of elements in each row.
Definition: device_array.hpp:300
kfusion::cuda::DevPtr::elemSize
__kf_hdevice__ size_t elemSize() const
Definition: kernel_containers.hpp:27
kfusion::cuda::PtrStep::step
size_t step
stride between two consecutive rows in bytes. Step is stored always and everywhere in bytes!...
Definition: kernel_containers.hpp:46
kfusion::cuda::TextureBinder
Definition: texture_binder.hpp:10
kfusion::cuda::PtrStepSz::cols
int cols
Definition: kernel_containers.hpp:61
kfusion::cuda::DeviceArray2D::ptr
T * ptr(int y=0)
Returns pointer to given row in internal buffer.
Definition: device_array.hpp:294
kfusion
Utility.
Definition: capture.hpp:8
kfusion::cuda::PtrSz
Definition: kernel_containers.hpp:32
kfusion::cuda::DeviceArray
DeviceArray class
Definition: device_array.hpp:20
safe_call.hpp
kfusion::cuda::TextureBinder::TextureBinder
TextureBinder(const PtrStepSz< T > &arr, const struct texture< T, 2, readMode > &tex)
Definition: texture_binder.hpp:28
kfusion::cuda::DevPtr::data
T * data
Definition: kernel_containers.hpp:22
device_array.hpp
kfusion::cuda::DeviceArray::ptr
T * ptr()
Returns pointer for internal buffer in GPU memory.
Definition: device_array.hpp:259
kfusion::cuda::DeviceArray2D::rows
int rows() const
Returns number of rows.
Definition: device_array.hpp:301
kfusion::cuda::PtrStepSz::rows
int rows
Definition: kernel_containers.hpp:62
kfusion::cuda::DeviceMemory::sizeBytes
size_t sizeBytes() const
Definition: device_memory.cpp:139
cudaSafeCall
#define cudaSafeCall(expr)
Definition: safe_call.hpp:16
kfusion::cuda::PtrStepSz
Definition: kernel_containers.hpp:55
kfusion::cuda::TextureBinder::TextureBinder
TextureBinder(const PtrSz< T > &arr, const struct texture< T, 1, readMode > &tex)
Definition: texture_binder.hpp:41
kfusion::cuda::TextureBinder::~TextureBinder
~TextureBinder()
Definition: texture_binder.hpp:47
kfusion::cuda::DeviceArray2D
DeviceArray2D class
Definition: device_array.hpp:117
kfusion::cuda::DeviceMemory2D::step
size_t step() const
Returns stride between two consecutive rows in bytes for internal buffer. Step is stored always and e...
Definition: device_memory.cpp:258


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:25