From: gburri Date: Thu, 18 Dec 2014 08:55:49 +0000 (+0100) Subject: Correction de probl?me de compilation li? a RayTracing. X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=f2c6a4fc79746e2d5c6678699bd2ca93ffc49bcc;p=GPU.git Correction de probl?me de compilation li? a RayTracing. --- diff --git a/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/cpp/ImageFonctionel.cpp b/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/cpp/ImageFonctionel.cpp index b002904..af78e9e 100755 --- a/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/cpp/ImageFonctionel.cpp +++ b/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/cpp/ImageFonctionel.cpp @@ -34,10 +34,15 @@ using std::endl; \*-------------------------------------*/ ImageFonctionel::ImageFonctionel(AnimableFonctionel_I* ptrAnimable, ColorRGB_01* ptrColorTitreRGB) : - ImageFonctionelMOOs_A(ptrAnimable->getW(), ptrAnimable->getH(), *ptrAnimable->getDomaineMathInit()) + ImageFonctionelMOOs_A( + ptrAnimable->getW(), + ptrAnimable->getH(), + *ptrAnimable->getDomaineMathInit() + ) { this->ptrAnimable = ptrAnimable; this->ptrColorTitreRGB = ptrColorTitreRGB; + this->tName = ptrAnimable->getTName(); setEnableDomaineOverlay(true); } @@ -83,7 +88,7 @@ void ImageFonctionel::paintPrimitives(Graphic2Ds& graphic2D) // redefinition // top { float t = ptrAnimable->getT(); - string message = "t = " + StringTools::toString(t); + string message = this->tName + StringTools::toString(t); graphic2D.drawTitleTop(message, ptrfont); } diff --git a/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/header/AnimableFonctionel_I.h b/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/header/AnimableFonctionel_I.h index 098790d..d5a2efd 100755 --- a/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/header/AnimableFonctionel_I.h +++ b/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/header/AnimableFonctionel_I.h @@ -34,9 +34,9 @@ class AnimableFonctionel_I * getParaAnimation */ virtual float getT(void)=0; + virtual string getTName() { return "t = "; } virtual string getTitle(void)=0; - }; #endif diff --git a/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/header/ImageFonctionel.h b/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/header/ImageFonctionel.h index 70e1585..d0c1f6b 100755 --- a/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/header/ImageFonctionel.h +++ b/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/header/ImageFonctionel.h @@ -54,6 +54,8 @@ class ImageFonctionel: public ImageFonctionelMOOs_A // Input AnimableFonctionel_I* ptrAnimable; ColorRGB_01* ptrColorTitreRGB; + + string tName; }; #endif diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/NewtonDevice.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/NewtonDevice.cu index 534e37f..cc0b8a8 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/NewtonDevice.cu +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/NewtonDevice.cu @@ -2,13 +2,12 @@ #include using namespace std; -#include "NewtonDevice.h" - #include "Indice2D.h" #include "IndiceTools.h" #include "cudaTools.h" #include "Device.h" +#include "NewtonDevice.h" #include "NewtonMath.h" __global__ diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/math/NewtonMath.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/math/NewtonMath.h index e9b0dd8..d1dffc7 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/math/NewtonMath.h +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/math/NewtonMath.h @@ -14,6 +14,14 @@ class NewtonMath C // (-1/2 -sqrt(3)/2) }; + // Les trois solutions du système d'équation : A, B et C (vecteur 2D). + static const float A1 = 1.0; + static const float A2 = 0.0; + static const float B1 = -0.5; // -1.0 / 2.0 + static const float B2 = 0.866025403785; // sqrt(3.0) / 2.0 + static const float C1 = -0.5; // -1.0 / 2.0 + static const float C2 = -0.866025403785; // -sqrt(3.0) / 2.0 + public: /* * n est le nombre d'iteration. @@ -30,15 +38,6 @@ class NewtonMath __device__ void colorXY(uchar4* ptrColor, float x1, float x2) const { - const float A1 = 1.0; - const float A2 = 0.0; - const float B1 = -1.0 / 2.0; - const float B2 = sqrt(3.0) / 2.0; - const float C1 = -1.0 / 2.0; - const float C2 = -sqrt(3.0) / 2.0; - - //const float epsilon = 0.1; - float nearest_current_solution_distance = FLT_MAX; Solution nearest_current_solution = A; @@ -64,7 +63,8 @@ class NewtonMath nearest_current_solution_distance = distance_to_C; } - /*if (Indice2D::tid() == 0) + /* For DEBUG. + * if (Indice2D::tid() == 0) { printf("nearest_current_solution_distance: %f\n", nearest_current_solution_distance); }*/ @@ -73,7 +73,8 @@ class NewtonMath printf("d to a: %f\n", distance_to_A); printf("d to a: %f\n", distance_to_B); printf("d to a: %f\n", distance_to_C); - }*/ + } + */ if (nearest_current_solution_distance < this->epsilon) break; @@ -112,7 +113,7 @@ class NewtonMath __device__ static void nextX(float x1, float x2, float& x1_next, float& x2_next) { - float f_x1 = x1 * x1 * x2 - 3.0 * x1 * x2 * x2 - 1.0; + float f_x1 = x1 * x1 * x1 - 3.0 * x1 * x2 * x2 - 1.0; float f_x2 = x2 * x2 * x2 - 3.0 * x1 * x1 * x2; // La matrice est représentée comme cela : diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/host/Newton.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/host/Newton.cu index a468b05..eaa92ea 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/host/Newton.cu +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/host/Newton.cu @@ -7,14 +7,14 @@ using namespace std; #include "Device.h" #include "NewtonDevice.h" -Newton::Newton(int w, int h) - : variateurN(IntervalI(5, 1000), 1), - variateurEpsilon(IntervalF(0.01, 10), 0.01), - w(w), h(h), - dg(8, 8, 1), - db(32, 32, 1), - ptrDomaineMathInit(new DomaineMath(-2, -2, 2, 2)), - title("Fractal Newton") +Newton::Newton(int w, int h) : + variateurEpsilon(IntervalF(0.01, 1), 0.001), + w(w), + h(h), + dg(8, 8, 1), + db(32, 32, 1), + ptrDomaineMathInit(new DomaineMath(-2, -2, 2, 2)), + title("Fractal Newton") { Device::assertDim(dg, db); } @@ -26,14 +26,13 @@ Newton::~Newton() void Newton::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath) { - newton<<>>(ptrDevPixels, this->w, this->h, domaineMath, this->t, this->epsilon); + newton<<>>(ptrDevPixels, this->w, this->h, domaineMath, 100, this->epsilon); HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG). } void Newton::animationStep() { - this->t = this->variateurN.varierAndGet(); this->epsilon = this->variateurEpsilon.varierAndGet(); } @@ -54,7 +53,12 @@ DomaineMath* Newton::getDomaineMathInit() float Newton::getT() { - return this->t; + return this->epsilon; + } + +string Newton::getTName() + { + return "epsilon : "; } string Newton::getTitle() diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/host/Newton.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/host/Newton.h index 0b876f0..a9fb73c 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/host/Newton.h +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/host/Newton.h @@ -21,14 +21,13 @@ class Newton : public AnimableFonctionel_I DomaineMath* getDomaineMathInit() /*override*/; float getT() /*override*/; + string getTName(); string getTitle(void) /*override*/; private: - VariateurI variateurN; // Variateur sur le nombre d'iteration max. VariateurF variateurEpsilon; // Variateur sur epsilon. - float t; float epsilon; // Inputs diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/provider/NewtonProvider.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/provider/NewtonProvider.h index 06d19e1..4c402b2 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/provider/NewtonProvider.h +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/provider/NewtonProvider.h @@ -1,5 +1,5 @@ -#ifndef NEWTON_PROVIDER_H_ -#define NEWTON_PROVIDER_H_ +#ifndef NEWTON_PROVIDER_H +#define NEWTON_PROVIDER_H #include "Newton.h" #include "ImageFonctionel.h" diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/RayTracingDevice.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/RayTracingDevice.cu index 368e469..3d80bc4 100644 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/RayTracingDevice.cu +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/RayTracingDevice.cu @@ -8,17 +8,14 @@ using namespace std; #include "Device.h" #include "RayTracingDevice.h" -#include "RayTracingMath.h" __global__ -void rayTracing(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, float t) +void rayTracing(uchar4* ptrDevPixels, int w, int h, float t) { const int TID = Indice2D::tid(); const int NB_THREAD = Indice2D::nbThread(); const int WH = w * h; - RayTracingMath rayTracing; // TODO: prendre - uchar4 color; color.w = 255; // Par défaut, l'image est opaque. diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/RayTracingDevice.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/RayTracingDevice.h index 47e93ae..5e4487d 100644 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/RayTracingDevice.h +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/RayTracingDevice.h @@ -4,6 +4,6 @@ #include "DomaineMath.h" __global__ -void rayTracing(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, float t); +void rayTracing(uchar4* ptrDevPixels, int w, int h, float t); #endif diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/Sphere.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/Sphere.h index 566b4ab..0567fb8 100644 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/Sphere.h +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/Sphere.h @@ -3,14 +3,13 @@ #include "cudaTools.h" #include "cudaType_CPU.h" -#include "mathTools.h" +#include "MathTools.h" -#endif class Sphere { public: __host__ - Sphere(float3 centre, float r, float hue) : + Sphere(cpu::float3 centre, float r, float hue) : centre(centre), hueInitial(hue) { @@ -23,7 +22,7 @@ class Sphere } __host__ - void setCentre(float3 centre) + void setCentre(const cpu::float3& centre) { this->centre = centre; } @@ -42,7 +41,7 @@ class Sphere } __device__ - float hCarre(float2 xySol) + float hCarre(cpu::float2 xySol) { float a = (centre.x - xySol.x); float b = (centre.y - xySol.y); @@ -87,7 +86,7 @@ class Sphere private: float r; - float3 centre; + cpu::float3 centre; float hueInitial; float rCarre; diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/math/RayTracingMath.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/math/RayTracingMath.h deleted file mode 100644 index 91b32da..0000000 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/math/RayTracingMath.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef RAY_TRACING_MATH_H -#define RAY_TRACING_MATH_H - -class RayTracingMath - { - - }; - -#endif diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.cu index 36e3862..5034594 100644 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.cu +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.cu @@ -8,6 +8,7 @@ using namespace std; #include "RayTracing.h" #include "Device.h" #include "RayTracingDevice.h" +#include "Sphere.h" RayTracing::RayTracing(int w, int h) : w(w), h(h), @@ -18,20 +19,18 @@ RayTracing::RayTracing(int w, int h) Device::assertDim(dg, db); const int nbSpheres = 10; - Sphere* = this->createSpheres(10); - + Sphere* shperes = this->createSpheres(10); // Copie les spheres dans la constant memory. } RayTracing::~RayTracing() { - delete this->ptrDomaineMathInit; } -void RayTracing::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath) +void RayTracing::runGPU(uchar4* ptrDevPixels) { - rayTracing<<>>(ptrDevPixels, this->w, this->h, domaineMath, this->t); + rayTracing<<>>(ptrDevPixels, this->w, this->h, this->t); HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG). } @@ -61,19 +60,23 @@ string RayTracing::getTitle() return this->title; } -Sphere* createSpheres(int n) +Sphere* RayTracing::createSpheres(int n) { Sphere* spheres = new Sphere[n]; const float bord = 200; for (int i = 0; i < n; ++i) { - spheres[i].setR(float(AleaTools::uniformeAB(20, this->w / 10 - 1))); - spheres[i].setCentre(float3 { - float(AleaTools::uniformeAB(bord, this->w - bord)), - float(AleaTools::uniformeAB(bord, this->h - bord)), - float(AleaTools::uniformeAB(10, 2.0 * this->w)) - }); - spheres[i].setHue(float(AleaTools::uniformeAB(0, 1)) + spheres[i].setR(float(this->alea.uniformeAB(20, this->w / 10 - 1))); + + cpu::float3 centre + { + float(this->alea.uniformeAB(double(bord), double(this->w - bord))), + float(this->alea.uniformeAB(double(bord), double(this->h - bord))), + float(this->alea.uniformeAB(10.0, 2.0 * this->w)) + }; + + spheres[i].setCentre(centre); + spheres[i].setHueInitial(float(this->alea.uniformeAB(0.0, 1.0))); } } diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.h index 80729b8..5c0e77d 100644 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.h +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.h @@ -4,6 +4,8 @@ #include "cudaTools.h" #include "Animable_I.h" #include "MathTools.h" +#include "cudaType_CPU.h" + #include "Sphere.h" class RayTracing : public Animable_I @@ -25,6 +27,8 @@ class RayTracing : public Animable_I private: Sphere* createSpheres(int n); + AleaTools alea; + float t; const int w; diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/provider/RayTracingProvider.cpp b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/provider/RayTracingProvider.cpp index 0486785..f232f0b 100644 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/provider/RayTracingProvider.cpp +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/provider/RayTracingProvider.cpp @@ -8,8 +8,8 @@ RayTracing* RayTracingProvider::create() return new RayTracing(dw, dh); } -ImageFonctionel* RayTracingProvider::createGL() +Image* RayTracingProvider::createGL() { ColorRGB_01* ptrColorTitre = new ColorRGB_01(0, 0, 0); - return new ImageFonctionel(create(), ptrColorTitre); // both ptr destroy by destructor of ImageFonctionel + return new Image(create(), ptrColorTitre); // both ptr destroy by destructor of ImageFonctionel } diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/provider/RayTracingProvider.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/provider/RayTracingProvider.h index f78ffc5..c4e560f 100644 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/provider/RayTracingProvider.h +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/provider/RayTracingProvider.h @@ -2,13 +2,13 @@ #define RAYTRACING_PROVIDER_H #include "RayTracing.h" -#include "ImageFonctionel.h" +#include "Image.h" class RayTracingProvider { public: static RayTracing* create(); - static ImageFonctionel* createGL(); + static Image* createGL(); }; #endif diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/05_HeatTransfert/moo/host/HeatTransfert.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/05_HeatTransfert/moo/host/HeatTransfert.h index 795613f..bd6882f 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/05_HeatTransfert/moo/host/HeatTransfert.h +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/05_HeatTransfert/moo/host/HeatTransfert.h @@ -13,7 +13,7 @@ class HeatTransfert : public Animable_I static const int NB_ITERATION_AVEUGLE = 1000; public: - HeatTransfert(); + HeatTransfert(int w, int h); virtual ~HeatTransfert(); void runGPU(uchar4* ptrDevPixels) /*override*/; diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/mainGL.cpp b/WCudaMSE/Student_Cuda_Image/src/cpp/core/mainGL.cpp index 9f1b84a..ecda2fd 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/mainGL.cpp +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/mainGL.cpp @@ -13,6 +13,7 @@ using namespace std; #include "FractalProvider.h" #include "NewtonProvider.h" #include "HeatTransfertProvider.h" +#include "RayTracingProvider.h" template class Viewer @@ -36,12 +37,13 @@ class Viewer int mainGL(void) { - //Viewer rippling0(true, true, 10, 10); - //Viewer rippling0(true, true, 10, 10); - //Viewer fractalMandelbrot(true, true, 20, 20); - //Viewer fractalJulia(true, true, 30, 30); + // Viewer rippling0(true, true, 10, 10); + // Viewer rippling0(true, true, 10, 10); + // Viewer fractalMandelbrot(true, true, 20, 20); + // Viewer fractalJulia(true, true, 30, 30); Viewer newtown(true, true, 20, 20); - //Viewer heatTransfert(true, false, 20, 20); + // Viewer heatTransfert(true, false, 20, 20); + // Viewer rayTracing(true, true, 20, 20); GLUTImageViewers::runALL(); // Bloquant, Tant qu'une fenetre est ouverte