WIP: Vulkan: Many small things to get no crashes #112287
@ -297,6 +297,8 @@ messenger_callback(VkDebugUtilsMessageSeverityFlagBitsEXT message_severity,
|
||||
debugging_tools.print_labels(callback_data);
|
||||
}
|
||||
|
||||
BLI_assert(callback_data->messageIdNumber != 0x47172512);
|
||||
|
||||
return VK_FALSE;
|
||||
};
|
||||
|
||||
|
@ -253,13 +253,34 @@ void VKDevice::discard_image(VkImage vk_image, VmaAllocation vma_allocation)
|
||||
discarded_images_.append(std::pair(vk_image, vma_allocation));
|
||||
}
|
||||
|
||||
void VKDevice::discard_image_view(VkImageView vk_image_view)
|
||||
{
|
||||
discarded_image_views_.append(vk_image_view);
|
||||
}
|
||||
|
||||
void VKDevice::discard_buffer(VkBuffer vk_buffer, VmaAllocation vma_allocation)
|
||||
{
|
||||
discarded_buffers_.append(std::pair(vk_buffer, vma_allocation));
|
||||
}
|
||||
|
||||
void VKDevice::discard_render_pass(VkRenderPass vk_render_pass)
|
||||
{
|
||||
discarded_render_passes_.append(vk_render_pass);
|
||||
}
|
||||
void VKDevice::discard_frame_buffer(VkFramebuffer vk_frame_buffer)
|
||||
{
|
||||
discarded_frame_buffers_.append(vk_frame_buffer);
|
||||
}
|
||||
|
||||
void VKDevice::destroy_discarded_resources()
|
||||
{
|
||||
VK_ALLOCATION_CALLBACKS
|
||||
|
||||
while (!discarded_image_views_.is_empty()) {
|
||||
VkImageView vk_image_view = discarded_image_views_.pop_last();
|
||||
vkDestroyImageView(vk_device_, vk_image_view, vk_allocation_callbacks);
|
||||
}
|
||||
|
||||
while (!discarded_images_.is_empty()) {
|
||||
std::pair<VkImage, VmaAllocation> image_allocation = discarded_images_.pop_last();
|
||||
vmaDestroyImage(mem_allocator_get(), image_allocation.first, image_allocation.second);
|
||||
@ -269,6 +290,16 @@ void VKDevice::destroy_discarded_resources()
|
||||
std::pair<VkBuffer, VmaAllocation> buffer_allocation = discarded_buffers_.pop_last();
|
||||
vmaDestroyBuffer(mem_allocator_get(), buffer_allocation.first, buffer_allocation.second);
|
||||
}
|
||||
|
||||
while (!discarded_render_passes_.is_empty()) {
|
||||
VkRenderPass vk_render_pass = discarded_render_passes_.pop_last();
|
||||
vkDestroyRenderPass(vk_device_, vk_render_pass, vk_allocation_callbacks);
|
||||
}
|
||||
|
||||
while (!discarded_frame_buffers_.is_empty()) {
|
||||
VkFramebuffer vk_frame_buffer = discarded_frame_buffers_.pop_last();
|
||||
vkDestroyFramebuffer(vk_device_, vk_frame_buffer, vk_allocation_callbacks);
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -75,6 +75,9 @@ class VKDevice : public NonCopyable {
|
||||
|
||||
Vector<std::pair<VkImage, VmaAllocation>> discarded_images_;
|
||||
Vector<std::pair<VkBuffer, VmaAllocation>> discarded_buffers_;
|
||||
Vector<VkRenderPass> discarded_render_passes_;
|
||||
Vector<VkFramebuffer> discarded_frame_buffers_;
|
||||
Vector<VkImageView> discarded_image_views_;
|
||||
|
||||
public:
|
||||
VkPhysicalDevice physical_device_get() const
|
||||
@ -181,7 +184,10 @@ class VKDevice : public NonCopyable {
|
||||
}
|
||||
|
||||
void discard_image(VkImage vk_image, VmaAllocation vma_allocation);
|
||||
void discard_image_view(VkImageView vk_image_view);
|
||||
void discard_buffer(VkBuffer vk_buffer, VmaAllocation vma_allocation);
|
||||
void discard_render_pass(VkRenderPass vk_render_pass);
|
||||
void discard_frame_buffer(VkFramebuffer vk_framebuffer);
|
||||
void destroy_discarded_resources();
|
||||
|
||||
/** \} */
|
||||
|
@ -469,12 +469,11 @@ void VKFrameBuffer::render_pass_free()
|
||||
if (vk_render_pass_ == VK_NULL_HANDLE) {
|
||||
return;
|
||||
}
|
||||
VK_ALLOCATION_CALLBACKS
|
||||
|
||||
const VKDevice &device = VKBackend::get().device_get();
|
||||
VKDevice &device = VKBackend::get().device_get();
|
||||
if (device.is_initialized()) {
|
||||
vkDestroyRenderPass(device.device_get(), vk_render_pass_, vk_allocation_callbacks);
|
||||
vkDestroyFramebuffer(device.device_get(), vk_framebuffer_, vk_allocation_callbacks);
|
||||
device.discard_render_pass(vk_render_pass_);
|
||||
device.discard_frame_buffer(vk_framebuffer_);
|
||||
}
|
||||
image_views_.clear();
|
||||
vk_render_pass_ = VK_NULL_HANDLE;
|
||||
|
@ -56,9 +56,9 @@ VKImageView::VKImageView(VKImageView &&other)
|
||||
VKImageView::~VKImageView()
|
||||
{
|
||||
if (vk_image_view_ != VK_NULL_HANDLE) {
|
||||
VK_ALLOCATION_CALLBACKS
|
||||
const VKDevice &device = VKBackend::get().device_get();
|
||||
vkDestroyImageView(device.device_get(), vk_image_view_, vk_allocation_callbacks);
|
||||
VKDevice &device = VKBackend::get().device_get();
|
||||
device.discard_image_view(vk_image_view_);
|
||||
vk_image_view_ = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user