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=f9a89262ac559f28fc371a755cc570f34f2de5f4;hpb=bd178531f80f8bc41c998d1c4588f9e18cc29389;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 f9a8926..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,56 +12,11 @@ using std::cout; using std::endl; -/*----------------------------------------------------------------------*\ - |* Declaration *| - \*---------------------------------------------------------------------*/ - -/*--------------------------------------*\ - |* Imported *| - \*-------------------------------------*/ - -/*--------------------------------------*\ - |* Public *| - \*-------------------------------------*/ - -__global__ void fractalMandelbrot(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n); -__global__ void fractalJulia(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float c_r, float c_i); -__device__ void fractal(uchar4* ptrDevPixels, int w, int h, const DomaineMath& domaineMath, int n, const FractalMath& fractalMath); - -/*--------------------------------------*\ - |* Private *| - \*-------------------------------------*/ - -/*----------------------------------------------------------------------*\ - |* Implementation *| - \*---------------------------------------------------------------------*/ - -/*--------------------------------------*\ - |* Public *| - \*-------------------------------------*/ - -/*--------------------------------------*\ - |* Private *| - \*-------------------------------------*/ - - -__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); - } - -__device__ void fractal(uchar4* ptrDevPixels, int w, int h, const DomaineMath& domaineMath, int n, const FractalMath& fractalMath) +__device__ void fractal(uchar4* ptrDevPixels, int w, int hFrom, int hTo, const DomaineMath& domaineMath, int n, const FractalMath& fractalMath) { 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. @@ -73,9 +29,9 @@ __device__ void fractal(uchar4* ptrDevPixels, int w, int h, const DomaineMath& d { IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ) - // (i,j) domaine ecran + // (i,j) domaine écran // (x,y) domaine math - domaineMath.toXY(pixelI, pixelJ, &x, &y); // (i,j) -> (x,y) + domaineMath.toXY(pixelI + hFrom, pixelJ, &x, &y); // (i,j) -> (x,y) fractalMath.colorXY(&color, x, y); @@ -85,7 +41,15 @@ __device__ void fractal(uchar4* ptrDevPixels, int w, int h, const DomaineMath& d } } -/*----------------------------------------------------------------------*\ - |* 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); + }