I have a PBO which is updated each frame by CUDA. After it, I also want to update a texture using this PBO, which I do using glTexSubImage2d. I’m afraid updating the whole texture is expensive and would like to update only the viewable region of the texture while my PBO has the whole data on it.
The problem is that, although glTexSubImage2d accepts an offset, width and height as parameters, they’re only used when painting to the texture, while I still need my buffer data to be linearly layed. I’m afraid preparing the buffer data myself might be too expensive (actually it would be extremely expensive, since my PBO resides in GPU memory.)
Is there any alternative to glTexSubImage2d which also takes parameters for the buffer offset or should I keep updating the whole texture at once?
Please read up on the pixel store parameters, set with glPixelStore. The parameters
GL_UNPACK_ROW_LENGTH,GL_UNPACK_SKIP_PIXELSandGL_UNPACK_SKIP_ROWSare of most interest for you:You’re still going to use glTexImage and/or glTexSubImage for data transfer.