|
MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
|
| bool MayaFlux::IO::upload_volume | ( | const Kakshya::VolumeData & | data, |
| const std::shared_ptr< Buffers::VolumeGridBuffer > & | volume | ||
| ) |
Upload every field of a host VolumeData into a GPU-resident volume.
The reverse of download_volume: for each field in data whose name is declared on volume, writes its bytes into the current write slot via VolumeGridBuffer::seed_raw. The calling thread must have command queue access, matching download_volume's requirement, since seed_raw records a transfer that must resolve before the next one can be issued.
A scalar field (VolumeField holding vector<float>) uploads directly. A vector field is expanded from glm::vec3 to glm::vec4 first, zeroing the fourth component, because the GPU layout carries that padding and VolumeData does not — the inverse of the gather download_volume performs. That expansion costs an allocation at four thirds the input size.
A field named in data but not declared on volume, or whose declared stride does not match what the field's variant implies (float for a scalar, vec4 for a vector), is skipped with an error; the rest of the upload proceeds. Neither VolumeData's lattice nor its cell count is checked against the volume's own — a mismatch surfaces as seed_raw's own size-mismatch error per field, not as a single upfront rejection.
Each field is one seed_raw call rather than a batched transfer: simpler than building a seed_raw counterpart to read_fields' batching, at the cost of one staging round trip per field instead of one for the whole upload. Worth revisiting if upload_volume becomes a per-frame path rather than the one-shot load this exists for.
| data | Source, typically from IO::VolumeReader::load(). |
| volume | Destination. Fields must already be declared; this call never declares one. |
Definition at line 124 of file VolumeTransfer.cpp.
References MayaFlux::Kakshya::VolumeData::fields, MayaFlux::Journal::FileIO, MayaFlux::Journal::IO, MayaFlux::Kakshya::VolumeData::is_consistent(), MF_DEBUG, and MF_ERROR.
Referenced by MayaFlux::IO::IOManager::load_volume().
Here is the call graph for this function:
Here is the caller graph for this function: