Vulkan,我是否需要以及何时从 VK_* 结构中释放内存

Vulkan, do I need and when free memory from VK_* structures

愚蠢的问题,抱歉

第一题

void init_something(...){
    VkTypeSomething data[100];
    VkResourceStruct resource={... .pointer_data=data};
    VkCreateSomething(... , resource); //isit safe? resource[] is not lost?
}

void vk_clean(...){
    VkDestroySomething_that_use_resource(...);
    // free resource?
}

第二题

相同的代码,更改 VkTypeSomething *data;data=malloc(...);(函数中没有空闲)

如果我 malloc,我何时需要释放该数据,我是否需要释放它

Vulkan 页面显示 "structures are destroyed on VkDestroy... call" 和 "VkDestroy... must have valid poiinters in structures on call" 因此无法在调用前释放它(我知道它不能像这样工作)

所以无法获取在某处创建的结构内部的指针...我是否需要在 VkDestroy 之后保存我创建的所有指针并自行释放它们?

好像明白了,但还是不确定 据我了解,"VkCreate... use setup-data only once" 和 调用 VkCreate 后删除所有内容是安全的...这是真的吗?

Vulkan 句柄vkCreate* 创建,由 vkDestroy* 销毁。它们与任何结构无关。我不确定您的自定义 VkCreate* 是什么或做什么,所以这超出了 Vulkan 的范围。

您是所有 struct 的所有者。通常,Vulkan 仅在函数调用期间借用它们(Vulkan 规范):

The ownership of application-owned memory is immediately acquired by any Vulkan command it is passed into. Ownership of such memory must be released back to the application at the end of the duration of the command, so that the application can alter or free this memory as soon as all the commands that acquired it have returned.