vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
454 stars 72 forks source link

Does it support asynchronous loading? #156

Closed CeSun closed 1 year ago

CeSun commented 1 year ago

such as:

var model = await LoadAsync("");
vpenades commented 1 year ago

No, and the reason is because there's not much that can be parallelized when loading.

You can always wrap the Load method with an await Task.Run( ... );

CeSun commented 1 year ago

No, and the reason is because there's not much that can be parallelized when loading.

You can always wrap the Load method with an await Task.Run( ... );

I understand simulating async with threads. Regarding model loading, it may be possible to use async to optimize the IO of reading files. Or expose an interface for "analyzing model files from memory"

vpenades commented 1 year ago

The bulk of the loading process is parsing the json, parallelizing loading multiple files (textures, binary blobs) it's usually not recomended because the storage device (Hard Disk) is usually a bottleneck, so you would end having multiple threads waiting for each other's non parallelizable IO operations.

In short, I don't think it's worth to overcomplicate things given the potential little benefits you could get.