From b5f58c1ad9b19f3fe7ee06a4ab5ec5498dfc0652 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 21 Feb 2015 21:55:24 +0500 Subject: Cycles: Experiment with making previews more interactive There were two major problems with the interactivity of material previews: - Beckmann tables were re-generated on every material tweak. This is because preview scene is not set to be persistent, so re-triggering the render leads to the full scene re-sync. - Images could take rather noticeable time to load with OIIO from the disk on every tweak. This patch addressed this two issues in the following way: - Beckmann tables are now static on CPU memory. They're couple of hundred kilobytes only, so wouldn't expect this to be an issue. And they're needed for almost every render anyway. This actually also makes blackbody table to be static, but it's even smaller than beckmann table. Not totally happy with this approach, but others seems to complicate things quite a bit with all this render engine life time and so.. - For preview rendering all images are considered to be built-in. This means instead of OIIO which re-loads images on every re-render they're coming from ImBuf cache which is fully manageable from blender side and unused images gets freed later. This would make it impossible to have mipmapping with OSL for now, but we'll be working on that later anyway and don't think mipmaps are really so crucial for the material preview. This seems to be a better alternative to making preview scene persistent, because of much optimal memory control from blender side. Reviewers: brecht, juicyfruit, campbellbarton, dingto Subscribers: eyecandy, venomgfx Differential Revision: https://developer.blender.org/D1132 --- intern/cycles/render/shader.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'intern/cycles/render/shader.h') diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h index 1dee47c7731..a1d697a7b7b 100644 --- a/intern/cycles/render/shader.h +++ b/intern/cycles/render/shader.h @@ -36,6 +36,7 @@ #include "util_map.h" #include "util_param.h" #include "util_string.h" +#include "util_thread.h" #include "util_types.h" CCL_NAMESPACE_BEGIN @@ -171,8 +172,9 @@ protected: typedef unordered_map AttributeIDMap; AttributeIDMap unique_attribute_id; - vector blackbody_table; - vector beckmann_table; + thread_mutex lookup_table_mutex; + static vector blackbody_table; + static vector beckmann_table; size_t blackbody_table_offset; size_t beckmann_table_offset; -- cgit v1.2.3