Find problems in your app's vertex function by pausing your app at any time, and viewing the current geometry from an angle you choose.
Use the geometry viewer to see a wireframe of the geometry that your app rendered in the captured frame. Using the mouse and touch gestures, you can view the geometry at different angles to check for issues. When you click individual primitives to select them, Xcode shows you the values of its vertices in a tabular view. In addition, you can open the selected primitive in the shader debugger to make changes to your vertex function and see the results live.
Capture a Frame
The geometry viewer works in conjunction with Xcode's Metal frame capture. Build and run your project, then click the camera button on Xcode's debugging toolbar.
For more information about frame capture, see Frame Capture Debugging Tools.
Select a Draw Call
When Xcode finishes capturing, it halts your app and displays the frame's call history in the Debug navigator. From the call list, expand your render command encoder and select a draw call.
Open the Geometry Viewer
When you select a draw call, Xcode shows the draw's bound resources in center pane. In Vertex resources, Xcode exposes the geometry that resulted from this draw call. To view it, double-click Geometry.
Xcode shows the draw call's geometry in the center pane.
View Your Geometry From Different Angles
Attain a new perspective in the geometry wireframe using the mouse and trackpad gestures. This enables you to zoom in to a specific area to check for erroneous geometry, or extraneous geometry that may initially be out of sight.
Inspect Vertex Values
When a primitive is misplaced or misshaped, it's possible the issue lies in the data you're passing to the vertex function. Look to the variables view to ensure the input and output to your vertex function is correct.
Select a primitive in Xcode's center pane.
Xcode fills the variables view below the primitive with the primitive's vertex positions.
If your vertex function has multiple outputs, refer to the additional columns to the right of position.
Inspect Your Vertex Function in the Shader Debugger
Some of the geometry may be misplaced or have values that are obviously incorrect. To consider whether the issue is mistaken shader code, debug your vertex function using the shader debugger. In the wireframe view, select a primitive that's misplaced or misshaped and click Debug.
The vertex shader that calculated the unexpected value shows in Xcode's center pane. To discover the cause of the problem, step through each line of code and inspect its values on the right pane until the anomaly is visible.
Update Your Vertex Shader Live
If you discover a problem in your vertex function, you can adjust the code and update the captured frame live to ensure you solved the issue. When you change a line of code, Xcode enables the Refresh button.
Click Refresh to update the frame with the new vertex shader, and Xcode refreshes its geometry view according to your change.