Hi,
In my application I have replace the following struct :
typedef struct { float x, y, z; } Point;
with a float3 like this #define Point float3
But now, it does not work anymore.
At the startup I transfert some "Point" in a memory buffer for the kernel.
In C++ I have the same structure (Point) that I setup and after I transfert it to the kernel.
Does anyone know if I can directly transfert a "float3" like structure (here point) from the host to kernel like this ?
Thanks
In my C++ code I have the class Point like this now
class Point { float x,y,z,w; };
Because in cl.h I have :
typedef cl_float4 cl_float3;
#define CL_ALIGNED
typedef union
{
cl_float CL_ALIGNED(16) s[4];
}cl_float4;
and in my kernel code, I have : #define Point float3
But it still not work 😞
For information, here are the structures I use :
The OPEN CL structures :
#define Point float3
typedef struct { float x,y,z; } Vector3;
typedef struct { float u, v; } UV;
typedef struct {
Point o;
Vector3 d;
float mint, maxt;
} Ray;
typedef struct {
Point pMin, pMax;
} BBox;
typedef struct {
Point P;
Normal N;
UV Tex;
} Vertex;
typedef struct {
BBox bbox;
unsigned int primitive;
unsigned int skipIndex;
} BVHAccelArrayNode;
The C++ structures :
class Point { float x, y, z, w; };
typedef struct { float x,y,z; } Vector3;
class Ray
{
static const float RAY_EPSILON;
Point d;
Vector3 d;
mutable float mint, maxt;
};
class BBox {
Point pMin, pMax;
};
typedef struct {
Point P;
Normal N;
UV Tex;
} Vertex;
struct BVHAccelArrayNode
{
BBox bbox;
unsigned int primitive;
unsigned int skipIndex;
};
class UV { float u,v; }
Thanks micah,
1 - The C++ definition of cl_float3 is float s[4]; under windows. So my Point define as class Point { float x,y,z,w; } is the same !!
2 - What is strange is that even when I change my kernel code and my host code to use the 'w' value, I got problems ! Like this
HOST : class Point { float x,y,z,w; }
Kerne : typedef struct { float x,y,z,w; } Point
Maybe I have an alignment problem ? The addition of a float in the 2 structures should change nothing ? Right ?
Hi,
Can someone tell me if I have an alignment problem ?
Because, even when I change the 'Point' structure on both side... I got different results in my application !
Yes, I can do this...
Where should I send the test case please ?
viewon01,
Has this issue been resolved?
Can you provide a simple test case. The code you sent was very large and had some files missing. Also please provide the system configuration you are using. CPU,GPU,SDK,Catalyst & OS.
Thanks