MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ capture_volume()

uint32_t MayaFlux::IO::IOManager::capture_volume ( const std::shared_ptr< Buffers::VolumeGridBuffer > &  volume,
const std::string &  path_pattern,
const std::vector< std::string > &  field_names = {},
const IO::VolumeWriteOptions &  options = {},
uint32_t  max_frames = 0,
uint64_t  frame_interval = 1 
)

Begin recording a numbered .vdb sequence from a volume.

Constructs a VolumeCapture on the engine scheduler and retains it. The capture spawns a GraphicsRoutine that reads one frame and suspends on a FrameDelay, so it advances on the frame clock and resumes on the thread that has command queue access. Nothing polls it and nothing drives it.

The readback stays on the graphics thread because it must. The encode is dispatched to the save task pool, so the per-frame cost on the graphics thread is the transfer alone.

For a capture the caller owns and drives itself, construct IO::VolumeCapture directly.

Parameters
volumeVolume to record.
path_patternDestination with one index field, such as "smoke.{:04}.vdb". Zero padding matters.
field_namesFields to record. Empty means all.
optionsWriter options, applied to every frame.
max_framesStop after this many frames. Zero is unbounded.
frame_intervalFrames between captures.
Returns
Capture handle for stop_volume_capture, or 0 on failure.

Definition at line 1356 of file IOManager.cpp.

1363{
1364 if (!volume) {
1366 "capture_volume: null volume");
1367 return 0;
1368 }
1369
1370 if (!m_scheduler) {
1372 "capture_volume: TaskScheduler unavailable");
1373 return 0;
1374 }
1375
1376 auto capture = Detail::create_volume_capture(
1377 *m_scheduler, volume, path_pattern, field_names, options,
1378 [this](Kakshya::VolumeData&& data,
1379 const std::string& path,
1380 const IO::VolumeWriteOptions& opts) {
1381 return save_volume(std::move(data), path, opts);
1382 },
1383 max_frames, frame_interval);
1384
1385 const uint32_t id = m_next_volume_capture_id.fetch_add(1, std::memory_order_relaxed);
1386
1387 std::lock_guard lock(m_volume_captures_mutex);
1388 m_volume_captures.emplace(id, std::move(capture));
1389 return id;
1390}
#define MF_ERROR(comp, ctx,...)
std::mutex m_volume_captures_mutex
std::atomic< uint32_t > m_next_volume_capture_id
bool save_volume(Kakshya::VolumeData data, const std::string &filepath, const IO::VolumeWriteOptions &options={})
Save an already-downloaded VolumeData to disk asynchronously.
std::unordered_map< uint32_t, std::unique_ptr< IO::VolumeCapture > > m_volume_captures
std::shared_ptr< Vruta::TaskScheduler > m_scheduler
std::unique_ptr< VolumeCapture > create_volume_capture(Vruta::TaskScheduler &scheduler, const std::shared_ptr< Buffers::VolumeGridBuffer > &volume, const std::string &path_pattern, const std::vector< std::string > &field_names, const VolumeWriteOptions &options, std::function< bool(Kakshya::VolumeData &&, const std::string &, const VolumeWriteOptions &)> save_fn, uint32_t max_frames, uint64_t frame_interval)
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.

References MayaFlux::IO::Detail::create_volume_capture(), MayaFlux::Journal::FileIO, MayaFlux::Journal::IO, m_next_volume_capture_id, m_scheduler, m_volume_captures, m_volume_captures_mutex, MF_ERROR, and save_volume().

+ Here is the call graph for this function: