Hi,
I'm facing a problem, I have the following structure :
typedef struct __attribute__((packed))
{
float Ks;
clSpectrum Cs;
float exponent;
} ShaderParam_plastic;
But when I convert it to :
typedef struct __attribute__((packed))
{
float Kd;
clSpectrum Cd;
float Ks;
clSpectrum Cs;
float exponent;
} ShaderParam_plastic;
I got a crash ! I have checked for the data I send and they are aligned correctly !
In fact I use this structure :
typedef struct __attribute__((packed))
{
unsigned int shaderId;
union __attribute__((packed))
{
ShaderParam_emitter emitter;
ShaderParam_glass glass;
ShaderParam_matte matte;
ShaderParam_mirror mirror;
ShaderParam_plastic plastic;
ShaderParam_Textured_emitter Textured_emitter;
ShaderParam_Textured_glass Textured_glass;
ShaderParam_Textured_matte Textured_matte;
ShaderParam_Textured_mirror Textured_mirror;
ShaderParam_transmissive transmissive;
} params;
} ShaderParameters;
Even my union is aligned !!! If the syntax is correct ?
链接已复制
11 回复数
In the OpenCL spec. page 199, they wrote this :
"You may only specify this attribute on the definition of a enum, struct orunion, not on a typedef which does not also define the enumerated type,structure or union."
Does it mean that I cannot pack a "typedef" ? or that I can write :
typedef struct__attribute__((packed)) MyStruct {...};
But not ?
typedef__attribute__((packed))struct MyStruct {...};
NB:I have replace my typedef with a struct, but it still crash !!!
NB2: I cannot use "align" because my OpenCL code is generated at run-time. So, it is difficult to do and error prone :-P (Also, my buffer is generated from a malloc, then filled at run-time with memcpy !!)
Even with this version of my code ... my soft still got a crash !!!
[cpp]struct __attribute__((packed)) ShaderParam_transmissive { float Ks __attribute__((packed)); clSpectrum Cs __attribute__((packed)); float eta __attribute__((packed)); }; struct __attribute__((packed)) ShaderParametersStruct { uint shaderId __attribute__((packed)); union __attribute__((packed)) { struct ShaderParam_emitter emitter; struct ShaderParam_glass glass; struct ShaderParam_matte matte; struct ShaderParam_matte_rough matte_rough; struct ShaderParam_mirror mirror; struct ShaderParam_plastic plastic; struct ShaderParam_Textured_emitter Textured_emitter; struct ShaderParam_Textured_glass Textured_glass; struct ShaderParam_Textured_matte Textured_matte; struct ShaderParam_Textured_mirror Textured_mirror; struct ShaderParam_transmissive transmissive; } __attribute__((packed)) params __attribute__((packed)); };[/cpp]
Hi,
Thanks for your post.
There is a documented known issue in the current SDK, which prevents the usage of user defined structures as arguments for kernels. This issue might be solved by passing these structures in OpenCL memory objects.
If the bare definition of a packed structure fails, please letme know, soI can file a bug on this issue.
Thanks
Guy
Thanks for your post.
There is a documented known issue in the current SDK, which prevents the usage of user defined structures as arguments for kernels. This issue might be solved by passing these structures in OpenCL memory objects.
If the bare definition of a packed structure fails, please letme know, soI can file a bug on this issue.
Thanks
Guy
Thanks,
In my kernel I use this :
__kernel void __attribute__((vec_type_hint(float4))) RenderPath(
...
__constantchar* shaderParametersBuffer
...
)
and later I access it like this :
ShaderParameters shaderParams = *((__constantShaderParameters*)(shaderParametersBuffer + offset));
where 'offset' is defined in bytes !!!
So, maybe it is not related to this issue ?
Regards
Right Shiri,
Krys, in addition, I encourage you to join The Intel Visual Adrenaline Software Development Program. Log into the program site and see our community and suooirt offering to visual computing developers.
As this product is in preview stage, support through forum is what we offer. Looking forward, we will work to expand our support offering to provide you the level that you need.
Thanks,
Arnon
Hi,
I will take a look at your program, thanks for the information.
I have test the new SDK and everything works perfectly !! :-D and even faster.
Congratulation for your release... good job :-)
So, is it possible to be in touch with a "project manager" in order to discuss some "marketing stuffs" ?
Regards
