Merge branch 'blender2.7'
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 6 Feb 2019 14:22:53 +0000 (15:22 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 6 Feb 2019 14:22:53 +0000 (15:22 +0100)
1  2 
intern/cycles/blender/addon/engine.py
intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/device/device_cpu.cpp
intern/cycles/device/device_cuda.cpp
intern/cycles/render/buffers.cpp
intern/cycles/render/film.cpp
intern/cycles/render/session.cpp

Simple merge
@@@ -406,109 -390,131 +406,114 @@@ 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_rlay_name.c_str(), NULL);
 -              BL::RenderResult::layers_iterator b_single_rlay;
 -              b_rr.layers.begin(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_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;
 +      b_rlay_name = b_view_layer.name();
 +
 +      /* add passes */
 +      vector<Pass> passes = sync->sync_render_passes(b_rlay, b_view_layer, session_params);
 +      buffer_params.passes = passes;
 +
 +      PointerRNA crl = RNA_pointer_get(&b_view_layer.ptr, "cycles");
-       bool use_denoising = get_boolean(crl, "use_denoising");
-       bool denoising_passes = use_denoising || get_boolean(crl, "denoising_store_passes");
++      bool full_denoising = get_boolean(crl, "use_denoising");
++      bool write_denoising_passes = get_boolean(crl, "denoising_store_passes");
 +
-       session->tile_manager.schedule_denoising = use_denoising;
-       buffer_params.denoising_data_pass = denoising_passes;
++      bool run_denoising = full_denoising || write_denoising_passes;
++
++      session->tile_manager.schedule_denoising = run_denoising;
++      buffer_params.denoising_data_pass = run_denoising;
 +      buffer_params.denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES);
++      buffer_params.denoising_prefiltered_pass = write_denoising_passes;
 +
