diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-04-29 18:46:46 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-04-29 18:57:38 +0300 |
commit | 3b7bce45d23e033a135b16b5da6cd741867f0a78 (patch) | |
tree | c005a505d2bf0decfad170c2368e0979d13cdbde /source | |
parent | 9ef727d3d4e6627efa190fa308d9169da5cca83b (diff) |
Fix T97686 DRW: Freeze when switching to material preview or render view
This was caused by the compilation job being created suspended (to avoid
UI slowdown because of the material Preview Icons). The suspended job
wasn't passing the `WM_jobs_test` in `DRW_deferred_shader_remove` and
the material would still be in the compile queue with its status equal to
`GPU_MAT_QUEUED`. This would block the main thread in the waiting loop.
But since the job manager timer needs to execute in the main thread, the
compilation job was never being pushed out of its suspended state.
This lead to a complete lock situation.
The solution is to use `WM_jobs_customdata_from_type` which does exactly
what we need.
Also fixed a nullptr free.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/intern/draw_manager_shader.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c index facd9eecf8e..4bc3898c5e7 100644 --- a/source/blender/draw/intern/draw_manager_shader.c +++ b/source/blender/draw/intern/draw_manager_shader.c @@ -237,16 +237,10 @@ static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred) void DRW_deferred_shader_remove(GPUMaterial *mat) { - for (wmWindowManager *wm = G_MAIN->wm.first; wm; wm = wm->id.next) { - if (WM_jobs_test(wm, wm, WM_JOB_TYPE_SHADER_COMPILATION) == false) { - /* No job running, do not create a new one by calling WM_jobs_get. */ - continue; - } + LISTBASE_FOREACH (wmWindowManager *, wm, &G_MAIN->wm) { LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { - wmJob *wm_job = WM_jobs_get( - wm, win, wm, "Shaders Compilation", 0, WM_JOB_TYPE_SHADER_COMPILATION); - - DRWShaderCompiler *comp = (DRWShaderCompiler *)WM_jobs_customdata_get(wm_job); + DRWShaderCompiler *comp = (DRWShaderCompiler *)WM_jobs_customdata_from_type( + wm, wm, WM_JOB_TYPE_SHADER_COMPILATION); if (comp != NULL) { BLI_spin_lock(&comp->list_lock); LinkData *link = (LinkData *)BLI_findptr(&comp->queue, mat, offsetof(LinkData, data)); @@ -256,7 +250,7 @@ void DRW_deferred_shader_remove(GPUMaterial *mat) } BLI_spin_unlock(&comp->list_lock); - MEM_freeN(link); + MEM_SAFE_FREE(link); } } } |