0

I'm trying to optimize the upload of textures from CPU memory to OpenGL.

Initially I was using glTexImage2D and that works, but obviously isn't using DMA, so I'm trying to use PBOs.

Unfortunately, the API I have to use that provides the texture data allocates the CPU memory for them and returns a pointer. I can't control where in memory it places the data.

If I create a PBO then map it, I have to either 'manually' move my data into the PBO-allocated memory, or use glBufferData to initialize it with the texture data before calling glTexImage2D. This appears significantly slower than not using a PBO at all.

Any other techniques I could try, or is this just a limitation of how PBO's work?

Roddy
  • 66,617
  • 42
  • 165
  • 277
  • What about [`glTexSubImage2D`](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexSubImage2D.xhtml)? – Rabbid76 Sep 30 '20 at 11:30
  • @Rabbid76 - Can you elaborate - I'm not sure how that's going to help, as I still need to move the entire texture? – Roddy Sep 30 '20 at 11:36
  • Of course you have to move the entire texture from the CPU to the GPU. But while [`glTexImage2D `](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexImage2D.xhtml) creates new texture object and a new data store, `glTexSubImage2D` just writes to an existing data store. – Rabbid76 Sep 30 '20 at 11:41
  • 1
    Thanks! Understood. I'll give that a try. – Roddy Sep 30 '20 at 11:58
  • Done, but `glTexSubImage2D` isn't making any measurable difference. I think the size of the pixel transfers I'm making (8 megapixels per call) swamps any per-call overhead improvement. – Roddy Oct 01 '20 at 07:27

0 Answers0