|
| 1 | +--- |
| 2 | +title: Arm Performance Studio Godot integrations |
| 3 | +weight: 3 |
| 4 | + |
| 5 | +### FIXED, DO NOT MODIFY |
| 6 | +layout: learningpathall |
| 7 | +--- |
| 8 | + |
| 9 | +## Arm Performance Studio Godot integrations |
| 10 | + |
| 11 | +[Arm Performance Studio](https://developer.arm.com/Tools%20and%20Software/Arm%20Performance%20Studio) is a free suite of analysis tools to help you profile game performance on mobile devices with Arm CPUs and GPUs. Arm provides a Godot extension to make data from Godot games visible in the Arm Performance Studio tools, [Streamline](https://developer.arm.com/Tools%20and%20Software/Streamline%20Performance%20Analyzer) and [Performance Advisor](https://developer.arm.com/Tools%20and%20Software/Performance%20Advisor). |
| 12 | + |
| 13 | +This package provides a simple way to incorporate annotations into your Godot project. These annotations enable you to mark the timeline with events or custom counters which provides valuable context alongside the performance data in Streamline, so you can see what was happening in the game when bottlenecks occur. For example, here we can see markers that highlight where a wave of enemies is spawning: |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +{{% notice Note %}} |
| 18 | +The Arm Performance Studio Integration extension is supported with Godot version 4.3 and later. |
| 19 | +{{% /notice %}} |
| 20 | + |
| 21 | +### How to install the Arm Performance Studio Integration extension |
| 22 | + |
| 23 | +1. In Godot, click **AssetLib** to see the available extensions. |
| 24 | + |
| 25 | +2. Find the **Arm Performance Studio Integration** extension, then double-click to open the extension. |
| 26 | + |
| 27 | +3. The extension opens in a dialog box. Click **Download**. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +4. A new dialog box opens where you can change the install folder if required. Click Install. |
| 32 | + |
| 33 | +### Using the extension |
| 34 | + |
| 35 | +All functionality in the extension is provided by the PerformanceStudio class, so first create an instance of it: |
| 36 | + |
| 37 | +```console |
| 38 | +var performance_studio = PerformanceStudio.new() |
| 39 | +``` |
| 40 | + |
| 41 | +### Adding single markers to a Godot project |
| 42 | + |
| 43 | +The simplest annotations are single markers, which can have a name and a color. To use them in a Godot project where you have installed this extension, simply call into the Performance Studio library as follows: |
| 44 | + |
| 45 | +```console |
| 46 | +performance_studio.marker("Game Started") |
| 47 | +``` |
| 48 | + |
| 49 | +This will emit a timestamped marker with the label "Game Started". When you capture a profile in Streamline, you can see this marker along the top of the timeline at the point that the game starts. |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +To give the annotation a color, use the `marker_color` method: |
| 54 | + |
| 55 | +```console |
| 56 | +performance_studio.marker_color("Game Started", Color8(0, 255, 0)) |
| 57 | +``` |
| 58 | + |
| 59 | +### Defining regions in a Godot project |
| 60 | + |
| 61 | +To define regions of interest within the game, you can specify a pair of markers prefixed with “Region Start” and “Region End”, for example: |
| 62 | + |
| 63 | +```console |
| 64 | +performance_studio.marker("Region Start Times Square") |
| 65 | +# Do work |
| 66 | +performance_studio.marker("Region End Times Square") |
| 67 | +``` |
| 68 | + |
| 69 | +These regions are shown on the frame rate analysis chart in the Performance Advisor report. |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +Also, dedicated charts for each region are appended to the end of the report, so you can analyze each region independently. |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | +### Using channels in a Godot project |
| 78 | + |
| 79 | +Channels are custom event timelines associated with a software thread. You can create channels and place annotations within them. A channel annotation has a text label and a color but, unlike markers, they span a range of time. |
| 80 | + |
| 81 | +To create a channel called "Spawner" and insert an annotation called "Spawning Wave", with the color red: |
| 82 | + |
| 83 | +```console |
| 84 | +var channel : PerformanceStudio_Channel |
| 85 | + |
| 86 | +func _ready() -> void: |
| 87 | + channel = performance_studio.create_channel("Spawner") |
| 88 | + |
| 89 | +# Annotations can then be inserted into a channel: |
| 90 | +func _on_new_wave_started() -> void: |
| 91 | + channel.annotate_color("Spawning Wave", Color8(255, 0, 0)) |
| 92 | + |
| 93 | +func _on_wave_completed() -> void: |
| 94 | + channel.end() |
| 95 | +``` |
| 96 | + |
| 97 | +To see channels in Streamline, select the **Core Map** view, and expand the **VkThread** thread: |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +### Creating counters |
| 102 | + |
| 103 | +Counters are numerical data points that can be plotted as a chart in the Streamline timeline view. Counters can be created as either absolute counters, where every value is an absolute value, or as a delta counter, where values are the number of instances of an event since the last value was emitted. All values are floats and will be presented to 2 decimal places. |
| 104 | + |
| 105 | +When charts are first defined, you can specify a title and series name. The title names the chart, the series names the data series. |
| 106 | + |
| 107 | +Multiple counter series can use the same title, which means that they will be plotted on the same chart in the Streamline timeline. |
| 108 | + |
| 109 | +To create a counter: |
| 110 | + |
| 111 | +```console |
| 112 | +var counter = performance_studio.create_counter("Title", "Series", false) |
| 113 | +``` |
| 114 | + |
| 115 | +Counter values are set easily as shown below: |
| 116 | + |
| 117 | +```console |
| 118 | +counter.setValue(42.2) |
| 119 | +``` |
| 120 | + |
| 121 | +### Custom Activity Maps |
| 122 | + |
| 123 | +[Custom Activity Map (CAM)](https://developer.arm.com/documentation/101816/latest/Annotate-your-code/User-space-annotations/Custom-Activity-Map-annotations) views allow execution information to be plotted on a hierarchical set of timelines. Like channel annotations, CAM views plot jobs on tracks, but unlike channel annotations, CAM views are not associated with a specific thread. Each CAM view contains one or more tracks and each track contains one or more jobs. |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | +To create a custom activity map and add tracks to it: |
| 128 | + |
| 129 | +```console |
| 130 | +var game_cam : PerformanceStudio_CAM |
| 131 | +var wave_track : PerformanceStudio_CAMTrack |
| 132 | +var ui_track : PerformanceStudio_CAMTrack |
| 133 | + |
| 134 | +func _ready() -> void: |
| 135 | + # Create the CAM |
| 136 | + game_cam = performance_studio.create_cam("Game Activity") |
| 137 | + |
| 138 | + # Add tracks to the CAM |
| 139 | + wave_track = game_cam.create_track("Wave Activity") |
| 140 | + ui_track = game_cam.create_track("UI Activity") |
| 141 | +``` |
| 142 | + |
| 143 | +To create a job within a track: |
| 144 | + |
| 145 | +```console |
| 146 | +var wave_job : PerformanceStudio_CAMJob |
| 147 | + |
| 148 | +func _on_new_wave_started() -> void: |
| 149 | + wave_job = wave_track.create_job("Spawning Wave", Color8(255, 0, 0)) |
| 150 | + |
| 151 | +func _on_wave_completed() -> void: |
| 152 | + wave_job.stop() |
| 153 | +``` |
0 commit comments