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

◆ upload_to_gpu() [2/3]

MAYAFLUX_API void MayaFlux::Buffers::upload_to_gpu ( const void *  data,
size_t  size,
const std::shared_ptr< VKBuffer > &  target,
const std::shared_ptr< VKBuffer > &  staging = nullptr,
size_t  dst_offset = 0 
)

Upload raw data to GPU buffer (auto-detects host-visible vs device-local)

Parameters
dataSource data pointer
sizeSize in bytes
targetTarget GPU buffer
stagingOptional staging buffer (created if needed for device-local)

Convenience wrapper over StagingUtils that:

  • Converts raw pointer → DataVariant
  • Auto-detects if buffer is host-visible or device-local
  • Handles staging buffer creation if needed
Parameters
dst_offsetByte offset into target to write at. The default 0 overwrites from the start; a nonzero value uploads a sub-range, leaving the rest of target as it was.

Definition at line 412 of file StagingUtils.cpp.

418{
419 if (!target) {
420 error<std::invalid_argument>(
421 Journal::Component::Buffers,
422 Journal::Context::BufferProcessing,
423 std::source_location::current(),
424 "upload_to_gpu: target buffer is null");
425 }
426
427 if (size == 0) {
428 return;
429 }
430
431 std::vector<uint8_t> raw_bytes(size);
432 std::memcpy(raw_bytes.data(), data, size);
433 Kakshya::DataVariant data_variant(raw_bytes);
434
435 if (target->is_host_visible()) {
436 upload_host_visible(target, data_variant, dst_offset);
437 } else {
438 std::shared_ptr<VKBuffer> staging_buf = staging;
439
440 if (!staging_buf) {
441 staging_buf = create_staging_buffer(size);
442 }
443
444 upload_device_local(target, staging_buf, data_variant, dst_offset);
445 }
446}
std::shared_ptr< VKBuffer > create_staging_buffer(size_t size)
Create staging buffer for transfers.
void upload_device_local(const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging_buffer, const Kakshya::DataVariant &data, size_t dst_offset)
Upload data to a device-local buffer using a staging buffer.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, create_staging_buffer(), upload_device_local(), and upload_host_visible().

Referenced by MayaFlux::Buffers::FormaBindingsProcessor::flush_descriptor(), MayaFlux::Buffers::NodeTextureProcessor::initialize_gpu_resources(), MayaFlux::IO::ImageReader::load_into_buffer(), MayaFlux::Buffers::FormaProcessor::processing_function(), MayaFlux::Buffers::CompositeGeometryProcessor::processing_function(), MayaFlux::Buffers::NetworkGeometryProcessor::processing_function(), MayaFlux::Buffers::AggregateBindingsProcessor::processing_function(), MayaFlux::Buffers::NetworkGeometryProcessor::try_incremental_upload(), MayaFlux::Buffers::DescriptorBindingsProcessor::update_from_buffer(), MayaFlux::Buffers::DescriptorBindingsProcessor::update_from_network(), MayaFlux::Buffers::DescriptorBindingsProcessor::update_from_node(), MayaFlux::Buffers::TextureProcessor::update_geometry_if_dirty(), upload_audio_to_gpu(), MayaFlux::Buffers::MeshNetworkProcessor::upload_combined(), upload_from_view(), MayaFlux::Nexus::Emitter::upload_influence_ubo(), MayaFlux::Buffers::TextureProcessor::upload_initial_geometry(), MayaFlux::Buffers::DataWriteProcessor::upload_raw(), upload_resizing(), MayaFlux::Buffers::DataWriteProcessor::upload_secondary(), upload_structured_view(), upload_to_gpu(), upload_to_gpu(), and MayaFlux::Buffers::DataWriteProcessor::upload_vertex().

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