How to pass a structure to the kernel?

May 11, 2014 at 11:15 AM
Edited May 11, 2014 at 11:15 AM
The cuda file and the C# file should know the structure.
Can you write me a simple code that this can be done?
Coordinator
May 11, 2014 at 11:45 AM
Check one of the Fluids-samples. In Cuda part you can find a definition for "Vertex" which is:
typedef unsigned long DWORD;

typedef struct vertex {
    float x, y, z;
    DWORD c;     
} Vertex;
In C# you simply need to redefine a structure having the same layout:
[StructLayout(LayoutKind.Sequential)]
struct vertex
{
    public float x;
    public float y;
    public float z;
    public uint c;
}
Then you can use the C#-vertex like any other structure defined in C# and you can use the Cuda-vertex in your kernels.
May 11, 2014 at 11:58 AM
Yes I see it now. Thanks. Its simple. I will create what I want to do in no time.