2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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"
|
2012-11-05 08:04:57 +00:00
|
|
|
#include "util_stats.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
#include "util_thread.h"
|
2012-10-13 12:38:32 +00:00
|
|
|
#include "util_vector.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
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;
|
2012-10-13 12:38:32 +00:00
|
|
|
bool progressive_refine;
|
2011-04-27 11:58:34 +00:00
|
|
|
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;
|
2012-09-04 13:29:07 +00:00
|
|
|
int2 tile_size;
|
2013-09-03 22:39:21 +00:00
|
|
|
TileOrder tile_order;
|
2012-09-17 10:55:18 +00:00
|
|
|
int start_resolution;
|
2011-08-24 10:44:04 +00:00
|
|
|
int threads;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2013-08-30 23:49:38 +00:00
|
|
|
bool display_buffer_linear;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
double cancel_timeout;
|
|
|
|
double reset_timeout;
|
|
|
|
double text_timeout;
|
|
|
|
|
2012-10-26 09:25:02 +00:00
|
|
|
enum { OSL, SVM } shadingsystem;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
SessionParams()
|
|
|
|
{
|
|
|
|
background = false;
|
2012-10-13 12:38:32 +00:00
|
|
|
progressive_refine = false;
|
2011-04-27 11:58:34 +00:00
|
|
|
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;
|
2012-09-04 13:29:07 +00:00
|
|
|
tile_size = make_int2(64, 64);
|
2012-09-17 10:55:18 +00:00
|
|
|
start_resolution = INT_MAX;
|
2011-08-24 10:44:04 +00:00
|
|
|
threads = 0;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2013-08-30 23:49:38 +00:00
|
|
|
display_buffer_linear = false;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
cancel_timeout = 0.1;
|
|
|
|
reset_timeout = 0.1;
|
|
|
|
text_timeout = 1.0;
|
2012-10-26 09:25:02 +00:00
|
|
|
|
|
|
|
shadingsystem = SVM;
|
2013-09-03 22:39:21 +00:00
|
|
|
tile_order = TILE_CENTER;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2012-10-13 12:38:32 +00:00
|
|
|
&& progressive_refine == params.progressive_refine
|
2011-04-27 11:58:34 +00:00
|
|
|
&& 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
|
2012-09-17 10:55:18 +00:00
|
|
|
&& start_resolution == params.start_resolution
|
2011-08-24 10:44:04 +00:00
|
|
|
&& threads == params.threads
|
2013-08-30 23:49:38 +00:00
|
|
|
&& display_buffer_linear == params.display_buffer_linear
|
2011-04-27 11:58:34 +00:00
|
|
|
&& cancel_timeout == params.cancel_timeout
|
|
|
|
&& reset_timeout == params.reset_timeout
|
2012-10-26 09:25:02 +00:00
|
|
|
&& text_timeout == params.text_timeout
|
2013-09-03 22:39:21 +00:00
|
|
|
&& tile_order == params.tile_order
|
2012-10-26 09:25:02 +00:00
|
|
|
&& shadingsystem == params.shadingsystem); }
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 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;
|
2012-09-04 13:29:07 +00:00
|
|
|
TileManager tile_manager;
|
2012-11-05 08:04:57 +00:00
|
|
|
Stats stats;
|
2012-09-04 13:29:07 +00:00
|
|
|
|
|
|
|
boost::function<void(RenderTile&)> write_render_tile_cb;
|
|
|
|
boost::function<void(RenderTile&)> update_render_tile_cb;
|
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
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
void device_free();
|
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();
|
2012-09-04 13:29:07 +00:00
|
|
|
void path_trace();
|
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
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
bool acquire_tile(Device *tile_device, RenderTile& tile);
|
|
|
|
void update_tile_sample(RenderTile& tile);
|
|
|
|
void release_tile(RenderTile& tile);
|
|
|
|
|
|
|
|
void update_progress_sample();
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
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;
|
2012-09-04 13:29:07 +00:00
|
|
|
thread_mutex tile_mutex;
|
|
|
|
thread_mutex buffers_mutex;
|
|
|
|
thread_mutex display_mutex;
|
2011-08-29 10:21:10 +00:00
|
|
|
|
2012-02-23 19:48:18 +00:00
|
|
|
bool kernels_loaded;
|
|
|
|
|
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;
|
2012-10-13 12:38:32 +00:00
|
|
|
|
|
|
|
/* progressive refine */
|
2012-10-23 17:24:23 +00:00
|
|
|
double last_update_time;
|
2012-10-13 12:38:32 +00:00
|
|
|
bool update_progressive_refine(bool cancel);
|
|
|
|
|
|
|
|
vector<RenderBuffers *> tile_buffers;
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __SESSION_H__ */
|
|
|
|
|