MayaFlux 0.1.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 127 of file StagingUtils.cpp.

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