I’ve been porting some code from desktop to Android and suddenly found my loading times were up to a couple of minutes. Turns out this was due to filling a ByteBuffer with initial pixels for a new texture.
Looping over all the pixels and doing relative ByteBuffer.put(byte) calls was taking ~10. But creating a temporary array, looping over that and then doing a single bulk ByteBuffer.put(byte[]) takes about 500ms. Filling the array with Arrays.fill() is about 200ms.
Have other people seen the same performance behaviour or is this a quirk of my device (S3)? What’s the fastest way to fill a byte buffer with unique values?