我在 MacOS 上有一个 MetalKit 项目,除了深度模板外,一切都按预期工作。
因为我只能找到 iOS 深度模板的示例,所以我正在关注这些示例。在创建渲染管道后立即调用下面的代码片段,但 newDepthStencilStateWithDescriptor 的返回值似乎无效(设备和标签均为空)。
我可能错误地设置了 MTKView,但我不能确定,因为没有使用 MTKView 和 MacOS 的深度模板示例。
如果有人能解释这是如何发生的,我如何调试它,或者如果他们有我可以比较的示例代码,那就太好了。
desc := MTLDepthStencilDescriptor.alloc.init.autorelease;
desc.setDepthCompareFunction(MTLCompareFunctionLess);
desc.setDepthWriteEnabled(true);
desc.setLabel(NSSTR('MY DEPTH STENCIL'));
depthStencilState := device.newDepthStencilStateWithDescriptor(desc);
<MTLDepthStencilDescriptorInternal: 0x1003153a0>
label = MY DEPTH STENCIL
depthCompareFunction = MTLCompareFunctionLess
depthWriteEnabled = 1
frontFace:
stencilCompareFunction = MTLCompareFunctionAlways
stencilFailOperation = MTLStencilOperationKeep
stencilPassDepthFailOperation = MTLStencilOperationKeep
stencilPassDepthPassOperation = MTLStencilOperationKeep
stencilReadMask = 0xffffffff
stencilWriteMask = 0xffffffff
backFace:
stencilCompareFunction = MTLCompareFunctionAlways
stencilFailOperation = MTLStencilOperationKeep
stencilPassDepthFailOperation = MTLStencilOperationKeep
stencilPassDepthPassOperation = MTLStencilOperationKeep
stencilReadMask = 0xffffffff
stencilWriteMask = 0xffffffff
<MTLIGDepthStencilState: 0x1003241d0>
label = <none>
device = <null>
请注意深度模板不工作和以错误顺序绘制的片段。