PDA

View Full Version : using a 3d texture slice as shader input



joshj
10-08-2011, 09:04 AM
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?

aqnuep
10-08-2011, 09:57 AM
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 (http://www.opengl.org/registry/specs/NV/texture_barrier.txt).

joshj
10-09-2011, 10:54 AM
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.