I need to build an Image processing application for Android. Performance is the main requirement and I am looking to use gpu compute. I want to know which of the 3 libraries is best to use.
I know OpenGL is primarily for graphics but also supports computer shaders.
I am not sure how well supported OpenCL is on Android
RenderScript lacks documentation and I think is slower than other libraries.
Conclusion. The main difference between OpenGL and OpenCL is that OpenGL is used for graphics programming while OpenCL is used for heterogeneous computing. OpenGL is used in video game designing, simulation, etc. OpenGL helps to increase the performance of the system and allows parallel computing.
Here mostly the same as on iOS applies - You don't need to use opengl but if you do you do have more possibilities in complexity, graphics and flexibility. Till Android 3.0 (API 11) you are able to enable hardware acceleration even for 2d canvas graphics.
RenderScript is especially useful for applications performing image processing, computational photography, or computer vision. To begin with RenderScript, there are two main concepts you should understand: The language itself is a C99-derived language for writing high-performance compute code.
Android includes support for high performance 2D and 3D graphics with the Open Graphics Library (OpenGL®), specifically, the OpenGL ES API. OpenGL is a cross-platform graphics API that specifies a standard software interface for 3D graphics processing hardware.
For an Image Processing App, the heaviest part is in the processing (transforming/manipulating) the pixels of images in memory, not rendering images to screens/buffers.
Sure, that kind of processing is general and needs a general-purpose computation API.
Thus, we can eliminate OpenGL ES. It supports shaders, but the OpenGL ES Shading Language is very limited and definitely not suitable for general processing.
RenderScript, according to this:
RenderScript does not use any GPU or DSPs cores. That is a common misconception encouraged by Google's deliberately vague documentation. RenderScript used to have an interface to OpenGL ES, but that has been deprecated and has never been used for much beyond animated wallpapers. RenderScript will use multiple CPU cores, if available, but I suspect RenderScript will be replaced by OpenCL.
I'm working for a big video game company, we don't have any plan to use RenderScript. We think Vulkan is a better choice. I suggest you choose Vulkan too but the problem is that the number of Android devices supporting Vulkan is pretty low now.
Therefore, to answer your question, please go with OpenCL. Although OpenCL is not part of the Android platform, many manufacturers provide drivers or even SDKs to support OpenCL on Android. At least, it is better than Vulkan in terms of number of supported devices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With