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;h=a98ed36ce58b7c547cd48e0ffdc47551dcc5d249;hb=2fd5d915e8a9de4d957d6031d2d68088784eac3c;hp=8281489ecf2a55d6556146ddcef2b693cca41875;hpb=7798b7c27cf13aaeada22faae8648df8cb339f1b;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 index 8281489..a98ed36 100755 --- 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 @@ -1,8 +1,9 @@ +#include "FractalDevice.h" + #include #include "Indice2D.h" #include "IndiceTools.h" -#include "DomaineMath.h" #include "cudaTools.h" #include "Device.h" @@ -11,40 +12,8 @@ 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) +__device__ void fractal(uchar4* ptrDevPixels, int w, int h, const DomaineMath& domaineMath, int n, const FractalMath& fractalMath) { - FractalMath fractalMath(n); - const int TID = Indice2D::tid(); const int NB_THREAD = Indice2D::nbThread(); const int WH = w * h; @@ -57,22 +26,30 @@ __global__ void fractal(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineM int s = TID; while (s < WH) - { - IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ) + { + 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) + // (i,j) domaine écran + // (x,y) domaine math + domaineMath.toXY(pixelI, pixelJ, &x, &y); // (i,j) -> (x,y) - fractalMath.colorXY(&color,x, y, t); // update color + fractalMath.colorXY(&color, x, y); - ptrDevPixels[s] = color; + ptrDevPixels[s] = color; - s += NB_THREAD; - } + s += NB_THREAD; + } } -/*----------------------------------------------------------------------*\ - |* End *| - \*---------------------------------------------------------------------*/ +__global__ void fractalMandelbrot(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n) + { + FractalMandelbrotMath fractalMath(n); + fractal(ptrDevPixels, w, h, domaineMath, n, fractalMath); + } + +__global__ void fractalJulia(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float c_r, float c_i) + { + FractalJuliaMath fractalMath(n, c_r, c_i); + fractal(ptrDevPixels, w, h, domaineMath, n, fractalMath); + }