X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F02_Mandelbrot_Julia%2Fmoo%2Fdevice%2FFractalDevice.cu;fp=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F02_Mandelbrot_Julia%2Fmoo%2Fdevice%2FFractalDevice.cu;h=8281489ecf2a55d6556146ddcef2b693cca41875;hb=7798b7c27cf13aaeada22faae8648df8cb339f1b;hp=0000000000000000000000000000000000000000;hpb=3e601cb6c0cc2c5b3a9b30ebf3ad1102e53c0e0b;p=GPU.git diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/device/FractalDevice.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/device/FractalDevice.cu new file mode 100755 index 0000000..8281489 --- /dev/null +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/device/FractalDevice.cu @@ -0,0 +1,78 @@ +#include + +#include "Indice2D.h" +#include "IndiceTools.h" +#include "DomaineMath.h" +#include "cudaTools.h" +#include "Device.h" + +#include "FractalMath.h" + +using std::cout; +using std::endl; + +/*----------------------------------------------------------------------*\ + |* Declaration *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Imported *| + \*-------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +__global__ void fractal(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float t); + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +/*----------------------------------------------------------------------*\ + |* Implementation *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +__global__ void fractal(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float t) + { + FractalMath fractalMath(n); + + const int TID = Indice2D::tid(); + const int NB_THREAD = Indice2D::nbThread(); + const int WH = w * h; + + uchar4 color; + color.z = 255; // Par défaut, l'image est opaque. + + double x, y; + int pixelI, 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) + + fractalMath.colorXY(&color,x, y, t); // update color + + ptrDevPixels[s] = color; + + s += NB_THREAD; + } + } + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/ +