繁体   English   中英

找不到金属“纹理”

[英]Metal 'texture' not found

在基于Metal的ImageView的每个实现中,我都面临着相同的问题

let targetTexture = currentDrawable?.texture else{ return }

类型“ MTLDrawable”的值没有成员“纹理”

好像苹果已经改变了一些金属API

这是我尝试使用的全部功能:

func renderImage()
{
    guard let
        image = image,
        let targetTexture = currentDrawable?.texture else{return}

    let commandBuffer = commandQueue.makeCommandBuffer()

    let bounds = CGRect(origin: CGPoint.zero, size: drawableSize)

    let originX = image.extent.origin.x
    let originY = image.extent.origin.y

    let scaleX = drawableSize.width / image.extent.width
    let scaleY = drawableSize.height / image.extent.height
    let scale = min(scaleX, scaleY)

    let scaledImage = image
        .applying(CGAffineTransform(translationX: -originX, y: -originY))
        .applying(CGAffineTransform(scaleX: scale, y: scale))

    ciContext.render(scaledImage,
                     to: targetTexture,
                     commandBuffer: commandBuffer,
                     bounds: bounds,
                     colorSpace: colorSpace)

    commandBuffer.present(currentDrawable!)

    commandBuffer.commit()
}

执行系统和xcode更新后,我遇到了同样的问题。 事实证明,在更新过程中,xcode将构建目标切换到了模拟器。 将目标切换回设备后,所有内容都会再次编译。

Metal不适用于模拟器,但是如果您只希望构建通过并专注于应用程序的其他区域,则可以尝试执行以下类似操作:对于仍然希望在模拟器上运行的用户,可以通过以下方法解决最少让它运行和编译(尽管没有Metal功能)

https://navoshta.com/metal-camera-bonus-running-simulator/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM