X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FTuto_Image_Cuda%2Fsrc%2Fcpp%2Fcore%2F02_Damier_Zoomable%2Fmoo%2Fdevice%2FdamierDevice.cu;fp=WCudaMSE%2FTuto_Image_Cuda%2Fsrc%2Fcpp%2Fcore%2F02_Damier_Zoomable%2Fmoo%2Fdevice%2FdamierDevice.cu;h=e25d726d1576f13f12e61f4eaf24b00c85b97686;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git diff --git a/WCudaMSE/Tuto_Image_Cuda/src/cpp/core/02_Damier_Zoomable/moo/device/damierDevice.cu b/WCudaMSE/Tuto_Image_Cuda/src/cpp/core/02_Damier_Zoomable/moo/device/damierDevice.cu new file mode 100755 index 0000000..e25d726 --- /dev/null +++ b/WCudaMSE/Tuto_Image_Cuda/src/cpp/core/02_Damier_Zoomable/moo/device/damierDevice.cu @@ -0,0 +1,80 @@ +#include "Indice2D.h" +#include "IndiceTools.h" +#include "DomaineMath.h" +#include "cudaTools.h" +#include "Device.h" +#include "DamierMath.h" + + + +/*----------------------------------------------------------------------*\ + |* Declaration *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Imported *| + \*-------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +__global__ void damier(uchar4* ptrDevPixels,int w, int h,DomaineMath domaineMath, int n,float t); + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + + + +/*----------------------------------------------------------------------*\ + |* Implementation *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +__global__ void damier(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float t) + { + DamierMath damierMath = DamierMath(n); + + const int TID = Indice2D::tid(); + const int NB_THREAD = Indice2D::nbThread(); + + const int WH=w*h; + + uchar4 color; + + double x; + double y; + + int pixelI; + int pixelJ; + + int s = TID; + while (s < WH) + { + IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ) + + // (i,j) domaine ecran + // (x,y) domaine math + domaineMath.toXY(pixelI, pixelJ, &x, &y); // (i,j) -> (x,y) + + damierMath.colorXY(&color,x, y,t); // update color + + ptrDevPixels[s] = color; + + s += NB_THREAD; + } + + } + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/ +