Properly free mesh buffers
This commit is contained in:
parent
354487878e
commit
da6f245c79
3 changed files with 13 additions and 0 deletions
|
@ -40,6 +40,7 @@ public:
|
||||||
uint32_t findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties);
|
uint32_t findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties);
|
||||||
|
|
||||||
void fillMeshBuffers(Mesh* mesh);
|
void fillMeshBuffers(Mesh* mesh);
|
||||||
|
void destroyMeshBuffers(Mesh* mesh);
|
||||||
|
|
||||||
VkInstance getInstance() const {
|
VkInstance getInstance() const {
|
||||||
return instance_;
|
return instance_;
|
||||||
|
|
|
@ -79,6 +79,8 @@ int main(int, char*[]) {
|
||||||
renderer->render(world, target);
|
renderer->render(world, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderer->destroyMeshBuffers(mesh);
|
||||||
|
|
||||||
renderer->destroyRenderTarget(target);
|
renderer->destroyRenderTarget(target);
|
||||||
|
|
||||||
vkDestroySurfaceKHR(renderer->getInstance(), surface, nullptr);
|
vkDestroySurfaceKHR(renderer->getInstance(), surface, nullptr);
|
||||||
|
|
|
@ -347,6 +347,16 @@ void Renderer::fillMeshBuffers(Mesh* mesh) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::destroyMeshBuffers(Mesh* mesh) {
|
||||||
|
vkDeviceWaitIdle(device_);
|
||||||
|
|
||||||
|
vkFreeMemory(device_, mesh->indexMemory, nullptr);
|
||||||
|
vkDestroyBuffer(device_, mesh->indexBuffer, nullptr);
|
||||||
|
|
||||||
|
vkFreeMemory(device_, mesh->vertexMemory, nullptr);
|
||||||
|
vkDestroyBuffer(device_, mesh->vertexBuffer, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::createInstance() {
|
void Renderer::createInstance() {
|
||||||
uint32_t layerCount = 0;
|
uint32_t layerCount = 0;
|
||||||
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
||||||
|
|
Reference in a new issue