spectral

Bit operations in OpenCL Kernel

Discussion created by spectral on Oct 13, 2010
Latest reply on Oct 13, 2010 by Illusio

 

 

Hi,

 

In my OpenCL kernel I use the following code :

 

#define BxDFType uint
#define    BSDF_UNDEFINED     0
#define    BSDF_REFLECTION    1<<0
#define    BSDF_TRANSMISSION  1<<1
#define    BSDF_DIFFUSE       1<<2
#define    BSDF_GLOSSY        1<<3
#define    BSDF_SPECULAR      1<<4
#define    BSDF_ALL_TYPES         BSDF_DIFFUSE | BSDF_GLOSSY | BSDF_SPECULAR
#define    BSDF_ALL_REFLECTION    BSDF_REFLECTION | BSDF_ALL_TYPES
#define    BSDF_ALL_TRANSMISSION  BSDF_TRANSMISSION | BSDF_ALL_TYPES
#define    BSDF_ALL               BSDF_ALL_REFLECTION | BSDF_ALL_TRANSMISSION

#define    BSDF_CONDUCTOR 1<<5
#define    BSDF_DIELECTRIC 1<<6
#define    BSDF_MICROFACET_BLINN 1<<8
#define    BSDF_MICROFACET_ANISOTROPIC 1<<9

 

And I do some operations like this :

 

BxDFType type;

 

1) Set a specific flag : type = (type | BSDF_CONDUCTOR)

2) Remove a specific flag : type = (type & ~ BSDF_CONDUCTOR)

3) Check if a flag is set : if (type & BSDF_CONDUCTOR) ...

4) Check if a flag is not set : if (!(type & BSDF_CONDUCTOR)) ...

5) Check that a flag is set : if (type == BSDF_UNDEFINED)... nothing defined !

 

But it sounds that there are some of theses operations that doesn't work well !

Because I'm unable to debug I can find where is my error. So, I just would like to check with you if

we can do theses operations in OpenCL ?



 

 

 

Outcomes