Using a 3d texture slice as shader input

I would like to update a 3d texture by rendering one slice at a time. However, at each step I would also like to access the previous slice to read its values. Setting up each slice as a render target works fine, but is it also possible to use such a slice as an input in my shader? (I’m trying to avoid explicitly copying the previously written slice to a separate texture.)

I believe it is undefined to use a sampler3D that is bound to the same 3d texture that is being written to. But is it still undefined if the shader is gauranteed to never read/write texels in the same slice at the same time?

Or, as a different option, if I have a sampler2D (or sampler2DArray), can I somehow bind it to the same data as the 3d texture to avoid a copy?

No, it is not, at least not in all cases. For texture arrays and 3D textures you can use other slices without restriction, but you can also use the slices you are rendering to with certain limitations. Check the extension NV_texture_barrier.

Thanks for the response. I didn’t know about the NV_texture_barrier extension, but it sounds like a sampler3d should do what I need.

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