headless mode that doest write to file with -p flag added

parent 1d1221c9
......@@ -41,7 +41,7 @@ int mandelbrot_avx(Complex c, unsigned max_iterations) {
__m256d threshold = _mm256_set1_pd(4.0);
__m256d one = _mm256_set1_pd(1.0);
int k = 1;
unsigned int k = 1;
__m256d mk = _mm256_set1_pd(k);
while (k < max_iterations) {
......@@ -109,8 +109,8 @@ calculate_color(unsigned int iterations, unsigned int max_iterations)
double t = (double)iterations / max_iterations;
t = 0.5 + 0.5 * tan(log(t + 0.0001) * 3.0);
cl.r = 255 * t * 0.5;
cl.g = 255 * t * 0.4;
cl.b = 255 * t * 0.3;
cl.g = 255 * t * 0.3;
cl.b = 255 * t * 0.5;
cl.a = 255;
}
return cl;
......@@ -177,7 +177,8 @@ struct arguments
unsigned int max_iterations;
short unsigned use_avx;
short unsigned use_omp;
int recalc;
short unsigned dry_run;
short unsigned recalc;
double x_min;
double x_max;
......@@ -190,13 +191,14 @@ struct arguments
static struct argp_option options[] =
{
{"output file", 'o', "FILE", 0, "Render to image, default False", 0},
{"output", 'o', "FILE", 0, "Render to image, default False", 0},
{"width", 'w', "WIDTH", 0, "Width of window/image, default 640", 0},
{"height", 'h', "HEIGHT", 0, "Height of window/image, default 480", 0},
{"iterations", 'i', "ITERATIONS", 0, "Max iterations, default 250.", 0},
{"dont_use_avx", 'x', 0, 0, "NOT use avx for calculations, default False", 0},
{"dont_use_omp", 't', 0, 0, "NOT use openmpfor calculations, default False", 0},
{"no_avx", 'x', 0, 0, "NOT use avx for calculations, default False", 0},
{"no_omp", 't', 0, 0, "NOT use openmpfor calculations, default False", 0},
{"recalc", 'r', 0, 0, "Recalculate set on every frame, default False", 0},
{"dry", 'p', 0, 0, "Dry run, headless mode without writing to file and sdl nonsense, default False.", 0},
{"x_min", 'a', "VALUE", 0, "X min", 0},
{"x_max", 'b', "VALUE", 0, "X max", 0},
......@@ -213,6 +215,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
struct arguments *arguments = state->input;
switch (key)
{
case 'p':
arguments->dry_run=1;
break;
case 'i':
arguments->max_iterations = atoi(arg);
break;
......@@ -287,6 +292,22 @@ render_cl(Array *arr, SDL_Texture *texture, SDL_Renderer *renderer, int width, i
SDL_RenderCopy(renderer, texture, NULL, NULL);
}
short unsigned
dry_headless(ViewInfo *view, int width, int height, unsigned int max_iterations,
short unsigned use_avx, short unsigned use_omp) {
Array arr = {
malloc(width * height * sizeof(Color)),
width * height * sizeof(Color)
};
calculate_set(&arr, height, width, *view, use_avx, use_omp, max_iterations);
free(arr.pointer);
return 0;
}
short unsigned
render_headless(ViewInfo view, const char* filename,
int width, int height, unsigned int max_iterations,
......@@ -330,14 +351,11 @@ main(int argc, char **argv)
NULL,
640, 480,
250, 1, 1,
0,-2.0, 1.0, -1.5, 1.5, 1.0,
0,0,-2.0, 1.0,
-1.5, 1.5, 1.0
};
argp_parse(&argp, argc, argv, 0, 0, &args);
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
printf("error initializing SDL: %s\n", SDL_GetError());
return 1;
}
ViewInfo view = {
.x_min = args.x_min * args.zoom,
......@@ -347,6 +365,17 @@ main(int argc, char **argv)
.zoom = args.zoom
};
if (args.dry_run){
dry_headless(&view, args.width, args.height, args.max_iterations, args.use_avx, args.use_omp);
return 0;
}
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
printf("error initializing SDL: %s\n", SDL_GetError());
return 1;
}
if (args.output_file) {
render_headless(view, args.output_file,
args.width, args.height,
......
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