use tex1Dfetch to access textureReference?

Hi all,

I’m writing a C++ class of DeviceTextureMemory. I want to include a const textureReference* into the class, and everytime I bind a texture reference to the linear memory allocated on GPU, I can just call DeviceTextureMemory::bind(void)

But it seems the kernel cannot access textureReference, with tex1Dfetch.

Does that mean I can only declare texture<float, 1, someReadMode> tex, in global scape, and acess it within the kernel, just like the case of constant?


Yes. Texture references only have valid scope within the compilation unit they are defined in. One of the shortcomings of not having a gpu linker. I usually add host wrapper functions for accessing file local stuff like constant symbols and textures, then you can pass function pointers to the access functions around freely. It isn’t all that clean compared with passing the object itself, but it works.