Nicolas Winkler hace 5 años
padre
commit
28028b0807

+ 4 - 5
Almond.pro

@@ -6,9 +6,6 @@
 
 QT       += core gui opengl xml
 
-QMAKE_LINK=clang++
-QMAKE_CXX=clang++
-
 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
 TARGET = Almond
@@ -85,9 +82,11 @@ win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../libs/ffmpeg-4.1.1-win32
 else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../libs/ffmpeg-4.1.1-win32-dev/lib/ -lavcodec
 else:unix: LIBS += -L$$PWD/../libs/ffmpeg-4.1.1-win32-dev/lib/ -lavcodec
 
-INCLUDEPATH += $$PWD/../libs/ffmpeg-4.1.1-win32-dev/include
-DEPENDPATH += $$PWD/../libs/ffmpeg-4.1.1-win32-dev/include
+win32:INCLUDEPATH += $$PWD/../libs/ffmpeg-4.1.1-win32-dev/include
+win32:DEPENDPATH += $$PWD/../libs/ffmpeg-4.1.1-win32-dev/include
 
+win32:INCLUDEPATH += ../libs/boost_1_72_0
+DEFINES += WITH_BOOST=1
 
 #win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../Program Files (x86)/AMD APP SDK/3.0/lib/x86/' -lOpenCL
 #else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../Program Files (x86)/AMD APP SDK/3.0/lib/x86/' -lOpenCL

+ 5 - 5
MandelVideoGenerator.cpp

@@ -20,12 +20,12 @@ void MandelVideoGenerator::generate(void)
 
     VideoStream vs(evi.width, evi.height, evi.path, evi.bitrate, evi.preset.c_str());
 
-    double x = evi.end.x + evi.end.width / 2;
-    double y = evi.end.y + evi.end.height / 2;
-    double w = evi.start.width;
-    double h = evi.start.height;
+    mnd::Real x = evi.end.x + evi.end.width / 2;
+    mnd::Real y = evi.end.y + evi.end.height / 2;
+    mnd::Real w = evi.start.width;
+    mnd::Real h = evi.start.height;
 
-    double bigW = 10000000000000000.0;
+    mnd::Real bigW = 10000000000000000.0;
     double bigFac = 1.0;
     Bitmap<RGBColor> big;
     Bitmap<RGBColor> small;

+ 18 - 20
MandelWidget.cpp

@@ -168,13 +168,13 @@ TexGrid::TexGrid(MandelView& owner, int level) :
 
 std::pair<GridIndex, GridIndex> TexGrid::getCellIndices(mnd::Real x, mnd::Real y)
 {
-    return { ::floor(x / dpp / MandelView::chunkSize), ::floor(y / dpp / MandelView::chunkSize) };
+    return { GridIndex(mnd::floor(x / dpp / MandelView::chunkSize)), GridIndex(mnd::floor(y / dpp / MandelView::chunkSize)) };
 }
 
 
 std::pair<mnd::Real, mnd::Real> TexGrid::getPositions(GridIndex x, GridIndex y)
 {
-    return { x * dpp * MandelView::chunkSize, y * dpp * MandelView::chunkSize };
+    return { mnd::Real(x) * dpp * MandelView::chunkSize, mnd::Real(y) * dpp * MandelView::chunkSize };
 }
 
 
@@ -208,17 +208,15 @@ void Job::run(void)
     mnd::Real gw = grid->dpp * MandelView::chunkSize;
 
     Bitmap<float> f(MandelView::chunkSize, MandelView::chunkSize);
-    mnd::MandelInfo mi;
-    mi.view.x = absX;
-    mi.view.y = absY;
-    mi.view.width = mi.view.height = gw;
-    mi.bWidth = mi.bHeight = MandelView::chunkSize;
-    mi.maxIter = maxIter;
-    printf("w: %ld, h: %ld\n", mi.bWidth, mi.bHeight);
-    fflush(stdout);
-    generator->generate(mi, f.pixels.get());
+    std::unique_ptr<mnd::MandelInfo> mi = std::make_unique<mnd::MandelInfo>();
+    mi->view.x = absX;
+    mi->view.y = absY;
+    mi->view.width = mi->view.height = gw;
+    mi->bWidth = mi->bHeight = MandelView::chunkSize;
+    mi->maxIter = maxIter;
+    generator->generate(*mi, f.pixels.get());
     auto* rgb = new Bitmap<RGBColor>(f.map<RGBColor>([&mi, this](float i) {
-        return i >= mi.maxIter ? RGBColor{ 0, 0, 0 } : gradient.get(i);
+        return i >= mi->maxIter ? RGBColor{ 0, 0, 0 } : gradient.get(i);
     }));
     emit done(level, i, j, calcState, rgb);
 }
