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 one frame. 20-- There are 3 possible combinations how those functions will be called, i.e.: 21-- 1. HwcPresentOrValidateDisplay and then HwcPresentDisplay 22-- 2. HwcPresentOrValidateDisplay 23-- 3. HwcValidateDisplay and then HwcPresentDisplay 24DROP VIEW IF EXISTS raw_hwc_function_spans; 25CREATE VIEW raw_hwc_function_spans AS 26SELECT 27 id, 28 display_id, 29 name, 30 dur, 31 LEAD(name, 1, '') OVER (PARTITION BY display_id ORDER BY ts) AS next_name, 32 LEAD(dur, 1, 0) OVER (PARTITION BY display_id ORDER BY ts) AS next_dur 33FROM( 34 SELECT 35 id, 36 ts, 37 dur, 38 track_id, 39 CASE 40 WHEN INSTR(name, ' ') = 0 THEN name 41 ELSE SUBSTR(name, 1, INSTR(name, ' ')-1) 42 END AS name, 43 CASE 44 WHEN INSTR(name, ' ') = 0 THEN 'unspecified' 45 ELSE SUBSTR(name, INSTR(name, ' ')+1) 46 END AS display_id 47 FROM slice 48 WHERE name GLOB 'HwcPresentOrValidateDisplay*' OR name GLOB 'HwcValidateDisplay*' 49 OR name GLOB 'HwcPresentDisplay*' 50) 51ORDER BY ts; 52 53DROP VIEW IF EXISTS {{output}}; 54CREATE VIEW {{output}} AS 55SELECT 56 id, 57 display_id, 58 CASE 59 WHEN name = 'HwcValidateDisplay' AND next_name = 'HwcPresentDisplay' THEN dur + next_dur 60 WHEN name = 'HwcPresentOrValidateDisplay' AND next_name = 'HwcPresentDisplay' THEN dur + next_dur 61 WHEN name = 'HwcPresentOrValidateDisplay' AND next_name != 'HwcPresentDisplay' THEN dur 62 ELSE 0 63 END AS execution_time_ns, 64 CASE 65 WHEN name = 'HwcValidateDisplay' AND next_name = 'HwcPresentDisplay' THEN 'separated_validation' 66 WHEN name = 'HwcPresentOrValidateDisplay' AND next_name = 'HwcPresentDisplay' THEN 'unskipped_validation' 67 WHEN name = 'HwcPresentOrValidateDisplay' AND next_name != 'HwcPresentDisplay' THEN 'skipped_validation' 68 ELSE 'unknown' 69 END AS validation_type 70FROM raw_hwc_function_spans 71WHERE (name = 'HwcValidateDisplay' OR name = 'HwcPresentOrValidateDisplay'); 72