Rippling CUDA Warmup et Smart.
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / 01_Rippling / moo / device / ripplingDevice.cu
index d599127..3e3235f 100755 (executable)
@@ -1,6 +1,7 @@
 #include <iostream>\r
 \r
 #include "Indice2D.h"\r
+#include "IndiceTools.h"\r
 #include "cudaTools.h"\r
 #include "Device.h"\r
 \r
@@ -41,9 +42,29 @@ __global__ void rippling(uchar4* ptrDevPixels, int w, int h, float t);
 \r
 __global__ void rippling(uchar4* ptrDevPixels, int w, int h, float t)\r
     {\r
-    RipplingMath ripplingMath = RipplingMath(w, h);\r
+    RipplingMath ripplingMath(w, h);\r
 \r
-    // TODO pattern entrelacement\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
+    color.z = 255;\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
+       ripplingMath.color(pixelI, pixelJ, t, color);   // update color\r
+       ptrDevPixels[s] = color;\r
+\r
+       s += NB_THREAD;\r
+       }\r
     }\r
 \r
 /*----------------------------------------------------------------------*\\r