Merge branch 'master' into blender2.8
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 28 Aug 2018 17:15:08 +0000 (19:15 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 28 Aug 2018 17:15:08 +0000 (19:15 +0200)
20 files changed:
1  2 
CMakeLists.txt
build_files/buildbot/slave_compile.py
build_files/cmake/platform/platform_win32.cmake
intern/cycles/blender/addon/engine.py
intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_shader.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/device/device_cuda.cpp
intern/cycles/render/buffers.cpp
intern/cycles/render/light.cpp
intern/cycles/render/nodes.cpp
intern/cycles/util/util_math_intersect.h
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/ghost/intern/GHOST_WindowWin32.cpp
intern/opencolorio/CMakeLists.txt
source/blender/blenkernel/intern/seqeffects.c
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/makesrna/intern/rna_nodetree.c
source/blender/nodes/shader/nodes/node_shader_emission.c
source/creator/CMakeLists.txt

diff --cc CMakeLists.txt
@@@ -165,7 -165,9 +165,8 @@@ option_defaults_init
        _init_OPENCOLORIO
        _init_SDL
        _init_FFTW3
 -      _init_GAMEENGINE
        _init_OPENSUBDIV
+       _init_SYSTEM_OPENJPG
  )
  
  # customize...
@@@ -157,13 -159,11 +157,9 @@@ if 'cmake' in builder
          if target != 'blender':
              target_build_dir += '_' + target
          target_name = 'install'
-         # Make sure build directory exists and enter it
-         if not os.path.isdir(target_build_dir):
-             os.mkdir(target_build_dir)
-         os.chdir(target_build_dir)
          # Tweaking CMake options to respect the target
          target_cmake_options = cmake_options[:]
 -        if target == 'player':
 -            target_cmake_options.append("-C" + os.path.join(blender_dir, cmake_player_config_file))
 -        elif target == 'cuda':
 +        if target == 'cuda':
              target_cmake_options += cuda_cmake_options
              target_chroot_prefix = cuda_chroot_prefix[:]
              target_name = 'cycles_kernel_cuda'
Simple merge
@@@ -395,91 -381,111 +395,89 @@@ void BlenderSession::render(BL::Depsgra
        BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_v3d, b_rv3d, scene->camera, width, height);
  
        /* render each layer */
 -      BL::RenderSettings r = b_scene.render();
 -      BL::RenderSettings::layers_iterator b_layer_iter;
 -      BL::RenderResult::views_iterator b_view_iter;
 +      BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval();
  
        /* We do some special meta attributes when we only have single layer. */
 -      const bool is_single_layer = (r.layers.length() == 1);
 +      const bool is_single_layer = (b_scene.view_layers.length() == 1);
  
 -      for(r.layers.begin(b_layer_iter); b_layer_iter != r.layers.end(); ++b_layer_iter) {
 -              b_rlay_name = b_layer_iter->name();
 +      /* temporary render result to find needed passes and views */
 +      BL::RenderResult b_rr = begin_render_result(b_engine, 0, 0, 1, 1, b_view_layer.name().c_str(), NULL);
 +      BL::RenderResult::layers_iterator b_single_rlay;
 +      b_rr.layers.begin(b_single_rlay);
 +      BL::RenderLayer b_rlay = *b_single_rlay;
  
 -              /* temporary render result to find needed passes and views */
 -              BL::RenderResult b_rr = begin_render_result(b_engine, 0, 0, 1, 1, b_rlay_name.c_str(), NULL);
 -              BL::RenderResult::layers_iterator b_single_rlay;
 -              b_rr.layers.begin(b_single_rlay);
 +      /* add passes */
 +      array<Pass> passes = sync->sync_render_passes(b_rlay, b_view_layer, session_params);
 +      buffer_params.passes = passes;
  
 -              /* layer will be missing if it was disabled in the UI */
 -              if(b_single_rlay == b_rr.layers.end()) {
 -                      end_render_result(b_engine, b_rr, true, true, false);
 -                      continue;
 -              }
 +      PointerRNA crl = RNA_pointer_get(&b_view_layer.ptr, "cycles");
 +      bool use_denoising = get_boolean(crl, "use_denoising");
-       buffer_params.denoising_data_pass = use_denoising;
 -              BL::RenderLayer b_rlay = *b_single_rlay;
 -
 -              /* add passes */
 -              array<Pass> passes = sync->sync_render_passes(b_rlay, *b_layer_iter, session_params);
 -              buffer_params.passes = passes;
 -
 -              PointerRNA crl = RNA_pointer_get(&b_layer_iter->ptr, "cycles");
 -              bool use_denoising = get_boolean(crl, "use_denoising");
 -
 -              session->tile_manager.schedule_denoising = use_denoising;
 -              buffer_params.denoising_data_pass = use_denoising;
 -              buffer_params.denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES);
 -
 -              session->params.use_denoising = use_denoising;
 -              session->params.denoising_radius = get_int(crl, "denoising_radius");
 -              session->params.denoising_strength = get_float(crl, "denoising_strength");
 -              session->params.denoising_feature_strength = get_float(crl, "denoising_feature_strength");
 -              session->params.denoising_relative_pca = get_boolean(crl, "denoising_relative_pca");
 -
 -              scene->film->denoising_data_pass = buffer_params.denoising_data_pass;
 -              scene->film->denoising_clean_pass = buffer_params.denoising_clean_pass;
 -              scene->film->pass_alpha_threshold = b_layer_iter->pass_alpha_threshold();
 -              scene->film->tag_passes_update(scene, passes);
 -              scene->film->tag_update(scene);
 -              scene->integrator->tag_update(scene);
 -
 -              int view_index = 0;
 -              for(b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter, ++view_index) {
 -                      b_rview_name = b_view_iter->name();
 -
 -                      /* set the current view */
 -                      b_engine.active_view_set(b_rview_name.c_str());
 -
 -                      /* update scene */
 -                      BL::Object b_camera_override(b_engine.camera_override());
 -                      sync->sync_camera(b_render, b_camera_override, width, height, b_rview_name.c_str());
 -                      sync->sync_data(b_render,
 -                                      b_v3d,
 -                                      b_camera_override,
 -                                      width, height,
 -                                      &python_thread_state,
 -                                      b_rlay_name.c_str());
 -
 -                      /* Make sure all views have different noise patterns. - hardcoded value just to make it random */
 -                      if(view_index != 0) {
 -                              scene->integrator->seed += hash_int_2d(scene->integrator->seed, hash_int(view_index * 0xdeadbeef));
 -                              scene->integrator->tag_update(scene);
 -                      }
 +      session->tile_manager.schedule_denoising = use_denoising;
++      buffer_params.denoising_data_pass = use_denoising;
++      buffer_params.denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES);
 -                      /* Update number of samples per layer. */
 -                      int samples = sync->get_layer_samples();
 -                      bool bound_samples = sync->get_layer_bound_samples();
 -                      int effective_layer_samples;
 +      session->params.use_denoising = use_denoising;
++      session->params.denoising_radius = get_int(crl, "denoising_radius");
++      session->params.denoising_strength = get_float(crl, "denoising_strength");
++      session->params.denoising_feature_strength = get_float(crl, "denoising_feature_strength");
++      session->params.denoising_relative_pca = get_boolean(crl, "denoising_relative_pca");
 -                      if(samples != 0 && (!bound_samples || (samples < session_params.samples)))
 -                              effective_layer_samples = samples;
 -                      else
 -                              effective_layer_samples = session_params.samples;
 +      scene->film->denoising_data_pass = buffer_params.denoising_data_pass;
