The main motivation for this patch is to be able to load half-typed grids directly from files containing non-half-typed grids in order to keep the process peak memory low. When having large grids or large number of grids this can be important.
The PR does (atm) the conversion according to the following rules:
stored grid value type
desired conversion
returned grid
float
half
half
double
half
half
vec2f
half
vec2h
vec3f
half
vec3h
vec2d
half
vec2h
vec3d
half
vec3h
The above rules can be extended if desirable, and in the future there could be also 'store' counterpart to do conversion into other grid types while storing. That could potentially replace the need for "saveFloatAsHalf" flag.
The core implementation has been already tested with various vdb files, some of them using saveFloatAsHalf, and the approach seems to be working without issues.
The implementation is straightforward and follows these steps:
User specifies desired conversion when calling File::open or when instantiating Stream
Desired conversion information then propagates into StreamMetadata
GridDescriptor::read picks up the conversion from the metadata and from io::ConvertingReaderFactory it gets a reader and the resulting grid valuetype. It then instantiates a grid with this new valuetype instead of using the original value type. If there is no suitable reader for the desired conversion, the method instantiates a grid with the original valuetype.
The reader returned from io::ConvertingReaderFactory is later also stored in StreamMetadata and used during topology/buffers loading.
This is still WIP and it depends on #1730 .
The main motivation for this patch is to be able to load half-typed grids directly from files containing non-half-typed grids in order to keep the process peak memory low. When having large grids or large number of grids this can be important.
The above rules can be extended if desirable, and in the future there could be also 'store' counterpart to do conversion into other grid types while storing. That could potentially replace the need for "saveFloatAsHalf" flag.
The core implementation has been already tested with various vdb files, some of them using saveFloatAsHalf, and the approach seems to be working without issues.
The implementation is straightforward and follows these steps:
File::open
or when instantiatingStream
StreamMetadata
GridDescriptor::read
picks up the conversion from the metadata and fromio::ConvertingReaderFactory
it gets a reader and the resulting grid valuetype. It then instantiates a grid with this new valuetype instead of using the original value type. If there is no suitable reader for the desired conversion, the method instantiates a grid with the original valuetype.io::ConvertingReaderFactory
is later also stored inStreamMetadata
and used during topology/buffers loading.