Frame Debugger 帧调试器 性能系列5

Frame Debugger 帧调试器

本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>)
仅作为个人学习使用,不得作为商业用途,欢迎转载,并请注明出处。
文章中涉及到的操作都是基于Unity2018.3版本
参考链接:https://docs.unity3d.com/Manual/FrameDebugger.html

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.
帧调试器(Frame Debugger)允许您为正在运行的游戏在特定的帧冻结回放,并查看用于渲染该帧的单次绘制调用。除列出DC外,调试器还允许您逐个逐个地遍历它们,这样您就可以非常详细地看到场景是如何从图形元素中一步步构造出来。
[外链图片转存失败(img-hyAFv7hN-1565762628460)(https://docs.unity3d.com/uploads/Main/FrameDebugger.jpg)]

Using the Frame Debugger

The Frame Debugger window (menu: Window > Analysis > Frame Debugger) shows the drawcall information and lets you control the “playback” of the frame under construction.
Frame Debugger显示DC信息,允许您控制正在构建的帧的“回放”。

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序列(以及其他事件,如 framebuffer clear),该层次结构标识了调用的起源。列表右侧的面板提供了关于DC的更多信息,例如用于渲染的几何细节和着色器。

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.
点击列表中的一个项目将显示场景(在游戏视图中),它会出现并包括那个DC。工具栏中的左右箭头按钮在列表中向前和向后移动一步,你也可以使用箭头键达到同样的效果。此外,窗口顶部的滑块可以让您快速地“刷”通过DC来快速定位感兴趣的项目。当DC对应于GameObject的几何体时,该对象将在主层次结构面板中突出显示,以帮助识别。

If rendering happens into a RenderTexture at the selected draw call, then contents of that RenderTexture 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:
在选定的DC中,如果渲染发生的渲染纹理(RT),那么渲染纹理的内容将显示在游戏视图中。这是有用的检查各种屏幕外渲染目标是如何建立的,例如漫反射 g-buffer在延迟渲染中:
[外链图片转存失败(img-qvmv4OmZ-1565762628461)(https://docs.unity3d.com/uploads/Main/FrameDebugAnimDiffuse.gif)]
Or looking at how the shadow maps are rendered:
或者看看阴影图是如何渲染的:
[外链图片转存失败(img-YRpUPz04-1565762628461)(https://docs.unity3d.com/uploads/Main/FrameDebugAnimShadow.gif)]

Remote Frame Debugger
Frame Debugger 帧调试器 性能系列5_第1张图片

To use Frame Debugger remotely, the player has to support multithreaded rendering (for ex., WebGL, iOS don’t support it, thus frame debugger cannot be run on it), most of the Unity platforms support it, secondly you have to check ‘Development Build’ when building.
要远程使用Frame Debugger,玩家必须支持多线程渲染(对于ex. WebGL, iOS不支持,因此Frame Debugger 不能在其上运行),大多数Unity平台都支持它,其次你必须在构建时检查“Development Build”是否开启。

Note for Desktop platforms: be sure to check ‘Run In Background’ option before building, otherwise, when you’ll connect Frame Debugger to player, it won’t reflect any rendering changes until it has focus, assuming you’re running both Editor and the player on the same machine, when you’ll control Frame Debugger in Editor, you’ll take the focus from the player.
注意桌面平台:一定要检查“在后台运行”选项在Build之前,否则,当你将调试器连接到运行器,直到游戏获得焦点,它才反映渲染变化,假设你正在运行编辑和运行器在同一台机器上,编辑器控制帧调试器时,您将会从运行窗口中失去了焦点。

Quick Start:

  • From Editor build the project to target platform (select Development Player)
  • Run the player
  • Go back to the Editor
  • Open Frame Debugger window
  • Click Active Profiler, select the player
  • Click Enable, frame debugger should enable on the player

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.
在信息面板的顶部是一个工具栏,可以让你隔离红、绿、蓝和alpha通道,以查看游戏的当前状态。类似地,您可以使用这些通道按钮右侧的levels 滑块,根据亮度级别隔离视图的区域。只有在渲染到渲染纹理时才启用。

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:
当一次渲染成多个渲染目标时,你可以选择在游戏视图中显示哪一个。这里分别显示的是在5.0延迟着色模式下的漫反射、高光、法线和自发光/间接照明缓冲:
[外链图片转存失败(img-o75Og3IT-1565762628462)(https://docs.unity3d.com/uploads/Main/FrameDebugMRTDiffuse.jpg)]
[外链图片转存失败(img-sVhwHiEw-1565762628462)(https://docs.unity3d.com/uploads/Main/FrameDebugMRTSpec.jpg)]
[外链图片转存失败(img-oBvseJEF-1565762628462)(https://docs.unity3d.com/uploads/Main/FrameDebugMRTNormal.jpg)]
Additionally, you can see the depth buffer contents by picking “Depth” from the dropdown:
另外,从下拉菜单中选择“depth”可以看到depth buffer的内容:
[外链图片转存失败(img-YQLvyQpN-1565762628462)(https://docs.unity3d.com/uploads/Main/FrameDebugMRTDepth.jpg)]

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:
通过分离渲染纹理的alpha通道,可以看到延迟g-buffer的occlusion (存储在RT0 alpha中)和smoothness (存储在RT1 alpha中):
[外链图片转存失败(img-Fpkr1vd6-1565762628463)(https://docs.unity3d.com/uploads/Main/FrameDebugMRTDiffuseA.jpg)]
[外链图片转存失败(img-WJyxVXqY-1565762628463)(https://docs.unity3d.com/uploads/Main/FrameDebugMRTSpecA.jpg)]

The emission and ambient/indirect lighting in this Scene is very dark; we can make it more visible by changing the Levels slider:
场景的自发光和环境/间接照明非常暗;我们可以使它更显着通过改变水平滑块:
[外链图片转存失败(img-Fs6Xlrbn-1565762628463)(https://docs.unity3d.com/uploads/Main/FrameDebugMRTLightRange.jpg)]

Viewing shader property values
查看着色器属性值

For draw calls, the Frame Debugger can also show shader property values that are used. Click on “Shader Properties” tab to show them:
对于DC,Frame Debugger还可以显示使用的着色器属性值。点击“着色器属性”标签来显示它们:
[外链图片转存失败(img-m0ckewPG-1565762628463)(https://docs.unity3d.com/uploads/Main/FrameDebugShaderProperties.jpg)]

For each property, the value is shown, as well as which shader stages it was used in (vertex, fragment, geometry, hull, domain). Note that when using OpenGL (e.g. on a Mac), all shader properties are considered to be part of vertex shader stage, due to how GLSL shaders work.
对于每个属性,都会显示值,以及它在哪个着色器阶段(顶点、碎片、几何、hull、domain)中被使用。注意,当使用OpenGL(例如在Mac上)时,由于GLSL着色器的工作方式,所有着色器属性都被认为是顶点着色器阶段的一部分。

In the editor, thumbnails for textures are displayed too, and clicking on them highlights the textures in the project window.
在编辑器中,纹理缩略图也会显示出来,点击它们会在项目窗口中高亮显示纹理。

Alternative frame debugging techniques

You could also use external tools to debug rendering. Editor integration exists for easily launching RenderDoc to inspect the Scene or Game view in the Editor.
您还可以使用外部工具来调试渲染。编辑器集成是为了方便地启动RenderDoc来检查编辑器中的场景或游戏视图。

You can also build a standalone player and run it through any of the following:
你也可以建立一个独立的播放器和运行它通过以下任何一个:

  • Visual Studio graphics debugger
  • Intel GPA
  • RenderDoc
  • NVIDIA NSight
  • AMD GPU PerfStudio
  • Xcode GPU Frame Capture
  • GPU Driver Instruments

When you’ve done this, capture a frame of rendering, then step through the draw calls and other rendering events to see what’s going on. This is a very powerful approach, because these tools can provide you with a lot of information to really drill down.
完成此操作后,捕获一个渲染帧,然后逐步遍历DC和其他渲染事件,以查看发生了什么。这是一种非常强大的方法,因为这些工具可以为您提供大量信息以进行深入研究。

你可能感兴趣的:(Performance,Unity,Graphics,Performance,渲染性能,文档翻译)