xaenec's picture

CLoo how to move single float4?

Hi,

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
xaenec's picture

okay ive got it working by defining and using a serializable float4 like struct.