Generic convolve

I try to implement a generic convolution using texture and constant memories but I encounter a problem with texture and constant memory scope. Is there a way to encapsulate texture and constant variables ? I try to do something like that :


template <typename T, unsigned D1, unsigned D2>

struct convolve2D


static void set_kernel(const T kernel[D1][D2]);

static void link_tex(const gpu_image src);

static global void apply(gpu_image dst);

static texture <T, 2, cudaReadModeElementType> tex;

static constant T kernel[D1][D2];


Sorry, constant variables are only allowed at file scope (and not on struct members). See the programming guide, section b.2.5.

Maybe you could pass a pointer to the kernel as a parameter to your apply() function instead?