X-Git-Url: http://git.euphorik.ch/?p=GPU.git;a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F01_Rippling%2Fmoo%2Fdevice%2FripplingDevice.cu;h=3e3235f0b7309c50ea01f9a83591527304fa5384;hp=d599127b2762384c4550c49da97c5f6702597341;hb=b1138708dfa104f784170fcf2d50989156e5c5d0;hpb=f4016003996bd8f9dd903ad9ba6ec6269140a928 diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/01_Rippling/moo/device/ripplingDevice.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/01_Rippling/moo/device/ripplingDevice.cu index d599127..3e3235f 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/01_Rippling/moo/device/ripplingDevice.cu +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/01_Rippling/moo/device/ripplingDevice.cu @@ -1,6 +1,7 @@ #include #include "Indice2D.h" +#include "IndiceTools.h" #include "cudaTools.h" #include "Device.h" @@ -41,9 +42,29 @@ __global__ void rippling(uchar4* ptrDevPixels, int w, int h, float t); __global__ void rippling(uchar4* ptrDevPixels, int w, int h, float t) { - RipplingMath ripplingMath = RipplingMath(w, h); + RipplingMath ripplingMath(w, h); - // TODO pattern entrelacement + const int TID = Indice2D::tid(); + const int NB_THREAD = Indice2D::nbThread(); + + const int WH = w * h; + + uchar4 color; + color.z = 255; + + int pixelI; + int pixelJ; + + int s = TID; + while (s < WH) + { + IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ) + + ripplingMath.color(pixelI, pixelJ, t, color); // update color + ptrDevPixels[s] = color; + + s += NB_THREAD; + } } /*----------------------------------------------------------------------*\