Skip to content

Need support for uploading and downloading images with staging memory #2

@pknowles

Description

@pknowles

The existing staging system handles transfer to VkBuffer but not VkImage. The implementation on top of the existing system is not quite trivial because vkCmdCopyBufferToImage and vkCmdCopyImageToBuffer operate in VkBufferImageCopy rectangular regions and require block alignment. Block/pixel alignment should be easy enough as it's small and known. Options for handling rectangular regions:

  • Just support arbitrary large alignments? Transfer fails if the user only has tiny pools.
  • Change the input interface to support transferring 3D blocks rather than linear to multi-dimension, then find a way to pack it.
  • Try bigger transfers and reduce by dimension until a single transfer can be made.
  • Split transfer regions into remainders by dimension if needed, i.e. 1D + 2D + 3D + 2D + 1D.

Will need to support 1D, 2D, 3D, cube maps, array textures, arrays of these, except for 3D-array textures. VkBufferImageCopy::imageSubresource thankfully specifies a single mipmap to transfer.

void vkCmdCopyBufferToImage(
    VkCommandBuffer                             commandBuffer,
    VkBuffer                                    srcBuffer,
    VkImage                                     dstImage,
    VkImageLayout                               dstImageLayout,
    uint32_t                                    regionCount,
    const VkBufferImageCopy*                    pRegions);

typedef struct VkBufferImageCopy {
    VkDeviceSize                bufferOffset;
    uint32_t                    bufferRowLength;
    uint32_t                    bufferImageHeight;
    VkImageSubresourceLayers    imageSubresource;
    VkOffset3D                  imageOffset;
    VkExtent3D                  imageExtent;
} VkBufferImageCopy;

typedef struct VkImageSubresourceLayers {
    VkImageAspectFlags    aspectMask;
    uint32_t              mipLevel;
    uint32_t              baseArrayLayer;
    uint32_t              layerCount;
} VkImageSubresourceLayers;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions