【发布时间】:2021-06-09 05:27:57
【问题描述】:
当我使用rgba32Float 像素格式绘制MTLTexture 时,我的代码可以工作,然后我可以从中取出CVPixelBuffer。
但是FlutterTexture 需要bgra8Unorm 格式。由于性能开销,我不想转换 CVPixelBuffer。
所以我尝试使用bgra8Unorm 像素格式在MTLTexture 上进行渲染,但以下片段着色器代码无法编译:
fragment vector_uchar4 fragmentShader2(Vertex interpolated [[stage_in]]) {
return 0xFFFFFFFF;
}
出现错误:Invalid return type 'vector_uchar4' for fragment function
我尝试将其替换为 uint 类型,但它会因错误而崩溃:
Fatal error: 'try!' expression unexpectedly raised an error:
Error Domain=AGXMetalA11 Code=3
"output of type uint is not compatible with a MTLPixelFormatBGRA8Unorm color attachement."
UserInfo={NSLocalizedDescription=output of type uint is not compatible with a MTLPixelFormatBGRA8Unorm color attachement.}
如果我使用vector_float4 或vector_half4 返回类型,我的纹理和缓冲区都是空的。
对于bgra8Unorm 像素格式,我必须使用哪种返回类型并获得非空图像?金属有可能吗?
【问题讨论】:
标签: ios swift flutter metal metalkit