Update 3D Texture inside GPU


Is it possible to update the values of a 3D texture with values that I have in another 2D texture (all the process inside the GPU)?

I know how to update values of a 2D texture, for example using FBO color attachment, but not for 3D texture.

Any suggestions? Thanks!

Well, afaik not yet. Rendering into a 3d texture can be implemented by using a ‘flat 3d texture’. For further information have a look into this paper http://www.markmark.net/cloudsim/ !

The problem of using flat 3d texture is the interpolation. I can’t use the gpu trilinear interpolation because I have a 2d texture that stores the slices of a 3d texture.

The fact is that I can’t use interpolation, because I will mix values of the border of two slices in the wrong way. So I have to compute the interpolation in a shader.

What do you think?

Well, the FBO extension spec includes support to FBO color attachment to each slice. But if you want to update more than one slice using FBO, you’ll need MRT, so you could update 4 slices at each step.

But this is the spec. At implementation this feature would be not supported. I was trying to do that about one year ago with my NVIDIA 5900FX, but I couldn’t. I don’t know if it was because the hardware, the drivers or both.

You could try to do that, in one year there are new drivers and new hardware.

PD: this is one of the faults of FBO in my opinion. FBO must support at least one texture type, texture type, etc configuration. But you haven’t got any way to know the supported configuration. Well or at least I don’t know it, someone knows? :slight_smile:

The problem of have a stack of 2D textures to represent the 3D texture is in the rendering, because I can’t use the trilinear interpolation that gives OpenGL.

I want to use 3D textures to exploit this property that the flat 3D textures don’t have (they only allow bilinear interpolation). But I need to update the values of the 3D texture between consecutive frames. I have the new values on the GPU, so I want to avoid the transaction between the GPU and CPU.

In my implementation I’m initializing each slice with a one pixel border with value 0.
I’m solving partial differential equations in 3d and after each iteration vertical and horizontal lines are rendered to set the border values back to 0.
For rendering, I’m sampling texel i with its four neighbours and the texel (of same local slice position as texel i) of the slice in the upper and lower row.

speed: Why can you not implement trilinear interpolation in your shader as you were talking about earlier? You can even use the bilinear interpolation that OpenGL provides and just do the last dimension. Sure from a cache point-of-view having OpenGL do the whole trilinear would be better, but while we are waiting…

You can do trilinear for “flat” textures as well. This will be awful for cache though, but it is definately possible.

I will do the trilinear in the shader.
I want a color attachment for 3D textures!! :rolleyes:
I will be waiting for this… :wink:

Using the GeForce 8800 extensions you can select the slice you want to render into in the geometry shader.

Can you not use a PBO to copy from the 2D render target, then upload with a glTexSubImage command?

If you’re running on a GeForce 8 series card, you can render to any slice of a 3D texture using FBO. There’s some sample code here:

Do you know if the drivers for Linux will suport this feature?

I haven’t tested that sample on Linux yet, but it does work on the equivalent Windows driver. It should work.