在具有不同像素格式的金属纹理之间复制
Copy between Metal textures with different pixel formats
我尝试了不同的 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) '
谢谢!
您可以使用 metal perfomance shaders 或自定义计算着色器。
MPSImageConversion - A filter that performs a conversion of color
space, alpha, or pixel format.
As with all Metal Performance Shaders filters, the conversion filter
allows for source and destination textures with different pixel
formats and, in that case, will convert the source texture's format to
the destination texture's format.
我尝试了不同的 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) '
谢谢!
您可以使用 metal perfomance shaders 或自定义计算着色器。
MPSImageConversion - A filter that performs a conversion of color space, alpha, or pixel format.
As with all Metal Performance Shaders filters, the conversion filter allows for source and destination textures with different pixel formats and, in that case, will convert the source texture's format to the destination texture's format.