Unity3D - 圖形性能優化:幀調試器

Unity官方文檔之“圖形性能優化-幀調試器”翻譯,E文鏈接

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的很多信息,所以是很強大的。
發佈了60 篇原創文章 · 獲贊 638 · 訪問量 51萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章