Ejemplo n.º 1
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Set current pause state
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Session::set_pause(bool pause_) {
	bool notify = false;
	{
		thread_scoped_lock pause_lock(pause_mutex);
		if(pause != pause_) {
			pause  = pause_;
			notify = true;
		}
	}
	if(notify) pause_cond.notify_all();
} //set_pause()
Ejemplo n.º 2
0
void FrameGrabberDSA::conditionalBreakpoint() {

	// Grabber thread blocks while paused
	boost::mutex::scoped_lock pause_lock(paused_mutex);

	// Disable Push Mode
	if(paused && !request_single_frames) {
		ts->SetFramerateRetries(0, true, false, 3, true); // Disable DSA push-mode
	}

	while(paused) { // Loop to catch spurious wake-ups
		paused_changed.wait(pause_lock); // wait() unlocks automatically
	}

	// Prepare to receive tactile sensor frame (Push or Pull Mode)
	setFramerate(framerate); // Restore previous framerate
}
Ejemplo n.º 3
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DESTRUCTOR
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Session::~Session() {
	if(session_thread) {
		progress.set_cancel("Exiting");
		{
			thread_scoped_lock pause_lock(pause_mutex);
			pause = false;
		}
		pause_cond.notify_all();
		wait();
	}
	if(params.interactive && display && params.output_path != "") {
		progress.set_status("Writing Image", params.output_path);
		display->write(params.output_path);
	}
	if(display) delete display;
	if(scene) delete scene;

	delete server;
} //~Session()
Ejemplo n.º 4
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Render loop
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Session::run_render() {
	reset_time          = start_time = time_dt();
	paused_time         = 0.0;
    bool bStarted       = false;

    params.image_stat.uiCurSamples = 0;

    if(params.interactive) progress.set_start_time(start_time);

    bool is_done = false;
	while(!progress.get_cancel()) {
		if(!params.interactive) {
			// If no work left and in background mode, we can stop immediately
			if(is_done) {
                update_status_time();
				progress.set_status(string(pass_name) + " finished");
				break;
			}
		} //if(!params.interactive)
		else {
			// If in interactive mode, and we are either paused or done for now,
			// wait for pause condition notify to wake up again
			thread_scoped_lock pause_lock(pause_mutex);
			if(pause || is_done) {
				update_status_time(pause, is_done);
				while(true) {
                    if(pause) server->pauseRender(true);

					double pause_start = time_dt();
					pause_cond.wait(pause_lock);
					paused_time += time_dt() - pause_start;

				    progress.set_start_time(start_time + paused_time);
					update_status_time(pause, is_done);
					progress.set_update();

                    if(!pause) {
                        server->pauseRender(false);
                        break;
                    }
				}
			} //if(pause || is_ready)
			if(progress.get_cancel()) break;
		} //if(!params.interactive), else

		if(!is_done) {
            time_sleep(0.01);

			// Update scene on the render-server - send all changed objects
            if(!bStarted || params.interactive) update_scene_to_server(frame_idx, total_frames);

            if(!bStarted) {
                server->startRender(params.interactive, params.width, params.height, params.interactive ? ::OctaneEngine::OctaneClient::IMAGE_8BIT : (params.hdr_tonemapped ? ::OctaneEngine::OctaneClient::IMAGE_FLOAT_TONEMAPPED : ::OctaneEngine::OctaneClient::IMAGE_FLOAT),
                                     params.out_of_core_enabled, params.out_of_core_mem_limit, params.out_of_core_gpu_headroom); //FIXME: Perhaps the wrong place for it...
                bStarted = true;
            }

            if(!server->getServerErrorMessage().empty()) {
                progress.set_cancel("ERROR! Check console for detailed error messages.");
                server->clearServerErrorMessage();
            }
			if(progress.get_cancel()) break;

			// Buffers mutex is locked entirely while rendering each
			// sample, and released/reacquired on each iteration to allow
			// reset and draw in between
			thread_scoped_lock buffers_lock(render_buffer_mutex);

			// Update status and timing
			//update_status_time();

            update_render_buffer();
            if(!server->getServerErrorMessage().empty()) {
                progress.set_cancel("ERROR! Check console for detailed error messages.");
                server->clearServerErrorMessage();
            }

			// Update status and timing
			update_status_time();
			progress.set_update();
		} //if(!is_done)
        else {
			thread_scoped_lock buffers_lock(render_buffer_mutex);
            update_render_buffer();

            // Update status and timing
			update_status_time();
        }
		is_done = !params.interactive && (params.image_stat.uiCurSamples >= params.samples);
	} //while(!progress.get_cancel())
} //run_render()