Commit: 781c9f520632798d1d550e8738794c1e4cf939bd
Author: YimingWu
Date:   Tue Dec 3 20:23:43 2019 +0800
Branches: temp-lanpr-review
https://developer.blender.org/rB781c9f520632798d1d550e8738794c1e4cf939bd

LANPR: Grease pencil mode init code fix.

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

M       source/blender/draw/engines/lanpr/lanpr_engine.c
M       source/blender/editors/include/ED_lanpr.h
M       source/blender/editors/lanpr/lanpr_cpu.c

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

diff --git a/source/blender/draw/engines/lanpr/lanpr_engine.c 
b/source/blender/draw/engines/lanpr/lanpr_engine.c
index bc31b8cc11c..0a3dee19f6e 100644
--- a/source/blender/draw/engines/lanpr/lanpr_engine.c
+++ b/source/blender/draw/engines/lanpr/lanpr_engine.c
@@ -128,10 +128,13 @@ static void lanpr_engine_init(void *ved)
                                 {GPU_ATTACHMENT_TEXTURE(txl->ms_resolve_depth),
                                  
GPU_ATTACHMENT_TEXTURE(txl->ms_resolve_color)});
 
-  BLI_spin_init(&lanpr_share.lock_loader);
-  BLI_spin_init(&lanpr_share.lock_render_status);
+  if (!(lanpr_share.init_complete & LANPR_INIT_LOCKS)) {
+    BLI_spin_init(&lanpr_share.lock_loader);
+    BLI_spin_init(&lanpr_share.lock_render_status);
+    lanpr_share.init_complete |= LANPR_INIT_LOCKS;
+  }
 
-  lanpr_share.init_complete = 1;
+  lanpr_share.init_complete |= LANPR_INIT_ENGINE;
 }
 
 void DRW_scene_lanpr_freecache(Scene *sce)
diff --git a/source/blender/editors/include/ED_lanpr.h 
b/source/blender/editors/include/ED_lanpr.h
index b891dc5ddde..497085c2d6c 100644
--- a/source/blender/editors/include/ED_lanpr.h
+++ b/source/blender/editors/include/ED_lanpr.h
@@ -276,6 +276,11 @@ typedef enum LANPR_RenderStatus {
   LANPR_RENDER_FINISHED = 3,
 } LANPR_RenderStatus;
 
+typedef enum LANPR_INIT_STATUS {
+  LANPR_INIT_ENGINE = (1 << 0),
+  LANPR_INIT_LOCKS = (1 << 1),
+} LANPR_INIT_STATUS;
+
 typedef struct LANPR_SharedResource {
 
   /* We only allocate once for all */
@@ -308,7 +313,7 @@ typedef struct LANPR_SharedResource {
   void *ved_viewport;
   void *ved_render;
 
-  int init_complete;
+  LANPR_INIT_STATUS init_complete;
 
   /** To bypass or cancel rendering.
    * This status flag should be kept in lanpr_share not render_buffer,
diff --git a/source/blender/editors/lanpr/lanpr_cpu.c 
b/source/blender/editors/lanpr/lanpr_cpu.c
index 601bc5aa229..106054bb32f 100644
--- a/source/blender/editors/lanpr/lanpr_cpu.c
+++ b/source/blender/editors/lanpr/lanpr_cpu.c
@@ -2610,6 +2610,12 @@ LANPR_RenderBuffer *ED_lanpr_create_render_buffer(Scene 
*s)
   BLI_spin_init(&rb->lock_task);
   BLI_spin_init(&rb->render_data_pool.lock_mem);
 
+  if (!(lanpr_share.init_complete & LANPR_INIT_LOCKS)) {
+    BLI_spin_init(&lanpr_share.lock_loader);
+    BLI_spin_init(&lanpr_share.lock_render_status);
+    lanpr_share.init_complete |= LANPR_INIT_LOCKS;
+  }
+
   return rb;
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to