40mb texture!

Started by
8 comments, last by frob 18 years, 2 months ago
We need to a way to load a 3D-texture of 40mb onto the gpu in runtime without too big a performance loss =) We stream in the data from disk using a thread which works just perfect, but the bottleneck is the glTexImage3D call. Is it possible to upload an empty texture at startup and then just update it in parts using TexSubImage3DEXT, we tried it but didn't succeed.
Advertisement
If you pass a null pointer to TexImage, a texture object of desired size and format but no defined image data is allocated and you can use TexSubImage to upload the data to it later.
We tried that, but it looks like the texture is uploaded first when we use it.
glTexSubImage3D is part of OpenGL 1.2, so it seems odd that it doesn't work. You could try glTexSubImage3D instead of glTexSubImage3DEXT, but I'd guess it points to the same function.

Can you elaborate on how it didn't work? Presumably you're linking the function correctly, it compiles, and you're getting a valid pointer back?

As Brother Bob says, you need to first create the empty texture with glTexImage3d before calling glTexSubImage3d on it.

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

Well... we get a proper pointer to the process and the texture is created correctly. But still the texture doesn't seem to be uploaded at the gpu at startup. It also seems that the data sent in by subimage does not feed into the texture.

//Create texture. At startup.glGenTextures(1, &textureID);glBindTexture(GL_TEXTURE_3D, textureID);glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA16F_ARB, 128, 128, 128, 0, GL_RGBA, GL_FLOAT, NULL);


//Upload new partsglBindTexture(GL_TEXTURE_3D, textureID);glTexSubImage3DEXT(GL_TEXTURE_3D, 0, 0, 0, 0, 32, 32, 32, GL_RGBA, GL_FLOAT, m_dataReader->getData());and so on...			
I *think* I read about someone with the same problem recently, and that the advice was to actually render something (a tiny quad for example) with the empty texture bound to it, and they found that by doing that it was uploaded. Again, I am going out on a limb here because I haven't got this far with my OpenGL adventure yet, and I can't find the thread I was reading.

F451
Try passing an empty 128*128*128 array instead of NULL into your glTexImage3d call. I vaguely recall having a similar problem recently and this seemed to fix it on my Geforce 6800 at least.

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

The upload of the NULL texture works when we texture a small quad with it at startup, that's neat. But the glTexSubImageEXT is worse. It only seem to work correctly when we update the whole texture as one subimage, not when doing it in parts.

//Works nice...glBindTexture(GL_TEXTURE_3D, textureID);glTexSubImage3DEXT(GL_TEXTURE_3D, 0, 0, 0, texSize, texSize, texSize, GL_RGBA, GL_FLOAT, m_dataReader->getSomeData());//Does not work nice...glBindTexture(GL_TEXTURE_3D, textureID);glTexSubImage3DEXT(GL_TEXTURE_3D, 0, 0, 0, texSize/2, texSize/2, texSize/2, GL_RGBA, GL_FLOAT, m_dataReader->getSomeOtherData());
On the bright side, at least you have *SOMETHING* that works, even though it is slow.

Are you getting an error with that code above? I don't see a check of glGetError() in it.

There's a whole bunch of possible error codes you could be getting, especially considering the size of block you need.
Quote:Original post by frob
There's a whole bunch of possible error codes you could be getting, especially considering the size of block you need.


These two jump out at me. :-)

* GL_INVALID_ENUM is generated when target is not GL_TEXTURE_3D_EXT.
* GL_INVALID_OPERATION is generated when the texture array has not been defined by a previous glTexImage3DEXT operation.

This topic is closed to new replies.

Advertisement