Sign in to follow this  
rldivide

uploading a very large texture in smaller blocks ?

Recommended Posts

Hello, I have a very large (let's say 8192x8192), dynamically generated texture array on the CPU side. Part of the data is updated each time the user does an action. Is there a simple way to upload it to the GPU in blocks of 2048x2048 (for compatibility with older GPUs) ? The problem is that i can't directly map glTexture2D onto my array for uploading because my array is a continuous set of data, so if I glTexture2D(2048,2048) with a pointer to my array it will actually take the first 8192x512 from the array and map it to 2048x2048 on the GPU side, which is obviously wrong. Any tip ?

Share this post


Link to post
Share on other sites
Use glTexSubImage to update a part of a texture, and play with the unpack parameters to glPixelStore if your source image is a part of a larger image also. Look at the skip row, skip line and line width unpack parameters.

Share this post


Link to post
Share on other sites
Ah, glTexSubImage2D+glPixelStore sounds to be what I need !

However I'm not familiar at all with glPixelStore and hardly find tutorials about it.
If I understand correctly, I should set GL_UNPACK_ROW_LENGTH to 8192
and GL_UNPACK_SKIP_ROWS/GL_UNPACK_SKIP_PIXELS to the top left coordinate in my array ?

Share this post


Link to post
Share on other sites
The skip-parameters should be the offset, in rows and pixels, where the subrectangle starts. Whether it is the top left, or any other corner, depends on where you have the origin. So assuming you have the origin in the top left corner, then you are correct.

Share this post


Link to post
Share on other sites
In my opinion even the texture with 2048x2048 is the good choice to rendering with meshes.
??? CPU & other processors doesn't like to enter to the memory so often.

Share this post


Link to post
Share on other sites
Quote:
Original post by FXACE
In my opinion even the texture with 2048x2048 is the good choice to rendering with meshes.

That totally depends on the magnification of the texels.

Quote:
??? CPU & other processors doesn't like to enter to the memory so often.

It depends on how you schedule it. Though I am unsure about the meaning of the triple-question-mark you invoked.

Share this post


Link to post
Share on other sites

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