I have a requirement to process large array in my android app and currently it has become performance problem. To solve this my plan is to move the array processing in to GPU. I tried do this using Android Render script but that failed due to various reasons so my question is is there a way to move this calculation to GPU using opengl or OpenGL ES ? if someone can give me a idea to fix this it will be grate help.

here is problematic code

for (int i = 0; i <35000; i += 16)
    {
        int lumOne = in[i];
        lumOne += 128;
        pixelData[lumOne]=pixelData[lumOne]+1;

        int lumTwo = in[i+2];
        lumTwo += 128;
        pixelData[lumTwo]=pixelData[lumTwo]+1;

    }
有帮助吗?

解决方案

To use OpenGL ES 2.0 shader programs for general purpose computing means that your input data set will be supplied encoded into textures to OpenGL ES and that the output data set will be stored (rendered) to a texture attached to an FBO, rather than displayed on-screen. You then have to use glReadPixels() to read that image back into an array that you can use. There are some articles here that can help with using FBOs and glReadPixels().

http://montgomery1.com/opengl/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top