1-- 2-- Copyright 2024 The Android Open Source Project 3-- 4-- Licensed under the Apache License, Version 2.0 (the "License"); 5-- you may not use this file except in compliance with the License. 6-- You may obtain a copy of the License at 7-- 8-- https://www.apache.org/licenses/LICENSE-2.0 9-- 10-- Unless required by applicable law or agreed to in writing, software 11-- distributed under the License is distributed on an "AS IS" BASIS, 12-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13-- See the License for the specific language governing permissions and 14-- limitations under the License. 15-- 16 17INCLUDE PERFETTO MODULE slices.with_context; 18 19-- Break down camera Camera graph execution slices per node, port group, and frame. 20-- This table extracts key identifiers from Camera graph execution slice names and 21-- provides timing information for each processing stage. 22CREATE PERFETTO TABLE pixel_camera_frames ( 23 -- Unique identifier for this slice. 24 id ID(slice.id), 25 -- Start timestamp of the slice. 26 ts TIMESTAMP, 27 -- Duration of the slice execution. 28 dur DURATION, 29 -- Track ID for this slice. 30 track_id JOINID(track.id), 31 -- Thread ID (utid) executing this slice. 32 utid JOINID(thread.id), 33 -- Name of the thread executing this slice. 34 thread_name STRING, 35 -- Name of the processing node in the Camera graph. 36 node STRING, 37 -- Port group name for the node. 38 port_group STRING, 39 -- Frame number being processed. 40 frame_number LONG, 41 -- Camera ID associated with this slice. 42 cam_id LONG 43) AS 44SELECT 45 id, 46 ts, 47 dur, 48 track_id, 49 utid, 50 thread_name, 51 -- Slices follow the pattern "camX_Y:Z (frame N)" where X is the camera ID, 52 -- Y is the node name, Z is the port group, and N is the frame number 53 substr(str_split(name, ':', 0), 6) AS node, 54 str_split(str_split(name, ':', 1), ' (', 0) AS port_group, 55 cast_int!(STR_SPLIT(STR_SPLIT(name, '(frame', 1), ')', 0)) AS frame_number, 56 cast_int!(STR_SPLIT(STR_SPLIT(name, 'cam', 1), '_', 0)) AS cam_id 57FROM thread_slice 58-- Only include slices matching the Camera graph pattern and with valid durations 59WHERE 60 name GLOB 'cam*_*:* (frame *)' AND dur != -1; 61