Fix #146560: Vulkan: Improve multires out of memory issue

This seems like an out of memory issue where the storage
buffer could not be allocated but still used as a destination
for a copy. After an out of memory issue memory can be fragmented
and any allocation can still fail.

On `AMD Radeon(TM) 890M Graphics Advanced Micro Devices AMD`
`24.30.58` I got to multires subdivision level 2+6 using the steps
described in the report. 2+7 is failing for me. 2+6 already requires 16GB
of memory using large chunks.

OpenGL and Vulkan work with other limits and memory models and can
have different behavior. This PR only improves the mentioned issue, but
can still fail in other areas.

Pull Request: https://projects.blender.org/blender/blender/pulls/147713
This commit is contained in:
Jeroen Bakker
2025-10-10 15:19:43 +02:00
parent 0a35af2fc0
commit 93cdea62f6

View File

@@ -36,6 +36,12 @@ void VKStorageBuffer::update(const void *data)
{
VKContext &context = *VKContext::get();
ensure_allocated();
if (!buffer_.is_allocated()) {
CLOG_WARN(&LOG,
"Unable to upload data to storage buffer as the storage buffer could not be "
"allocated on GPU.");
return;
}
if (usage_ == GPU_USAGE_STREAM) {
const VKDevice &device = VKBackend::get().device;
@@ -81,8 +87,9 @@ void VKStorageBuffer::allocate()
VkMemoryPropertyFlags(0),
VmaAllocationCreateFlags(0),
0.8f);
BLI_assert(buffer_.is_allocated());
debug::object_label(buffer_.vk_handle(), name_);
if (buffer_.is_allocated()) {
debug::object_label(buffer_.vk_handle(), name_);
}
}
void VKStorageBuffer::bind(int slot)