Texture bind reuse or rebind

Hi, I use texture for data manipulation. I am quite new to texture.
My use case is a texture binds to a buffer, data in the buffer will be updated in a loop, within the loop, a kernel will access the buffer via texture.
my question is,
should I

  1. bind the texture
  2. call kernel
  3. unbind texture
  4. update buffer
  5. go back to 1


  1. bind the texture
  2. call kernel
  3. update buffer
  4. go back to 2

end of loop
unbind texture

thanks a lot.

texture binding (texture references) is deprecated, you should use bindless textures (texture objects)

The following should be safe:

  1. create cudaArray for texture buffer
  2. fill cudaArray
  3. create texture object using cudaArray
  4. call kernel
  5. destroy texture object
  6. go to step 2

you could also use 2 textures and ping-pong between them, for example to overlap the update of the cudaArray with the kernel execution

1 Like

OK, thank you for your recomendation, I’ll try texture object.
BTW, But if texture references must be used, which way above is better?

(1) Thou shalt not use texture references. Seriously. Don’t do it.

(2) Instead of asking hypotheticals as to which way works better, I recommend running some quick experiments to find out which way works better in the specific context of your use case.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.