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

◆ download_host_visible()

MAYAFLUX_API void MayaFlux::Buffers::download_host_visible ( const std::shared_ptr< VKBuffer > &  source,
const std::shared_ptr< VKBuffer > &  target 
)

Download data from a host-visible buffer.

Parameters
sourceSource VKBuffer to download data from
targetTarget VKBuffer to store the downloaded data

This function handles downloading data from a host-visible VKBuffer. It maps the buffer memory, copies the data into a CPU-accessible format, and updates the associated target buffer.

Definition at line 215 of file StagingUtils.cpp.

216{
217 auto& source_resources = source->get_buffer_resources();
218 void* mapped = source_resources.mapped_ptr;
219 if (!mapped) {
220 error<std::runtime_error>(
221 Journal::Component::Buffers,
222 Journal::Context::BufferProcessing,
223 std::source_location::current(),
224 "Host-visible buffer has no mapped pointer");
225 }
226
227 source->mark_invalid_range(0, source->get_size_bytes());
228
229 auto buffer_service = Registry::BackendRegistry::instance()
230 .get_service<Registry::Service::BufferService>();
231
232 if (!buffer_service) {
233 error<std::runtime_error>(
234 Journal::Component::Buffers,
235 Journal::Context::BufferProcessing,
236 std::source_location::current(),
237 "upload_host_visible requires a valid buffer service");
238 }
239
240 auto invalid_ranges = source->get_and_clear_invalid_ranges();
241 for (auto& [offset, size] : invalid_ranges) {
242 buffer_service->invalidate_range(
243 source_resources.memory,
244 offset,
245 size);
246 }
247
248 std::vector<uint8_t> raw_bytes(source->get_size_bytes());
249 std::memcpy(raw_bytes.data(), mapped, source->get_size_bytes());
250
251 std::dynamic_pointer_cast<VKBuffer>(target)->set_data({ raw_bytes });
252}
uint64_t offset
Definition Composite.cpp:10
bool size
Source source()
Begin a Source chain.
Definition Plot.hpp:127
Backend buffer management service interface.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Registry::BackendRegistry::get_service(), MayaFlux::Registry::BackendRegistry::instance(), offset, and size.

Referenced by download_from_gpu(), and MayaFlux::Buffers::BufferDownloadProcessor::download_host_visible().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: