Sign in to follow this  

40mb texture!

This topic is 4342 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 parts

glBindTexture(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...


Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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());

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4342 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this