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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user