RenderPassDescriptor中没有设置rendertargets

时间:2018-02-07 16:31:53

标签: ios metal

信号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()时发生崩溃。

任何人都知道如何避免崩溃,检查是否存在rendertargets并中止?

0 个答案:

没有答案