@@ -318,7 +316,7 @@ MandelView::MandelView(mnd::Generator* generator, MandelWidget& owner, int maxIt
 
 
 int MandelView::getLevel(mnd::Real dpp) {
-    return int(::log2(dpp / chunkSize));
+    return int(log2(dpp / chunkSize));
 }
 
 
@@ -417,7 +415,7 @@ GridElement* MandelView::searchAbove(int level, GridIndex i, GridIndex j, int re
 
     if (above != nullptr) {
         auto newElement = std::make_unique<GridElement>(
-            false, above->img->clip((i & 1), (j & 1))
+            false, above->img->clip(short(i & 1), short(j & 1))
         );
         GridElement* ret = newElement.get();
         grid.setCell(i, j, std::move(newElement));
@@ -491,8 +489,8 @@ void MandelView::paint(const mnd::MandelViewport& mvp)
     realYTop = (realYTop - mvp.y) * height / mvp.height;
     for(GridIndex i = left; i <= right; i++) {
         for(GridIndex j = top; j <= bottom; j++) {
-            mnd::Real x = realXLeft + (i - left) * w;
-            mnd::Real y = realYTop + (j - top) * w;
+            mnd::Real x = w * int(i - left) + realXLeft;
+            mnd::Real y = w * int(j - top) + realYTop;
 
             GridElement* t = grid.getCell(i, j);
 
@@ -510,7 +508,7 @@ void MandelView::paint(const mnd::MandelViewport& mvp)
             }
 
             if (t != nullptr) {
-                t->img->drawRect(x, y, w, w);
+                t->img->drawRect(float(x), float(y), float(w), float(w));
                 /*glBegin(GL_LINE_LOOP);
                 glVertex2f(x, y);
                 glVertex2f(x + w, y);
@@ -524,7 +522,7 @@ void MandelView::paint(const mnd::MandelViewport& mvp)
             }
             else {
                 calcer.calc(grid, level, i, j, 1000);
-                this->empty->drawRect(x, y, w, w);
+                this->empty->drawRect(float(x), float(y), float(w), float(w));
             }
         }
     }
@@ -655,8 +653,8 @@ void MandelWidget::updateAnimations(void)
 
     lastAnimUpdate = now;
 
-    if (::abs(currentViewport.width / targetViewport.width - 1.0) < 0.1e-5
-            && ::abs(currentViewport.height / targetViewport.height - 1.0) < 0.1e-5) {
+    if (mnd::abs(currentViewport.width / targetViewport.width - 1.0) < 0.1e-5
+            && mnd::abs(currentViewport.height / targetViewport.height - 1.0) < 0.1e-5) {
         // animation finished
     }
     else {

+ 14 - 1
exportdialogs.cpp

@@ -75,6 +75,17 @@ ExportVideoDialog::ExportVideoDialog(QWidget* parent, const ExportVideoInfo& evi
     evd.vidHeight->setValidator(new QIntValidator(1, 10000000, this));
     evd.bitrate->setValidator(new QIntValidator(1, 10000000, this));
 
+#ifdef WITH_BOOST
+    evd.startX->setText(QString::fromStdString(evi.start.x.str()));
+    evd.startY->setText(QString::fromStdString(evi.start.y.str()));
+    evd.startW->setText(QString::fromStdString(evi.start.width.str()));
+    evd.startH->setText(QString::fromStdString(evi.start.height.str()));
+
+    evd.endX->setText(QString::fromStdString(evi.end.x.str()));
+    evd.endY->setText(QString::fromStdString(evi.end.y.str()));
+    evd.endW->setText(QString::fromStdString(evi.end.width.str()));
+    evd.endH->setText(QString::fromStdString(evi.end.height.str()));
+#else
     evd.startX->setText(QString::number(evi.start.x));
     evd.startY->setText(QString::number(evi.start.y));
     evd.startW->setText(QString::number(evi.start.width));
@@ -84,6 +95,7 @@ ExportVideoDialog::ExportVideoDialog(QWidget* parent, const ExportVideoInfo& evi
     evd.endY->setText(QString::number(evi.end.y));
     evd.endW->setText(QString::number(evi.end.width));
     evd.endH->setText(QString::number(evi.end.height));
+#endif // WITH_BOOST
 
     auto presets = {
         "ultrafast",
@@ -156,7 +168,7 @@ void ExportVideoDialog::on_pushButton_clicked()
     this->repaint();
 }
 
-
+/*
 bool exportVideo(const ExportVideoInfo& evi)
 {
     auto lerp = [] (double a, double b, double v) {
@@ -191,3 +203,4 @@ bool exportVideo(const ExportVideoInfo& evi)
     }
     return true;
 }
+*/

+ 4 - 4
libmandel/CMakeLists.txt

@@ -10,7 +10,7 @@ project(mandel VERSION 1.0.0 DESCRIPTION "library for mandelbrot calculations")
 
 find_package(OpenCL)
 find_package(OpenMP)
-set(Boost_DEBUG 1)
+#set(Boost_DEBUG 1)
 find_package(Boost 1.53)
 
 find_path(MPFR_INCLUDES
@@ -67,10 +67,10 @@ if (APPLE AND OpenCL_FOUND)
 endif()
 
     target_compile_definitions(mandel PUBLIC WITH_BOOST)
-if(BOOST_FOUND)
+if(Boost_FOUND)
     target_compile_definitions(mandel PUBLIC WITH_BOOST)
-    include_directories(${Boost_INCLUDE_DIR})
-endif(BOOST_FOUND)
+    target_include_directories(mandel PRIVATE ${Boost_INCLUDE_DIRS})
+endif(Boost_FOUND)
 
 if (ARCH STREQUAL "X86_64" OR ARCH STREQUAL "X86")
     if (MSVC)

+ 18 - 2
libmandel/include/Types.h

@@ -2,8 +2,12 @@
 #define MANDEL_TYPES_H
 
 #include <cinttypes>
+#include <cmath>
 #ifdef WITH_BOOST
 #   include <boost/multiprecision/cpp_bin_float.hpp>
+#   if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#       include <boost/multiprecision/float128.hpp>
+#   endif
 #   include <boost/multiprecision/cpp_int.hpp>
 #endif
 
@@ -12,16 +16,28 @@ namespace mnd
 
 
 #ifdef WITH_BOOST
+#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+    using Float128 = boost::multiprecision::float128;
+#else
     using Float128 = boost::multiprecision::cpp_bin_float_quad;
+#endif
+    inline Float128 abs(const Float128& x) { return boost::multiprecision::abs(x); }
+    inline Float128 floor(const Float128& x) { return boost::multiprecision::floor(x); }
+    inline Float128 log(const Float128& x) { return boost::multiprecision::log(x); }
 
-    using Real = double;
+    using Real = Float128;
     using Integer = boost::multiprecision::int128_t;
 #else
     using Real = double;
     using Integer = int64_t;
 #endif
 
-
+    inline double abs(double x) { return ::abs(x); }
+    inline float abs(float x) { return ::abs(x); }
+    inline double floor(double x) { return ::floor(x); }
+    inline float floor(float x) { return ::floorf(x); }
+    inline double log(double x) { return ::log(x); }
+    inline float log(float x) { return ::logf(x); }
 }
 
 

+ 1 - 3
libmandel/src/Generators.cpp

@@ -20,15 +20,13 @@ AdaptiveGenerator::AdaptiveGenerator(Generator* floatGen, Generator* doubleGen)
 AdaptiveGenerator::AdaptiveGenerator(Generator* floatGen, Generator* doubleGen, Generator* quadGen)
 {
     generators.push_back({ 0.0000001, floatGen });
-    generators.push_back({ 1.0e-17, doubleGen });
+    generators.push_back({ 5.0e-16, doubleGen });
     generators.push_back({ 0.0, quadGen });
 }
 
 
 void AdaptiveGenerator::generate(const mnd::MandelInfo& info, float* data)
 {
-    printf("w: %ld, h: %ld\n", info.bWidth, info.bHeight);
-    fflush(stdout);
     Real pixelW = info.view.width / info.bWidth;
     Real pixelH = info.view.height / info.bHeight;
     Real minimum = pixelW < pixelH ? pixelW : pixelH;