Fix: Cycles occasional crash after Metal render

Happens for renders from command line, when kernel specialization
thread is still working after the allocators on the Blender side
have been deinitialized.

Add an explicit deinitializaiton, which ensures all Cycles worker
and cache threads are finished before the allocators are deinitialized.

This should solve occasional crashes when running regression tests
for Metal or Metal-RT.

Pull Request: https://projects.blender.org/blender/blender/pulls/128239
This commit is contained in:
Sergey Sharybin
2024-09-27 14:39:49 +02:00
committed by Sergey Sharybin
parent 98f0926825
commit 95f361ac31
5 changed files with 24 additions and 0 deletions

View File

@@ -35,6 +35,10 @@
# include <OSL/oslquery.h>
#endif
#ifdef WITH_METAL
# include "device/metal/device.h"
#endif
CCL_NAMESPACE_BEGIN
namespace {
@@ -144,6 +148,10 @@ static PyObject *init_func(PyObject * /*self*/, PyObject *args)
static PyObject *exit_func(PyObject * /*self*/, PyObject * /*args*/)
{
#ifdef WITH_METAL
device_metal_exit();
#endif
ShaderManager::free_memory();
TaskScheduler::free_memory();
Device::free_memory();