Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions en/16_Multiple_Objects.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,37 @@ void recordCommandBuffer(uint32_t imageIndex) {
}
----

=== Update Cleanup

Since each `GameObject` now owns its own uniform buffers, `cleanup` needs to unmap and
release them individually instead of relying on the single set of uniform buffer members
from earlier chapters:

[,c{pp}]
----
void cleanup() {
for (auto& gameObject : gameObjects) {
for (size_t i = 0; i < gameObject.uniformBuffersMemory.size(); i++) {
if (gameObject.uniformBuffersMapped[i] != nullptr) {
gameObject.uniformBuffersMemory[i].unmapMemory();
}
}

gameObject.uniformBuffers.clear();
gameObject.uniformBuffersMemory.clear();
gameObject.uniformBuffersMapped.clear();
gameObject.descriptorSets.clear();
}

glfwDestroyWindow(window);
glfwTerminate();
}
----

`mainLoop` already calls `device.waitIdle()` after the render loop exits and before
`cleanup` runs, so it's safe to unmap and release these resources here - the GPU is
guaranteed to be done using them.

== Performance Considerations

When rendering multiple objects, keep these performance considerations in mind:
Expand Down
Loading