Unity官方文件之“圖形效能優化-幀偵錯程式”的翻譯

Kaitiren發表於2016-07-18

Frame Debugger 幀偵錯程式

The Frame Debugger lets you freeze playback for a running game on a particular frame and view the individual draw calls that are used to render that frame. As well as listing the drawcalls, the debugger also lets you step through them one-by-one so you can see in great detail how the scene is constructed from its graphical elements.

幀偵錯程式可以讓你凍結回放執行中游戲的某一幀,然後看那一幀渲染的draw calls。和列出draw calls一樣,幀偵錯程式也允許你逐幀除錯,所以你可以看到場景如何從它的圖形元素構建的大量細節。

Using the Frame Debugger 使用幀偵錯程式

The Frame Debugger window (menu: Window > Frame Debugger) shows the drawcall information and lets you control the “playback” of the frame under construction.

幀偵錯程式視窗(選單:視窗 > 幀偵錯程式)顯示drawcall資訊,並且允許你控制構建過程幀的“回放”。

The main list shows the sequence of drawcalls (and other events like framebuffer clear) in the form of a hierarchy that identifies where they originated from. The panel to the right of the list gives further information about the drawcall such as the geometry details and the shader used for rendering.

主列表以資源最初的組織結構格式顯示drawcalls序列(和其它事件比如幀緩衝清除),列表右側的板面顯示了關於drawcall更詳細的資訊,比如幾何細節和渲染使用的著色器。

Clicking on an item from the list will show the scene (in the Game view) as it appears up to and including that drawcall. The left and right arrow buttons in the toolbar move forward and backward in the list by a single step and you can also use the arrow keys to the same effect. Additionally, the slider at the top of the window lets you “scrub” rapidly through the drawcalls to locate an item of interest quickly. Where a drawcall corresponds to the geometry of a GameObject, that object will be highlighted in the main Hierarchy panel to assist identification.

點選列表中的一個條目,會(在遊戲檢視中)隨著它的出現顯示場景和它的drawcall。工具欄中的左右箭頭按鈕可以前向或後向選中列表中的條目,使用鍵盤上的方向鍵也可以。此外,視窗頂部的滾動條可以讓你快速的略過drawcalls定位感興趣的條目。當一個drawcall對應於一個物體的幾何元素時,這個物體在列表皮膚的資源識別符號會高亮。

If rendering happens into a RenderTexture at the selected draw call, then contents of that render texture are displayed in the Game View. This is useful for inspecting how various off-screen render targets are built up, for example diffuse g-buffer in deferred shading:

如果選中的drawcall渲染到紋理(RenderTexture),遊戲檢視中會顯示渲染紋理的影象。這對於檢查各種離屏渲染目標如何建立有用,比如延遲著色的散射物體緩衝(g-buffer,Geometry Buffer)。

Or looking at how the shadow maps are rendered:或者看看如下,陰影是如何被渲染的:

Render target display options 渲染目標顯示選項

At the top of the information panel is a toolbar which lets you isolate the red, green, blue and alpha channels for the current state of the Game view. Similarly, you can isolate areas of the view according to brightness levels using the Levels slider to the right of these channel buttons. These are only enabled when rendering into a RenderTexture.

資訊皮膚的頂部是一個工具欄,允許你分離遊戲檢視當前狀態的紅、綠、藍和透明通道。同樣的,你可以使用通道按鈕右邊的等級滑動條來根據亮度等級分離視野區域。只有渲染到紋理時才能這樣。

When rendering into multiple render targets at once you can select which one to display in the game view. Shown here are the diffuse, specular, normals and emission/indirect lighting buffers in 5.0 deferred shading mode, respectively:

當一次渲染到多個渲染目標時,你可以選擇在遊戲檢視中顯示哪一個。下面的檢視分別是Unity 5.0延遲著色模式的散射、鏡面反射、法線和發射或非直線光:

Additionally, you can see the depth buffer contents by picking “Depth” from the dropdown:

此外,你可以通過選擇下拉選單的“深度”看到深度快取內容:

By isolating alpha channel of the render texture, you can see occlusion (stored in RT0 alpha) and smoothness (stored in RT1 alpha) of the deferred g-buffer:

通過分離渲染到紋理的透明通道,你可以看到延遲g-buffer的閉合(RT0透明通道中)和平滑(RT1透明通道中):

The emission and ambient/indirect lighting in this scene is very dark; we can make it more visible by changing the Levels slider:

這個場景中的發射光和環境光很暗,我們可以通過滑動等級滾動條讓它更能被看清楚:

Alternative frame debugging techniques 其它可供選擇的幀除錯技術:

You could also use external tools to debug rendering. Build a standalone player, run it through Visual Studio graphics debuggerIntel GPARenderDocNVIDIA NSight orAMD GPU PerfStudio, then capture a frame of rendering, and step through the draw calls and other rendering events to see what’s going on.

你也可以使用外部的工具除錯渲染。打一個獨立播放包,用Visual Studio圖形偵錯程式Intel GPARenderDocNVIDIA NSightAMD GPU PerfStudio執行,然後抓取渲染的一幀,並且逐步除錯draw calls和其它渲染事件看看發生了什麼。

This is a very powerful approach, since these tools can provide you with a lot of information to really drill down.

因為這些工具提供了真正穿過每個draw call的很多資訊,所以是很強大的。

相關文章