Is there a limit to the number MTLIO load texture commands that can safely be executed in a single command buffer?
When I tried loading each face (6) of a cube texture using a single command buffer, some of the faces will have bad data. Basically...
let cmdBuf = ioCommandQueue.makeCommandBuffer() for slice in 0...5 { cmdBuf.load(cubeTexture, slice: slice, level: 0, size: size, sourceBytesPerRow:bytesPerRow, sourceBytesPerImage: bytesPerImage, destinationOrigin: destOrigin, sourceHandle: fileHandles[slice], sourceHandleOffset: 0) } cmdBuf.commit() cmdBuf.waitUntilCompleted() /* This passes, even though my texture is messed up...? */ assert(cmdBuf.status == .complete) // Also, no errors or warnings when XCode Diagnostics / Metal Validation is turned on.
If I use multiple command buffers (one load texture command each), everything is fine...
for slice in 0...5 { // IMPORTANT: Moved inside the LOOP let cmdBuf = ioCommandQueue.makeCommandBuffer() cmdBuf.load(cubeTexture, slice: slice, level: 0, size: size, sourceBytesPerRow:bytesPerRow, sourceBytesPerImage: bytesPerImage, destinationOrigin: destOrigin, sourceHandle: fileHandles[slice], sourceHandleOffset: 0) // IMPORTANT: Moved inside the LOOP cmdBuf.commit() cmdBuf.waitUntilCompleted() assert(cmdBuf.status == .complete) }
I'm assuming this a bug (opened FB10582329)... Or at the very least, some documentation or Metal Validation log would be helpful to understanding what's going wrong/workaround.
I've uploaded reduced reproduction (Single Swift file, command line application, XCode project) to this GitHub Repository: https://github.com/peterwmwong/x-mtlio-load-multiple-textures
Thanks.