longo92 wrote: ↑Thu Jul 09, 2020 10:09 am
Hi,
A question about glTexSubImage2D implementation:
Is it possible that the raspberry pi 0 gpu legacy driver implementation performs a copy only of the pointer data (instead of an entire copy)?
It seems reasonable since the memory is unified.
Thanks,
Alessandro
I can't see any way of being able to get away with not copying the data. The physical memory may be unified but the VC4 texture units don't go through an MMU, think what would happen if Linux swapped the memory for your image out.
Using gTexSubImage suggests that you are copying the data into part of a larger texture, the texture needs to be one complete image, having a random rectangle of the texture stored separately to the rest in a random location would be a nightmare.
Then there's the fact that textures aren't generally stored in linear order due to that not being very friendly to the texture caches. Usually a texture is split into small tiles which snake around the texture in some manner (I think the RPi zigzags). This is so texels close to each other in coordinate space are more likely to be close in memory. Textures need to be fast to read regardless of rotation.
Finally, when you've submitted your image using glTexSubImage2D() you can safely free your image without affecting OpenGL's texture. OpenGL doesn't make any assumption that an application's memory is available to the graphics driver after a call returns (the texture memory could reside on a separate memory device not accessable by the cpu).