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)