【发布时间】:2018-05-28 07:49:08
【问题描述】:
我有这个简单的 OpenGLES 混合代码到 Metal:
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);
我在 Metal 中编写了代码,但我很困惑它是否完全相同。具体来说,我是否需要提及 alpha 混合因子。因为我看到此代码在 Metal 中的性能比 OpenGLES 差,这很奇怪。如果此代码中缺少任何内容,请告诉我。
let renderPipelineDescriptorGreen = MTLRenderPipelineDescriptor()
renderPipelineDescriptorGreen.vertexFunction = vertexFunctionGreen
renderPipelineDescriptorGreen.fragmentFunction = fragmentFunctionAccumulator
renderPipelineDescriptorGreen.colorAttachments[0].pixelFormat = .bgra8Unorm
renderPipelineDescriptorGreen.colorAttachments[0].isBlendingEnabled = true
renderPipelineDescriptorGreen.colorAttachments[0].rgbBlendOperation = .add
renderPipelineDescriptorGreen.colorAttachments[0].sourceRGBBlendFactor = .one
renderPipelineDescriptorGreen.colorAttachments[0].destinationRGBBlendFactor = .one
【问题讨论】: