Share via


Multiple-Pass レンダリング

マルチパス レンダリングは、アプリケーションがシーン グラフを複数回走査して、ディスプレイにレンダリングする出力を生成するプロセスです。 マルチパス レンダリングでは、複雑なシーンが同時に実行できるタスクに分割されるため、パフォーマンスが向上します。

複数パスレンダリングを実行するには、追加のパスごとに遅延コンテキストとコマンド リストを作成します。 アプリケーションはシーン グラフを走査する間に、コマンド ( 描画などのレンダリング コマンドなど) を遅延コンテキストに記録します。 アプリケーションはトラバーサルを完了すると、遅延コンテキストで FinishCommandList メソッドを呼び出します。 最後に、アプリケーションは、各コマンド リストでコマンドを実行するために、即時コンテキストで ExecuteCommandList メソッドを呼び出します。

次の擬似コードは、マルチパス レンダリングを実行する方法を示しています。

{
 ImmCtx->SetRenderTarget( pRTViewOfResourceX );
 DefCtx1->SetTexture( pSRView1OfResourceX );
 DefCtx2->SetTexture( pSRView2OfResourceX );

 for () // Traverse the scene graph.
  {
    ImmCtx->Draw(); // Pass 0: immediate context renders primitives into resource X.

    // The following texturing by the deferred contexts occurs after the 
    // immediate context makes calls to ExecuteCommandList. 
    // Resource X is then comletely updated by the immediate context. 
    DefCtx1->Draw(); // Pass 1: deferred context 1 performs texturing from resource X.
    DefCtx2->Draw(); // Pass 2: deferred context 2 performs texturing from resource X.
      }

  // Create command lists and record commands into them.
  DefCtx1->FinishCommandList( &pCL1 ); 
  DefCtx2->FinishCommandList( &pCL2 );

  ImmCtx->ExecuteCommandList( pCL1 ); // Execute pass 1.
  ImmCtx->ExecuteCommandList( pCL2 ); // Exeucte pass 2.
}

Note

イミディエイト コンテキストは、レンダリング ターゲット ビュー (RTV) としてイミディエイト コンテキストにバインドされているリソースを変更します。これに対し、各遅延コンテキストでは、単にリソースが使用されます。これは、遅延コンテキストにシェーダー リソース ビュー (SRV) としてバインドされます。 即時および遅延コンテキストの詳細については、「 イミディエイト レンダリングと遅延レンダリング」を参照してください。

 

レンダリング