-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New sample 'ThreadedResourcePrep' showcasing background preparation of meshes. #3454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
and what kind of improvement could you measure? |
|
On my laptop with Ryzen7 (7435HS, 3.10GHz) and nVidia RTX 4070, under Debug build, reloading all meshes at once:
I think the gain is so minor because textures and skeletons are still prepared synchronously when |
/** Copy out the raw data fetched from disk after resource preparation completes (state `LOADSTATE_PREPARED`).
* For advanced users only - you can manually parse the mesh data to retrieve linked resources (materials & skeleton).
* @returns Mesh file data if in state `LOADSTATE_PREPARED`, otherwise null.
*/
from Ogre.log: 03:19:39: [ThreadedResourcePrep]facial.mesh: skeletons:0, materials:5 03:19:39: [ThreadedResourcePrep]penguin.meshskeletons:1, materials:1 03:19:39: [ThreadedResourcePrep]knot.mesh: skeletons:0, materials:1 03:19:39: [ThreadedResourcePrep]sibenik.mesh: skeletons:0, materials:18 03:19:39: [ThreadedResourcePrep]ninja.mesh: skeletons:1, materials:2 03:19:39: [ThreadedResourcePrep]spine.mesh: skeletons:1, materials:1 03:19:39: [ThreadedResourcePrep]fish.mesh: skeletons:1, materials:1 03:19:39: [ThreadedResourcePrep]jaiqua.mesh: skeletons:1, materials:1 03:19:39: [ThreadedResourcePrep]robot.mesh: skeletons:1, materials:1 03:19:39: [ThreadedResourcePrep]Sword.mesh: skeletons:0, materials:4 03:19:39: [ThreadedResourcePrep]Barrel.mesh: skeletons:0, materials:1 03:19:39: [ThreadedResourcePrep]Sinbad.mesh: skeletons:1, materials:7 03:19:39: [ThreadedResourcePrep]DamagedHelmet.mesh: skeletons:0, materials:1 03:19:40: [ThreadedResourcePrep]razor.mesh: skeletons:0, materials:1 03:19:40: [ThreadedResourcePrep]geosphere4500.mesh: skeletons:0, materials:1 03:19:40: [ThreadedResourcePrep]dragon.mesh: skeletons:0, materials:3 03:19:40: [ThreadedResourcePrep]geosphere8000.mesh: skeletons:0, materials:1
|
I've proved my previous assumption. When I also prepare textures & skeletons on background, the stat becomes:
Major win, but required me to hack OgreCore by adding |
|
yeah.. maybe you should just bg load all materials in a resource group instead of that.. |
|
That would be pretty disappointing though. I'm looking for a supported (non-deprecated) solution for Rigs of Rods which has literally hundreds of user made mods distributed in ZIP archives, most having multiple variants (+multiple skins) inside single ZIP. Bruteforcing prep for all resources just isn't a reasonable solution. Plus, using this approach in a sample would sort of send out a message that threaded prep is technically here but it's not useful for the common case. Frankly my motivation to create this sample was to either find a workaround or point a finger at this issue. I'm open to suggestions how to tackle this. I noticed there is EDIT: I'll also explore the possibility of using custom loader just to load it the same way, just parsing it on the go. It should save me the copying of the whole stream which |
|
|
• Yes RoR loads every mod to separate RG, so brute prepping all content would be bearable. I will explore the ManualLoader option first, though. |
|
I looked at @paroj can you advise? |
|
you cannot just prepare meshes. The ManualResourceLoader API is made to mainly handle load. |
This reverts the `Mesh::copyPreparedMeshFileData()` hack ~ commit cd1c47d. However, the early discovery logic is kept, the mesh file is simply loaded twice. To double check load()-ing the mesh doesn't prepare any other resources, the reload test can be performed without the early discovery where mesh gets simply load()-ed, then background prep of textures/skeletons is queried.
To enable it, tick all the checkboxes (to be cleaned up). This means the mesh is prepared via ResourceBackgroundQueue, then a custom task is queued to WorkQueue which: 1. loads the mesh file again, 2. discovers skeletons+textures using custom code 3. and then queues all of them via ResourceBackgroundQueue. I expected to see almost no FPS spike with this approach as everything is both fetched to RAM and analyzed on background, only the final mesh loading (which constructs actual hardware buffers) is done on foreground. However, the results are basically identical to just loading the mesh on foreground first and then queue textures+skeletons via ResourceBackgroundQueue.
|
I added "Threaded early discovery" mode. To enable it, tick all the checkboxes on top left (to be cleaned up).
I expected to see almost no FPS spike with this approach as everything is both fetched to RAM and analyzed on background, only the final mesh loading (which constructs actual hardware buffers) is done on foreground. |
|
maybe this is better suited as a VTest, as there is nothing visual here, but rather tests the workflow.
and are executed as part of our CI. They generate this overview page: however, we do not validate the images but only fail if the test crashes |
I wanted to see the
ResourceBackgroundQueue::prepare()functionality in action before I use it anywhere else - so I created a proof-of concept app in the form of OGRE Sample. I was particularly interested in the common case - loading a mesh, complete with linked material(s) and texture(s).Opening as draft because of things left to do: