IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> Viewing Your GPU Workload with the Metal Debugger 利用Metal Debugger来查看显卡工作(排错) -> 正文阅读

[开发工具]Viewing Your GPU Workload with the Metal Debugger 利用Metal Debugger来查看显卡工作(排错)

Step through your app’s state on the GPU using various Metal tools in Xcode.
内容:在Xcode中使用Metal变量来步进显卡的程序状态
说明:本文需要结合前面一个程序来熟练 Metal调试。
没有下载内容。

Overview

To understand how the computer runs your app or to debug problems, you typically use a debugger. Traditional传统的 debuggers work by pausing on a single thread, but this doesn’t work very well with Metal apps. Xcode provides提供了 a debugger specifically针对性的调试器 for Metal through its frame capture workflow.

To debug a Metal app with the Metal debugger, you capture捕获 a single frame of animation and examine the commands that the app generated to create it.

In this article, you run the Using a Render Pipeline to Render Primitives example through Xcode’s Metal debugger to learn how to examine a Metal app at runtime. 这篇文档,通过运行《Using a Render Pipeline to render Primitives》例子来运行metal调试器,来学习如何实时检查Metal程序运行。

Enable the Metal Debugger in the Xcode Project

In the Rendering example, go into the project’s build settings and change the Metal compiler options so that the debug information includes source code for your shaders. Set “Produce debugging information” for Debug to “Yes, include source code”.
按下图所示打开Metal调试器
在这里插入图片描述
Apps shipped to customers shouldn’t contain debugging information, so set Release to No.

Capture a Frame 捕获一帧

The Metal Debugger works in conjunction结合 with Xcode’s Metal frame capture feature. To use the Metal Debugger, first you capture a frame using the following steps. 首先使用下面步骤捕获一帧。
Build and run your project. In the case of Using a Render Pipeline to Render Primitives, the app displays a triangle.

在这里插入图片描述
While the app is running, return to Xcode and click the camera icon on the debugging toolbar: 在Xcode版本Version 13.0 (13A233)中,图像修改为“M”字样图标。metal作为一个新的苹果openGL,版本变化较大,需要注意。

在这里插入图片描述

Inspect Your Draw Call 检查你的绘图调用

The Using a Render Pipeline to Render Primitives app draws a triangle by calling drawPrimitives(type:vertexStart:vertexCount:). Xcode captures this draw call and all of the other function calls you made in the frame and displays those in the Debug navigator, shown below.

在这里插入图片描述
If your draw call rendered in the wrong color or screen location, you identify it in the captured frame to get more information about why.

The MyRenderEncoder group shows the commands that Metal executed to create the triangle. Xcode records your calls to set the viewport, the render pipeline state, arguments for the vertex function, and finally a command to draw the triangle. Click the draw call to select it.

在这里插入图片描述
In the main view, Xcode shows you the details of the draw call separated into categories––Vertex, Fragment, and Attachment.

在这里插入图片描述
Each one represents a stage of the draw call. Analyze分析 these stages in more detail to figure out指出 the cause of an issue问题所在, as shown in the following sections.

Inspect Your Vertices in the Geometry Viewer 在几何视图中查看你的顶点

The vertex stage displays a collection of vertices which correspond to your app’s primitives, also referred to as meshes, or geometry. To visually inspect this data for any issues, double-click Geometry.

在这里插入图片描述
Xcode renders a wireframe线框 of the vertex stage’s output in a geometry viewer. Below that, Xcode lists the same data in a table. Click a vertex in the wireframe, and Xcode selects its corresponding相应的 row in the table.

在这里插入图片描述
By checking out the vertex information in this way, you can ensure that visually and numerically, the vertex output looks correct.

If there were misplaced放错地方 vertices on screen, it’s possible the error lies in the data you provided to the vertex function. Bound Resources also lists your vertex stage inputs, so check there for any discrepancies差异 by navigating back using the left-directional in the breadcrumb(就是下面的<箭头).

在这里插入图片描述
See your inputs to the vertex function that Xcode lists at the top.

在这里插入图片描述
Double-click the first vertex buffer and Xcode displays the buffer’s contents in a table.

在这里插入图片描述
Each row identifies对应 one vertex, including its position and color. Xcode renders a preview of the color to the right of the vertex’s numeric color data. If this table reflects反映 values you don’t expect, adjust your code or other source within your app that provides data to the vertex function to resolve the issue.

View Your Vertex Function in the Shader Debugger 在着色器调试器中 查看你的顶点函数

If one or more of your app’s vertices are rendered at an incorrect position or color, the issue may be caused by a mistake in your app’s vertex shader code. To check out that possibility, open your vertex function in the shader debugger using the following steps. Select one of your vertices (marked by callout 1 in the following image) and click the Debug button (marked by callout 2).

在这里插入图片描述
Xcode shows your vertex function’s source code in its shader debugger.

在这里插入图片描述
When the code opens, ensure it’s the shader you expect. Otherwise, the problem indicates you’re using the wrong rendering pipeline, or that you’ve misconfigured the rendering pipeline. Because you configure the rendering pipeline that includes the shaders, you should know which shader you intend to process the primitive you chose.

Next to each line of code, the shader debugger shows the values calculated and stored at the time the line was executed by the GPU.

在这里插入图片描述

Click the dot to the right of the calculated value that’s marked by callout 1 in the following image. Xcode shows you the calculated values for multiple vertices, marked by callout 2.

在这里插入图片描述
This enables you to compare the results of all vertex function calls in the same frame. Doing so can reveal inconsistencies that suggest there’s a bug in your shader code or input data.

View Your Fragment Function in the Shader Debugger 在着色器调试器中查看你的片元函数

You can also see how the fragment function processed a specific fragment. To see how each line of code in your fragment shader determined the pixel’s output color, look to the attachments Xcode displays in the assistant editor.

在这里插入图片描述
Click and hold the mouse until Xcode displays the targeting reticle. Move the mouse to choose a pixel.

在这里插入图片描述
Click the Debug button.

在这里插入图片描述

Xcode opens your fragment function in the shader debugger, with the code lines annotated with the calculations for this pixel.
在这里插入图片描述

When the code opens, ensure it’s the shader you expect. Otherwise, the problem indicates表明 you’re using the wrong rendering pipeline, or that you’ve misconfigured the rendering pipeline. Because you configure the rendering pipeline that includes the shaders, you should know which shader you intend to process the pixel you chose.

Click the dot to the right of the calculated value, marked by callout 1 in the following image. Xcode displays a visualization of the color your app returned for this pixel, marked by callout 2 in the following image.
在这里插入图片描述

If there were more lines in the Rendering app’s fragment shader, you could inspect those in a similar manner to understand how each line contributed to the output pixel color.

Metal provides many other great tools that you can use to debug and optimize your app’s performance and energy usage. For more information, see Tools.

【Viewing Your GPU Workload with the Metal Debugger 】结束

  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2021-10-03 17:15:42  更:2021-10-03 17:16:22 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/16 1:37:59-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码