[Bf-blender-cvs] [639d92f1ed1] lanpr-under-gp: LineArt: Temp fix for using in motion blur situation. (Doubles render time)

YimingWu noreply at git.blender.org
Fri Sep 18 14:17:21 CEST 2020


Commit: 639d92f1ed115eff9f56300cbfb348eafd058a80
Author: YimingWu
Date:   Fri Sep 18 20:16:35 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB639d92f1ed115eff9f56300cbfb348eafd058a80

LineArt: Temp fix for using in motion blur situation. (Doubles render time)

===================================================================

M	source/blender/editors/lineart/lineart_cpu.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c

===================================================================

diff --git a/source/blender/editors/lineart/lineart_cpu.c b/source/blender/editors/lineart/lineart_cpu.c
index f0f31669e60..ee8aecbf6b6 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -2562,7 +2562,7 @@ void ED_lineart_destroy_render_data(void)
   }
 
   if (G.debug_value == 4000) {
-    printf("LRT: Destroy render data.\n");
+    printf("LRT: Destroyed render data.\n");
   }
 }
 
@@ -2571,6 +2571,7 @@ void ED_lineart_destroy_render_data_external(void)
   if (!lineart_share.init_complete) {
     return;
   }
+
   while (ED_lineart_calculation_flag_check(LRT_RENDER_RUNNING)) {
     /* Wait to finish, XXX: should cancel here */
   }
@@ -2592,6 +2593,9 @@ LineartRenderBuffer *ED_lineart_create_render_buffer(Scene *scene)
 {
   /* Re-init render_buffer_shared */
   if (lineart_share.render_buffer_shared) {
+    if (G.debug_value == 4000) {
+      printf("LRT: **** Destroy on create.\n");
+    }
     ED_lineart_destroy_render_data_external();
   }
 
@@ -3990,6 +3994,9 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph *UNUSED(depsgraph),
     MEM_freeN(stroke_data);
   }
 
+  if (G.debug_value == 4000) {
+    printf("LRT: Generated strokes.\n");
+  }
   /* release render lock so cache is free to be manipulated. */
   BLI_spin_unlock(&lineart_share.lock_render_status);
 }
@@ -4235,6 +4242,11 @@ void ED_lineart_post_frame_update_external(bContext *C,
         lineart_share.main_window = NULL;
       }
 
+      if (G.debug_value == 4000) {
+        printf("LRT: ---- Post frame update called at LRT_SYNC_WAITING, %s.\n",
+               from_modifier ? "from modifier" : "from scene update");
+      }
+
       /** Lock caller thread before calling feature line computation.
        * This worker is not a background task, so we don't need to try another lock
        * to wait for the worker to finish. The lock will be released in the compute function.
@@ -4248,6 +4260,14 @@ void ED_lineart_post_frame_update_external(bContext *C,
     }
   }
   else if (ED_lineart_modifier_sync_flag_check(LRT_SYNC_FRESH)) {
+    /* This code path is not working with motion blur on "render animation". not sure why, but here
+     * if we retain the data and restore the flag, results will be correct. (The wrong
+     * clearing happens when dg->mode == DAG_EVAL_VIEWPORT) so can't really catch it there.) */
+    if (scene->eevee.flag & SCE_EEVEE_MOTION_BLUR_ENABLED) {
+      ED_lineart_modifier_sync_flag_set(LRT_SYNC_IDLE, from_modifier);
+      return;
+    }
+
     /* To avoid double clearing. */
     ED_lineart_modifier_sync_flag_set(LRT_SYNC_CLEARING, from_modifier);
 
@@ -4257,8 +4277,12 @@ void ED_lineart_post_frame_update_external(bContext *C,
     /* Due to using GPencil modifiers, and the scene is updated each time some value is changed, we
      * really don't need to keep the buffer any longer. If in the future we want fast refresh on
      * parameter changes (e.g. thickness or picking different result in an already validated
-     * buffer), remove ED_lineart_destroy_render_data_external() below. */
+     * buffer), remove ED_lineart_destroy_render_data_external() below.*/
     if (!from_modifier) {
+      if (G.debug_value == 4000) {
+        printf("LRT: ---- Destroy on update (%d).\n", DEG_get_mode(dg));
+      }
+
       ED_lineart_destroy_render_data_external();
     }
 
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index b29829bdf57..b7befb11eaf 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -93,6 +93,10 @@ static void generate_strokes_actual(
                              (lmd->line_types & LRT_EDGE_FLAG_INTERSECTION) :
                              lmd->line_types));
 #endif
+  if (G.debug_value == 4000) {
+    printf("LRT: Generating from modifier.\n");
+  }
+
   ED_lineart_gpencil_generate_strokes_direct(
       depsgraph,
       ob,
@@ -172,6 +176,10 @@ static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Objec
     /* Don't have data yet, update line art. Note:  ED_lineart_post_frame_update_external will
      * automatically return when calculation is already in progress.*/
     if (is_render) {
+
+      if (G.debug_value == 4000) {
+        printf("LRT: -------- Modifier calls for update when idle.\n");
+      }
       ED_lineart_post_frame_update_external(
           NULL, DEG_get_evaluated_scene(depsgraph), depsgraph, true);
       while (!ED_lineart_modifier_sync_flag_check(LRT_SYNC_FRESH) ||
@@ -184,6 +192,9 @@ static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Objec
     }
   }
   else if (ED_lineart_modifier_sync_flag_check(LRT_SYNC_WAITING)) {
+    if (G.debug_value == 4000) {
+      printf("LRT: -------- Modifier is waiting for data in LRT_SYNC_WAITING.\n");
+    }
     /* Calculation in process */
     /* Calculation already started. TODO: Cancel and restart in render update! */
     if (is_render) {
@@ -199,9 +210,6 @@ static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Objec
 
   /* If we reach here, means calculation is finished (LRT_SYNC_FRESH), we grab cache. flag reset is
    * done by calculation function.*/
-  if (G.debug_value == 4000) {
-    printf("LRT: Generating from modifier.\n");
-  }
   generate_strokes_actual(md, depsgraph, ob, gpl, gpf);
 
   WM_main_add_notifier(NA_EDITED | NC_GPENCIL, NULL);



More information about the Bf-blender-cvs mailing list