-       scene->film->denoising_flags = 0;
-       if(!get_boolean(crl, "denoising_diffuse_direct"))        scene->film->denoising_flags |= DENOISING_CLEAN_DIFFUSE_DIR;
-       if(!get_boolean(crl, "denoising_diffuse_indirect"))      scene->film->denoising_flags |= DENOISING_CLEAN_DIFFUSE_IND;
-       if(!get_boolean(crl, "denoising_glossy_direct"))         scene->film->denoising_flags |= DENOISING_CLEAN_GLOSSY_DIR;
-       if(!get_boolean(crl, "denoising_glossy_indirect"))       scene->film->denoising_flags |= DENOISING_CLEAN_GLOSSY_IND;
-       if(!get_boolean(crl, "denoising_transmission_direct"))   scene->film->denoising_flags |= DENOISING_CLEAN_TRANSMISSION_DIR;
-       if(!get_boolean(crl, "denoising_transmission_indirect")) scene->film->denoising_flags |= DENOISING_CLEAN_TRANSMISSION_IND;
-       if(!get_boolean(crl, "denoising_subsurface_direct"))     scene->film->denoising_flags |= DENOISING_CLEAN_SUBSURFACE_DIR;
-       if(!get_boolean(crl, "denoising_subsurface_indirect"))   scene->film->denoising_flags |= DENOISING_CLEAN_SUBSURFACE_IND;
-       scene->film->denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES);
-       buffer_params.denoising_clean_pass = scene->film->denoising_clean_pass;
++      scene->film->denoising_clean_pass = buffer_params.denoising_clean_pass;
 +      session->params.denoising_radius = get_int(crl, "denoising_radius");
 +      session->params.denoising_strength = get_float(crl, "denoising_strength");
 +      session->params.denoising_feature_strength = get_float(crl, "denoising_feature_strength");
 +      session->params.denoising_relative_pca = get_boolean(crl, "denoising_relative_pca");
  
 -                      /* Update tile manager if we're doing resumable render. */
 -                      update_resumable_tile_manager(effective_layer_samples);
 +      scene->film->pass_alpha_threshold = b_view_layer.pass_alpha_threshold();
 +      scene->film->tag_passes_update(scene, passes);
 +      scene->film->tag_update(scene);
 +      scene->integrator->tag_update(scene);
  
 -                      /* Update session itself. */
 -                      session->reset(buffer_params, effective_layer_samples);
 +      BL::RenderResult::views_iterator b_view_iter;
 +      int view_index = 0;
 +      for(b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter, ++view_index) {
 +              b_rlay_name = b_view_layer.name();
 +              b_rview_name = b_view_iter->name();
  
 -                      /* render */
 -                      session->start();
 -                      session->wait();
 +              /* set the current view */
 +              b_engine.active_view_set(b_rview_name.c_str());
  
 -                      if(session->progress.get_cancel())
 -                              break;
 +              /* update scene */
 +              BL::Object b_camera_override(b_engine.camera_override());
 +              sync->sync_camera(b_render, b_camera_override, width, height, b_rview_name.c_str());
 +              sync->sync_data(b_render,
 +                              b_depsgraph,
 +                              b_v3d,
 +                              b_camera_override,
 +                              width, height,
 +                              &python_thread_state);
 +              builtin_images_load();
 +
 +              /* Make sure all views have different noise patterns. - hardcoded value just to make it random */
 +              if(view_index != 0) {
 +                      scene->integrator->seed += hash_int_2d(scene->integrator->seed, hash_int(view_index * 0xdeadbeef));
 +                      scene->integrator->tag_update(scene);
                }
  
 -              if(is_single_layer) {
 -                      BL::RenderResult b_rr = b_engine.get_result();
 -                      string num_aa_samples = string_printf("%d", session->params.samples);
 -                      b_rr.stamp_data_add_field("Cycles Samples", num_aa_samples.c_str());
 -                      /* TODO(sergey): Report whether we're doing resumable render
 -                       * and also start/end sample if so.
 -                       */
 -              }
 +              int effective_layer_samples = session_params.samples;
 +
 +              /* TODO: Update number of samples per layer. */
 +#if 0
 +              if(samples != 0 && (!bound_samples || (samples < session_params.samples)))
 +                      effective_layer_samples = samples;
 +#endif
  
 -              /* free result without merging */
 -              end_render_result(b_engine, b_rr, true, true, false);
 +              /* Update tile manager if we're doing resumable render. */
 +              update_resumable_tile_manager(effective_layer_samples);
 +
 +              /* Update session itself. */
 +              session->reset(buffer_params, effective_layer_samples);
 +
 +              /* render */
 +              session->start();
 +              session->wait();
  
                if(!b_engine.is_preview() && background && print_render_stats) {
                        RenderStats stats;
@@@ -502,20 -571,36 +503,36 @@@ array<Pass> BlenderSync::sync_render_pa
                        Pass::add(pass_type, passes);
        }
  
 -      PointerRNA crp = RNA_pointer_get(&b_srlay.ptr, "cycles");
+       scene->film->denoising_flags = 0;
 +      PointerRNA crp = RNA_pointer_get(&b_view_layer.ptr, "cycles");
        if(get_boolean(crp, "denoising_store_passes") &&
           get_boolean(crp, "use_denoising"))
        {
 -              b_engine.add_pass("Denoising Normal",          3, "XYZ", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Normal Variance", 3, "XYZ", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Albedo",          3, "RGB", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Albedo Variance", 3, "RGB", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Depth",           1, "Z",   b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Depth Variance",  1, "Z",   b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Shadow A",        3, "XYV", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Shadow B",        3, "XYV", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Image",           3, "RGB", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Image Variance",  3, "RGB", b_srlay.name().c_str());
 +              b_engine.add_pass("Denoising Normal",          3, "XYZ", b_view_layer.name().c_str());
 +              b_engine.add_pass("Denoising Normal Variance", 3, "XYZ", b_view_layer.name().c_str());
 +              b_engine.add_pass("Denoising Albedo",          3, "RGB", b_view_layer.name().c_str());
 +              b_engine.add_pass("Denoising Albedo Variance", 3, "RGB", b_view_layer.name().c_str());
 +              b_engine.add_pass("Denoising Depth",           1, "Z",   b_view_layer.name().c_str());
 +              b_engine.add_pass("Denoising Depth Variance",  1, "Z",   b_view_layer.name().c_str());
 +              b_engine.add_pass("Denoising Shadow A",        3, "XYV", b_view_layer.name().c_str());
 +              b_engine.add_pass("Denoising Shadow B",        3, "XYV", b_view_layer.name().c_str());
 +              b_engine.add_pass("Denoising Image",           3, "RGB", b_view_layer.name().c_str());
 +              b_engine.add_pass("Denoising Image Variance",  3, "RGB", b_view_layer.name().c_str());
+ #define MAP_OPTION(name, flag) if(!get_boolean(crp, name)) scene->film->denoising_flags |= flag;
+               MAP_OPTION("denoising_diffuse_direct",        DENOISING_CLEAN_DIFFUSE_DIR);
+               MAP_OPTION("denoising_diffuse_indirect",      DENOISING_CLEAN_DIFFUSE_IND);
+               MAP_OPTION("denoising_glossy_direct",         DENOISING_CLEAN_GLOSSY_DIR);
+               MAP_OPTION("denoising_glossy_indirect",       DENOISING_CLEAN_GLOSSY_IND);
+               MAP_OPTION("denoising_transmission_direct",   DENOISING_CLEAN_TRANSMISSION_DIR);
+               MAP_OPTION("denoising_transmission_indirect", DENOISING_CLEAN_TRANSMISSION_IND);
+               MAP_OPTION("denoising_subsurface_direct",     DENOISING_CLEAN_SUBSURFACE_DIR);
+               MAP_OPTION("denoising_subsurface_indirect",   DENOISING_CLEAN_SUBSURFACE_IND);
+ #undef MAP_OPTION
+               if(scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES) {
 -                      b_engine.add_pass("Denoising Clean", 3, "RGB", b_srlay.name().c_str());
++                      b_engine.add_pass("Denoising Clean", 3, "RGB", b_view_layer.name().c_str());
+               }
        }
  #ifdef __KERNEL_DEBUG__
        if(get_boolean(crp, "pass_debug_bvh_traversed_nodes")) {
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -311,81 -259,13 +311,82 @@@ OperationDepsNode *DepsgraphNodeBuilder
        return find_operation_node(id, comp_type, "", opcode, name, name_tag);
  }
  
 +ID *DepsgraphNodeBuilder::get_cow_id(const ID *id_orig) const
 +{
 +      return graph_->get_cow_id(id_orig);
 +}
 +
 +ID *DepsgraphNodeBuilder::ensure_cow_id(ID *id_orig)
 +{
 +      if (id_orig->tag & LIB_TAG_COPIED_ON_WRITE) {
 +              /* ID is already remapped to copy-on-write. */
 +              return id_orig;
 +      }
 +      IDDepsNode *id_node = add_id_node(id_orig);
 +      return id_node->id_cow;
 +}
 +
  /* **** Build functions for entity nodes **** */
  
 -void DepsgraphNodeBuilder::begin_build() {
 +void DepsgraphNodeBuilder::begin_build()
 +{
 +      /* Store existing copy-on-write versions of datablock, so we can re-use
 +       * them for new ID nodes.
 +       */
 +      cow_id_hash_ = BLI_ghash_ptr_new("Depsgraph id hash");
 +      foreach (IDDepsNode *id_node, graph_->id_nodes) {
 +              if (deg_copy_on_write_is_expanded(id_node->id_cow)) {
 +                      if (id_node->id_orig == id_node->id_cow) {
 +                              continue;
 +                      }
 +                      BLI_ghash_insert(cow_id_hash_,
 +                                       id_node->id_orig,
 +                                       id_node->id_cow);
 +                      id_node->id_cow = NULL;
 +              }
 +      }
 +
 +      GSET_FOREACH_BEGIN(OperationDepsNode *, op_node, graph_->entry_tags)
 +      {
 +              ComponentDepsNode *comp_node = op_node->owner;
 +              IDDepsNode *id_node = comp_node->owner;
 +
 +              SavedEntryTag entry_tag;
 +              entry_tag.id = id_node->id_orig;
 +              entry_tag.component_type = comp_node->type;
 +              entry_tag.opcode = op_node->opcode;
 +              saved_entry_tags_.push_back(entry_tag);
 +      };
 +      GSET_FOREACH_END();
 +
 +      /* Make sure graph has no nodes left from previous state. */
 +      graph_->clear_all_nodes();
 +      graph_->operations.clear();
 +      BLI_gset_clear(graph_->entry_tags, NULL);
 +}
 +
 +void DepsgraphNodeBuilder::end_build()
 +{
 +      foreach (const SavedEntryTag& entry_tag, saved_entry_tags_) {
 +              IDDepsNode *id_node = find_id_node(entry_tag.id);
 +              if (id_node == NULL) {
 +                      continue;
 +              }
 +              ComponentDepsNode *comp_node =
 +                      id_node->find_component(entry_tag.component_type);
 +              if (comp_node == NULL) {
 +                      continue;
 +              }
 +              OperationDepsNode *op_node = comp_node->find_operation(entry_tag.opcode);
 +              if (op_node == NULL) {
 +                      continue;
 +              }
 +              op_node->tag_update(graph_);
 +      }
  }
  
- void DepsgraphNodeBuilder::build_id(ID *id) {
+ void DepsgraphNodeBuilder::build_id(ID *id)
+ {
        if (id == NULL) {
                return;
        }
Simple merge