Creating a cube texture from in-memory data

Given six KTX, ASTC compressed textures -- all equal in size and attributes -- a.ktx, b.ktx, c.ktx, d.ktx, e.ktx, & f.ktx, I can embed them in the bundle and then create a working cube via-

let cube = MDLTexture(cubeWithImagesNamed: [ "a.ktx", "b.ktx", "c.ktx", "d.ktx", "e.ktx", "f.ktx"])

This can be assigned to background.contents and works great.

If, on the other hand, I have loaded those six textures from some other source into six separate MTLTextures, I cannot provide them as an array to background.contents (it fails with "image at index 0 is NULL). I have attempted to create a cube MTLTexture with the appropriate MTLTextureDescriptor.textureCubeDescriptor (using the pixel format and other attributes from the source textures), then copying the data via MTLBlitCommandEncoder, however the end result, while error free, is a cube that is wholly purple.

I suspect this may be that the source textures are ASTC compressed, but am a bit at a loss as the documentation is rather sparse. Everything else seems to be incredibly easy relative to this very simple need of creating a cube from textures that aren't named bundle items.

Any guidance or hints would be greatly appreciated.

Hi, a few quick questions:

Are the individual textures (that are being blitted from) valid? (i.e. not purple)If yes, what are the source and destination pixel formats to the blit? (if you can paste the textureDescriptors that would help)As a debugging step are you able to use getBytes (https://developer.apple.com/documentation/metal/mtltexture/1516318-getbytes) or replaceRegion (https://developer.apple.com/documentation/metal/mtltexture/1515679-replace) to copy to the cube on the CPU?

Thanks

Creating a cube texture from in-memory data
 
 
Q