小编mon*_*eci的帖子

RenderScript绑定指针与分配

RenderScript是否保证内存布局或跨越从Java层绑定的全局指针?

我在某处读到最好使用rsGetElementAt/rsSetElementAt函数,因为不保证布局.

其他地方据说在针对GPU优化时避免使用这些优化,而绑定指针则可以.


在我的特定情况下,我需要内核来访问许多周围像素的值.到目前为止,我已经完成了从Java层绑定的浮点指针.

Java的:

script.set_width(inputWidth);
script.bind_input(inputAllocation);
Run Code Online (Sandbox Code Playgroud)

RS:

int width;
float *input;

void root(const float *v_in, float *v_out, uint32_t x, uint32_t y) {
    int current = x + width * y;
    int above   = current - width;
    int below   = current + width;

    *v_out = input[above   - 1] + input[above  ] + input[above   + 1] +
             input[current - 1] + input[current] + input[current + 1] +
             input[below   - 1] + input[below  ] + input[below   + 1] …
Run Code Online (Sandbox Code Playgroud)

android renderscript

5
推荐指数
1
解决办法
1070
查看次数

标签 统计

android ×1

renderscript ×1