Ios 在具有不同像素格式的金属纹理之间复制

Ios 在具有不同像素格式的金属纹理之间复制,ios,objective-c,metal,Ios,Objective C,Metal,我已经尝试了不同的copyFromTexture:…方法,但它们似乎总是希望纹理之间的像素格式相同。我觉得从带有MTLPixelFormatRGBA8Uint颜色格式的MTLTexture复制到带有MTLPixelFormatRGBA16Float的MTLTexture应该很简单,我这里缺少什么?我真的需要使用Accelerate框架或类似工具来转换CPU上的像素格式吗?希望我能在每一帧都做些快速的事情 我的代码: [blitCommandEncoder copyFromTexture:temp

我已经尝试了不同的
copyFromTexture:…
方法,但它们似乎总是希望纹理之间的像素格式相同。我觉得从带有
MTLPixelFormatRGBA8Uint
颜色格式的MTLTexture复制到带有
MTLPixelFormatRGBA16Float
的MTLTexture应该很简单,我这里缺少什么?我真的需要使用Accelerate框架或类似工具来转换CPU上的像素格式吗?希望我能在每一帧都做些快速的事情

我的代码:

[blitCommandEncoder copyFromTexture:tempTexture sourceSlice:0 sourceLevel:0 toTexture:anotherTexture destinationSlice:0 destinationLevel:0 sliceCount:1 levelCount:1];
控制台错误:

-[MTLDebugBlitCommandEncoder internalValidateCopyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:options:]:447: failed assertion `[sourceTexture pixelFormat](MTLPixelFormatRGBA8Uint) must equal [destinationTexture pixelFormat](MTLPixelFormatRGBA16Float) '
谢谢

可以使用计算着色器或自定义计算着色器

-执行颜色转换的过滤器 空间、alpha或像素格式

与所有金属性能着色器过滤器一样,转换过滤器 允许源纹理和目标纹理具有不同的像素 格式,在这种情况下,将源纹理的格式转换为 目标纹理的格式