渲染脚本和GPU [英] Renderscript and the GPU

查看:94
本文介绍了渲染脚本和GPU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

知道,Renderscript的设计掩盖了我在哪个处理器上运行的事实,但是有什么方法可以编写代码,例如在具有GPU计算能力的设备上(在Nexus 10),它在GPU上运行吗?有什么办法可以说明脚本的功能正在GPU上运行吗?

I know that Renderscript's design is to obscure the fact about what processor I'm running on, but is there any way to write the code such that on GPU-compute-capable devices (at the moment, Nexus 10), it will run on the GPU? Is there any way to tell that a script's function is running on the GPU?

www.leapconf.com/downloads/LihuaZhang-MulticoreWare.pdf建议,如果我不使用全局变量,不使用递归并且不在内核中的任何地方调用rsDebug,它将在内核上运行GPU;那是对的吗?

www.leapconf.com/downloads/LihuaZhang-MulticoreWare.pdf suggests that if I don't use globals, I don't use recursion, and don't call rsDebug anywhere in a kernel, it will be run on the GPU; is that correct?

我希望看到人们已经通过某种方式验证的简短脚本将在gpu上作为纯基于计算的任务运行(例如,没有图形功能).

I'd love to see a short script that people have somehow verified will run on the gpu as a purely compute-based task (eg., no graphics work).

推荐答案

通常,有关Nexus 10行为的说法是正确的.关于调用某些RS运行时函数(例如,不要调用rsGetAllocation),还有其他一些事情会导致CPU运行函数.但是,我认为在4.2中不是分配或绑定指针的全局变量是可以的.

In general, those claims about Nexus 10's behavior are correct. There are some other things about calling some of the RS runtime functions (for example, don't call rsGetAllocation) that would cause the CPU to run a function. However, I think globals that aren't allocations or bound pointers are okay in 4.2.

展望未来,其中许多限制将被放宽(全球性因素是最大的限制).

Going forward, a lot of those restrictions are going to be relaxed (globals being the big one).

就看内核在哪里运行而言,用4.2可以解决这个问题的方法并不多.我们尚无令人信服的理由这样做,但是,如果事实证明这确实很重要,则可以通过systrace之类的方法添加这些内容而没有太多困难.如果您能证明这会伤害您的原因,请随时向我们投诉:我认为代码将在GPU上运行得更快."

In terms of seeing where a kernel runs: there's not much you can do with 4.2 to figure that out. We haven't seen a compelling reason to do so yet, but if this turns out to be really important it's something we could add without too much difficulty via something like systrace. Feel free to complain to us if you can demonstrate why that's hurting you beyond "I assume the code will run faster on the GPU."

我非常确定ImageProcessing中的Mandelbrot实现(fw/base/tests/RenderScriptTests/ImageProcessing/)在4.2的GPU上运行.

I'm pretty sure that the Mandelbrot implementation in ImageProcessing (fw/base/tests/RenderScriptTests/ImageProcessing/) runs on the GPU in 4.2.

这篇关于渲染脚本和GPU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