Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternatives to glReadPixels #10

Closed
gaurav-fueled opened this issue Sep 26, 2014 · 3 comments
Closed

Alternatives to glReadPixels #10

gaurav-fueled opened this issue Sep 26, 2014 · 3 comments

Comments

@gaurav-fueled
Copy link

Readme contains : Experiment with alternatives to glReadPixels(). Add a PBO speed test. (Doesn't seem to be a way to play with eglCreateImageKHR from Java.)

but It seems it has not been added yet.

I am trying to use https://github.com/CyberAgent/android-gpuimage for some image processing tasks. There seems to a speed bottle neck at https://github.com/CyberAgent/android-gpuimage/blob/febdf4900b437b2069661fd371d5469196e26f18/library/src/jp/co/cyberagent/android/gpuimage/PixelBuffer.java#L194
If there is some faster alternatives to glReadPixels it would greatly enhance the image processing time.

@fadden
Copy link
Contributor

fadden commented Sep 29, 2014

The performance of glReadPixels() seems to vary widely between different devices and different driver releases. This is why I added a trivial benchmark to Grafika. (What values do you get?)

http://bigflake.com/mediacodec/#ExtractMpegFrames shows some timing values for extracting video frames with glReadPixels(); on a Nexus 5 the function ran quickly, and most of the time was spent elsewhere (primarily PNG compression in that case).

(The convertToBitmap() function you reference could be sped up by inverting the Y axis in the GL rendering, rather than the bitmap copy, and it'd annoy the GC less if the pixel buffers were allocated once and re-used. But if that's not the bottleneck then there's no reason to mess with it.)

One partially-completed attempt to use non-public APIs from the NDK can be found at http://stackoverflow.com/questions/21151259/replacing-glreadpixels-with-egl-khr-image-base-for-faster-pixel-copy/21199078#21199078 ; I think with the final "edit" it would actually work, but I never got around to trying it out (and at this point it's unlikely I ever will).

The fastest way to get images to disk is to use the MP4 video encoder, but that's usually not appropriate unless your input is video.

@gaurav-fueled
Copy link
Author

Hey @fadden,

The time glReadPixels in convertToBitmap() method takes on Nexus 5 (Android L) for 3264 X 2448 size image comes out to be 689 milli seconds.

In grafika 3264 X 2448 size image takes 51.416 milli seconds on Nexus 5 with on Android L.

@fadden
Copy link
Contributor

fadden commented Oct 1, 2014

That's a lot of pixels. Even so, I suspect you may be hitting a slow path in the driver to get performance that bad.

In any event, this is a bit out of scope for Grafika, since there isn't yet a public Java-language API that will make this faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants