Archived post by sniperjake945

here’s something fun. if you’ve ever wanted to pass the layer data into a function in opencl and then read from the layer, here’s how to do it! 🙂
“`c #bind layer src? val=0 #bind layer &dst
float4 buffereIndexCUSTOM(const IMX_Layer* in_layer, int2 xy){ return bufferIndexF4(in_layer, xy, in_layer->stat->border, in_layer->stat->storage, in_layer->stat->channels); }
@KERNEL { float4 vals = buffereIndexCUSTOM(@src.layer, @ixy); @dst.set(vals); }
“`
this way you can use layer data in functions! you lose the ability to use `@binding` inside of the functions, but at least you have access to the layer functions. For more info on the IMX_Layer struct check out `$HFS/houdini/ocl/include/imx.h` and then if you’re curious what functions you have access to you, you’ll want to read the `$HFS/houdini/ocl/include/imx_internal.h` include

someone here has probably already figured this out, and i will say that its super easy to crash your opencl playing with these functions, but it definitely makes passing data into and out of functions way easier!