-       session->params.use_denoising = use_denoising;
-       session->params.denoising_passes = denoising_passes;
++      session->params.run_denoising = run_denoising;
++      session->params.full_denoising = full_denoising;
++      session->params.write_denoising_passes = write_denoising_passes;
 +      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->denoising_prefiltered_pass = buffer_params.denoising_prefiltered_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");
 +
 +      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);
  
 -              /* 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;
 -              }
 +      BL::RenderResult::views_iterator b_view_iter;
  
 -              BL::RenderLayer b_rlay = *b_single_rlay;
 -
 -              /* add passes */
 -              vector<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 full_denoising = get_boolean(crl, "use_denoising");
 -              bool write_denoising_passes = get_boolean(crl, "denoising_store_passes");
 -
 -              bool run_denoising = full_denoising || write_denoising_passes;
 -
 -              session->tile_manager.schedule_denoising = run_denoising;
 -              buffer_params.denoising_data_pass = run_denoising;
 -              buffer_params.denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES);
 -              buffer_params.denoising_prefiltered_pass = write_denoising_passes;
 -
 -              session->params.run_denoising = run_denoising;
 -              session->params.full_denoising = full_denoising;
 -              session->params.write_denoising_passes = write_denoising_passes;
 -              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->denoising_prefiltered_pass = buffer_params.denoising_prefiltered_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);
 -                      }
 +      int num_views = 0;
 +      for(b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter) {
 +              num_views++;
 +      }
  
 -                      /* Update number of samples per layer. */
 -                      int samples = sync->get_layer_samples();
 -                      bool bound_samples = sync->get_layer_bound_samples();
 -                      int effective_layer_samples;
 +      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();
  
 -                      if(samples != 0 && (!bound_samples || (samples < session_params.samples)))
 -                              effective_layer_samples = samples;
 -                      else
 -                              effective_layer_samples = session_params.samples;
 +              /* set the current view */
 +              b_engine.active_view_set(b_rview_name.c_str());
  
 -                      /* Update tile manager if we're doing resumable render. */
 -                      update_resumable_tile_manager(effective_layer_samples);
 +              /* 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();
 +
 +              /* Attempt to free all data which is held by Blender side, since at this
 +               * point we knwo that we've got everything to render current view layer.
 +               */
 +              /* At the moment we only free if we are not doing multi-view (or if we are rendering the last view).
 +               * See T58142/D4239 for discussion.
 +               */
 +              if(view_index == num_views - 1) {
 +                      free_blender_memory_if_possible();
 +              }
  
 -                      /* Update session itself. */
 -                      session->reset(buffer_params, effective_layer_samples);
 +              /* 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);
 +              }
  
 -                      /* render */
 -                      session->start();
 -                      session->wait();
 +              /* Update number of samples per layer. */
 +              int samples = sync->get_layer_samples();
 +              bool bound_samples = sync->get_layer_bound_samples();
 +              int effective_layer_samples;
  
 -                      if(session->progress.get_cancel())
 -                              break;
 -              }
 +              if(samples != 0 && (!bound_samples || (samples < session_params.samples)))
 +                      effective_layer_samples = samples;
 +              else
 +                      effective_layer_samples = session_params.samples;
  
 -              BL::RenderResult b_full_rr = b_engine.get_result();
 -              if(is_single_layer) {
 -                      string num_aa_samples = string_printf("%d", session->params.samples);
 -                      render_add_metadata(b_full_rr, "Cycles Samples", num_aa_samples);
 -                      /* TODO(sergey): Report whether we're doing resumable render
 -                       * and also start/end sample if so.
 -                       */
 -              }
 +              /* Update tile manager if we're doing resumable render. */
 +              update_resumable_tile_manager(effective_layer_samples);
  
 -              if(scene->film->cryptomatte_passes & CRYPT_OBJECT) {
 -                      add_cryptomatte_layer(b_full_rr, b_rlay_name+".CryptoObject",
 -                                            scene->object_manager->get_cryptomatte_objects(scene));
 -              }
 -              if(scene->film->cryptomatte_passes & CRYPT_MATERIAL) {
 -                      add_cryptomatte_layer(b_full_rr, b_rlay_name+".CryptoMaterial",
 -                                            scene->shader_manager->get_cryptomatte_materials(scene));
 -              }
 -              if(scene->film->cryptomatte_passes & CRYPT_ASSET) {
 -                      add_cryptomatte_layer(b_full_rr, b_rlay_name+".CryptoAsset",
 -                                            scene->object_manager->get_cryptomatte_assets(scene));
 -              }
 +              /* Update session itself. */
 +              session->reset(buffer_params, effective_layer_samples);
  
 -              /* free result without merging */
 -              end_render_result(b_engine, b_rr, true, true, false);
 +              /* render */
 +              session->start();
 +              session->wait();
  
                if(!b_engine.is_preview() && background && print_render_stats) {
                        RenderStats stats;
@@@ -529,11 -575,12 +526,12 @@@ vector<Pass> BlenderSync::sync_render_p
                        Pass::add(pass_type, passes);
        }
  
 -      PointerRNA crp = RNA_pointer_get(&b_srlay.ptr, "cycles");
 +      PointerRNA crp = RNA_pointer_get(&b_view_layer.ptr, "cycles");
-       bool use_denoising = get_boolean(crp, "use_denoising");
-       bool store_denoising_passes = get_boolean(crp, "denoising_store_passes");
+       bool full_denoising = get_boolean(crp, "use_denoising");
+       bool write_denoising_passes = get_boolean(crp, "denoising_store_passes");
        scene->film->denoising_flags = 0;
-       if(use_denoising || store_denoising_passes) {
+       if(full_denoising || write_denoising_passes) {
  #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_subsurface_direct",     DENOISING_CLEAN_SUBSURFACE_DIR);
                MAP_OPTION("denoising_subsurface_indirect",   DENOISING_CLEAN_SUBSURFACE_IND);
  #undef MAP_OPTION
 -              b_engine.add_pass("Noisy Image", 4, "RGBA", b_srlay.name().c_str());
 +              b_engine.add_pass("Noisy Image", 4, "RGBA", b_view_layer.name().c_str());
        }
  
-       if(store_denoising_passes) {
+       if(write_denoising_passes) {
 -              b_engine.add_pass("Denoising Normal",          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 Depth",           1, "Z",   b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Shadowing",       1, "X",   b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Variance",        3, "RGB", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Intensity",       1, "X",   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 Variance",  3, "RGB", b_view_layer.name().c_str());
++              b_engine.add_pass("Denoising Shadowing",       1, "X",   b_view_layer.name().c_str());
++              b_engine.add_pass("Denoising Variance",        3, "RGB", b_view_layer.name().c_str());
++              b_engine.add_pass("Denoising Intensity",       1, "X",   b_view_layer.name().c_str());
  
                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__
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge