diff options
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/blender/addon/engine.py | 3 | ||||
-rw-r--r-- | intern/cycles/blender/python.cpp | 10 | ||||
-rw-r--r-- | intern/cycles/blender/sync.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/session/session.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/session/session.h | 3 | ||||
-rw-r--r-- | intern/cycles/session/tile.cpp | 9 | ||||
-rw-r--r-- | intern/cycles/session/tile.h | 4 | ||||
-rw-r--r-- | intern/cycles/util/path.cpp | 13 | ||||
-rw-r--r-- | intern/cycles/util/path.h | 3 |
9 files changed, 35 insertions, 23 deletions
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index 910ac4a373e..88526212d31 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -60,9 +60,8 @@ def init(): path = os.path.dirname(__file__) user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', path=''))) - temp_path = bpy.app.tempdir - _cycles.init(path, user_path, temp_path, bpy.app.background) + _cycles.init(path, user_path, bpy.app.background) _parse_command_line() diff --git a/intern/cycles/blender/python.cpp b/intern/cycles/blender/python.cpp index f509d5c2eeb..f3279ff03a3 100644 --- a/intern/cycles/blender/python.cpp +++ b/intern/cycles/blender/python.cpp @@ -138,20 +138,18 @@ static const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) static PyObject *init_func(PyObject * /*self*/, PyObject *args) { - PyObject *path, *user_path, *temp_path; + PyObject *path, *user_path; int headless; - if (!PyArg_ParseTuple(args, "OOOi", &path, &user_path, &temp_path, &headless)) { + if (!PyArg_ParseTuple(args, "OOi", &path, &user_path, &headless)) { return nullptr; } - PyObject *path_coerce = nullptr, *user_path_coerce = nullptr, *temp_path_coerce = nullptr; + PyObject *path_coerce = nullptr, *user_path_coerce = nullptr; path_init(PyC_UnicodeAsByte(path, &path_coerce), - PyC_UnicodeAsByte(user_path, &user_path_coerce), - PyC_UnicodeAsByte(temp_path, &temp_path_coerce)); + PyC_UnicodeAsByte(user_path, &user_path_coerce)); Py_XDECREF(path_coerce); Py_XDECREF(user_path_coerce); - Py_XDECREF(temp_path_coerce); BlenderSession::headless = headless; diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp index 56137374d8e..588e057b9ad 100644 --- a/intern/cycles/blender/sync.cpp +++ b/intern/cycles/blender/sync.cpp @@ -832,6 +832,14 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine, SessionParams params; PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); + if (background && !b_engine.is_preview()) { + /* Viewport and preview renders do not require temp directory and do request session + * parameters more often than the background render. + * Optimize RNA-C++ usage and memory allocation a bit by saving string access which we know is + * not needed for viewport render. */ + params.temp_dir = b_engine.temporary_directory(); + } + /* feature set */ params.experimental = (get_enum(cscene, "feature_set") != 0); diff --git a/intern/cycles/session/session.cpp b/intern/cycles/session/session.cpp index a839303debc..2c50a9a6d7f 100644 --- a/intern/cycles/session/session.cpp +++ b/intern/cycles/session/session.cpp @@ -426,6 +426,11 @@ void Session::do_delayed_reset() buffer_params_.update_passes(scene->passes); tile_manager_.update(buffer_params_, scene); + /* Update temp directory on reset. + * This potentially allows to finish the existing rendering with a previously configure temporary + * direcotry in the host software and switch to a new temp directory when new render starts. */ + tile_manager_.set_temp_dir(params.temp_dir); + /* Progress. */ progress.reset_sample(); progress.set_total_pixel_samples(static_cast<uint64_t>(buffer_params_.width) * diff --git a/intern/cycles/session/session.h b/intern/cycles/session/session.h index 3f73593f008..adfd1346600 100644 --- a/intern/cycles/session/session.h +++ b/intern/cycles/session/session.h @@ -69,6 +69,9 @@ class SessionParams { ShadingSystem shadingsystem; + /* Session-specific temporary directory to store in-progress EXR files in. */ + string temp_dir; + SessionParams() { headless = false; diff --git a/intern/cycles/session/tile.cpp b/intern/cycles/session/tile.cpp index afd1f334120..ab1b3b8ec36 100644 --- a/intern/cycles/session/tile.cpp +++ b/intern/cycles/session/tile.cpp @@ -23,6 +23,7 @@ #include "scene/film.h" #include "scene/integrator.h" #include "scene/scene.h" +#include "session/session.h" #include "util/algorithm.h" #include "util/foreach.h" #include "util/log.h" @@ -394,6 +395,11 @@ void TileManager::update(const BufferParams ¶ms, const Scene *scene) } } +void TileManager::set_temp_dir(const string &temp_dir) +{ + temp_dir_ = temp_dir; +} + bool TileManager::done() { return tile_state_.next_tile_index == tile_state_.num_tiles; @@ -452,7 +458,8 @@ const int2 TileManager::get_size() const bool TileManager::open_tile_output() { - write_state_.filename = path_temp_get("cycles-tile-buffer-" + tile_file_unique_part_ + "-" + + write_state_.filename = path_join(temp_dir_, + "cycles-tile-buffer-" + tile_file_unique_part_ + "-" + to_string(write_state_.tile_file_index) + ".exr"); write_state_.tile_out = ImageOutput::create(write_state_.filename); diff --git a/intern/cycles/session/tile.h b/intern/cycles/session/tile.h index 7c8f7570d3e..80a5db543cd 100644 --- a/intern/cycles/session/tile.h +++ b/intern/cycles/session/tile.h @@ -71,6 +71,8 @@ class TileManager { * Will store all parameters needed for buffers access outside of the scene graph. */ void update(const BufferParams ¶ms, const Scene *scene); + void set_temp_dir(const string &temp_dir); + inline int get_num_tiles() const { return tile_state_.num_tiles; @@ -136,6 +138,8 @@ class TileManager { bool open_tile_output(); bool close_tile_output(); + string temp_dir_; + /* Part of an on-disk tile file name which avoids conflicts between several Cycles instances or * several sessions. */ string tile_file_unique_part_; diff --git a/intern/cycles/util/path.cpp b/intern/cycles/util/path.cpp index e27c929fba9..4efdeeae7f0 100644 --- a/intern/cycles/util/path.cpp +++ b/intern/cycles/util/path.cpp @@ -66,7 +66,6 @@ typedef struct stat path_stat_t; static string cached_path = ""; static string cached_user_path = ""; -static string cached_temp_path = ""; static string cached_xdg_cache_path = ""; namespace { @@ -336,11 +335,10 @@ static string path_xdg_cache_get() } #endif -void path_init(const string &path, const string &user_path, const string &temp_path) +void path_init(const string &path, const string &user_path) { cached_path = path; cached_user_path = user_path; - cached_temp_path = temp_path; #ifdef _MSC_VER // workaround for https://svn.boost.org/trac/boost/ticket/6320 @@ -384,15 +382,6 @@ string path_cache_get(const string &sub) #endif } -string path_temp_get(const string &sub) -{ - if (cached_temp_path == "") { - cached_temp_path = Filesystem::temp_directory_path(); - } - - return path_join(cached_temp_path, sub); -} - #if defined(__linux__) || defined(__APPLE__) string path_xdg_home_get(const string &sub = ""); #endif diff --git a/intern/cycles/util/path.h b/intern/cycles/util/path.h index 7ec5ed60d7f..98c3302eae2 100644 --- a/intern/cycles/util/path.h +++ b/intern/cycles/util/path.h @@ -32,10 +32,9 @@ CCL_NAMESPACE_BEGIN /* program paths */ -void path_init(const string &path = "", const string &user_path = "", const string &tmp_path = ""); +void path_init(const string &path = "", const string &user_path = ""); string path_get(const string &sub = ""); string path_user_get(const string &sub = ""); -string path_temp_get(const string &sub = ""); string path_cache_get(const string &sub = ""); /* path string manipulation */ |