drm_hwcomposer: Move pixops calculation
This change moves the pixops calculation into HwcLayer. This simplifies the logic to determine the total pixops over the client range performed within Backend. This change also moves the display size calculation into HwcDisplay. Change-Id: Id7e12657a512db3aaea98d88833c818c10efef66
This commit is contained in:
parent
2261f81762
commit
3ceb722bc9
6 changed files with 30 additions and 30 deletions
|
|
@ -40,16 +40,6 @@ const HwcLayer* GetCursorLayer(const std::vector<const HwcLayer*>& layers) {
|
|||
return *it;
|
||||
}
|
||||
|
||||
std::pair<uint32_t, uint32_t> GetDisplaySize(const HwcDisplay *display) {
|
||||
const auto *config = display->GetNextConfig();
|
||||
if (config == nullptr) {
|
||||
return std::make_pair(0, 0);
|
||||
}
|
||||
|
||||
return std::make_pair(config->mode.GetRawMode().hdisplay,
|
||||
config->mode.GetRawMode().vdisplay);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
auto Backend::ValidateDisplay(HwcDisplay* display) -> ValidatedComposition {
|
||||
|
|
@ -113,10 +103,8 @@ auto Backend::ValidateDisplay(HwcDisplay* display) -> ValidatedComposition {
|
|||
}
|
||||
|
||||
display->total_stats().gpu_pixops += CalcPixOps(layers, client_start,
|
||||
client_size,
|
||||
GetDisplaySize(display));
|
||||
display->total_stats().total_pixops += CalcPixOps(layers, 0, layers.size(),
|
||||
GetDisplaySize(display));
|
||||
client_size);
|
||||
display->total_stats().total_pixops += CalcPixOps(layers, 0, layers.size());
|
||||
if (use_cursor_plane) {
|
||||
++display->total_stats().cursor_plane_frames;
|
||||
}
|
||||
|
|
@ -162,22 +150,13 @@ bool Backend::HardwareSupportsLayerType(CompositionType comp_type) {
|
|||
}
|
||||
|
||||
uint32_t Backend::CalcPixOps(const std::vector<const HwcLayer*>& layers,
|
||||
size_t first_z, size_t size,
|
||||
std::pair<uint32_t, uint32_t> display_size) {
|
||||
uint32_t whole_display = display_size.first * display_size.second;
|
||||
size_t first_z, size_t size) {
|
||||
uint32_t pixops = 0;
|
||||
ALOGE_IF(first_z + size > layers.size(),
|
||||
"CalcPixOps provided range outside of layers");
|
||||
for (size_t z_order = first_z;
|
||||
z_order < std::min(first_z + size, layers.size()); ++z_order) {
|
||||
const auto* layer = layers[z_order];
|
||||
const auto& df = layer->GetLayerData().pi.display_frame;
|
||||
if (df.i_rect.has_value()) {
|
||||
pixops += df.i_rect->Width() * df.i_rect->Height();
|
||||
} else {
|
||||
// nullopt frame rect means whole display.
|
||||
pixops += whole_display;
|
||||
}
|
||||
pixops += layers[z_order]->GetPixOps();
|
||||
}
|
||||
return pixops;
|
||||
}
|
||||
|
|
@ -255,8 +234,7 @@ std::tuple<size_t, size_t> Backend::GetExtraClientRange(
|
|||
// fewest GPU pixops.
|
||||
uint32_t gpu_pixops = UINT32_MAX;
|
||||
for (size_t i = 0; i < steps; i++) {
|
||||
const uint32_t po = CalcPixOps(layers, start + i, client_size,
|
||||
GetDisplaySize(display));
|
||||
const uint32_t po = CalcPixOps(layers, start + i, client_size);
|
||||
if (po < gpu_pixops) {
|
||||
gpu_pixops = po;
|
||||
client_start = start + i;
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ class Backend {
|
|||
const std::vector<const HwcLayer*>& layers);
|
||||
static bool HardwareSupportsLayerType(CompositionType comp_type);
|
||||
static uint32_t CalcPixOps(const std::vector<const HwcLayer*>& layers,
|
||||
size_t first_z, size_t size,
|
||||
std::pair<uint32_t, uint32_t> display_size);
|
||||
size_t first_z, size_t size);
|
||||
static CompositionTypeMap GetCompositionTypes(
|
||||
const std::vector<const HwcLayer*>& layers, size_t client_first_z,
|
||||
size_t client_size, bool use_cursor_plane);
|
||||
|
|
|
|||
|
|
@ -1069,7 +1069,7 @@ void HwcDisplay::SetHdrOutputMetadata(ui::Hdr type) {
|
|||
m->eotf = 3; // HLG
|
||||
break;
|
||||
default:
|
||||
ALOGW("HDR type %d is not supported.", type);
|
||||
ALOGW("HDR type %d is not supported.", static_cast<int>(type));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1176,4 +1176,13 @@ void HwcDisplay::SetConfigGroupsForActiveConfig() {
|
|||
configs_.SanitizeGroups();
|
||||
}
|
||||
|
||||
std::pair<uint32_t, uint32_t> HwcDisplay::GetSize() const {
|
||||
const auto *config = GetNextConfig();
|
||||
if (config == nullptr) {
|
||||
return std::make_pair(0, 0);
|
||||
}
|
||||
return std::make_pair(config->mode.GetRawMode().hdisplay,
|
||||
config->mode.GetRawMode().vdisplay);
|
||||
}
|
||||
|
||||
} // namespace android::drm_hwcomposer
|
||||
|
|
|
|||
|
|
@ -232,6 +232,8 @@ class HwcDisplay {
|
|||
|
||||
bool NeedsClientLayerUpdate() const;
|
||||
|
||||
std::pair<uint32_t, uint32_t> GetSize() const;
|
||||
|
||||
private:
|
||||
// Create AtomicCommitArgs to commit at the next vsync. Returns nullopt if
|
||||
// such AtomicCommitArgs cannot be created due to lack of drm resources or
|
||||
|
|
|
|||
|
|
@ -132,4 +132,12 @@ bool HwcLayer::IsLayerUsableAsDevice() const {
|
|||
return it->second.fb != nullptr;
|
||||
}
|
||||
|
||||
uint32_t HwcLayer::GetPixOps() const {
|
||||
const auto& df = GetLayerData().pi.display_frame;
|
||||
if (df.i_rect.has_value()) {
|
||||
return df.i_rect->Width() * df.i_rect->Height();
|
||||
}
|
||||
return parent_->GetSize().first * parent_->GetSize().second;
|
||||
}
|
||||
|
||||
} // namespace android::drm_hwcomposer
|
||||
|
|
|
|||
|
|
@ -106,6 +106,10 @@ class HwcLayer {
|
|||
frontend_private_data_ = std::move(data);
|
||||
}
|
||||
|
||||
// Returns the number of pixel operations this layer would require if it were
|
||||
// client-composited.
|
||||
uint32_t GetPixOps() const;
|
||||
|
||||
private:
|
||||
// sf_type_ stores the initial type given to us by surfaceflinger,
|
||||
// validated_type_ stores the type after running ValidateDisplay
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue