简体   繁体   English

RenderScript和V8支持库之间的区别

[英]Differences between RenderScript and V8 Support Library

While working with V8 support library and the default RenderScript runtime in Android, I noticed that the same RenderScript code at the Java level can produce different results. 在使用V8支持库和Android中默认的RenderScript运行时时,我注意到Java级别的相同RenderScript代码可以产生不同的结果。

For example, there were slight differences in the resulting images, probably because of the different implementation of some intrinsics. 例如,可能由于某些内在函数的实现方式不同,导致生成的图像略有差异。

I also noticed that the support library version is "more asynchronous" than the native one. 我还注意到,支持库版本比本机版本“更具异步性”。 The native version would take some time to process "forEach()" methods, while the support library would return almost instantly after a "forEach()" call and do all the work when "copyTo" or "finish()" was called. 本机版本将花费一些时间来处理“ forEach()”方法,而支持库将在“ forEach()”调用之后几乎立即返回,并在调用“ copyTo”或“ finish()”时完成所有工作。

I also noticed that when " Allocation.createFromBitmap() " was called, the support library would use the bitmap memory and not allocate extra space outside the VM, while the native version would always allocate more space. 我还注意到,当调用“ Allocation.createFromBitmap() ”时,支持库将使用位图内存,而不在VM外部分配额外的空间,而本机版本将始终分配更多的空间。 I came to this conclusion using Qualcom's Trepn profiler . 我使用Qualcom的Trepn分析器得出了这个结论。

Are the differences documented somewhere? 差异是否记录在某处?

RenderScript support library is essentially the same as the native RenderScript in CPU path. RenderScript支持库与CPU路径中的本机RenderScript本质上相同。

There are several differences though: 但是有几个区别:

  1. Certain features that depend on private Android APIs (non-NDK API) do not exist in the support lib. 依赖私有Android API(非NDK API)的某些功能在支持库中不存在。
  2. The kernels (.rs) files are pre-compiled for the support lib, while the native RenderScript will do a JIT compilation on device. 内核(.rs)文件已针对支持库进行了预编译,而本机RenderScript将在设备上进行JIT编译。
  3. The support lib is also able to execute in the native RenderScript path, if the the Android version on the device is higher than both "renderscriptTargetApi" and "targetSdkVersion". 如果设备上的Android版本高于“ renderscriptTargetApi”和“ targetSdkVersion”,则支持库也可以在本地RenderScript路径中执行。

The differences in memory usage and other behaviors may come from the GPU driver on the device. 内存使用情况和其他行为的差异可能来自设备上的GPU驱动程序。 GPU may need to copy the bitmap to GPU memory with specified strides / alignments. GPU可能需要按照指定的步幅/对齐方式将位图复制到GPU内存中。

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

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