Hello,
I posted a problem here a while ago where the pixel layout in a GraphicBuffer rendered to with OpenGLES and EGLImage was padded for every row (https://developer.qualcomm.com/forum/qdn-forums/maximize-hardware/mobile...). I needed the data to be sequential without padding so I simply used memcpy to copy the rows into a new buffer. My question is if there is a way to prevent this padding or some other way of removing the need to copy the data row by row? Performance is a major factor.
Could you explain a bit more where you are seeing the padding?
From your last post: I am rendering RGBA8888 to a 480x1080 texture and the resulting texture was padded to 640x1080"
Could you review in more detail and code where the 480 and 640 are coming from?
Thanks for posting.
Creation of GraphicBuffer:
The reason I use a 480x1080 texture is I render a monochrome (R8) 1920x1080 texture and if I understand correctly EGLImage with GraphicBuffers only supports RGBA8888 and RGB565.
I render a 480x1080 RGBA texture in OpenGLES to the graphicbuffer with this viewport set:
Get pointer to the pixels:
When I iterate over the buffer (as byte array), after each row of pixels (1920 bytes) there is 640 bytes of padding (with value 0). So for example the second row starts at:
So I wonder if there is a way to prevent this padding? Building Android 4.4.4 for Nexus 5 by the way.
Implementation of GraphiBuffer is fairly hardware dependent and it's overall size is a performance optimization. The padding amount will vary on different devices and even change in the future. Our recommendation is to use a different approach to capture the frame and avoid doing the memory copy.