mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
vk: Allow creating temporary subresources to fail if we run out of memory.
This commit is contained in:
parent
92d1534917
commit
9d11c8cbb5
6 changed files with 85 additions and 19 deletions
|
|
@ -100,6 +100,9 @@ namespace vk
|
|||
ensure(!value && !memory);
|
||||
validate(dev, info);
|
||||
|
||||
const bool nullable = !!(info.flags & VK_IMAGE_CREATE_ALLOW_NULL);
|
||||
info.flags &= ~VK_IMAGE_CREATE_ALLOW_NULL;
|
||||
|
||||
CHECK_RESULT(vkCreateImage(m_device, &info, nullptr, &value));
|
||||
|
||||
VkMemoryRequirements memory_req;
|
||||
|
|
@ -111,10 +114,19 @@ namespace vk
|
|||
fmt::throw_exception("No compatible memory type was found!");
|
||||
}
|
||||
|
||||
memory = std::make_shared<vk::memory_block>(m_device, memory_req.size, memory_req.alignment, allocation_type_info, allocation_pool);
|
||||
CHECK_RESULT(vkBindImageMemory(m_device, value, memory->get_vk_device_memory(), memory->get_vk_device_memory_offset()));
|
||||
|
||||
current_layout = info.initialLayout;
|
||||
memory = std::make_shared<vk::memory_block>(m_device, memory_req.size, memory_req.alignment, allocation_type_info, allocation_pool, nullable);
|
||||
if (auto device_mem = memory->get_vk_device_memory();
|
||||
device_mem != VK_NULL_HANDLE) [[likely]]
|
||||
{
|
||||
CHECK_RESULT(vkBindImageMemory(m_device, value, device_mem, memory->get_vk_device_memory_offset()));
|
||||
current_layout = info.initialLayout;
|
||||
}
|
||||
else
|
||||
{
|
||||
ensure(nullable);
|
||||
vkDestroyImage(m_device, value, nullptr);
|
||||
value = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
u32 image::width() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue