My code works when I draw on MTLTexture with rgba32Float pixel format, I can take then CVPixelBuffer out of it.
But FlutterTexture requires bgra8Unorm format. I do not want to convert CVPixelBuffer due to performance overhead.
So I'm trying to render on MTLTexture with bgra8Unorm pixel format, but the following fragment shader code won't compile:
fragment vector_uchar4 fragmentShader2(Vertex interpolated [[stage_in]]) {
return 0xFFFFFFFF;
}
With error: Invalid return type 'vector_uchar4' for fragment function
I've tried to replace it with uint type, but it crashes with error:
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.}
If I use vector_float4 or vector_half4 return type my texture and buffers are empty.
Which return type I have to use for bgra8Unorm pixel format and get non empty image? Is it possible with metal at all?
