Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Tuto_Image_Cuda / src / cpp / core / 01_Vague_smart / moo / device / VagueDevice.cu
diff --git a/WCudaMSE/Tuto_Image_Cuda/src/cpp/core/01_Vague_smart/moo/device/VagueDevice.cu b/WCudaMSE/Tuto_Image_Cuda/src/cpp/core/01_Vague_smart/moo/device/VagueDevice.cu
new file mode 100755 (executable)
index 0000000..7d8112b
--- /dev/null
@@ -0,0 +1,68 @@
+#include "Indice2D.h"\r
+#include "IndiceTools.h"\r
+#include "cudaTools.h"\r
+#include "Device.h"\r
+\r
+#include "VagueMath.h"\r
+\r
+// Attention :         Choix du nom est impotant!\r
+//             VagueDevice.cu et non Vague.cu\r
+//             Dans ce dernier cas, problème de linkage, car le nom du .cu est le meme que le nom d'un .cpp (host)\r
+//             On a donc ajouter Device (ou n'importequoi) pour que les noms soient diffĂ©rents!\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    Declaration                                     *|\r
+ \*---------------------------------------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Public                  *|\r
+ \*-------------------------------------*/\r
+\r
+__global__ void vague(uchar4* ptrDevPixels,int w, int h,float t);\r
+\r
+/*--------------------------------------*\\r
+ |*            Private                 *|\r
+ \*-------------------------------------*/\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    Implementation                                  *|\r
+ \*---------------------------------------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Public                  *|\r
+ \*-------------------------------------*/\r
+\r
+__global__ void vague(uchar4* ptrDevPixels, int w, int h, float t)\r
+    {\r
+    VagueMath vagueMath = VagueMath(w, h);\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
+    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
+       vagueMath.colorIJ(&color,pixelI, pixelJ, t);    // update color\r
+       ptrDevPixels[s] = color;\r
+\r
+       s += NB_THREAD;\r
+       }\r
+    }\r
+\r
+/*--------------------------------------*\\r
+ |*            Private                 *|\r
+ \*-------------------------------------*/\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    End                                             *|\r
+ \*---------------------------------------------------------------------*/\r
+\r