jMonkeyEngine / jmonkeyengine

A complete 3-D game development suite written in Java.
http://jmonkeyengine.org
BSD 3-Clause "New" or "Revised" License
3.77k stars 1.12k forks source link

Multithreading in AssetManager #5

Open ghost opened 10 years ago

ghost commented 10 years ago

Multithreading is an important issue right now. Taking advantage of it in jME3 is critical. Some areas where multithreading can be used:

The details on how to implement these areas using multithreading will be specified later.


Some parts of jME3 are already multi-threaded:

Physics runs in a parallel thread. Networking runs in a parallel thread. Audio and OGG streaming is done on a parallel thread. Terrain streaming/LOD is done in a parallel thread.

jME3 is still missing asset loading on a separate thread, which can be critical if the application loads assets dynamically.


The AssetManager is the last part of jME3 that needs to take advantage of multithreading.

Reference on googlecode: https://code.google.com/p/jmonkeyengine/issues/detail?id=94

empirephoenix commented 8 years ago

Actually, the assetmanager is quite capble of being used in a background thread, however the uploading to the gpu is not currently.

shadowislord commented 8 years ago

To upload to GPU you can use Application.enqueue() with a Callable that calls RenderManager.preloadScene().

Actually what I was thinking was something like

Future<T> loadAssetLater(AssetKey<T> assetKey)

which would let you load an asset on a separate thread. Perhaps you can set the executor via

void setExecutorService(ExecutorService executorService)
pavly-gerges commented 2 years ago

Long time, what's the status of this ? I will work on it, please provide adequate information on what's need to be done if possible, there a multiple approaches this can be done.

stephengold commented 2 years ago

I believe JME's asset manager is sufficiently multithreaded. In my opinion, what's missing is documentation---in other words, a tutorial explaining how to load assets in the background.

pavly-gerges commented 2 years ago

I believe JME's asset manager is sufficiently multithreaded. In my opinion, what's missing is documentation---in other words, a tutorial explaining how to load assets in the background.

Hmm, I guess this is not the case, jme lacks an async TaskManager in general, see #75, and by building a good async task manager we will be able to natively load our assets easily without the need of external means of java concurrency, I was willing to put some effort onto this and try implementing the feature if that is the case.