0

I have a piece of code where I am drawing a string of length around 20 characters into Skia Bitmap of size 1000x100 pixels. Then load that into a texture and draw it on screen.

I found that it is taking around 29-30ms just to upload the SkBitmap data (the buffer returned by SkBitmap.getPixels()) into a texture.

The code for this is uploaded in another post

Drawing text to texture using Skia

measureStart = systemTime();
if (!initTexture(&texFrame, bitmap))
{
    LOGD("framerate: Unable to create/upload texture based off bitmap");
    return;
}
timeDiff += (int(ns2us(systemTime()-measureStart)));

I drew 30 frames and took an average of timeDiffs. It is taking around 30ms.

I created another program that doesn't use OpenGL at all, just uses Skia to render text and show it on frame buffer directly. That took 1ms to do the same.

This doesn't make sense. I am running this code on android box (with GPU) with Android 4.0.3. ARM and GPU share the same RAM.

How to make this faster?

Community
  • 1
  • 1
videoguy
  • 1,732
  • 2
  • 24
  • 49
  • What device / chipset? Some devices can be slow, though 30ms for a 1024x1024x4 does seem a bit long. It's possible the driver is swizzling the texture on upload for faster rendering later. Does the time drop to 7.5ms if you use a 512x512 texture? – fadden Feb 06 '14 at 18:03
  • It is a TI processor with ARM v7 NEON support and SGX530 is the GPU. The SkBitmap size is not big like 1024x1024. It is 1024x100. I started with a bigger bitmap and reduced it to the above size to make it faster. 30ms is still too much time for this. – videoguy Feb 06 '14 at 18:15
  • Hopefully 1024x128 so it's a power of 2 in both dimensions. Have you tried wrapping just the `glTexImage2D()` call with the start/stop time calls, to verify that it's the sole source of the 30ms delay? – fadden Feb 06 '14 at 20:42
  • initTexture() has code to handle to sizes that are not power of 2. The times I got are for glTexImage2D and glTexSubImage2D() calls. – videoguy Feb 07 '14 at 04:26
  • FWIW, I added a simple 512x512 RGBA glTexImage2D() benchmark to Grafika (https://github.com/google/grafika). I see 1.6ms on N5 and N10 running Android 4.4.x. – fadden Apr 28 '14 at 21:18

0 Answers0