1

MacOS に MetalKit プロジェクトがあり、深度ステンシルを除いてすべてが期待どおりに機能します。

iOS の深度ステンシルの例しか見つからなかったので、それらに従っています。以下のスニペットは、レンダー パイプラインが作成された直後に呼び出されていますが、newDepthStencilStateWithDescriptor からの戻り値が無効のようです (デバイスとラベルは両方とも null です)。

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>

深度ステンシルが機能せず、断片が間違った順序で描画されることに注意してください。

ここに画像の説明を入力

4

1 に答える 1