computeFunction must not be nil 报错

computeFunction must not be nil error reported

金属着色函数重复调用248次左右后报ComputeFunction must not be nill的错误。

/Library/Caches/com.apple.xbs/Sources/Metal/Metal-56.6/Framework/MTLComputePipeline.mm:230: failed assertion `computeFunction must not be nil.'
Abort trap: 6

前 247 次调用正常,但程序在第 248 次调用时失败。 是什么原因造成的,如何避免? 提前致谢。

只有命令缓冲区和编码器是瞬态的,可以在每次调用时创建(在 draw() 函数内)。 libraries/functions 不是瞬态的,因此您应该避免重复创建它们。