Copying structs containing dynamically allocated arrays to the GPU

I’m working on a implicit surface raytracer using CUDA, and I’m using the following structures to represent a surface:

//Term3: one term of the polynomial of a 3-dimensional algebraic implicit surface

//coeff: coefficient of the term

//x, y, z: powers of x, y and z

struct Term3

{

	float coeff;

	int x, y, z;

};

struct Polynomial3

{

	Term3* terms;

	int nTerms;

};

struct Surface

{

	Polynomial3 surface;

	Polynomial3 gradient[3];//one polynomial for each coordinate

	float3 position;

	float4 rotation;

	float3 scale;

	float3 aabbMin;

	float3 aabbMax;

};

The problem is that Polynomial3::terms is a dynamically allocated array because a polynomial may have any number of terms. How can I memcpy a Surface object to the GPU? I tried several different ways without any success :/

Thanks.

Hello!

I think you’re having the same problem I did once. Check this thread, it might help you: http://forums.nvidia.com/index.php?showtopic=100493&hl=

You can also look at this thread:

[link] http://forums.nvidia.com/index.php?showtop…&pid=590259 [/link]

Hey, thank you guys! I got it working. Also thanks for the guys who replied in those threads.