[Bf-blender-cvs] [d44aebd3fe6] master: Previews: delay icon preview renders a bit for smoother interaction

Brecht Van Lommel noreply at git.blender.org
Fri Jun 28 16:55:30 CEST 2019


Commit: d44aebd3fe6e706c0c9d7938ed6f695163f268b8
Author: Brecht Van Lommel
Date:   Fri Jun 28 16:37:13 2019 +0200
Branches: master
https://developer.blender.org/rBd44aebd3fe6e706c0c9d7938ed6f695163f268b8

Previews: delay icon preview renders a bit for smoother interaction

With Eevee the user interface, 3D viewport and small icon materials previews
are rendered on the same GPU. This can lead to some choppy interaction when
dragging sliders. Delaying the icon preview render until the user is done with
that helps a bit, though it's no guarantee.

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

M	source/blender/editors/render/render_preview.c

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

diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 76b88b8df22..35130988aba 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -38,6 +38,8 @@
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
 
+#include "PIL_time.h"
+
 #include "BLO_readfile.h"
 
 #include "DNA_world_types.h"
@@ -1206,6 +1208,16 @@ static void icon_preview_startjob_all_sizes(void *customdata,
   IconPreview *ip = (IconPreview *)customdata;
   IconPreviewSize *cur_size;
 
+  /* Wait 2s to start rendering icon previews, to not bog down user interaction.
+   * Particularly important for heavy scenes and Eevee using OpenGL that blocks
+   * the user interface drawing. */
+  for (int i = 0; i < 20; i++) {
+    PIL_sleep_ms(100);
+    if (*stop) {
+      return;
+    }
+  }
+
   for (cur_size = ip->sizes.first; cur_size; cur_size = cur_size->next) {
     PreviewImage *prv = ip->owner;
 
@@ -1253,6 +1265,10 @@ static void icon_preview_startjob_all_sizes(void *customdata,
 
     common_preview_startjob(sp, stop, do_update, progress);
     shader_preview_free(sp);
+
+    if (*stop) {
+      break;
+    }
   }
 }
 
@@ -1470,6 +1486,9 @@ void ED_preview_shader_job(const bContext *C,
 void ED_preview_kill_jobs(wmWindowManager *wm, Main *UNUSED(bmain))
 {
   if (wm) {
+    /* This is called to stop all preview jobs before scene data changes, to
+     * avoid invalid memory access. */
     WM_jobs_kill(wm, NULL, common_preview_startjob);
+    WM_jobs_kill(wm, NULL, icon_preview_startjob_all_sizes);
   }
 }



More information about the Bf-blender-cvs mailing list