Beispiel #1
0
void workitem_free(workitem *item)
{
  /* It's OK to free all of these; pipeline_free() with class_id 0 is a no-op */
  pipeline_free(item->pipeline, item->row_buffer_1, item->rowbuf1_cls);
  pipeline_free(item->pipeline, item->row_buffer_2, item->rowbuf2_cls);
  pipeline_free(item->pipeline, item->ndb_key_buffer, item->keybuf1_cls);
  pipeline_free(item->pipeline, item->key_buffer_2, item->keybuf2_cls);

  pipeline_free(item->pipeline, item, workitem_class_id);
}
Beispiel #2
0
static void
Wcs_dealloc(
    Wcs* self) {

    Wcs_clear(self);
    pipeline_free(&self->x);
    Py_TYPE(self)->tp_free((PyObject*)self);
}
Beispiel #3
0
END_TEST

START_TEST (test_inspect_pipeline)
{
	pipeline *p;
	char *str;

	p = pipeline_new ();
	pipeline_command_args (p, "foo", "bar", NULL);
	pipeline_command_args (p, "grep", "baz", "quux", NULL);
	fail_unless (pipeline_get_ncommands (p) == 2);
	pipecmd_setenv (pipeline_get_command (p, 1), "KEY", "value");
	str = pipeline_tostring (p);
	fail_unless (!strcmp (str, "foo bar | KEY=value grep baz quux"));
	free (str);
	pipeline_free (p);
}
Beispiel #4
0
/*
 * print prompt, read cmd, parse cmd, evaluation cmd
 */
void prompt() {
	char *line = NULL;
	char *argv[MAXARGS];
	int argc = 0;

	memset(argv, 0, sizeof(argv));

	line = readline("$ ");
	if (line == NULL) {
		builtin_exit();
	}
	size_t len = strlen(line);
	if (len <= 1) {
		free(line);
		return;
	}
	add_history(line);

	if (builtin(line)) {
		free(line);
		return;
	}

	job_t *job = (job_t *) malloc(sizeof(job_t));
	memset(job, 0, sizeof(job_t));
	job->line = strdup(line);

	argc = tokenize(line, argv);
	pipeline_t *p = spawn_pipeline(argc, argv);
	if (p != NULL) {
		job->pid = execute(p);
		job->bg = p->bg;

		if (job->pid > 0) {
			queue_job(job);
		} else {
			job_rm(&root, fg);
			job_free(&job);
		}
	}

	tcsetpgrp(0, s_pgid);
	pipeline_free(p);
	free(line);
}
Beispiel #5
0
void filter_changesets (database_t * db,
                        changeset_t ** serial, changeset_t ** serial_end,
                        const char * filter_command)
{
    // Set up a pipeline for running the subprocess and sending the data to it.
    struct filter_context context = { db, serial, serial_end };
    pipeline * pl = pipeline_new();
    pipeline_command (
        pl,
        pipecmd_new_function ("filter source", filter_output, NULL, &context));
    pipeline_command_argstr (pl, filter_command);
    pipeline_want_out (pl, -1);

    fflush (NULL);                      // We're forking...
    pipeline_start (pl);

    filter_input (db, pipeline_get_outfile (pl));

    int res = pipeline_wait (pl);
    if (res != 0)
        fatal ("filter subprocess gave error: %i\n", res);

    pipeline_free (pl);
}
static struct pipeline *create_pipeline(struct gles *gles, int argc,
					char *argv[], bool regenerate,
					struct framebuffer *source)
{
	struct framebuffer *target = NULL;
	struct geometry *plane, *output, *geometry;
	struct pipeline *pipeline;
	int i;

	pipeline = pipeline_new(gles);
	if (!pipeline)
		return NULL;

	/*
	 * FIXME: Keep a reference to the created geometry so that it can be
	 *        properly disposed of.
	 */
	plane = grid_new(0);
	if (!plane)
		return NULL;

	output = grid_new(subdivisions);
	if (!output)
		return NULL;

	if (transform)
		grid_randomize(output);

