vkCmdCopyBufferToImage() & vkCmdCopyImageToBuffer() support a VkBuffer

that is bound to an offseted position in a VkDeviceMemory.
This commit is contained in:
Bill Hollings 2018-04-09 14:26:02 -04:00
parent 256c76683e
commit c08e22e097
2 changed files with 4 additions and 3 deletions

View File

@ -630,6 +630,7 @@ void MVKCmdBufferImageCopy::encode(MVKCommandEncoder* cmdEncoder) {
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 @@ void MVKCmdBufferImageCopy::encode(MVKCommandEncoder* cmdEncoder) {
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 @@ void MVKCmdBufferImageCopy::encode(MVKCommandEncoder* cmdEncoder) {
sourceOrigin: mtlTxtOrigin
sourceSize: mtlTxtSize
toBuffer: mtlBuffer
destinationOffset: (cpyRgn.bufferOffset + (bytesPerImg * lyrIdx))
destinationOffset: (mtlBuffOffset + cpyRgn.bufferOffset + (bytesPerImg * lyrIdx))
destinationBytesPerRow: bytesPerRow
destinationBytesPerImage: bytesPerImg
options: blitOptions];

View File

@ -75,7 +75,7 @@ open-source libraries on which **MoltenVK** relies:
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