信号SIGABRT错误:
validateRenderPassDescriptor:611: failed assertion
`No rendertargets set in RenderPassDescriptor.'
下面是我设置MTLRenderPassDescriptor的方法:
guard let currenDrawable: CAMetalDrawable = self.currentDrawable else { return }
let renderPassDescriptor = MTLRenderPassDescriptor()
renderPassDescriptor.colorAttachments[0].texture = currenDrawable.texture
renderPassDescriptor.colorAttachments[0].loadAction = .clear
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColor(red: 0, green: 0, blue: 0, alpha: 0)
let renderCommandEncoder = commandBuffer.makeRenderCommandEncoder(descriptor: renderPassDescriptor)
调用makeRenderCommandEncoder()时发生崩溃。
有人知道如何避免崩溃,检查渲染目标是否不存在并中止吗?
1条答案
按热度按时间vkc1a9a21#
renderPassDescriptor.colorAttachments[0]
使用前必须初始化,添加即可