1-- 2-- Copyright 2021 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 17-- The HWC execution time will be calculated based on the runtime of 18-- HwcPresentOrValidateDisplay, HwcValidateDisplay, and/or HwcPresentDisplay 19-- which are happened in the same onMessageRefresh. 20-- There are 3 possible combinations how those functions will be called in 21-- a single onMessageRefresh, i.e.: 22-- 1. HwcPresentOrValidateDisplay and then HwcPresentDisplay 23-- 2. HwcPresentOrValidateDisplay 24-- 3. HwcValidateDisplay and then HwcPresentDisplay 25DROP VIEW IF EXISTS raw_hwc_function_spans; 26CREATE VIEW raw_hwc_function_spans AS 27SELECT 28 id, 29 name, 30 ts AS begin_ts, 31 ts+dur AS end_ts, 32 dur, 33 LEAD(name, 1, '') OVER (PARTITION BY track_id ORDER BY ts) AS next_name, 34 LEAD(ts, 1, 0) OVER (PARTITION BY track_id ORDER BY ts) AS next_ts, 35 LEAD(dur, 1, 0) OVER (PARTITION BY track_id ORDER BY ts) AS next_dur, 36 LEAD(name, 2, '') OVER (PARTITION BY track_id ORDER BY ts) AS second_next_name, 37 LEAD(ts, 2, 0) OVER (PARTITION BY track_id ORDER BY ts) AS second_next_ts, 38 LEAD(dur, 2, 0) OVER (PARTITION BY track_id ORDER BY ts) AS second_next_dur 39FROM slice 40WHERE name = 'HwcPresentOrValidateDisplay' OR name = 'HwcValidateDisplay' 41 OR name = 'HwcPresentDisplay' OR name = 'onMessageRefresh' 42ORDER BY ts; 43 44DROP VIEW IF EXISTS {{output}}; 45CREATE VIEW {{output}} AS 46SELECT 47 id, 48 CASE 49 WHEN begin_ts <= next_ts AND next_ts <= end_ts THEN 50 CASE 51 WHEN begin_ts <= second_next_ts AND second_next_ts <= end_ts 52 THEN next_dur + second_next_dur 53 ELSE next_dur 54 END 55 ELSE 0 56 END AS execution_time_ns, 57 CASE 58 WHEN next_name = 'HwcPresentOrValidateDisplay' 59 AND second_next_name = 'HwcPresentDisplay' THEN 'unskipped_validation' 60 WHEN next_name = 'HwcPresentOrValidateDisplay' 61 AND second_next_name != 'HwcPresentDisplay' THEN 'skipped_validation' 62 WHEN next_name = 'HwcValidateDisplay' 63 AND second_next_name = 'HwcPresentDisplay' THEN 'separated_validation' 64 ELSE 'unknown' 65 END AS validation_type 66FROM raw_hwc_function_spans 67WHERE name = 'onMessageRefresh' AND dur > 0; 68