Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document GPU capture. #2178

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Docs/MoltenVK_Runtime_UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Table of Contents
- [Interacting with the **MoltenVK** Runtime](#interaction)
- [MoltenVK Header Files](#moltenvk_headers)
- [Configuring MoltenVK](#moltenvk_config)
- [Debugging Your **MoltenVK** Application using _Metal Frame Capture_](#gpu-capture)
- [*Metal Shading Language* Shaders](#shaders)
- [Troubleshooting Shader Conversion](#spv_vs_msl)
- [Performance Considerations](#performance)
Expand Down Expand Up @@ -466,6 +467,35 @@ A description of each configuration parameter supported by **MoltenVK** can be f
[`MoltenVK_Configuration_Parameters.md`](MoltenVK_Configuration_Parameters.md) document in the `Docs` directory.



<a name="gpu-capture"></a>
Debugging Your MoltenVK Application using _Metal Frame Capture_
-----------------------------------------------------------------

Since **MoltenVK** translates _Vulkan API_ calls to _Metal_, you can use _Apple's_
[Metal Frame Capture](https://developer.apple.com/documentation/xcode/capturing-a-metal-workload-in-xcode)
to help debug your application. You can configure **MoltenVK** to automatically write to a GPU trace file,
without manual intervention, by using the following environment variables and configuration parameters:

1. `METAL_CAPTURE_ENABLED=1`, to enable Metal GPU capture. This must be set as an environment variable,
or in _Xcode_ as an _Option_ in the _Scheme_ you use to launch your app from _Xcode_.
2. `MVK_CONFIG_AUTO_GPU_CAPTURE_SCOPE=n`, this defines the scope of the capture.
You can set `n` to:
- `0` to disable capturing,
- `1` to capture all frames created between the creation of a `VkDevice` to its destruction, or
- `2` to capture only the first frame.
3. `MVK_CONFIG_AUTO_GPU_CAPTURE_OUTPUT_FILE=filename.gputrace`, to set where the capture file
should be saved to. Note that `filename.gputrace` must not already exist, otherwise the file
will not be written, and an error will be logged.

Except for `METAL_CAPTURE_ENABLED=1`, the other parameters can be set as configuration parameters, as described
in the [Configuring MoltenVK](#moltenvk_config) section above (including as environment variables).

The created capture file can then be opened with _Xcode_ for investigation. You do not need to launch
your app from _Xcode_ to capture and generate the trace file.



<a name="shaders"></a>
*Metal Shading Language* Shaders
--------------------------------
Expand Down
Loading