MayaFlux 0.4.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 118 of file StagingUtils.cpp.

119{
120 auto& source_resources = source->get_buffer_resources();
121 void* mapped = source_resources.mapped_ptr;
122 if (!mapped) {
123 error<std::runtime_error>(
124 Journal::Component::Buffers,
125 Journal::Context::BufferProcessing,
126 std::source_location::current(),
127 "Host-visible buffer has no mapped pointer");
128 }
129
130 source->mark_invalid_range(0, source->get_size_bytes());
131
132 auto buffer_service = Registry::BackendRegistry::instance()
133 .get_service<Registry::Service::BufferService>();
134
135 if (!buffer_service) {
136 error<std::runtime_error>(
137 Journal::Component::Buffers,
138 Journal::Context::BufferProcessing,
139 std::source_location::current(),
140 "upload_host_visible requires a valid buffer service");
141 }
142
143 auto invalid_ranges = source->get_and_clear_invalid_ranges();
144 for (auto& [offset, size] : invalid_ranges) {
145 buffer_service->invalidate_range(
146 source_resources.memory,
147 offset,
148 size);
149 }
150
151 std::vector<uint8_t> raw_bytes(source->get_size_bytes());
152 std::memcpy(raw_bytes.data(), mapped, source->get_size_bytes());
153
154 std::dynamic_pointer_cast<VKBuffer>(target)->set_data({ raw_bytes });
155}
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(), and MayaFlux::Registry::BackendRegistry::instance().

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: