Skip to content

LiteFX::Rendering::Backends::VulkanCommandBuffer::transfer

Performs a buffer-to-image transfer from source to target.

Synopsis

Declared in <litefx/backends/vulkan.hpp>

[[dllimport, dllexport]] virtual void transfer(
    SharedPtr<IVulkanImage const> const& source,
    IVulkanImage const& target,
    UInt32 sourceSubresource = 0,
    UInt32 targetSubresource = 0,
    UInt32 subresources = 1) const override;

Description

The subresource parameter describes the index of the first sub-resource to copy. Each element gets copied into the subsequent sub-resource, where resources are counted in the following order:

  • Level: Contains the mip-map levels.
  • Layer: Contains the array slices.
  • Plane: Contains planes for multi-planar formats.

E.g., if 6 elements should be copied to an image with 3 mip-map levels and 3 layers, the elements 0-2 contain the mip-map levels of the first layer, while elements 3-5 contain the three mip-map levels of the second layer. The third layer would not receive any data in this example. If the image format has multiple planes, this procedure would be repeated for each plane, however one buffer element only maps to one sub-resource.

This method takes shared ownership over source, which means that a reference is hold until the parent command queue finished using the command buffer. At this point, the command queue calls releaseSharedState to release all shared references. Note that this is a relaxed constraint. It is only guaranteed, that the queue calls this method at some point after the command buffer has been executed.

Sharing ownership is helpful in situations where you only have a temporary buffer that you do not want to manually keep track of. For example, it makes sense to create a temporary staging buffer and delete it, if the remote resource has been initialized. In such a case, the command buffer can take ownership over the resource to release it after it has been executed.

Note that you have to manually ensure that source and target are in the proper state for transfer operations. You might have to use a IBarrier before starting the transfer.

Parameters

NameDescription
sourceThe source buffer to transfer data from.
targetThe target image to transfer data to.
sourceSubresourceA type for an unsigned 32 bit integer.
targetSubresourceA type for an unsigned 32 bit integer.
subresourcesA type for an unsigned 32 bit integer.