From 85fb76a6b9b079eed6205d139b8333dfd95215bb Mon Sep 17 00:00:00 2001 From: nihui Date: Wed, 27 May 2020 22:09:10 +0800 Subject: [PATCH] clear all internal state on command reset --- src/command.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/command.cpp b/src/command.cpp index 81f556e6e..bc605a825 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -2248,6 +2248,36 @@ int VkCompute::submit_and_wait() int VkCompute::reset() { + upload_staging_buffers.clear(); + download_post_buffers.clear(); + download_post_mats_fp16.clear(); + download_post_mats.clear(); + + for (size_t i=0; icommand_refcount, -1); + if (ptr->refcount == 0 && old_command_refcount == 1) + { + // no userspace reference and we are the last command reference + vkDestroyImageView(vkdev->vkdevice(), ptr->imageview, 0); + vkDestroyImage(vkdev->vkdevice(), ptr->image, 0); + + delete ptr; + } + else + { + // reference exists in user code or other command + } + } + image_blocks_to_destroy.clear(); + + descriptor_pools.clear(); + descriptorsets.clear(); + + delayed_records.clear(); + // reset command buffer and fence { VkResult ret = vkResetCommandBuffer(compute_command_buffer, 0);