dynamic update of texture in a kernel is it worth it


I had a simple question. I have a kernel which fills an array in global memory. I’d like the kernel executed after that to read the data generated by the previous kernel and produce something else. Is it worth binding this global array to texture each frame? Is it even valid and do I need to unbind the texture each time I update global memory?

It could look like this:


launch_firstKernel(); // fills mem d_result

bindTexture(d_result, resultTexture);

launch_secondKernel();// uses tex1dfetch(resultTexture)

I thought this could be beneficial since the texture cache could be enabled, but is it worth the effort? I don’t know what’s really going on behind the scene when texture binding is performed.


I havent tried this but this seems valid and possible. As far as I saw binding/unbinding shouldn’t take time/too much time.

I guess the best answer is to test it on your code :)

Its all a matter of how much it will take oppose to the time your kernels run.

would be interesting to see what you got though :)


It is a lot of trouble for little reason. You can write to device memory that is bound to a texture, leave it bound and read it in the next kernel.

I asked myself the same thing a few days ago


Thanks Tovi, looks like it’s worth giving textures a try.