gpt4 book ai didi

ios - 在具有不同像素格式的 Metal 纹理之间复制

转载 作者:行者123 更新时间:2023-12-01 19:30:56 36 4
gpt4 key购买 nike

我尝试了不同的copyFromTexture:...方法,但似乎它们始终希望纹理之间使用相同的像素格式。我觉得将具有MTLPixelFormatRGBA8Uint颜色格式的MTLTexture复制到具有MTLPixelFormatRGBA16Float的颜色格式应该很简单,我在这里缺少什么?我真的需要使用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-执行颜色转换的过滤器
空格,alpha或像素格式。
与所有Metal Performance Shaders滤镜一样,转换滤镜
允许具有不同像素的源和目标纹理
格式,在这种情况下,会将源纹理的格式转换为
目标纹理的格式。

关于ios - 在具有不同像素格式的 Metal 纹理之间复制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62850544/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com