首页 > 解决方案 > rs 文件中的 RenderScript 复制 3D 分配

问题描述

RenderScript 分配可以是 1D、2D 或 3D。几乎所有方法都支持这 3 个,但是复制方法缺少 3D。根据 Android 开发人员的说法,以下是所有数据访问功能:

rsAllocationCopy1DRange Copy consecutive cells between allocations
rsAllocationCopy2DRange Copy a rectangular region of cells between allocations
rsAllocationVLoadX  Get a vector from an allocation of scalars
rsAllocationVStoreX Store a vector into an allocation of scalars
rsGetElementAt  Return a cell from an allocation
rsGetElementAtYuv_uchar_U   Get the U component of an allocation of YUVs
rsGetElementAtYuv_uchar_V   Get the V component of an allocation of YUVs
rsGetElementAtYuv_uchar_Y   Get the Y component of an allocation of YUVs
rsSample    Sample a value from a texture allocation
rsSetElementAt  Set a cell of an allocation

如您所见,没有rsAllocationCopy3DRange. 我还是用这段代码试过了:

rsAllocationCopy3DRange(output, 0, 0, 0, 0, 0, w, h, d, data, 0, 0, 0, 0, 0);

并且编译失败。

如何复制 3D 分配?我可以编写一个内核函数,只返回输入然后返回rsForEach那个函数,但对于简单的副本来说似乎效率很低。

为什么没有3D副本?这没有意义。为什么 Java/Kotlin 端有 3D 副本,而 rs 端没有?

标签: androidrenderscript

解决方案


推荐阅读