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=1b326db65e6a6c2b1ca25cd5170cc53f92ea1b2d;hb=fd0031be0a39a5d902750affaff6322fcd5229b1;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..1b326db 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,43 +12,11 @@ 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 hFrom, int hTo, 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; + const int WH = w * (hTo - hFrom); uchar4 color; color.z = 255; // Par défaut, l'image est opaque. @@ -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 + hFrom, 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 hFrom, int hTo, DomaineMath domaineMath, int n) + { + FractalMandelbrotMath fractalMath(n); + fractal(ptrDevPixels, w, hFrom, hTo, 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, 0, h, domaineMath, n, fractalMath); + }