40 #include "cuv_general.hpp"
46 texture<float> tex_x_float;
47 texture<uchar4> tex_x_uchar4;
48 texture<uchar1> tex_x_uchar1;
50 inline size_t bind_x(
const uchar1 * x,
const unsigned int len)
53 cuvSafeCall(cudaBindTexture(&offset, tex_x_uchar1, (
const void *)x,
sizeof(uchar1)*len));
55 return offset/
sizeof(uchar1);
57 inline size_t bind_x(
const uchar4 * x,
const unsigned int len)
60 cuvSafeCall(cudaBindTexture(&offset, tex_x_uchar4, (
const void *)x,
sizeof(uchar4)*len));
62 return offset/
sizeof(uchar4);
64 inline size_t bind_x(
const float * x,
const unsigned int len)
67 cuvSafeCall(cudaBindTexture(&offset, tex_x_float, (
const void *)x,
sizeof(
float)*len));
69 return offset/
sizeof(float);
73 inline void unbind_x(
const float * x)
74 { cuvSafeCall(cudaUnbindTexture(tex_x_float)); }
75 inline void unbind_x(
const uchar4 * x)
76 { cuvSafeCall(cudaUnbindTexture(tex_x_uchar4)); }
77 inline void unbind_x(
const uchar1 * x)
78 { cuvSafeCall(cudaUnbindTexture(tex_x_uchar1)); }
80 template <
bool UseCache>
81 inline __device__
float fetch_x(
const float* x,
const int& i)
83 if (UseCache)
return tex1Dfetch(tex_x_float, i);
86 template <
bool UseCache>
87 inline __device__ uchar4 fetch_x(
const uchar4* x,
const int& i)
89 if (UseCache)
return tex1Dfetch(tex_x_uchar4, i);
92 template <
bool UseCache>
93 inline __device__ uchar1 fetch_x(
const uchar1* x,
const int& i)
95 if (UseCache)
return tex1Dfetch(tex_x_uchar1, i);