コード例 #1
0
	/**
	 * @brief Constructor.
	 *
	 * @param[in] scene_ A pointer to the scene to render.  Should be fully
	 *                   finalized for rendering.
	 * @param[out] image_ The image to render to.  Should be already
	 *                    initialized with 3 channels, for rgb.
	 * @param spp_ The number of samples to take per pixel for integration.
	 */
	PathTraceIntegrator(Scene *scene_, Film *image_, int spp_, int spp_max_, float variance_max_, uint seed_, int thread_count_=1, std::function<void()> callback_ = std::function<void()>()) {
		scene = scene_;
		image = image_;
		spp = spp_;
		spp_max = spp_max_;
		image_variance_max = variance_max_;
		seed = seed_;
		thread_count = thread_count_;
		path_length = 4;
		callback = callback_;

		blocks.resize(thread_count_ * 2);
	}
コード例 #2
0
	/**
	 * @brief Constructor.
	 *
	 * By default uses 1 thread and creates a queue 4 times the size
	 * of the thread count.
	 *
	 * @param thread_count Number of consumer threads to spawn for processing jobs.
	 * @param queue_size Size of the job queue buffer.  Zero means determine
	 *                   automatically from number of threads.
	 */
	explicit JobQueue(size_t thread_count=1, size_t queue_size=0) {
		done = false;

		// Set up queue
		if (queue_size == 0)
			queue_size = thread_count * 4;
		queue.resize(queue_size);

		// Create and start consumer threads
		threads.resize(thread_count);
		for (auto &thread: threads)
			thread = std::thread(&JobQueue<T>::run_consumer, this);
	}