Search code examples
androidrenderscript

Call cell in RenderScript Allocation


Lets say that I have an allocation where I want to change the value at cell x_0,y_0.Is there a way to either make a call that sets or gets the value of a cell or to run a kernel function that only runs for one cell?


Solution

  • You should probably use rsSetElementAt_uchar4() or whatever data type it is that you are setting. http://developer.android.com/guide/topics/renderscript/reference/rs_allocation_data.html#android_rs:rsSetElementAt is a guide for this.

    Alternatively, you can do a single cell kernel call via Script.LaunchOptions (which should have a nice reflected interface in your ScriptC_* files).

    http://developer.android.com/reference/android/renderscript/Script.LaunchOptions.html and http://developer.android.com/reference/android/renderscript/Script.html#forEach(int, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.FieldPacker, android.renderscript.Script.LaunchOptions)