If you want to look at neighboring pixels (and you are using rs_allocations), you should just use a single global rs_allocation rather than passing it as *v_in. This would look like:
rs_allocation in;
// Using the new kernel syntax where v_out becomes the return value.
uchar4 __attribute__((kernel)) doSomething(uint32_t x, uint32_t y) {
uchar4 u4 = rsGetElementAt_uchar4(in, x, y); // You can adjust x,y here to get neighbor values too.
float4 f4 = rsUnpackColor8888(u4);
...
return rsPackColorTo8888(f4);
}
Unfortunately, there is no nice way to get automatic clamping with a regular rs_allocation, but you can adjust your code to do the edge clamp manually. Keep maxX, maxY as global variables passed to the Script, and then dynamically check whether or not you are in range before any rsGetElementAt*(). If you do want automatic clamping/wrapping behaviors, you can also check out the rs_sampler and rsSample() APIs.