Consolidate stats collection within HwcDisplay
This change moves all modifications to the total_stats_ property out of the Backend. HwcDisplay becomes responsible for updating its own stats based on the results of validating and presenting a composition. Change-Id: I54ff8c2c8f6ad983ef583e60e2e77cf8b7866e9b
This commit is contained in:
parent
b393389438
commit
09c7c9f875
3 changed files with 31 additions and 26 deletions
|
|
@ -48,10 +48,13 @@ auto Backend::ValidateDisplay(HwcDisplay* display) -> ValidatedComposition {
|
|||
|
||||
const FlatteningController* flatcon = display->GetFlatCon();
|
||||
if (flatcon != nullptr && flatcon->ShouldFlatten()) {
|
||||
display->total_stats().frames_flattened++;
|
||||
return GetFlattenedComposition(layers, FlattenReason::kStaticScene);
|
||||
}
|
||||
|
||||
if (display->CtmByGpu()) {
|
||||
return GetFlattenedComposition(layers, FlattenReason::kCtmWithOffset);
|
||||
}
|
||||
|
||||
bool use_cursor_plane = false;
|
||||
const auto* cursor_layer = GetCursorLayer(layers);
|
||||
auto cursor_plane = display->GetPipe().GetUsablePlanes().second;
|
||||
|
|
@ -109,25 +112,15 @@ auto Backend::ValidateDisplay(HwcDisplay* display) -> ValidatedComposition {
|
|||
|
||||
// Final fallback: convert all layers to client composition.
|
||||
if (!success) {
|
||||
++display->total_stats().failed_kms_validate;
|
||||
validated_composition = GetFlattenedComposition(layers,
|
||||
FlattenReason::
|
||||
kValidateFailed);
|
||||
if (use_cursor_plane) {
|
||||
use_cursor_plane = false;
|
||||
validated_composition.cursor_plane_validated = false;
|
||||
++display->total_stats().failed_kms_cursor_validate;
|
||||
}
|
||||
} else if (display->CtmByGpu()) {
|
||||
validated_composition.flatten_reason = FlattenReason::kCtmWithOffset;
|
||||
}
|
||||
|
||||
display->total_stats().gpu_pixops += CalcPixOps(validated_composition);
|
||||
display->total_stats().total_pixops += CalcPixOps(layers, 0, layers.size());
|
||||
if (use_cursor_plane) {
|
||||
validated_composition.cursor_plane_validated = true;
|
||||
++display->total_stats().cursor_plane_frames;
|
||||
validated_composition.cursor_plane_validated = success;
|
||||
}
|
||||
|
||||
return validated_composition;
|
||||
}
|
||||
|
||||
|
|
@ -170,18 +163,6 @@ bool Backend::HardwareSupportsLayerType(CompositionType comp_type) {
|
|||
comp_type == CompositionType::kCursor;
|
||||
}
|
||||
|
||||
uint32_t Backend::CalcPixOps(
|
||||
const ValidatedComposition& validated_composition) {
|
||||
uint32_t pixops = 0;
|
||||
for (const auto& [layer, comp_type] :
|
||||
validated_composition.composition_types) {
|
||||
if (comp_type == CompositionType::kClient) {
|
||||
pixops += layer->GetPixOps();
|
||||
}
|
||||
}
|
||||
return pixops;
|
||||
}
|
||||
|
||||
uint32_t Backend::CalcPixOps(const std::vector<const HwcLayer*>& layers,
|
||||
size_t first_z, size_t size) {
|
||||
uint32_t pixops = 0;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ class Backend {
|
|||
static ValidatedComposition GetFlattenedComposition(
|
||||
const std::vector<const HwcLayer*>& layers, FlattenReason flatten_reason);
|
||||
static bool HardwareSupportsLayerType(CompositionType comp_type);
|
||||
static uint32_t CalcPixOps(const ValidatedComposition& validated_composition);
|
||||
static uint32_t CalcPixOps(const std::vector<const HwcLayer*>& layers,
|
||||
size_t first_z, size_t size);
|
||||
static CompositionTypeMap GetCompositionTypes(
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include "HwcDisplay.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <sstream>
|
||||
|
||||
#include <ui/ColorSpace.h>
|
||||
#include <utils/Trace.h>
|
||||
|
|
@ -36,6 +37,8 @@ using ColorGamut = ::android::ColorSpace;
|
|||
|
||||
namespace android::drm_hwcomposer {
|
||||
|
||||
using FlattenReason = Backend::FlattenReason;
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr auto kFlatteningTimeout = 1s;
|
||||
|
|
@ -340,6 +343,22 @@ auto HwcDisplay::ValidateStagedComposition() -> std::vector<ChangedLayer> {
|
|||
|
||||
validated_composition_.emplace(backend_->ValidateDisplay(this));
|
||||
|
||||
if (validated_composition_->flatten_reason ==
|
||||
FlattenReason::kValidateFailed) {
|
||||
++total_stats_.failed_kms_validate;
|
||||
} else if (validated_composition_->flatten_reason ==
|
||||
FlattenReason::kStaticScene) {
|
||||
++total_stats_.frames_flattened;
|
||||
}
|
||||
|
||||
if (validated_composition_->cursor_plane_validated.has_value()) {
|
||||
if (validated_composition_->cursor_plane_validated.value()) {
|
||||
++total_stats_.cursor_plane_frames;
|
||||
} else {
|
||||
++total_stats_.failed_kms_cursor_validate;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through the layers to find which layers actually changed.
|
||||
std::vector<ChangedLayer> changed_layers;
|
||||
for (auto &[id, layer] : layers_) {
|
||||
|
|
@ -353,7 +372,13 @@ auto HwcDisplay::ValidateStagedComposition() -> std::vector<ChangedLayer> {
|
|||
if (layer.IsTypeChanged()) {
|
||||
changed_layers.emplace_back(id, layer.GetValidatedType());
|
||||
}
|
||||
|
||||
total_stats_.total_pixops += layer.GetPixOps();
|
||||
if (layer.GetValidatedType() == CompositionType::kClient) {
|
||||
total_stats_.gpu_pixops += layer.GetPixOps();
|
||||
}
|
||||
}
|
||||
|
||||
return changed_layers;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue