vkCmdCopyBufferToImage() & vkCmdCopyImageToBuffer() support a VkBuffer
that is bound to an offseted position in a VkDeviceMemory.
diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm
index 4b1b6dd..e64b752 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm
+++ b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm
@@ -630,6 +630,7 @@
id<MTLTexture> mtlTexture = _image->getMTLTexture();
if ( !mtlBuffer || !mtlTexture ) { return; }
+ NSUInteger mtlBuffOffset = _buffer->getMTLBufferOffset();
MTLPixelFormat mtlPixFmt = mtlTexture.pixelFormat;
MVKCommandUse cmdUse = _toImage ? kMVKCommandUseCopyBufferToImage : kMVKCommandUseCopyImageToBuffer;
id<MTLBlitCommandEncoder> mtlBlitEnc = cmdEncoder->getMTLBlitEncoder(cmdUse);
@@ -671,7 +672,7 @@
for (uint32_t lyrIdx = 0; lyrIdx < cpyRgn.imageSubresource.layerCount; lyrIdx++) {
if (_toImage) {
[mtlBlitEnc copyFromBuffer: mtlBuffer
- sourceOffset: (cpyRgn.bufferOffset + (bytesPerImg * lyrIdx))
+ sourceOffset: (mtlBuffOffset + cpyRgn.bufferOffset + (bytesPerImg * lyrIdx))
sourceBytesPerRow: bytesPerRow
sourceBytesPerImage: bytesPerImg
sourceSize: mtlTxtSize
@@ -687,7 +688,7 @@
sourceOrigin: mtlTxtOrigin
sourceSize: mtlTxtSize
toBuffer: mtlBuffer
- destinationOffset: (cpyRgn.bufferOffset + (bytesPerImg * lyrIdx))
+ destinationOffset: (mtlBuffOffset + cpyRgn.bufferOffset + (bytesPerImg * lyrIdx))
destinationBytesPerRow: bytesPerRow
destinationBytesPerImage: bytesPerImg
options: blitOptions];
diff --git a/README.md b/README.md
index c7cb8e6..6edbd61 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,7 @@
brew install cmake
brew install python3
- For faster dependencies build, you can also install Ninja:
+ For faster dependency builds, you can also optionally install `ninja`:
brew install ninja