MayaFlux 1.0.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,
bool awaited = false )

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.
awaitedTrue when the caller has already waited for work using target, which skips the library-wide wait before a host write. Applies to host-visible targets only. A device-local target is always copied without blocking; the next write to staging waits for that copy only.

Definition at line 768 of file StagingUtils.cpp.

775{
776 if (!target) {
777 error<std::invalid_argument>(
780 std::source_location::current(),
781 "upload_to_gpu: target buffer is null");
782 }
783
784 if (size == 0) {
785 return;
786 }
787
788 const auto copy = [data, size](void* destination) {
789 std::memcpy(destination, data, size);
790 };
791
792 if (target->is_host_visible()) {
793 write_host_visible(target, size, dst_offset, copy, awaited);
794 } else {
795 std::shared_ptr<VKBuffer> staging_buf = staging;
796
797 if (!staging_buf) {
798 staging_buf = create_staging_buffer(size);
799 }
800
801 write_device_local(target, staging_buf, size, dst_offset, copy);
802 }
803}
std::shared_ptr< VKBuffer > create_staging_buffer(size_t size)
Create staging buffer for transfers.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains).
@ Buffers
Buffers, Managers, processors and processing chains.

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

Referenced by MayaFlux::Buffers::FormaBindingsProcessor::flush_descriptor(), MayaFlux::Buffers::NodeTextureProcessor::initialize_gpu_resources(), MayaFlux::IO::ImageReader::load_into_buffer(), MayaFlux::Buffers::AudioComputeProcessor::process_block(), MayaFlux::Buffers::AggregateBindingsProcessor::processing_function(), MayaFlux::Buffers::CompositeGeometryProcessor::processing_function(), MayaFlux::Buffers::NetworkGeometryProcessor::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::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(), MayaFlux::Buffers::DataWriteProcessor::upload_vertex(), and MayaFlux::Buffers::DataWriteProcessor::write_buffer().

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