MayaFlux 0.5.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 211 of file StagingUtils.cpp.

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

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

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: