-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
Description
Description
We are developing a threejs application which will be deployed on a very controlled hardware, which allows us to use high-resolution meshes and textures. The final scene has around 1M tris (not that large) and a few 16k textures (which does take a few seconds to load). We have a small proxy mesh loaded first as LOD0 which should allow for controls to still be responsive, while the real heavy meshes geometry+textures are loaded.
However, as described in this non-blocking assets loaders thread, the primary thing blocking the main thread is uploading textures to GPU - on the following screenshot, 8s to load the 7x16k and 8k textures. During these uploadTexture, the scene and controls are unresponsive, since the GPU cannot process frame updates and renders during texture uploads.
Solution
The above thread led to the TaskManager discussion yielding the WorkerPool.js implementation mid-2022.
Seeing the recent copyTextureToTexture WebGPURenderer support PR and this small stackoverflow thread I was wondering if it would be doable that the worker handling texture loading and uploading to the GPU could be parametrized to do it in chunks/tiles, so the uploadTexture bits could become non-blocking. As imagined in the SO post, we could use texSubImage2D/copyTextureToTexture to upload small chunks that fit in a 16 ms time window (if aiming for 60 fps). This way, the update/render loops would still be responsive, and texture would be loading incrementally until completely uploaded to GPU.
This could be parametrized for example by the tile count or resolution (NxM tiles or XxY pixels wide).
Alternatives
At the moment, we are using glb/gltf meshes, with draco mesh compression and avif texture compression (lower bandwidth impact). Switching to ktx2 texture compression yields textures which have ~10x lower gpuSize according to gltf-transform inspect (although ~2-3x larger on disk), which should proportionally reduce uploadTexture duration.
Additional context
No response
