Commit 17e4687f authored by Joachim Meyer's avatar Joachim Meyer

Fix crash with SSE double / float conversion. Try to fix single color images...

Fix crash with SSE double / float conversion. Try to fix single color images being black. Add 32 bit ffmpeg.exe. Some stability fixes with commandline.
parent df01a1db
......@@ -27,7 +27,10 @@ SOFTWARE.
#include "PolyBezierCurve.h"
#include <ctime>
NewtonFraktal::NewtonFraktal(int xRes, int yRes) : Image(xRes, yRes, Image::IMAGE_RGBA) { }
NewtonFraktal::NewtonFraktal(int xRes, int yRes) : Image(xRes, yRes, Image::IMAGE_RGBA) {
area = (double*)_aligned_malloc(2 * sizeof(double), 32);
center = (double*)_aligned_malloc(2 * sizeof(double), 32);
}
NewtonFraktal::~NewtonFraktal() {
......@@ -40,7 +43,7 @@ NewtonFraktal::~NewtonFraktal() {
void NewtonFraktal::draw() {
max_begin = clock();
double maxIters = 0;
int maxIters = 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (types[x + y * width] >= 0) {
......@@ -49,6 +52,10 @@ void NewtonFraktal::draw() {
}
}
if (maxIters < 35) {
maxIters = 35;
}
max_end = clock();
draw_begin = clock();
......@@ -78,7 +85,7 @@ void NewtonFraktal::draw() {
if (conDiv < 0.3)
conDiv = 0.3;
conDiv = colorCurve->getYValueAtX(conDiv / maxIters);
conDiv = colorCurve->getYValueAtX(conDiv / (double)maxIters);
col.setColorHSV(col.getHue(), col.getSaturation(), conDiv);
setPixel(x, y, col);
} else {
......
......@@ -58,8 +58,8 @@ public:
clock_t max_begin, max_end, draw_begin, draw_end;
private:
__declspec(align(MEM_ALIGN)) double area[2];
__declspec(align(MEM_ALIGN)) double center[2];
double *area;
double *center;
Polynom* polynom;
Polynom* derivation = nullptr;
......
......@@ -75,7 +75,7 @@ NewtonFraktalApp::NewtonFraktalApp(NewtonFraktalView *view) {
Entity::defaultBlendingMode = Renderer::BLEND_MODE_NONE;
CoreServices::getInstance()->getRenderer()->setTextureFilteringMode(Renderer::TEX_FILTERING_NEAREST);
Services()->getLogger()->setLogToFile(true);
//Services()->getLogger()->setLogToFile(true);
clOptionsSet = false;
......
......@@ -233,6 +233,10 @@ void NewtonFraktalGeneration::setDefaultGenerationMode(int newDef) {
defaultGenerator = getGeneratorForMode(defaultGenerationMode);
}
int NewtonFraktalGeneration::getDefaultGenerationMode() {
return defaultGenerationMode;
}
NewtonFraktalGenerator * NewtonFraktalGeneration::getGeneratorForMode(int mode) {
for (int i = 0; i < generators.size(); i++) {
if (generators[i]->generatorType == mode && generators[i]->status == 0)
......
......@@ -86,6 +86,7 @@ public:
NewtonFraktalGenerator* registerGenerator(NewtonFraktalGenerator* newGen, int generatorType);
void setDefaultGenerationMode(int newDef);
int getDefaultGenerationMode();
static vector<Color> colors;
......
......@@ -109,7 +109,7 @@
copy UIThemes.pak "$(TargetDir)"
copy "newton_float.cl" "$(TargetDir)"
copy "newton_double.cl" "$(TargetDir)"
if not exist "$(TargetDir)ffmpeg.exe" copy "$(ProjectDir)ffmpeg.exe" "$(TargetDir)"</Command>
if not exist "$(TargetDir)ffmpeg.exe" copy "$(ProjectDir)ffmpeg32.exe" "$(TargetDir)ffmpeg.exe"</Command>
</PostBuildEvent>
<MASM>
<PreprocessorDefinitions>ASMX86_32</PreprocessorDefinitions>
......@@ -168,7 +168,7 @@ if not exist "$(TargetDir)ffmpeg.exe" copy "$(ProjectDir)ffmpeg.exe" "$(TargetDi
copy UIThemes.pak "$(TargetDir)"
copy "newton_float.cl" "$(TargetDir)"
copy "newton_double.cl" "$(TargetDir)"
if not exist "$(TargetDir)ffmpeg.exe" copy "$(ProjectDir)ffmpeg.exe" "$(TargetDir)"</Command>
if not exist "$(TargetDir)ffmpeg.exe" copy "$(ProjectDir)ffmpeg32.exe" "$(TargetDir)ffmpeg.exe"</Command>
</PostBuildEvent>
<MASM>
<PreprocessorDefinitions>ASMX86_32</PreprocessorDefinitions>
......
......@@ -76,6 +76,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
srand(time(NULL));
Logger::getInstance()->setLogToFile(true);
Logger::log("Using SSE2: %s, AVX: %s.\n", InstructionSet::SSE2() ? "yes" : "no", InstructionSet::AVX() ? "yes" : "no");
#ifdef _DEBUG
debug = true;
#endif
......@@ -100,12 +103,12 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
return Msg.wParam;
} else {
Logger::getInstance()->setLogToFile(true);
if (debug)
OpenConsole();
if (vid) {
//int duration = 5, framerate = 20;
BezierCurve *areaCurve = new BezierCurve();
areaCurve->addControlPoint2d(0, 10);
//areaCurve->addControlPoint2d(2.0, 2.0);
......@@ -120,16 +123,24 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
//centerCurve->addControlPoint3d(0.3, 0.043820904830500, 0.729320429246429);
centerCurve->addControlPoint3d(duration / duration, 0.043820904830500, 0.729320429246429);
int res[2] = { 1920, 1080};
int res[2] = { 1920, 1080 };
NewtonFraktalGeneration *gen = new NewtonFraktalGeneration();
NewtonFraktalCLGenerator *clGen = new NewtonFraktalCLGenerator();
clGen->initCL(0, 0);
gen->registerGenerator(clGen, gen->GENERATION_MODE_CL);
gen->setDefaultGenerationMode(gen->GENERATION_MODE_CL);
if (clGen->err == CL_SUCCESS) {
gen->registerGenerator(clGen, gen->GENERATION_MODE_CL);
gen->setDefaultGenerationMode(gen->GENERATION_MODE_CL);
}
Polynom *polynom = Polynom::getRandomPolynom(23);
//Polynom *polynom = Polynom::readFromString("( 1 + 6 i)*x^ 23 + ( 14 + 3 i)*x^ 22 + ( 3 + 2 i)*x^ 21 + ( 6 + 8 i)*x^ 20 + ( 9 + 10 i)*x^ 19 + ( 4 + 2 i)*x^ 18 + ( 7 + 9 i)*x^ 17 + ( 3 + 11 i)*x^ 16 + ( 6 + 2 i)*x^ 15 + ( 5 + 8 i)*x^ 14 + ( 11 + 6 i)*x^ 13 + ( 7 + 7 i)*x^ 12 + ( 3 + 2 i)*x^ 11 + ( 9 + 6 i)*x^ 10 + ( 6 + 12 i)*x^ 9 + ( 2 + 10 i)*x^ 8 + ( 11 + 1 i)*x^ 7 + ( 12 + 1 i)*x^ 6 + ( 5 + 5 i)*x^ 5 + ( 14 + 7 i)*x^ 4 + ( 3 + 3 i)*x^ 3 + ( 4 + 14 i)*x^ 2 + ( 10 + 4 i)*x + ( 2 + 11 i)");
Polynom *polynom;
if (usingDouble())
polynom = Polynom::getRandomPolynom(MAX_DEGREE);
else
polynom = Polynom::getRandomPolynom(MAX_DEGREE_FLOAT);
delete polynom;
//polynom = Polynom::readFromString("( -5 + 0 i)*x^ 23 + ( 12 + -1 i)*x^ 22 + ( -16 + -16 i)*x^ 21 + ( -19 + 3 i)*x^ 20 + ( -2 + 19 i)*x^ 19 + ( -12 + 10 i)*x^ 18 + ( -7 + 15 i)*x^ 17 + ( -11 + -12 i)*x^ 16 + ( 2 + 15 i)*x^ 15 + ( -13 + 10 i)*x^ 14 + ( 9 + 13 i)*x^ 13 + ( -7 + 2 i)*x^ 12 + ( 9 + -15 i)*x^ 11 + ( -15 + 8 i)*x^ 10 + ( -13 + 9 i)*x^ 9 + ( 4 + -6 i)*x^ 8 + ( -10 + 2 i)*x^ 7 + ( -13 + -4 i)*x^ 6 + ( -3 + -1 i)*x^ 5 + ( -19 + -20 i)*x^ 4 + ( 1 + 8 i)*x^ 3 + ( 19 + -17 i)*x^ 2 + ( 16 + -19 i)*x + ( 8 + -19 i)");
polynom->printPolynom();
gen->generateZoom(areaCurve, centerCurve, framerate, duration, res, polynom, 0.35);
} else {
......@@ -138,20 +149,29 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
NewtonFraktalGeneration *gen = new NewtonFraktalGeneration();
NewtonFraktalCLGenerator *clGen = new NewtonFraktalCLGenerator();
clGen->initCL(0, 0);
gen->registerGenerator(clGen, gen->GENERATION_MODE_CL);
gen->setDefaultGenerationMode(gen->GENERATION_MODE_CL);
if (clGen->err == CL_SUCCESS) {
gen->registerGenerator(clGen, gen->GENERATION_MODE_CL);
gen->setDefaultGenerationMode(gen->GENERATION_MODE_CL);
}
NewtonFraktal *fraktal = new NewtonFraktal(res[0], res[1]);
fraktal->setArea(2, 2);
fraktal->setCenter(0, 0);
fraktal->setContrast(0.35);
fraktal->setPolynom(Polynom::getRandomPolynom(23));
gen->generate(fraktal, gen->GENERATION_MODE_CL);
Polynom *polynom;
if (usingDouble())
polynom = Polynom::getRandomPolynom(MAX_DEGREE);
else
polynom = Polynom::getRandomPolynom(MAX_DEGREE_FLOAT);
fraktal->setPolynom(polynom);
fraktal->getPolynom()->printPolynom();
gen->generate(fraktal, gen->getDefaultGenerationMode());
}
if (debug) {
cout << "Bitte Enter drcken..." << endl;
cout << "Please press Return..." << endl;
getchar();
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment