Finding an alternative to glTexSubImage2d with data offset support

I have a PBO that updates every CUDA frame. After that, I also want to update the texture using this PBO, which I use with glTexSubImage2d . I am afraid that updating the entire texture will be expensive and I would like to update only the visible area of ​​the texture, while my PBO has all the data on it.

The problem is that although glTexSubImage2d accepts the offset, width, and height values ​​as parameters, they are only used when painting the texture, while I still need buffer data that needs to be linearly laid. I'm afraid that preparing buffer data might be too expensive (in fact, it would be very expensive, since my PBO is in the GPU's memory.)

Is there an alternative to glTexSubImage2d that also accepts parameters for buffer offsets, or do I need to constantly update the entire texture?

+6
source share
2 answers

Read the pixel storage options, install glPixelStore . The parameters GL_UNPACK_ROW_LENGTH , GL_UNPACK_SKIP_PIXELS and GL_UNPACK_SKIP_ROWS are of interest to you:

Pixel Store Parameters

These values ​​are provided as a convenience to the programmer; they do not provide any functions that cannot be duplicated by increasing the pointer passed to glDrawPixels, glTexImage1D, glTexImage2D, glTexSubImage1D, glTexSubImage2D, glBitmap or glPolygonStipple. Setting GL_UNPACK_SKIP_PIXELS to i is equivalent to increasing the pointer to i ⁒ n components or indices, where n is the number of components or indices in each pixel. Setting GL_UNPACK_SKIP_ROWS to j is equivalent to increasing the pointer to j ⁒ k components or indices, where k is the number of components or indices per row, as calculated in the GL_UNPACK_ROW_LENGTH section.

You are still going to use glTexImage and / or glTexSubImage to transfer data.

+7
source

glTexSubimage2D has errors when retrieving data from PBO if the selected ROI in the texture is not equal to the size of the entire texture. This is a known issue that cannot be fixed (for example, a forum section ).

0
source

Source: https://habr.com/ru/post/909555/


All Articles