Share texture array among multiple texture object

Hello,

according to Appendix C.8 “Texture Objects” of the OpenGL Specs:
“A set of texture arrays and their related texture state can be treated as a single object. Such treatment allows for greater implementation efficiency when multiple arrays are used. In conjunction with the subtexture capability, it also allows clients to make gradual changes to existing texture arrays, rather than completely redefining them.”

So glTexImage creates a specific texture array, likely allocates the necessary memory and binds it to the current texture object.
Every texture object keeps references to the associated texture arrays.

For a specific application I would like to share texture arrays (or even better parts of texture arrays) among multiple texture object. For each texture object the texture array represents a different MIP-level. E.g. the same texture array is used as level 1 in texture object A and as level 5 in texture object B.

Currently I’m forced to allocate two texture arrays, fill the first one with data and use mechanisms like glCopy(Sub)TexImage, p-Buffer or FBO to copy from the first to the second array. Beside the overhead of the copy operation, this proceeding doubles the memory usage.

Because of this the double-referencing would save both time and memory.
So finally my questions: Is this possible?
And if not: Is there at least a faster way to copy the texture contents?

The only way to do this is if you happen to exactly share a set of LODs between textures (your example suggests this is LOD related). You could conceivably use a single texture and just use min and max LOD clamps to restrict LOD use.

Apart form that there is absolutely no way to do what you want.

Additionally you cannot copy from texture to texture, you can copy from framebuffer to texture. It’s anyone’s guess whether that would be a faster route than a simple load from system memory.

Originally posted by dorbie:
The only way to do this is if you happen to exactly share a set of LODs between textures (your example suggests this is LOD related). You could conceivably use a single texture and just use min and max LOD clamps to restrict LOD use.
That sounds like a good start.
But unfortunately I just ran into two other associated problems:

Although min and max LOD are set, OpenGL (or at least the nVidia implementation) still requires texture completeness down to the 1x1 pixel mip-level.

Originally posted by dorbie:
Additionally you cannot copy from texture to texture, you can copy from framebuffer to texture. It’s anyone’s guess whether that would be a faster route than a simple load from system memory.
Just realized: I solely create my textures using fragment shaders and Render-to-texture. In this special case it’s not necessary to use a dedicated copy operation. Instead the two textures are attached to different color attachments of the FBO and the same data can be written to both using gl_FragColor. This saves the additional readback of the first texture array.