
CLoo how to move single float4?
Posted Saturday, 4 June, 2011 - 11:06 by xaenec inHi,
I am new to OpenTK and CLoo, and I am working just a few days with it. So I am playing a bit around to get familar ... passing arrays of data ... computing something etc.
But in context of single datafields i've got a problem:
kernel void MoveToPos( int maxx, int maxy, float4 pos, global write_only float4* newpos) [...]
Passing maxx, maxy is no problem. Therefore I use kernel.SetValueArgument(0, .....
But for float4 pos I've no idea how to pass the data. At first I also tried kernel.SetValueArgument(2, ..... where the second argument was a simple float array. But CLoo tells me that I must not use nullable types. (e. g. kernel.SetValueArgument(2, new float[] {0, 1, 2, 3})
In order to that I've tried it using a computebuffer and to set it by SetMemoryArgument. gpupos = new ComputeBuffer<float>(context, ComputeMemoryFlags.Read_Only | ComputeMemoryFlags.CopyHostPointer, new float[] {0, 1, 2, 3}); But it ended in a "InvalidLength"-Exception, while setting the memory to the kernel.
Has someone any Idea how to solve this?
Thanks.
Regards Xae


Comments
Re: CLoo how to move single float4?
okay ive got it working by defining and using a serializable float4 like struct.