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.
}

注意

即時內容會修改資源,這會系結至即時內容做為轉譯目標檢視 (RTV) ;相反地,每個延後的內容只會使用資源,這會系結至延後的內容作為著色器資源檢視, (SRV) 。 如需立即和延遲內容的詳細資訊,請參閱 即時和延遲轉譯

 

轉譯