Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Tuto_Image_Cuda / src / cpp / core / 02_Damier_Zoomable / moo / device / damierDevice.cu
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 (executable)
index 0000000..e25d726
--- /dev/null
@@ -0,0 +1,80 @@
+#include "Indice2D.h"\r
+#include "IndiceTools.h"\r
+#include "DomaineMath.h"\r
+#include "cudaTools.h"\r
+#include "Device.h"\r
+#include "DamierMath.h"\r
+\r
+\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    Declaration                                     *|\r
+ \*---------------------------------------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Imported                *|\r
+ \*-------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Public                  *|\r
+ \*-------------------------------------*/\r
+\r
+__global__ void damier(uchar4* ptrDevPixels,int w, int h,DomaineMath domaineMath, int n,float t);\r
+\r
+/*--------------------------------------*\\r
+ |*            Private                 *|\r
+ \*-------------------------------------*/\r
+\r
+\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    Implementation                                  *|\r
+ \*---------------------------------------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Public                  *|\r
+ \*-------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Private                 *|\r
+ \*-------------------------------------*/\r
+\r
+__global__ void damier(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float t)\r
+    {\r
+    DamierMath damierMath = DamierMath(n);\r
+\r
+    const int TID = Indice2D::tid();\r
+    const int NB_THREAD = Indice2D::nbThread();\r
+\r
+    const int WH=w*h;\r
+\r
+    uchar4 color;\r
+\r
+    double x;\r
+    double y;\r
+\r
+    int pixelI;\r
+    int pixelJ;\r
+\r
+    int s = TID;\r
+    while (s < WH)\r
+       {\r
+       IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ)\r
+\r
+       // (i,j) domaine ecran\r
+       // (x,y) domaine math\r
+       domaineMath.toXY(pixelI, pixelJ, &x, &y); //  (i,j) -> (x,y)\r
+\r
+       damierMath.colorXY(&color,x, y,t); // update color\r
+\r
+       ptrDevPixels[s] = color;\r
+\r
+       s += NB_THREAD;\r
+       }\r
+\r
+    }\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    End                                             *|\r
+ \*---------------------------------------------------------------------*/\r
+\r