RenderScript: not matching function rsGetElementAt_uchar4

梦想的初衷 提交于 2019-12-12 04:54:30

问题


I've write very short RS, but after gradle sync Android Studio gives me error

Error:(8, 34) error: no matching function for call to 'rsGetElementAt_uchar4'

Script:

#pragma version(1)
#pragma rs java_package_name(xx.xxx.xxxxxxx)

uchar4 road = 0;
const uchar4 nothing = 0;

void init() {
    road.a = 0xff;
}

uchar4 __attribute__((kernel)) kernel(uchar4 original, uint32_t x, uint32_t y) {
    uchar4 masked = rsGetElementAt_uchar4(extra_alloc, x, y));
    if (original.r != masked.r || original.g != masked.g || original.b != masked.b) {
        return road;
    } else {
        return nothing;
    }
}

In build.gradle:

defaultConfig {
    applicationId "xx.xxx.xxxxxxx"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    renderscriptTargetApi 24 // I've tried almost every possible value
    renderscriptSupportModeEnabled true
}

The same code, but with usage of API 23 works:

#pragma version(1)
#pragma rs java_package_name(gl.kid.maptilt)

uchar4 road = 0; // I don't know, how to declare uchar4, any advice?
const uchar4 nothing = 0;

void init() {
    road.a = 0xff;
}

uchar4 __attribute__((kernel)) root(uchar4 original, uchar4 masked, uint32_t x, uint32_t y) {
    if (original.r != masked.r || original.g != masked.g || original.b != masked.b) {
        return road;
    } else {
        return nothing;
    }
}

回答1:


I will start with a disclaimer that I don't know much about RenderScript. That said, I think you followed code similar to this question, but you are missing the line:

rs_allocation extra_alloc;

Notice the bit in Java where it is set:

script.set_extra_alloc(inAllocationExtra);


来源:https://stackoverflow.com/questions/46074004/renderscript-not-matching-function-rsgetelementat-uchar4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!