stephen-hqxu / superterrainplus

SuperTerrain+: A real-time procedural 3D infinite terrain engine with geographical features and photorealistic rendering.
MIT License
12 stars 1 forks source link

Modularise world pipeline memory manager #53

Open stephen-hqxu opened 1 year ago

stephen-hqxu commented 1 year ago

The issue

The limitation

The current memory manager in STPWorldPipeline is integrated within the class, and uses GL texture object as the default backend.

The solution

It is better to allow user to choose which memory backend to use, this includes host and device memory. The implementation of memory manager should not be coupled with STPWorldPipeline. This allows adding new features in the future, for instance generate procedural landscape and store the terrain model to the disk rather than rendering it out, and host memory backend becomes useful in this case.

The additional

A possible implementation might be to separate memory manager from the world pipeline, and user can create as many memory modules as they want. The memory modules are not referencing world pipeline but only act as caches for storing the merged terrain texture.

The world pipeline should not store any information about any memory manager passed to the pipeline when loading chunks. As the world pipeline now includes double buffering, each memory module should keep their independent front and back buffer. Allow user to turn off double buffering if not required is a desirable feature.

There is no intention to support concurrent loading into different memory modules. Application must wait for loading to finish on one memory module, before starting the next one, since we only have one worker thread right now.