	for (i = 0; i < argc; i++) {
		struct pipeline_stage *stage = NULL;

		/*
		 * Render intermediate stages to a plane (2 triangles) geometry
		 * and the final one to a randomized grid to simulate geometric
		 * adaption.
		 */
		if (i >= argc - 1)
			geometry = output;
		else
			geometry = plane;

		/*
		 * FIXME: Keep a reference to the created target framebuffers
		 *        so that they can be properly disposed of.
		 */
		if (i < argc - 1) {
			target = framebuffer_new(gles->width, gles->height);
			if (!target) {
				fprintf(stderr, "failed to create framebuffer\n");
				goto error;
			}
		} else {
			target = display_framebuffer_new(gles->width, gles->height);
			if (!target) {
				fprintf(stderr, "failed to create display\n");
				goto error;
			}
		}

		if (strcmp(argv[i], "fill") == 0) {
			stage = simple_fill_new(gles, geometry, target,
						1.0, 0.0, 1.0);
			if (!stage) {
				fprintf(stderr, "simple_fill_new() failed\n");
				goto error;
			}
		} else if (strcmp(argv[i], "checkerboard") == 0) {
			stage = checkerboard_new(gles, geometry, target);
			if (!stage) {
				fprintf(stderr, "checkerboard_new() failed\n");
				goto error;
			}
		} else if (strcmp(argv[i], "clear") == 0) {
			stage = clear_new(gles, target, 1.0f, 1.0f, 0.0f);
			if (!stage) {
				fprintf(stderr, "clear_new() failed\n");
				goto error;
			}
		} else if (strcmp(argv[i], "copy") == 0) {
			stage = simple_copy_new(gles, geometry, source, target);
			if (!stage) {
				fprintf(stderr, "simple_copy_new() failed\n");
				goto error;
			}
		} else if (strcmp(argv[i], "copyone") == 0) {
			stage = copy_one_new(gles, geometry, source, target);
			if (!stage) {
				fprintf(stderr, "copy_one_new() failed\n");
				goto error;
			}
		} else if (strcmp(argv[i], "deinterlace") == 0) {
			stage = deinterlace_new(gles, geometry, source, target);
			if (!stage) {
				fprintf(stderr, "deinterlace_new() failed\n");
				goto error;
			}
		} else if (strcmp(argv[i], "cc") == 0) {
			stage = color_correct_new(gles, geometry, source,
						  target);
			if (!stage) {
				fprintf(stderr, "color_correct_new() failed\n");
				goto error;
			}
		} else {
			fprintf(stderr, "unsupported pipeline stage: %s\n",
				argv[i]);
			goto error;
		}

		/*
		 * Only add the generator to the pipeline if the regenerate
		 * flag was passed. Otherwise, render it only once.
		 */
		if (i > 0 || regenerate || argc == 1) {
			pipeline_add_stage(pipeline, stage);
		} else {
			stage->pipeline = pipeline;
			stage->render(stage);
			pipeline_stage_free(stage);
		}

		if (i < argc - 1)
			source = target;
	}

	return pipeline;

error:
	framebuffer_free(target);
	pipeline_free(pipeline);
	return NULL;
}
int main(int argc, char **argv)
{
	static const struct option options[] = {
		{ "depth", 1, NULL, 'd' },
		{ "help", 0, NULL, 'h' },
		{ "regenerate", 0, NULL, 'r' },
		{ "subdivisions", 1, NULL, 's' },
		{ "transform", 0, NULL, 't' },
		{ "version", 0, NULL, 'V' },
		{ NULL, 0, NULL, 0 },
	};
	struct framebuffer *display;
	struct framebuffer *source;
	struct pipeline *pipeline;
	unsigned long depth = 24;
	bool regenerate = false;
	float duration, texels;
	unsigned int frames;
	uint64_t start, end;
	struct timespec ts;
	struct gles *gles;
	int opt;

	while ((opt = getopt_long(argc, argv, "d:hrs:tV", options, NULL)) != -1) {
		switch (opt) {
		case 'd':
			depth = strtoul(optarg, NULL, 10);
			if (!depth) {
				fprintf(stderr, "invalid depth: %s\n", optarg);
				return 1;
			}
			break;

		case 'h':
			usage(stdout, argv[0]);
			return 0;

		case 'r':
			regenerate = true;
			break;

		case 's':
			subdivisions = strtoul(optarg, NULL, 10);
			break;

		case 't':
			transform = true;
			break;

		case 'V':
			printf("%s %s\n", argv[0], PACKAGE_VERSION);
			return 0;

		default:
			fprintf(stderr, "invalid option: '%c'\n", opt);
			return 1;
		}
	}

	if (optind >= argc) {
		usage(stderr, argv[0]);
		return 1;
	}

	gles = gles_new(depth, regenerate);
	if (!gles) {
		fprintf(stderr, "gles_new() failed\n");
		return 1;
	}

	display = display_framebuffer_new(gles->width, gles->height);
	if (!display) {
		fprintf(stderr, "display_framebuffer_new() failed\n");
		return 1;
	}

	source = framebuffer_new(gles->width, gles->height);
	if (!source) {
		fprintf(stderr, "failed to create framebuffer\n");
		return 1;
	}

	pipeline = create_pipeline(gles, argc - optind, &argv[optind],
				   regenerate, source);
	if (!pipeline) {
		fprintf(stderr, "failed to create pipeline\n");
		return 1;
	}

	texels = gles->width * gles->height * FRAME_COUNT;

	clock_gettime(CLOCK_MONOTONIC, &ts);
	start = timespec_to_usec(&ts);

	for (frames = 0; frames < FRAME_COUNT; frames++)
		pipeline_render(pipeline);

	clock_gettime(CLOCK_MONOTONIC, &ts);
	end = timespec_to_usec(&ts);

	pipeline_free(pipeline);
	framebuffer_free(source);
	display_framebuffer_free(display);
	gles_free(gles);

	duration = (end - start) / 1000000.0f;
	printf("Rendered %d frames in %fs\n", FRAME_COUNT, duration);
	printf("Average fps was %.02f\n", FRAME_COUNT / duration);
	printf("MTexels/s: %fs\n", (texels / 1000000.0f) / duration);

	return 0;
}