clear all internal state on command reset

This commit is contained in:
nihui
2020-05-27 22:09:10 +08:00
parent 15a4b2c878
commit 85fb76a6b9
+30
View File
@@ -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; i<image_blocks_to_destroy.size(); i++)
{
VkImageMemory* ptr = image_blocks_to_destroy[i];
int old_command_refcount = NCNN_XADD(&ptr->command_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);