RenderScript: Using ScriptGroup for image process causes horizontal stripes

Eth*_*n J 5 android bitmap renderscript

Problem Description:

I write a simple demo using RenderScrip for image process. In my demo, when I use a one-kernal renderscript, it works fine. Yet when I use a script group to connect two rs-kernals for execution, I found the output bitmap with horizontal stripes. Especially when you chose a bitmap with small size.

The output bitmap when I use a one-kernal renderscript: The output bitmap when I use a one-kernal renderscript

The output bitmap when I use a script group to connect two rs-kernals. Note these two rs-kernals are just the same as the one I use above: The output bitmap when I use a script group

Codes:

I believe my codes in rs-kernal are correct. Otherwise I can't can't the right output picture when using a single-kernal renderscript. The problem is about script group.

Here is some codes about how I connect the rs-kernals in script group:

    Type.Builder tb = new Type.Builder(mRs, Element.RGBA_8888(mRs));
    tb.setX(baseBitmapWidth);// the size of bitmap never changes during the whole process
    tb.setY(baseBitmapHeight);
    Type t = tb.create();

    ScriptGroup.Builder b = new ScriptGroup.Builder(mRs);

    int i = 0;
    for (i = 0; i < mOps.size(); i++) {
        RSOp op = mOps.get(i);
        b.addKernel(op.rsGetKernalID());
    }

    for (i = 1; i < mOps.size(); i++) {
        b.addConnection(t, mOps.get(i - 1).rsGetKernalID(), mOps.get(i)
                .rsGetKernalID());
    }

    mScriptGroup = b.create();
Run Code Online (Sandbox Code Playgroud)

Here is some codes about how the script group is executed:

    Bitmap preparedBitmap = baseBitmap.copy(baseBitmap.getConfig(), true);
    mInAllocation = Allocation.createFromBitmap(mRs, baseBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
    mOutAllocation = Allocation.createTyped(mRs, mInAllocation.getType());

    mScriptGroup.setInput(mOps.get(0).rsGetKernalID(), mInAllocation);
    mScriptGroup.setOutput(mOps.get(mOps.size() - 1).rsGetKernalID(),
            mOutAllocation);

    mScriptGroup.execute();

    mOutAllocation.copyTo(preparedBitmap);
Run Code Online (Sandbox Code Playgroud)

Eth*_*n J 0

已找到解决方案\xef\xbc\x9a\n只是使用了许多单核渲染脚本。使用前一个脚本的输出位图作为后一个脚本的输入。

\n