Fix: Crash On Exit When Using Vulkan
Vulkan device was deallocated, but when destroying the GHOST context the GPU context is reactivated and want to allocate buffers lazilly. This is solved by de-initializing the device on platform exit, resetting buffer pointers so double free can be detected. Pull Request: https://projects.blender.org/blender/blender/pulls/111462
This commit is contained in:
@@ -90,15 +90,14 @@ void VKBackend::detect_workarounds(VKDevice &device)
|
||||
void VKBackend::platform_exit()
|
||||
{
|
||||
GPG.clear();
|
||||
}
|
||||
|
||||
void VKBackend::delete_resources()
|
||||
{
|
||||
if (device_.is_initialized()) {
|
||||
device_.deinit();
|
||||
VKDevice &device = VKBackend::get().device_;
|
||||
if (device.is_initialized()) {
|
||||
device.deinit();
|
||||
}
|
||||
}
|
||||
|
||||
void VKBackend::delete_resources() {}
|
||||
|
||||
void VKBackend::samplers_update() {}
|
||||
|
||||
void VKBackend::compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len)
|
||||
|
||||
@@ -14,7 +14,9 @@ namespace blender::gpu {
|
||||
|
||||
VKBuffer::~VKBuffer()
|
||||
{
|
||||
free();
|
||||
if (is_allocated()) {
|
||||
free();
|
||||
}
|
||||
}
|
||||
|
||||
bool VKBuffer::is_allocated() const
|
||||
@@ -144,6 +146,8 @@ bool VKBuffer::free()
|
||||
const VKDevice &device = VKBackend::get().device_get();
|
||||
VmaAllocator allocator = device.mem_allocator_get();
|
||||
vmaDestroyBuffer(allocator, vk_buffer_, allocation_);
|
||||
allocation_ = VK_NULL_HANDLE;
|
||||
vk_buffer_ = VK_NULL_HANDLE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user