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 123 of file StagingUtils.cpp.

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