Ui: free a closed window's GPU objects at once
Since 079b6b0 Crafter.Graphics hands the handles a destroyed buffer, shader or pipeline owned to a deletion queue, which frames drain. A hidden window draws no frames, so the closed window's objects stayed allocated until the next one had drawn a few. Teardown has waited for the device already, so it drains the queue itself; so does Show's catch, since a Create that fails past the device's set-up (an asset missing) is tried again by every Show and each try left its objects queued. Measured on the workstation, that takes 2 MiB of GPU memory off a hidden window and 642,822 bytes off what valgrind finds possibly lost at exit.
This commit is contained in:
parent
e413632668
commit
8e94af86b5
1 changed files with 10 additions and 3 deletions
|
|
@ -74,6 +74,10 @@ export namespace ImsdMessages::Ui {
|
|||
day.reset();
|
||||
frames.reset();
|
||||
canvas.reset();
|
||||
// The library queues a window's buffers, shaders and pipelines
|
||||
// for deletion; with no window left no frame frees them, and
|
||||
// the device is idle here.
|
||||
Crafter::Device::DrainDeletions();
|
||||
gestures = GestureDetector{};
|
||||
hits.clear();
|
||||
hitKeys.clear();
|
||||
|
|
@ -167,10 +171,13 @@ export namespace ImsdMessages::Ui {
|
|||
// No display, a compositor without a global the library
|
||||
// needs, no Vulkan device: the library throws, and the app
|
||||
// has no window. It says so and runs on without one — a
|
||||
// resident instance keeps importing; a later Show fails at
|
||||
// once with the same reason, the device's set-up running
|
||||
// only once.
|
||||
// resident instance keeps importing. A later Show fails at
|
||||
// once with the same reason when the device's set-up failed
|
||||
// (it runs only once), and tries again past it (an asset
|
||||
// missing): what the failed Create queued is drained here,
|
||||
// as Teardown drains, since no frame will.
|
||||
canvas.reset();
|
||||
Crafter::Device::DrainDeletions();
|
||||
Log(std::format("no window: {}", e.what()));
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue