2011-06-23 14 views
2

SlimDX March SDK(2010年6月のDXSDK11については私が信じる)に問題があります。問題は、私がアウトプットマージャー状態への奥行きビューの添付をオンにするたびに、私は画面に何も出力しないということです。私はDX11のサンプルと私のコードを比較して正しいと思われます。私は深さテスト(常に渡すなどを含む)のためのあらゆる種類のフラグとフォーマットを試しましたが、何も動作していないようです。誰かが間違いを見つけられるのであれば、私は感謝しています。ここにコードがあります。ここでの手順は以下のとおりです。SlimDX 11デプスバッファの問題

 Format depthFormat = Format.D32_Float; 
    Texture2DDescription depthBufferDesc = new Texture2DDescription 
    { 
     ArraySize = 1, 
     BindFlags = BindFlags.DepthStencil, 
     CpuAccessFlags = CpuAccessFlags.None, 
     Format = depthFormat, 
     Height = width, 
     Width = height, 
     MipLevels = 1, 
     OptionFlags = ResourceOptionFlags.None, 
     SampleDescription = new SampleDescription(1, 0), 
     Usage = ResourceUsage.Default 
    }; 

    DepthBuffer = new DXTexture2D(Device, depthBufferDesc); 

    DepthStencilViewDescription dsViewDesc = new DepthStencilViewDescription 
    { 
     ArraySize = 0, 
     Format = depthFormat, 
     Dimension = DepthStencilViewDimension.Texture2D, 
     MipSlice = 0, 
     Flags = 0, 
     FirstArraySlice = 0 
    }; 

    DepthView = new DepthStencilView(Device, DepthBuffer, dsViewDesc); 

    DepthStencilStateDescription dsStateDesc = new DepthStencilStateDescription() 
    { 
     IsDepthEnabled = true, 
     IsStencilEnabled = false, 
     DepthWriteMask = DepthWriteMask.All, 
     DepthComparison = Comparison.Less, 
    }; 

    DepthState = DepthStencilState.FromDescription(Device, dsStateDesc); 
  • セットアップレンダーターゲット:

    DeviceContext.OutputMerger.DepthStencilState = DepthState; 
        DeviceContext.OutputMerger.SetTargets(DepthView, RenderView); 
        DeviceContext.Rasterizer.SetViewports(new Viewport(0, 0, ContextSettings.Width, ContextSettings.Height, 0.0f, 1.0f)); 
    
        Clear(); 
    
  •  D3DDevice device; 
        SwapChain swapChain; 
    
        /// Create the swap chain 
        SwapChainDescription desc = new SwapChainDescription() 
        { 
         BufferCount = 1, 
         ModeDescription = new ModeDescription 
         { 
          Width = ContextSettings.Width, 
          Height = ContextSettings.Height, 
          RefreshRate = new SlimDX.Rational(ContextSettings.RefreshRate, 1), 
          Format = ContextSettings.BufferFormat, 
         }, 
         IsWindowed = !ContextSettings.FullScreen, 
         OutputHandle = WindowHandle, 
         SampleDescription = new SampleDescription(1, 0), 
         SwapEffect = SwapEffect.Discard, 
         Usage = Usage.RenderTargetOutput, 
        }; 
    
        FeatureLevel[] featureLevels = new FeatureLevel[] { FeatureLevel.Level_11_0, FeatureLevel.Level_10_1 }; 
        DriverType driverType = DriverType.Hardware; 
    
        D3DDevice.CreateWithSwapChain(driverType, DeviceCreationFlags.Debug, featureLevels, desc, out device, out swapChain); 
    
        Device = device; 
        SwapChain = swapChain; 
    
        /// Setup window association 
        Factory factory = swapChain.GetParent<Factory>(); 
        factory.SetWindowAssociation(WindowHandle, WindowAssociationFlags.IgnoreAll); 
    
        /// Setup back buffers and render target views 
        RenderBuffer = DXTexture2D.FromSwapChain<DXTexture2D>(swapChain, 0); 
        RenderView = new RenderTargetView(Device, RenderBuffer); 
    
  • は、次に深度バッファを初期化します。

    1. はバックバッファを初期化します

    OutputMerger.SetTargetsからDepthViewを削除すると、画面上で画像が表示されるようになります(もちろん、デプステストは行われません)。

  • +0

    エラーまたは警告が表示されているかどうかを確認するためにDirectXが提供するデバッグ出力を確認しましたか?また、PIXを使って、ジオメトリで起こっていることを正確に見てみてください。 – MikeP

    +0

    深度ステンシルビューは、私が行ったのとまったく同じ方法で初期化しています。違いは、私が使用するフォーマットはFormat.D24_UNorm_S8_UIntです。それを試して、それが動作するかどうかを確認できますか? 編集:ああ、私はDepthStencilStateをまったく使用していません。それが問題の発生場所であるかどうかを調べることができますか? –

    答えて

    0

    それはdepthBufferDescで、私は幅に対する高さの変数と高さに幅を渡したことが判明。これは、異なる次元の2つのレンダーターゲットを作成して、それを分解していました。

    関連する問題