#ios #metalanguage
#iOS #метаязык
Вопрос:
Я создал простой металлический код для отображения некоторого 3D-объекта. Теперь код отлично работает на моем Mac.
Когда я перенес его на другой идентичный компьютер Mac с тем же установленным xcode 8, он выдает мне следующую ошибку
/BuildRoot/Library/Caches/com.apple.xbs/Sources/Metal/Metal-85.83/ToolsLayers/Debug/MTLDebugRenderCommandEncoder.mm:969: failed assertion `For depth attachment, the renderPipelineState pixelFormat must be MTLPixelFormatInvalid, as no texture is set.'
И ошибка, указывающая на следующую область:
let renderPassDescriptor = MTLRenderPassDescriptor()
renderPassDescriptor.colorAttachments[0].texture = drawable.texture
renderPassDescriptor.colorAttachments[0].loadAction = .Clear
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
renderPassDescriptor.colorAttachments[0].storeAction = .Store
renderPassDescriptor.depthAttachment.loadAction = .Clear
renderPassDescriptor.depthAttachment.clearDepth = 1.0
renderPassDescriptor.depthAttachment.storeAction = .MultisampleResolve
let commandBuffer = commandQueue.commandBuffer()
commandBuffer.addCompletedHandler { (commandBuffer) -> Void in
dispatch_semaphore_signal(self.bufferProvider.avaliableResourcesSemaphore)
}
renderEncoder = commandBuffer.renderCommandEncoderWithDescriptor(renderPassDescriptor)
//For now cull mode is used instead of depth buffer
renderEncoder.setCullMode(.None)
// renderEncoder.setDepthClipMode(.Clip)
renderEncoder.setDepthStencilState(depthStencilStateE)
renderEncoder.setRenderPipelineState(pipelineState)
в последней строке я получаю эту ошибку. кто-нибудь может помочь?
Комментарии:
1. Убедитесь, что значение drawable.texture не равно нулю.
2. добавляете ли вы формат цветного пикселя в metal view. что-то вроде приведенного ниже. metalView.colorPixelFormat = .bgra8Unorm