Multiple-Pass 渲染
多重渲染是一個應用程式多次遍歷其場景圖以產生渲染輸出到顯示器的過程。 多階段轉譯可改善效能,因為它會將複雜的場景分解成可以同時執行的工作。
若要執行多重通道渲染,您可以為每個額外的渲染遍建立延遲的上下文和命令清單。 當應用程式遍歷場景圖時,它會將命令(例如,Draw等渲染命令)記錄到延遲上下文中。 應用程式完成遍歷之後,它會在延遲的上下文上呼叫 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)。 如需有關即時和延遲環境的詳細資訊,請參閱 即時和延遲渲染。
相關主題