Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 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 | * http://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 | #include "PhaseOffsets.h" |
| 18 | |
| 19 | #include <cutils/properties.h> |
| 20 | |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 21 | #include <optional> |
| 22 | |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 23 | #include "SurfaceFlingerProperties.h" |
| 24 | |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 25 | namespace { |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 26 | |
Dominik Laskowski | f83570c | 2019-08-26 12:04:07 -0700 | [diff] [blame] | 27 | std::optional<nsecs_t> getProperty(const char* name) { |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 28 | char value[PROPERTY_VALUE_MAX]; |
| 29 | property_get(name, value, "-1"); |
| 30 | if (const int i = atoi(value); i != -1) return i; |
| 31 | return std::nullopt; |
| 32 | } |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 33 | |
Ady Abraham | 090d42c | 2020-01-08 12:08:11 -0800 | [diff] [blame] | 34 | bool fpsEqualsWithMargin(float fpsA, float fpsB) { |
| 35 | static constexpr float MARGIN = 0.01f; |
| 36 | return std::abs(fpsA - fpsB) <= MARGIN; |
| 37 | } |
| 38 | |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 39 | } // namespace |
| 40 | |
| 41 | namespace android::scheduler { |
| 42 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 43 | PhaseConfiguration::~PhaseConfiguration() = default; |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 44 | |
| 45 | namespace impl { |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 46 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 47 | PhaseOffsets::PhaseOffsets(const scheduler::RefreshRateConfigs& refreshRateConfigs) |
| 48 | : // Below defines the threshold when an offset is considered to be negative, i.e. targeting |
| 49 | // for the N+2 vsync instead of N+1. This means that: |
| 50 | // For offset < threshold, SF wake up (vsync_duration - offset) before HW vsync. |
| 51 | // For offset >= threshold, SF wake up (2 * vsync_duration - offset) before HW vsync. |
| 52 | mThresholdForNextVsync(getProperty("debug.sf.phase_offset_threshold_for_next_vsync_ns") |
| 53 | .value_or(std::numeric_limits<nsecs_t>::max())), |
| 54 | mOffsets(initializeOffsets(refreshRateConfigs)), |
| 55 | mRefreshRateFps(refreshRateConfigs.getCurrentRefreshRate().fps) {} |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 56 | |
| 57 | void PhaseOffsets::dump(std::string& result) const { |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 58 | const auto [early, earlyGl, late] = getCurrentOffsets(); |
Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 59 | using base::StringAppendF; |
| 60 | StringAppendF(&result, |
| 61 | " app phase: %9" PRId64 " ns\t SF phase: %9" PRId64 " ns\n" |
| 62 | " early app phase: %9" PRId64 " ns\t early SF phase: %9" PRId64 " ns\n" |
| 63 | " GL early app phase: %9" PRId64 " ns\tGL early SF phase: %9" PRId64 " ns\n" |
| 64 | "next VSYNC threshold: %9" PRId64 " ns\n", |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 65 | late.app, late.sf, early.app, early.sf, earlyGl.app, earlyGl.sf, |
| 66 | mThresholdForNextVsync); |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 67 | } |
| 68 | |
Ady Abraham | 090d42c | 2020-01-08 12:08:11 -0800 | [diff] [blame] | 69 | std::unordered_map<float, PhaseOffsets::Offsets> PhaseOffsets::initializeOffsets( |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 70 | const scheduler::RefreshRateConfigs& refreshRateConfigs) const { |
Ady Abraham | 090d42c | 2020-01-08 12:08:11 -0800 | [diff] [blame] | 71 | std::unordered_map<float, Offsets> offsets; |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 72 | |
| 73 | for (const auto& [ignored, refreshRate] : refreshRateConfigs.getAllRefreshRates()) { |
Sushil Chauhan | bdb9e6d | 2020-03-19 16:15:46 -0700 | [diff] [blame^] | 74 | const float fps = refreshRate->fps; |
| 75 | offsets.emplace(fps, getPhaseOffsets(fps, refreshRate->vsyncPeriod)); |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 76 | } |
| 77 | return offsets; |
| 78 | } |
| 79 | |
Sushil Chauhan | bdb9e6d | 2020-03-19 16:15:46 -0700 | [diff] [blame^] | 80 | PhaseOffsets::Offsets PhaseOffsets::getPhaseOffsets(float fps, nsecs_t vsyncPeriod) const { |
| 81 | if (fps > 65.0f) { |
| 82 | return getHighFpsOffsets(vsyncPeriod); |
| 83 | } else { |
| 84 | return getDefaultOffsets(vsyncPeriod); |
| 85 | } |
| 86 | } |
| 87 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 88 | PhaseOffsets::Offsets PhaseOffsets::getDefaultOffsets(nsecs_t vsyncDuration) const { |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 89 | const int64_t vsyncPhaseOffsetNs = sysprop::vsync_event_phase_offset_ns(1000000); |
| 90 | const int64_t sfVsyncPhaseOffsetNs = sysprop::vsync_sf_event_phase_offset_ns(1000000); |
| 91 | |
| 92 | const auto earlySfOffsetNs = getProperty("debug.sf.early_phase_offset_ns"); |
| 93 | const auto earlyGlSfOffsetNs = getProperty("debug.sf.early_gl_phase_offset_ns"); |
| 94 | const auto earlyAppOffsetNs = getProperty("debug.sf.early_app_phase_offset_ns"); |
| 95 | const auto earlyGlAppOffsetNs = getProperty("debug.sf.early_gl_app_phase_offset_ns"); |
| 96 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 97 | return { |
| 98 | { |
| 99 | earlySfOffsetNs.value_or(sfVsyncPhaseOffsetNs) < mThresholdForNextVsync |
| 100 | ? earlySfOffsetNs.value_or(sfVsyncPhaseOffsetNs) |
| 101 | : earlySfOffsetNs.value_or(sfVsyncPhaseOffsetNs) - vsyncDuration, |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 102 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 103 | earlyAppOffsetNs.value_or(vsyncPhaseOffsetNs), |
| 104 | }, |
| 105 | { |
| 106 | earlyGlSfOffsetNs.value_or(sfVsyncPhaseOffsetNs) < mThresholdForNextVsync |
| 107 | ? earlyGlSfOffsetNs.value_or(sfVsyncPhaseOffsetNs) |
| 108 | : earlyGlSfOffsetNs.value_or(sfVsyncPhaseOffsetNs) - vsyncDuration, |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 109 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 110 | earlyGlAppOffsetNs.value_or(vsyncPhaseOffsetNs), |
| 111 | }, |
| 112 | { |
| 113 | sfVsyncPhaseOffsetNs < mThresholdForNextVsync |
| 114 | ? sfVsyncPhaseOffsetNs |
| 115 | : sfVsyncPhaseOffsetNs - vsyncDuration, |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 116 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 117 | vsyncPhaseOffsetNs, |
| 118 | }, |
| 119 | }; |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 120 | } |
| 121 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 122 | PhaseOffsets::Offsets PhaseOffsets::getHighFpsOffsets(nsecs_t vsyncDuration) const { |
Ady Abraham | dec1a41 | 2020-01-24 10:23:50 -0800 | [diff] [blame] | 123 | const auto highFpsLateAppOffsetNs = |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 124 | getProperty("debug.sf.high_fps_late_app_phase_offset_ns").value_or(2000000); |
Ady Abraham | dec1a41 | 2020-01-24 10:23:50 -0800 | [diff] [blame] | 125 | const auto highFpsLateSfOffsetNs = |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 126 | getProperty("debug.sf.high_fps_late_sf_phase_offset_ns").value_or(1000000); |
| 127 | |
| 128 | const auto highFpsEarlySfOffsetNs = getProperty("debug.sf.high_fps_early_phase_offset_ns"); |
| 129 | const auto highFpsEarlyGlSfOffsetNs = getProperty("debug.sf.high_fps_early_gl_phase_offset_ns"); |
| 130 | const auto highFpsEarlyAppOffsetNs = getProperty("debug.sf.high_fps_early_app_phase_offset_ns"); |
| 131 | const auto highFpsEarlyGlAppOffsetNs = |
| 132 | getProperty("debug.sf.high_fps_early_gl_app_phase_offset_ns"); |
| 133 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 134 | return { |
| 135 | { |
| 136 | highFpsEarlySfOffsetNs.value_or(highFpsLateSfOffsetNs) < mThresholdForNextVsync |
| 137 | ? highFpsEarlySfOffsetNs.value_or(highFpsLateSfOffsetNs) |
| 138 | : highFpsEarlySfOffsetNs.value_or(highFpsLateSfOffsetNs) - |
| 139 | vsyncDuration, |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 140 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 141 | highFpsEarlyAppOffsetNs.value_or(highFpsLateAppOffsetNs), |
| 142 | }, |
| 143 | { |
| 144 | highFpsEarlyGlSfOffsetNs.value_or(highFpsLateSfOffsetNs) < |
| 145 | mThresholdForNextVsync |
| 146 | ? highFpsEarlyGlSfOffsetNs.value_or(highFpsLateSfOffsetNs) |
| 147 | : highFpsEarlyGlSfOffsetNs.value_or(highFpsLateSfOffsetNs) - |
| 148 | vsyncDuration, |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 149 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 150 | highFpsEarlyGlAppOffsetNs.value_or(highFpsLateAppOffsetNs), |
| 151 | }, |
| 152 | { |
| 153 | highFpsLateSfOffsetNs < mThresholdForNextVsync |
| 154 | ? highFpsLateSfOffsetNs |
| 155 | : highFpsLateSfOffsetNs - vsyncDuration, |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 156 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 157 | highFpsLateAppOffsetNs, |
| 158 | }, |
| 159 | }; |
| 160 | } |
| 161 | |
Ady Abraham | 090d42c | 2020-01-08 12:08:11 -0800 | [diff] [blame] | 162 | PhaseOffsets::Offsets PhaseOffsets::getOffsetsForRefreshRate(float fps) const { |
| 163 | const auto iter = std::find_if(mOffsets.begin(), mOffsets.end(), |
| 164 | [&fps](const std::pair<float, Offsets>& candidateFps) { |
| 165 | return fpsEqualsWithMargin(fps, candidateFps.first); |
| 166 | }); |
Sushil Chauhan | bdb9e6d | 2020-03-19 16:15:46 -0700 | [diff] [blame^] | 167 | |
| 168 | if (iter != mOffsets.end()) { |
| 169 | return iter->second; |
| 170 | } |
| 171 | |
| 172 | // Unknown refresh rate. This might happen if we get a hotplug event for an external display. |
| 173 | // In this case just construct the offset. |
| 174 | ALOGW("Can't find offset for %.2f fps", fps); |
| 175 | return getPhaseOffsets(fps, static_cast<nsecs_t>(1e9f / fps)); |
Ady Abraham | 090d42c | 2020-01-08 12:08:11 -0800 | [diff] [blame] | 176 | } |
| 177 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 178 | static void validateSysprops() { |
| 179 | const auto validatePropertyBool = [](const char* prop) { |
| 180 | LOG_ALWAYS_FATAL_IF(!property_get_bool(prop, false), "%s is false", prop); |
| 181 | }; |
| 182 | |
| 183 | validatePropertyBool("debug.sf.use_phase_offsets_as_durations"); |
| 184 | |
| 185 | LOG_ALWAYS_FATAL_IF(sysprop::vsync_event_phase_offset_ns(-1) != -1, |
| 186 | "ro.surface_flinger.vsync_event_phase_offset_ns is set but expecting " |
| 187 | "duration"); |
| 188 | |
| 189 | LOG_ALWAYS_FATAL_IF(sysprop::vsync_sf_event_phase_offset_ns(-1) != -1, |
| 190 | "ro.surface_flinger.vsync_sf_event_phase_offset_ns is set but expecting " |
| 191 | "duration"); |
| 192 | |
| 193 | const auto validateProperty = [](const char* prop) { |
| 194 | LOG_ALWAYS_FATAL_IF(getProperty(prop).has_value(), |
| 195 | "%s is set to %" PRId64 " but expecting duration", prop, |
| 196 | getProperty(prop).value_or(-1)); |
| 197 | }; |
| 198 | |
| 199 | validateProperty("debug.sf.early_phase_offset_ns"); |
| 200 | validateProperty("debug.sf.early_gl_phase_offset_ns"); |
| 201 | validateProperty("debug.sf.early_app_phase_offset_ns"); |
| 202 | validateProperty("debug.sf.early_gl_app_phase_offset_ns"); |
| 203 | validateProperty("debug.sf.high_fps_late_app_phase_offset_ns"); |
| 204 | validateProperty("debug.sf.high_fps_late_sf_phase_offset_ns"); |
| 205 | validateProperty("debug.sf.high_fps_early_phase_offset_ns"); |
| 206 | validateProperty("debug.sf.high_fps_early_gl_phase_offset_ns"); |
| 207 | validateProperty("debug.sf.high_fps_early_app_phase_offset_ns"); |
| 208 | validateProperty("debug.sf.high_fps_early_gl_app_phase_offset_ns"); |
| 209 | } |
| 210 | |
| 211 | static nsecs_t sfDurationToOffset(nsecs_t sfDuration, nsecs_t vsyncDuration) { |
| 212 | return sfDuration == -1 ? 1'000'000 : vsyncDuration - sfDuration % vsyncDuration; |
| 213 | } |
| 214 | |
| 215 | static nsecs_t appDurationToOffset(nsecs_t appDuration, nsecs_t sfDuration, nsecs_t vsyncDuration) { |
| 216 | return sfDuration == -1 ? 1'000'000 |
| 217 | : vsyncDuration - (appDuration + sfDuration) % vsyncDuration; |
| 218 | } |
| 219 | |
Ady Abraham | dfa3736 | 2020-01-21 18:02:39 -0800 | [diff] [blame] | 220 | PhaseDurations::Offsets PhaseDurations::constructOffsets(nsecs_t vsyncDuration) const { |
| 221 | return Offsets{ |
| 222 | { |
| 223 | mSfEarlyDuration < vsyncDuration |
| 224 | ? sfDurationToOffset(mSfEarlyDuration, vsyncDuration) |
| 225 | : sfDurationToOffset(mSfEarlyDuration, vsyncDuration) - vsyncDuration, |
| 226 | |
| 227 | appDurationToOffset(mAppEarlyDuration, mSfEarlyDuration, vsyncDuration), |
| 228 | }, |
| 229 | { |
| 230 | mSfEarlyGlDuration < vsyncDuration |
| 231 | ? sfDurationToOffset(mSfEarlyGlDuration, vsyncDuration) |
| 232 | : sfDurationToOffset(mSfEarlyGlDuration, vsyncDuration) - vsyncDuration, |
| 233 | |
| 234 | appDurationToOffset(mAppEarlyGlDuration, mSfEarlyGlDuration, vsyncDuration), |
| 235 | }, |
| 236 | { |
| 237 | mSfDuration < vsyncDuration |
| 238 | ? sfDurationToOffset(mSfDuration, vsyncDuration) |
| 239 | : sfDurationToOffset(mSfDuration, vsyncDuration) - vsyncDuration, |
| 240 | |
| 241 | appDurationToOffset(mAppDuration, mSfDuration, vsyncDuration), |
| 242 | }, |
| 243 | }; |
| 244 | } |
| 245 | |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 246 | static std::vector<float> getRefreshRatesFromConfigs( |
| 247 | const android::scheduler::RefreshRateConfigs& refreshRateConfigs) { |
| 248 | const auto& allRefreshRates = refreshRateConfigs.getAllRefreshRates(); |
| 249 | std::vector<float> refreshRates; |
| 250 | refreshRates.reserve(allRefreshRates.size()); |
| 251 | |
| 252 | for (const auto& [ignored, refreshRate] : allRefreshRates) { |
Ady Abraham | 2e1dd89 | 2020-03-05 13:48:36 -0800 | [diff] [blame] | 253 | refreshRates.emplace_back(refreshRate->fps); |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | return refreshRates; |
| 257 | } |
| 258 | |
| 259 | std::unordered_map<float, PhaseDurations::Offsets> PhaseDurations::initializeOffsets( |
| 260 | const std::vector<float>& refreshRates) const { |
Ady Abraham | 090d42c | 2020-01-08 12:08:11 -0800 | [diff] [blame] | 261 | std::unordered_map<float, Offsets> offsets; |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 262 | |
| 263 | for (const auto fps : refreshRates) { |
Ady Abraham | dfa3736 | 2020-01-21 18:02:39 -0800 | [diff] [blame] | 264 | offsets.emplace(fps, constructOffsets(static_cast<nsecs_t>(1e9f / fps))); |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 265 | } |
| 266 | return offsets; |
| 267 | } |
| 268 | |
| 269 | PhaseDurations::PhaseDurations(const scheduler::RefreshRateConfigs& refreshRateConfigs) |
| 270 | : PhaseDurations(getRefreshRatesFromConfigs(refreshRateConfigs), |
| 271 | refreshRateConfigs.getCurrentRefreshRate().fps, |
| 272 | getProperty("debug.sf.late.sf.duration").value_or(-1), |
| 273 | getProperty("debug.sf.late.app.duration").value_or(-1), |
| 274 | getProperty("debug.sf.early.sf.duration").value_or(mSfDuration), |
| 275 | getProperty("debug.sf.early.app.duration").value_or(mAppDuration), |
| 276 | getProperty("debug.sf.earlyGl.sf.duration").value_or(mSfDuration), |
| 277 | getProperty("debug.sf.earlyGl.app.duration").value_or(mAppDuration)) { |
| 278 | validateSysprops(); |
| 279 | } |
| 280 | |
| 281 | PhaseDurations::PhaseDurations(const std::vector<float>& refreshRates, float currentFps, |
| 282 | nsecs_t sfDuration, nsecs_t appDuration, nsecs_t sfEarlyDuration, |
| 283 | nsecs_t appEarlyDuration, nsecs_t sfEarlyGlDuration, |
| 284 | nsecs_t appEarlyGlDuration) |
| 285 | : mSfDuration(sfDuration), |
| 286 | mAppDuration(appDuration), |
| 287 | mSfEarlyDuration(sfEarlyDuration), |
| 288 | mAppEarlyDuration(appEarlyDuration), |
| 289 | mSfEarlyGlDuration(sfEarlyGlDuration), |
| 290 | mAppEarlyGlDuration(appEarlyGlDuration), |
| 291 | mOffsets(initializeOffsets(refreshRates)), |
| 292 | mRefreshRateFps(currentFps) {} |
| 293 | |
| 294 | PhaseOffsets::Offsets PhaseDurations::getOffsetsForRefreshRate(float fps) const { |
Ady Abraham | 090d42c | 2020-01-08 12:08:11 -0800 | [diff] [blame] | 295 | const auto iter = std::find_if(mOffsets.begin(), mOffsets.end(), [=](const auto& candidateFps) { |
| 296 | return fpsEqualsWithMargin(fps, candidateFps.first); |
| 297 | }); |
Ady Abraham | dfa3736 | 2020-01-21 18:02:39 -0800 | [diff] [blame] | 298 | |
| 299 | if (iter != mOffsets.end()) { |
| 300 | return iter->second; |
| 301 | } |
| 302 | |
Sushil Chauhan | bdb9e6d | 2020-03-19 16:15:46 -0700 | [diff] [blame^] | 303 | // Unknown refresh rate. This might happen if we get a hotplug event for an external display. |
Ady Abraham | dfa3736 | 2020-01-21 18:02:39 -0800 | [diff] [blame] | 304 | // In this case just construct the offset. |
| 305 | ALOGW("Can't find offset for %.2f fps", fps); |
| 306 | return constructOffsets(static_cast<nsecs_t>(1e9f / fps)); |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | void PhaseDurations::dump(std::string& result) const { |
| 310 | const auto [early, earlyGl, late] = getCurrentOffsets(); |
| 311 | using base::StringAppendF; |
| 312 | StringAppendF(&result, |
| 313 | " app phase: %9" PRId64 " ns\t SF phase: %9" PRId64 |
| 314 | " ns\n" |
| 315 | " app duration: %9" PRId64 " ns\t SF duration: %9" PRId64 |
| 316 | " ns\n" |
| 317 | " early app phase: %9" PRId64 " ns\t early SF phase: %9" PRId64 |
| 318 | " ns\n" |
| 319 | " early app duration: %9" PRId64 " ns\t early SF duration: %9" PRId64 |
| 320 | " ns\n" |
| 321 | " GL early app phase: %9" PRId64 " ns\tGL early SF phase: %9" PRId64 |
| 322 | " ns\n" |
| 323 | " GL early app duration: %9" PRId64 " ns\tGL early SF duration: %9" PRId64 |
| 324 | " ns\n", |
| 325 | late.app, |
| 326 | |
| 327 | late.sf, |
| 328 | |
| 329 | mAppDuration, mSfDuration, |
| 330 | |
| 331 | early.app, early.sf, |
| 332 | |
| 333 | mAppEarlyDuration, mSfEarlyDuration, |
| 334 | |
| 335 | earlyGl.app, |
| 336 | |
| 337 | earlyGl.sf, |
| 338 | |
| 339 | mAppEarlyGlDuration, mSfEarlyGlDuration); |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | } // namespace impl |
Dominik Laskowski | eddeda1 | 2019-07-19 11:54:13 -0700 | [diff] [blame] | 343 | } // namespace android::scheduler |