From 8aefef0b385405f689a0eea1e80f1c67f441787c Mon Sep 17 00:00:00 2001 From: Sushil Chauhan Date: Thu, 28 Jun 2018 11:39:01 -0700 Subject: hwc2: Skip SDM prepare for consecutive GPU composed frames Skip SDM prepare, if all the layers in the current draw cycle are marked as Skip and previous draw cycle had GPU Composition, since the resources for GPU Target layer, have already been validated and configured to driver. It avoids unnecessary CPU cycles in Strategy, Resource Manager, DAL, etc. in SDM and the Validate IOCTL in driver. CRs-Fixed: 2269870 Change-Id: I019a13d0eaf08c01d710555ff99f104d2a3d24ce --- sdm/libs/hwc2/hwc_display.cpp | 38 ++++++++++++++++++++++++++++++++++++++ sdm/libs/hwc2/hwc_display.h | 2 ++ 2 files changed, 40 insertions(+) (limited to 'sdm') diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp index 7bc4e734..22097222 100644 --- a/sdm/libs/hwc2/hwc_display.cpp +++ b/sdm/libs/hwc2/hwc_display.cpp @@ -1060,6 +1060,11 @@ HWC2::Error HWCDisplay::PrepareLayerStack(uint32_t *out_num_types, uint32_t *out } UpdateRefreshRate(); + + if (CanSkipSdmPrepare(out_num_types, out_num_requests)) { + return ((*out_num_types > 0) ? HWC2::Error::HasChanges : HWC2::Error::None); + } + if (!skip_prepare_) { DisplayError error = display_intf_->Prepare(&layer_stack_); if (error != kErrorNone) { @@ -2166,4 +2171,37 @@ void HWCDisplay::UpdateRefreshRate() { } } +// Skip SDM prepare if all the layers in the current draw cycle are marked as Skip and +// previous draw cycle had GPU Composition, as the resources for GPU Target layer have +// already been validated and configured to the driver. +bool HWCDisplay::CanSkipSdmPrepare(uint32_t *num_types, uint32_t *num_requests) { + if (!validated_ || layer_set_.empty()) { + return false; + } + + bool skip_prepare = true; + for (auto hwc_layer : layer_set_) { + if (!hwc_layer->GetSDMLayer()->flags.skip || + (hwc_layer->GetDeviceSelectedCompositionType() != HWC2::Composition::Client)) { + skip_prepare = false; + layer_changes_.clear(); + break; + } + if (hwc_layer->GetClientRequestedCompositionType() != HWC2::Composition::Client) { + layer_changes_[hwc_layer->GetId()] = HWC2::Composition::Client; + } + } + + if (skip_prepare) { + *num_types = UINT32(layer_changes_.size()); + *num_requests = 0; + layer_stack_invalid_ = false; + has_client_composition_ = true; + client_target_->ResetValidation(); + validate_state_ = kNormalValidate; + } + + return skip_prepare; +} + } // namespace sdm diff --git a/sdm/libs/hwc2/hwc_display.h b/sdm/libs/hwc2/hwc_display.h index 8cbd6bb9..084a2a5c 100644 --- a/sdm/libs/hwc2/hwc_display.h +++ b/sdm/libs/hwc2/hwc_display.h @@ -345,6 +345,8 @@ class HWCDisplay : public DisplayEventHandler { private: void DumpInputBuffers(void); void UpdateRefreshRate(); + bool CanSkipSdmPrepare(uint32_t *num_types, uint32_t *num_requests); + qService::QService *qservice_ = NULL; DisplayClass display_class_; uint32_t geometry_changes_ = GeometryChanges::kNone; -- cgit v1.2.3