2011-04-27 11:58:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011, Blender Foundation.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SESSION_H__
|
|
|
|
#define __SESSION_H__
|
|
|
|
|
2011-12-20 12:25:37 +00:00
|
|
|
#include "buffers.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
#include "device.h"
|
|
|
|
#include "tile.h"
|
|
|
|
|
|
|
|
#include "util_progress.h"
|
|
|
|
#include "util_thread.h"
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
2011-12-20 12:25:37 +00:00
|
|
|
class BufferParams;
|
2011-04-27 11:58:34 +00:00
|
|
|
class Device;
|
|
|
|
class DeviceScene;
|
|
|
|
class DisplayBuffer;
|
|
|
|
class Progress;
|
|
|
|
class RenderBuffers;
|
|
|
|
class Scene;
|
|
|
|
|
|
|
|
/* Session Parameters */
|
|
|
|
|
|
|
|
class SessionParams {
|
|
|
|
public:
|
2012-01-04 18:06:32 +00:00
|
|
|
DeviceInfo device;
|
2011-04-27 11:58:34 +00:00
|
|
|
bool background;
|
|
|
|
string output_path;
|
|
|
|
|
|
|
|
bool progressive;
|
2011-12-12 22:51:35 +00:00
|
|
|
bool experimental;
|
2011-09-16 13:14:02 +00:00
|
|
|
int samples;
|
2011-04-27 11:58:34 +00:00
|
|
|
int tile_size;
|
|
|
|
int min_size;
|
2011-08-24 10:44:04 +00:00
|
|
|
int threads;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
double cancel_timeout;
|
|
|
|
double reset_timeout;
|
|
|
|
double text_timeout;
|
|
|
|
|
|
|
|
SessionParams()
|
|
|
|
{
|
|
|
|
background = false;
|
|
|
|
output_path = "";
|
|
|
|
|
2011-09-14 22:26:55 +00:00
|
|
|
progressive = false;
|
2011-12-12 22:51:35 +00:00
|
|
|
experimental = false;
|
2011-09-16 13:14:02 +00:00
|
|
|
samples = INT_MAX;
|
2011-04-27 11:58:34 +00:00
|
|
|
tile_size = 64;
|
|
|
|
min_size = 64;
|
2011-08-24 10:44:04 +00:00
|
|
|
threads = 0;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
cancel_timeout = 0.1;
|
|
|
|
reset_timeout = 0.1;
|
|
|
|
text_timeout = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool modified(const SessionParams& params)
|
2012-01-04 18:06:32 +00:00
|
|
|
{ return !(device.type == params.device.type
|
|
|
|
&& device.id == params.device.id
|
2011-04-27 11:58:34 +00:00
|
|
|
&& background == params.background
|
|
|
|
&& output_path == params.output_path
|
2011-09-16 13:14:02 +00:00
|
|
|
/* && samples == params.samples */
|
2011-04-27 11:58:34 +00:00
|
|
|
&& progressive == params.progressive
|
2011-12-12 22:51:35 +00:00
|
|
|
&& experimental == params.experimental
|
2011-04-27 11:58:34 +00:00
|
|
|
&& tile_size == params.tile_size
|
|
|
|
&& min_size == params.min_size
|
2011-08-24 10:44:04 +00:00
|
|
|
&& threads == params.threads
|
2011-04-27 11:58:34 +00:00
|
|
|
&& cancel_timeout == params.cancel_timeout
|
|
|
|
&& reset_timeout == params.reset_timeout
|
|
|
|
&& text_timeout == params.text_timeout); }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Session
|
|
|
|
*
|
|
|
|
* This is the class that contains the session thread, running the render
|
|
|
|
* control loop and dispatching tasks. */
|
|
|
|
|
|
|
|
class Session {
|
|
|
|
public:
|
|
|
|
Device *device;
|
|
|
|
Scene *scene;
|
|
|
|
RenderBuffers *buffers;
|
|
|
|
DisplayBuffer *display;
|
|
|
|
Progress progress;
|
|
|
|
SessionParams params;
|
2011-09-16 13:14:02 +00:00
|
|
|
int sample;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
Session(const SessionParams& params);
|
|
|
|
~Session();
|
|
|
|
|
|
|
|
void start();
|
2011-12-20 12:25:37 +00:00
|
|
|
bool draw(BufferParams& params);
|
2011-04-27 11:58:34 +00:00
|
|
|
void wait();
|
|
|
|
|
|
|
|
bool ready_to_reset();
|
2011-12-20 12:25:37 +00:00
|
|
|
void reset(BufferParams& params, int samples);
|
2011-09-16 13:14:02 +00:00
|
|
|
void set_samples(int samples);
|
2011-08-29 10:21:10 +00:00
|
|
|
void set_pause(bool pause);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
struct DelayedReset {
|
|
|
|
thread_mutex mutex;
|
|
|
|
bool do_reset;
|
2011-12-20 12:25:37 +00:00
|
|
|
BufferParams params;
|
2011-09-16 13:14:02 +00:00
|
|
|
int samples;
|
2011-04-27 11:58:34 +00:00
|
|
|
} delayed_reset;
|
|
|
|
|
|
|
|
void run();
|
|
|
|
|
|
|
|
void update_scene();
|
2011-08-29 16:54:13 +00:00
|
|
|
void update_status_time(bool show_pause = false, bool show_done = false);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
void tonemap();
|
|
|
|
void path_trace(Tile& tile);
|
2011-12-20 12:25:37 +00:00
|
|
|
void reset_(BufferParams& params, int samples);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
void run_cpu();
|
2011-12-20 12:25:37 +00:00
|
|
|
bool draw_cpu(BufferParams& params);
|
|
|
|
void reset_cpu(BufferParams& params, int samples);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
void run_gpu();
|
2011-12-20 12:25:37 +00:00
|
|
|
bool draw_gpu(BufferParams& params);
|
|
|
|
void reset_gpu(BufferParams& params, int samples);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
TileManager tile_manager;
|
|
|
|
bool device_use_gl;
|
|
|
|
|
|
|
|
thread *session_thread;
|
|
|
|
|
|
|
|
volatile bool display_outdated;
|
|
|
|
|
|
|
|
volatile bool gpu_draw_ready;
|
|
|
|
volatile bool gpu_need_tonemap;
|
|
|
|
thread_condition_variable gpu_need_tonemap_cond;
|
|
|
|
|
2011-08-29 10:21:10 +00:00
|
|
|
bool pause;
|
|
|
|
thread_condition_variable pause_cond;
|
|
|
|
thread_mutex pause_mutex;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
double start_time;
|
|
|
|
double reset_time;
|
|
|
|
double preview_time;
|
2011-08-29 16:54:13 +00:00
|
|
|
double paused_time;
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __SESSION_H__ */
|
|
|
|
|