renderer manager: enqueue async preparing directly after sync preparing and wait after all were enqueued.

Async renderers can now already complete their preparing when others are still preparing in their sync phase. This should reduce the frame time a bit. It can even be enhanced with some feedback/task scheduler (track what time it takes avg and queue that one first next frame or so).
This commit is contained in:
Moritz Zwerger 2025-02-06 10:00:29 +01:00
parent 88df92ce84
commit 13037f4e0a
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -1,6 +1,6 @@
/* /*
* Minosoft * Minosoft
* Copyright (C) 2020-2024 Moritz Zwerger * Copyright (C) 2020-2025 Moritz Zwerger
* *
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* *
@ -96,16 +96,16 @@ class RendererManager(
} }
private fun prepare() { private fun prepare() {
val latch = SimpleLatch(0)
val worker = UnconditionalWorker(autoWork = true)
for (renderer in list) { for (renderer in list) {
renderer.prePrepareDraw() renderer.prePrepareDraw()
} if (renderer is AsyncRenderer) {
val latch = SimpleLatch(0)
val worker = UnconditionalWorker()
for (renderer in list) {
if (renderer !is AsyncRenderer) continue
worker += UnconditionalTask(priority = ThreadPool.HIGHER) { renderer.prepareDrawAsync() } worker += UnconditionalTask(priority = ThreadPool.HIGHER) { renderer.prepareDrawAsync() }
} }
}
worker.work(latch) worker.work(latch)
for (renderer in list) { for (renderer in list) {