简体   繁体   English

如何在Android中运行Opengl或OpenGL ES进行数组处理

[英]How to run Opengl or OpenGL ES for array processing in android

I have a requirement to process large array in my android app and currently it has become performance problem. 我需要在我的android应用中处理大型数组,目前它已成为性能问题。 To solve this my plan is to move the array processing in to GPU. 为了解决这个问题,我的计划是将阵列处理移入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 ? 我尝试使用Android Render脚本执行此操作,但是由于各种原因失败了,所以我的问题是是否可以使用opengl或OpenGL ES将计算结果移至GPU? 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. 要将OpenGL ES 2.0着色器程序用于通用计算,意味着您的输入数据集将被编码为OpenGL ES的纹理,并且输出数据集将被存储(呈现)到附加到FBO的纹理上,而不是显示在-屏幕。 You then have to use glReadPixels() to read that image back into an array that you can use. 然后,您必须使用glReadPixels()将该图像读回到可以使用的数组中。 There are some articles here that can help with using FBOs and glReadPixels(). 这里有一些文章可以帮助使用FBO和glReadPixels()。

http://montgomery1.com/opengl/ http://montgomery1.com/opengl/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM