[Bf-blender-cvs] [3b255693b16] temp-lanpr-cleanup2: LANPR: Changed scene runtime batch free execution path.

YimingWu noreply at git.blender.org
Wed Oct 30 14:03:57 CET 2019


Commit: 3b255693b165d5b93cdf9b09e35fb39cfce3f6cf
Author: YimingWu
Date:   Wed Oct 30 21:02:33 2019 +0800
Branches: temp-lanpr-cleanup2
https://developer.blender.org/rB3b255693b165d5b93cdf9b09e35fb39cfce3f6cf

LANPR: Changed scene runtime batch free execution path.

This ensures batches for every scenes (no matter copied or original)
are handled correctly.

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

M	source/blender/blenkernel/intern/scene.c
M	source/blender/draw/DRW_engine.h
M	source/blender/draw/engines/lanpr/lanpr_engine.c

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

diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 1a8b1067a59..4d5be3a5d2a 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -94,6 +94,9 @@
 #include "DEG_depsgraph_debug.h"
 #include "DEG_depsgraph_query.h"
 
+/* lanpr scene cache free function needs this. */
+#include "DRW_engine.h"
+
 #include "RE_engine.h"
 
 #include "engines/eevee/eevee_lightcache.h"
@@ -242,6 +245,7 @@ void BKE_lanpr_copy_data(const Scene *from, Scene *to)
     memcpy(new_ll, ll, sizeof(LANPR_LineLayer));
     memset(&new_ll->components, 0, sizeof(ListBase));
     new_ll->next = new_ll->prev = NULL;
+    new_ll->batch = NULL;
     BLI_addtail(&to->lanpr.line_layers, new_ll);
     for (llc = ll->components.first; llc; llc = llc->next) {
       new_llc = MEM_callocN(sizeof(LANPR_LineLayerComponent), "Copied Line Layer Component");
@@ -519,6 +523,8 @@ void BKE_lanpr_free_everything(Scene *s)
   LANPR_LineLayer *ll;
   LANPR_LineLayerComponent *llc;
 
+  DRW_scene_freecache(s);
+
   while ((ll = BLI_pophead(&lanpr->line_layers)) != NULL) {
     while ((llc = BLI_pophead(&ll->components)) != NULL) {
       MEM_freeN(llc);
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index 34d3ae1d207..6cb3732346c 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -139,6 +139,7 @@ void DRW_draw_select_id(struct Depsgraph *depsgraph,
 bool DRW_render_check_grease_pencil(struct Depsgraph *depsgraph);
 void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph);
 void DRW_gpencil_freecache(struct Object *ob);
+void DRW_scene_freecache(struct Scene *sce);
 
 /* This is here because GPUViewport needs it */
 struct DRWInstanceDataList *DRW_instance_data_list_create(void);
diff --git a/source/blender/draw/engines/lanpr/lanpr_engine.c b/source/blender/draw/engines/lanpr/lanpr_engine.c
index 120eecc5755..4bd868cfcf6 100644
--- a/source/blender/draw/engines/lanpr/lanpr_engine.c
+++ b/source/blender/draw/engines/lanpr/lanpr_engine.c
@@ -158,6 +158,18 @@ static void lanpr_engine_init(void *ved)
   lanpr_share.init_complete = 1;
 }
 
+void DRW_scene_freecache(Scene *sce)
+{
+  LANPR_LineLayer *ll;
+  
+  for (ll = sce->lanpr.line_layers.first; ll; ll = ll->next) {
+    if (ll->batch) {
+      GPU_batch_discard(ll->batch);
+      ll->batch = NULL;
+    }
+  }
+}
+
 static void lanpr_dpix_batch_free(void)
 {
   LANPR_BatchItem *dpbi;
@@ -478,7 +490,7 @@ static void lanpr_cache_init(void *vedata)
     }
   }
 
-  if (ED_lanpr_calculation_flag_check(LANPR_RENDER_FINISHED)) {
+  if (ED_lanpr_calculation_flag_check(LANPR_RENDER_FINISHED) || ED_lanpr_calculation_flag_check(LANPR_RENDER_IDLE)) {
     ED_lanpr_rebuild_all_command(&draw_ctx->scene->lanpr);
     ED_lanpr_calculation_set_flag(LANPR_RENDER_IDLE);
   }



More information about the Bf-blender-cvs mailing list