1-- Copyright 2024 The Chromium Authors 2-- Use of this source code is governed by a BSD-style license that can be 3-- found in the LICENSE file. 4 5INCLUDE PERFETTO MODULE slices.with_context; 6 7-- `Graphics.Pipeline` steps corresponding to work done by a Viz client to 8-- produce a frame (i.e. before surface aggregation). Covers steps: 9-- * STEP_ISSUE_BEGIN_FRAME 10-- * STEP_RECEIVE_BEGIN_FRAME 11-- * STEP_GENERATE_RENDER_PASS 12-- * STEP_GENERATE_COMPOSITOR_FRAME 13-- * STEP_SUBMIT_COMPOSITOR_FRAME 14-- * STEP_RECEIVE_COMPOSITOR_FRAME 15-- * STEP_RECEIVE_BEGIN_FRAME_DISCARD 16-- * STEP_DID_NOT_PRODUCE_FRAME 17-- * STEP_DID_NOT_PRODUCE_COMPOSITOR_FRAME 18CREATE PERFETTO TABLE chrome_graphics_pipeline_surface_frame_steps( 19 -- Slice Id of the `Graphics.Pipeline` slice. 20 id LONG, 21 -- The start timestamp of the slice/step. 22 ts TIMESTAMP, 23 -- The duration of the slice/step. 24 dur DURATION, 25 -- Step name of the `Graphics.Pipeline` slice. 26 step STRING, 27 -- Id of the graphics pipeline, pre-surface aggregation. 28 surface_frame_trace_id LONG, 29 -- Utid of the thread where this slice exists. 30 utid LONG, 31 -- Start time of the parent Chrome scheduler task (if any) of this step. 32 task_start_time_ts TIMESTAMP) 33AS 34SELECT 35 id, 36 ts, 37 dur, 38 extract_arg(arg_set_id, 'chrome_graphics_pipeline.step') AS step, 39 extract_arg(arg_set_id, 'chrome_graphics_pipeline.surface_frame_trace_id') 40 AS surface_frame_trace_id, 41 utid, 42 ts - (EXTRACT_ARG(thread_slice.arg_set_id, 'current_task.event_offset_from_task_start_time_us') * 1000) AS task_start_time_ts 43FROM thread_slice 44WHERE name = 'Graphics.Pipeline' AND surface_frame_trace_id IS NOT NULL; 45 46-- `Graphics.Pipeline` steps corresponding to work done on creating and 47-- presenting one frame during/after surface aggregation. Covers steps: 48-- * STEP_DRAW_AND_SWAP 49-- * STEP_SURFACE_AGGREGATION 50-- * STEP_SEND_BUFFER_SWAP 51-- * STEP_BUFFER_SWAP_POST_SUBMIT 52-- * STEP_FINISH_BUFFER_SWAP 53-- * STEP_SWAP_BUFFERS_ACK 54CREATE PERFETTO TABLE chrome_graphics_pipeline_display_frame_steps( 55 -- Slice Id of the `Graphics.Pipeline` slice. 56 id LONG, 57 -- The start timestamp of the slice/step. 58 ts TIMESTAMP, 59 -- The duration of the slice/step. 60 dur DURATION, 61 -- Step name of the `Graphics.Pipeline` slice. 62 step STRING, 63 -- Id of the graphics pipeline, post-surface aggregation. 64 display_trace_id LONG, 65 -- Utid of the thread where this slice exists. 66 utid LONG, 67 -- Start time of the parent Chrome scheduler task (if any) of this step. 68 task_start_time_ts TIMESTAMP) 69AS 70SELECT 71 id, 72 ts, 73 dur, 74 extract_arg(arg_set_id, 'chrome_graphics_pipeline.step') AS step, 75 extract_arg(arg_set_id, 'chrome_graphics_pipeline.display_trace_id') 76 AS display_trace_id, 77 utid, 78 ts - (EXTRACT_ARG(thread_slice.arg_set_id, 'current_task.event_offset_from_task_start_time_us') * 1000) AS task_start_time_ts 79FROM thread_slice 80WHERE name = 'Graphics.Pipeline' AND display_trace_id IS NOT NULL; 81 82-- Links surface frames (`chrome_graphics_pipeline_surface_frame_steps`) to the 83-- display frame (`chrome_graphics_pipeline_display_frame_steps`) into which 84-- they are merged. In other words, in general, multiple 85-- `surface_frame_trace_id`s will correspond to one `display_trace_id`. 86CREATE PERFETTO TABLE chrome_graphics_pipeline_aggregated_frames( 87 -- Id of the graphics pipeline, pre-surface aggregation. 88 surface_frame_trace_id LONG, 89 -- Id of the graphics pipeline, post-surface aggregation. 90 display_trace_id LONG) 91AS 92SELECT 93 args.int_value AS surface_frame_trace_id, 94 display_trace_id 95FROM chrome_graphics_pipeline_display_frame_steps step 96JOIN slice 97 USING (id) 98JOIN args 99 USING (arg_set_id) 100WHERE 101 step.step = 'STEP_SURFACE_AGGREGATION' 102 AND args.flat_key 103 = 'chrome_graphics_pipeline.aggregated_surface_frame_trace_ids'; 104 105-- Links inputs (`chrome_input_pipeline_steps.latency_id`) to the surface frame 106-- (`chrome_graphics_pipeline_surface_frame_steps`) to which they correspond. 107-- In other words, in general, multiple `latency_id`s will correspond to one 108-- `surface_frame_trace_id`. 109CREATE PERFETTO TABLE chrome_graphics_pipeline_inputs_to_surface_frames( 110 -- Id corresponding to the input pipeline. 111 latency_id LONG, 112 -- Id of the graphics pipeline, post-surface aggregation. 113 surface_frame_trace_id LONG) 114AS 115SELECT 116 args.int_value AS latency_id, 117 surface_frame_trace_id 118FROM chrome_graphics_pipeline_surface_frame_steps step 119JOIN slice 120 USING (id) 121JOIN args 122 USING (arg_set_id) 123WHERE 124 step.step = 'STEP_SUBMIT_COMPOSITOR_FRAME' 125 AND args.flat_key = 'chrome_graphics_pipeline.latency_ids'; 126