1
0
Fork 0
Commit graph

95 commits

Author SHA1 Message Date
Andrew Wolfers
e76c0c751d Cleanup includes in backend/ per IWYU style
Change-Id: I2a0d38bc92b3d9544b3954d4047d5ea8a34ef0bf
2025-11-11 19:14:29 +00:00
Andrew Wolfers
6c2df0cbdd Move CompositionPlanner from backend/ to compositor/
Change-Id: Iebd4a4d0e15c5171aa20fafe3686b7bc8c08a175
2025-11-06 18:32:05 +00:00
Andrew Wolfers
a890ccd62f Add atom reporting for flattening controller state
Change-Id: I09f60c95519d844359d5f1c70b940b47f756da21
2025-11-06 15:30:45 +00:00
Andrew Wolfers
460ef8d0a8 Add explicit mappings from HwcStats enums to atom types
Change-Id: I9496a7a5c3018a3dcea8eddd2bd6b5db80467419
2025-11-06 14:59:13 +00:00
Drew Davenport
9a89ceff02 Rename PipelineCreator interface to Backend
With the legacy Backend class renamed to CompositionPlanner, rename the
PipelineCreator interface to Backend. This interface maps most closely
to the concept of the "Backend".

Add some documentation to various Backend related classes.

Change-Id: I5d6a7afcebb9d0015c3d7629bf8c10324c8f07df
2025-10-31 12:37:30 -06:00
Drew Davenport
7a69d5507a Make generic and client backends private static
Rather than global variables with static scope, make them private static
members of their respective classes.

Change-Id: I20f0ad1d63fe14001266058983b0d013058667dc
2025-10-31 12:36:29 -06:00
Drew Davenport
0afe783d1a Override Planner for GenericPipelineCreator
Allow classes to inherit from GenericPipelineCreator and use it for
creating the DrmDisplayPipeline, but override which CompositionPlanner
is used.

Extract the GetFlattenedComposition function into a static function that
can be called from any backend.

Change-Id: Id75705b969eb6d23fbc6147c496ac3f3e9956abf
2025-10-31 09:37:48 -06:00
Drew Davenport
d04968bf87 Extract GenericPipelineCreator to its own files
Separate GenericPipelineCreator from the GenericCompositionPlanner
class.

Change-Id: I20db30d9473c808e0f2e2516fb2a1f03ebf93e01
2025-10-31 09:35:06 -06:00
Drew Davenport
47fab44195 Extract abstract CompositionPlanner interface
Rename the generic CompositionPlanner implementation to
GenericCompositionPlanner, and abstract the CompositionPlanner
interface.

Change-Id: I39d6fd44956d77669271999dd83fc78eebec742a
2025-10-31 09:34:40 -06:00
Drew Davenport
f119d34769 Rename Backend to CompositionPlanner
With the Backend concept expanding to also include the initial display
configuration and creation of DrmDisplayPipeline, rename the Backend
class to more precisely reflect its purpose.

Change-Id: I8a9a0d49242771e5df6e80cd50f0b2b0670c2de2
2025-10-30 12:07:09 -06:00
Drew Davenport
645d83d8eb Log an error for a Backend name conflict
Log an error and early-out if a backend with the same name is registered
multiple times.

Change-Id: Iec27c2987a3bb15702291870230d0bcac4a0704b
2025-10-30 09:27:28 -06:00
Drew Davenport
0e8dc3ebca Move some Backend functions to protected scope
These functions are not part of the Backend public interface, so move
them to protected.

Change-Id: I27dbafdec70f4277d3df952c9b01fd87f35b5943
2025-10-30 09:27:28 -06:00
Drew Davenport
3c2106f064 Allow Backend to create DrmDisplayPipeline
Define a PipelineCreator interface which allows Backends to use
Backend-specific heuristics in creating the DrmDisplayPipeline.

Change-Id: I1f929213ce403267b539635ec9d5853cf1a7f18a
2025-10-30 09:27:28 -06:00
Drew Davenport
0f5244ef78 Create DrmDisplayPipeline through BackendManager
Additionally, move the creation of the Backend into BackendManager so
that it the Backend is created along with the DrmDisplayPipeline

Change-Id: I24dc19cadb324429f229fe7751b60b70ab512265
2025-10-30 09:27:28 -06:00
Drew Davenport
043be2b9e3 Make BackendManager function private
This is only called from BackendManager and doesn't need to be part of
the public interface.

Change-Id: I0ffd375bea40ccf660d779464110c8cab25d0d02
2025-10-30 09:27:28 -06:00
Drew Davenport
b112216f38 Use new BackendManager::CreateBackendForConnector
Remove the old CreateBackendForDisplay and related functions that are
now obsolete.

Change-Id: Ic41c065b65a50e6a68ccc1e40b210e5aed6d009e
2025-10-30 09:27:28 -06:00
Drew Davenport
fbd684e3e0 Add BackendManager::CreateBackendForPipeline
Create a Backend for the given DrmDisplayPipeline using the same logic
in CreateBackendForDisplay.

A subsequent change will use this function and deprecate
CreateBackendForDisplay.

Change-Id: I72365f5c689f6643e2f6da11f76dde1ac68f3e2d
2025-10-30 09:27:28 -06:00
Andrew Wolfers
0c11f2e5db Enforce const in Backend where applicable
Change-Id: Ic55a1859a4407aa772f09cf11e1b03ab705a628e
2025-10-07 14:47:01 +00:00
Andrew Wolfers
09c7c9f875 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
2025-10-07 14:46:53 +00:00
Andrew Wolfers
b393389438 Add cursor result to ValidatedComposition
Change-Id: Ic4ccf3b34021c0b57d10438ea212375159f43bd4
2025-10-07 14:21:22 +00:00
Andrew Wolfers
8ec71d2657 Add FlattenReason to Backend
This change adds a new enum FlattenReason which
describes possible reasons that a given composition
would be flattened. The flatten reason is now
returned with the ValidationComposition.

Change-Id: Ia7ba2ffbdc3512fea9cb19ab6be63a99eaa3f367
2025-10-07 14:21:07 +00:00
Andrew Wolfers
a51a43422d drm_hwcomposer: Use cached validated composition
This change adds caching to save the most recently
validated composition. The cached value is used where
appropriate to avoid recalculating the DrmKmsPlan or
the CompositionTypeMap from ValidateDisplay again in
PresentDisplay. The cached ValidatedComposition
replaces the previously cached DrmKmsPlan, preserving
the lifecycle management requirements.

Change-Id: I59704e26ae1a6950e750d246314b2db6af2f11a0
2025-10-03 18:56:19 +00:00
Sasha McIntosh
ace08f065a drm_hwcomposer: Fix device composition bug
When all layers are designated for client composition, do not attempt to
add additional layer to client composition.

Change-Id: I4579c7d5f96cd148ae805e91cb0837284956bff9
2025-09-29 02:12:29 -06:00
Drew Davenport
08fea937a1 drm_hwcomposer: Update flatcon in HwcDisplay
Backend can get a const reference to the FlatteningController for
checking if the scene should be flattened or not. Updating of the
FlatteningController is moved to HwcDisplay just before deferring to the
Backend during the Validate.

Change-Id: I9c7cc309bb16ea7b60187476db67fc9df1485275
2025-09-19 17:36:27 -06:00
Drew Davenport
6075ab4596 drm_hwcomposer: Use unique_ptr for FlatteningController
FlatteningController is owned by HwcDisplay, so use a unique_ptr to
better control and indicate the ownership.

Remove the CreateInstance factory method and use std::make_unique
instead.

Change-Id: I0155c602dcf5a31d27fd2677f9f96ff9696a4022
2025-09-19 16:58:58 -06:00
Drew Davenport
2432cb0dfa drm_hwcomposer: Update FlatteningController behavior
Under the previous behavior, NewFrame both updated the internal state
tracking to indicate that the scene is not idle, as well as returning a
bool to indicate whether the scene should be flattened or not.
ShouldFlatten was not being used, and would return `true` during the
interval between the refresh callback being triggered and the next
NewFrame, which would be in response to the refresh callback. Subsequent
calls to ShouldFlatten would return `false` even though the scene
remains idle.

This commit updates NewFrame to only update the internal state. Callers
should call ShouldFlatten to check whether the controller has detected
that the scene should be flattened.

After the callback is triggered, ShouldFlatten returns true. It will
continue to return true after the first NewFrame, which would be in
response to the refresh callback. Subsequent NewFrame calls will reset
the idle detection.

Change-Id: I8b11a55bb6b101bb2ce473a844f5b9795a027956
2025-09-19 16:56:55 -06:00
Andrew Wolfers
0583f19628 drm_hwcomposer: Change cursor composition testing
This CL strengthens the cursor plane usage check with a test
commit. A test commit is a cheap and definitive means of
determining whether the cursor plane can be used. Under the
previous scheme, if a validation test commit would fail, it
was unclear whether the failure was due to the cursor plane
or due to other factors, and sometimes the cursor would be
demoted when it was not at fault. The new flow relies on the
result of the cursor test commit, and applies updated fallback
behavior to preserve the cursor as much as possible.

Change-Id: If3b86a4cbfb5220532a58b14797d6840c3a93af6
2025-09-11 13:16:49 +00:00
Andrew Wolfers
7e3f849bca drm_hwcomposer: Fix ValidateDisplay logic
This CL resolves some logical errors in Backend::ValidateDisplay.
Previously, it was possible for the ValidatedComposition's
composition_plan to improperly hold plane bindings when the
TestCompostion was skipped. Additionally, metric values were
not being counted properly, due to the client_start, client_size,
and use_cursor_plane variables not being updated when the
composition is flattened due to failed validation. Finally, the
client_start and client_size variables are moved out of the
validate_and_test helper, which makes their state simpler
to reason about.

Change-Id: I229d8aa38993c3e26ef61d9f6127ce17bac5336f
2025-09-11 13:16:37 +00:00
Andrew Wolfers
3ceb722bc9 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
2025-09-10 19:41:32 +00:00
Andrew Wolfers
2261f81762 drm_hwcomposer: Add Rect utility type
This change refactors the IRect and FRect types into a single
templated type Rect<T>, which allows the implementation to be
shared across both variants. This change also adds convenience
getters for the rect widths and heights, and updates callsites
accordingly.

Change-Id: I38509631d57706266186a7b7fa21bd43c0860890
2025-09-10 13:41:51 +00:00
Andrew Wolfers
9255d0d10b drm_hwcomposer: Migrate to android::drm_hwcomposer namespace
Change-Id: I2859aa8f55532d88231389724956fc77b0625339
2025-09-08 18:53:00 +00:00
Drew Davenport
a9e13211a6 drm_hwcomposer: Start making HwcDisplay const in Backend
Add some const correctness to HwcDisplay. Narrow the public
interface of HwcDisplay to avoid exposing non-const members
unnecessarily.

Change-Id: I691c9e0025065085ca1e2045bb1d6614535fdbdc
2025-08-27 13:01:59 -06:00
Drew Davenport
c75316c28e drm_hwcomposer: Return DrmKmsPlan from Backend
DrmKmsPlan lifetime is used to manage ownership of drm planes that have
affinity for multiple crtcs. As such, the DrmKmsPlan lifetime needs to
persist from a Validate call to when the composition is Presented to
ensure that such planes aren't stolen by another display.

Rather than stashing the DrmKmsPlan as part of TestComposition, return
the DrmKmsPlan as part of the Backend's Validate. HwcDisplay::Validate
then becomes responsible for lifetime management of the resulting
DrmKmsPlan as before.

Change-Id: I14ae115b2eed5c9b27e70f0b695fbbc4f3a4faa6
2025-08-26 09:27:21 -06:00
Andrew Wolfers
8674bc34a4 drm_hwcomposer: Enforce type consistency in Backend
This change cleans up some typing within Backend around data which
was inconsistently being handled as int, uint32_t, or size_t. This
change resolves an instance of integer underflow.

Change-Id: I4a2aa352b6cb4d1ff74929eb67c7edfc907cdb0c
2025-08-20 11:58:44 -06:00
Drew Davenport
ae70ed5bf1 drm_hwcomposer: Add HwcDisplay::TestComposition
Call this from the Backend when testing a composition. Future commit
will make this a const function to indicate that it doesn't change
HwcDisplay internal state.

Change-Id: I9bd6962e213acd76d13afbdc620418bd1ff95557
2025-08-19 09:16:22 -06:00
Drew Davenport
4a84e27035 drm_hwcomposer: Make HwcLayer const in Backend
Backend shouldn't directly mutate HwcLayer state, so make HwcLayer
const. Make a few other related functions const correct as well.

Change-Id: Id7f8e255e9e72b756399b1a4dabc3db779d64bc9
2025-08-19 09:16:22 -06:00
Drew Davenport
728701adba drm_hwcomposer: Rename Backend::MarkValidated
Rename to GetCompositionTypes to reflect that the function is no longer
setting HwcLayer state (marking). Also make the input |layers| const
since it's no longer being modified.

Change-Id: I53702a6df680b9a138bb16191a3cac0b17e4b632
2025-08-19 09:16:22 -06:00
Drew Davenport
b29c974d70 drm_hwcomposer: Return composition decision from backend
Rather than setting the ValidatedType on the layers directly from the
Backend, return the per-layer composition type decisions from the
Backend and let the HwcDisplay set it.

This is a step towards the goal of not setting HwcLayer state directly
from the Backend.

Change-Id: I8e2d1e7c6fb0d9071d5dca101ddb455b95535bd0
2025-08-19 09:16:22 -06:00
Drew Davenport
a5fb437d37 drm_hwcomposer: Move CompositionType out of HwcLayer struct
Moving this paves the way for reducing dependency on HwcLayer from the
Backend class

Change-Id: I62f057a0efcb7afc3c9a04cff3bd53b5c56c5ad9
2025-08-19 09:16:22 -06:00
Andrew Wolfers
f693821f25 drm_hwcomposer: Remove cursor condition from CalcPixOps
CalcPixOps determines the cost of GPU-composition over a range
of layers. This change removes cursor-specific logic that was
accounting for behavior that only applies when the cursor is
not GPU-composited. This change restores the standard logic,
so that the cost of GPU-compositing the cursor layer is corrected.

Change-Id: I310fd35e2cd4f4df6d334ae0d989f2298267323a
2025-07-31 13:00:16 +00:00
Andrew Wolfers
2a0a4114a2 drm_hwcomposer: Prevent cursor layer from being client composited
When the number of requested layers exceeds the available planes,
Backend::GetExtraClientRange chooses which layers to demote to
client (GPU) composition. The existing implementation prioritizes
minimizing the number of pixel operations which will be sent to
the GPU. Since the cursor layer tends to be one of the smaller
layers, it is often chosen. However, the cursor layer is generally
a poor choice for client composition because its position
frequently changes, causing the scene geometry to refresh. This
change updates the extended client range determination logic to
exclude the cursor layer from consideration.

Note: this behavior only applies to the cursor when it is being
device composited. When the cursor is being composited to the
HW cursor plane, it isn't competing for the same pool of planes,
so it was already a non-issue in that case.

Change-Id: I5cc2ac0f4ac2329c923b5c5060b78e80c32503f7
2025-07-14 13:21:30 +00:00
Andrew Wolfers
d1be5f8c8b drm_hwcomposer: Fix pixops calculations
This change resolves inaccuracies in the calculations of
per-layer pixel operation counts, i.e. "pixops". The display
frame of a layer attributes special meaning to a value of
nullopt, indicating that the frame occupies the whole display.
Correctly calculating the pixops for such a layer requires
checking the dimensions of the display mode. Additionally,
a layer being committed to the hardware cursor plane ignores
its display frame, instead using the dimensions of its buffer,
and therefore the pixops calculation needs to match.

Change-Id: I68cd2c3b42b9a556828a74eda715a106b958624b
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
2025-07-09 16:55:40 +00:00
Drew Davenport
cb4e848c3b drm_hwcomposer: Move GetBackendOverride to Properties
Add Properties::GetBackendOverride to query the sysprop, and handle the
default in BackendManager.

Change-Id: Ifc01a23d64a5406ba5c9f065b7d5967b42b1b5d5
2025-06-12 01:51:29 +00:00
Drew Davenport
23e05e0b85 drm_hwcomposer: Move common files out of hwc2_device directory
HwcDisplay etc. are shared between frontends and shouldn't live in the
hwc2_device directory.

Change-Id: I4bf3845f6cf7adde5f625a736cc1dffea27e5168
2025-05-23 09:01:32 -06:00
Drew Davenport
9d3be012fd drm_hwcomposer: Remove hwc2 usage from common code
No longer need to #include the hwcomposer2 headers in common code.

Pull the hwc2 specific files into a different filegroup. There is no
need to build these for hwc3. Additionally, no need for hwc2-specific
CPPFLAGS in common or hwc3 code.

Change-Id: Ie194e9dc4b0d8f7b900227bd5d3b73efc692d975
2025-05-23 09:01:32 -06:00
Drew Davenport
93132f482c drm_hwcomposer: Change HWC2::Error return value to bool
All errors from HwcDisplay::CreateComposition are handled the same way,
so just return a bool. There is no need for a finer grained return code.

Change-Id: I5a10cf2672d377efa715fba8f8eb50cd4c41316f
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-05-20 12:06:02 -06:00
Drew Davenport
7e573a50c9 drm_hwcomposer: Remove HWC2 CompositionType
Remove HWC2 CompositionType from midlayers. Define a new
HwcLayer::CompositionType enum to capture all composition types
supported by drm-hwcomposer.

HWC2 and HWC3 frontends do the necessary conversion to/from
HwcLayer::Composition type.

Since the last HWC2 usage has been removed from HwcLayer, remove the
hwc2 #include.

Change-Id: I00d579d699599f0918d114b35080933348aa513b
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-05-05 14:52:56 -06:00
Drew Davenport
771eacda69 drm_hwcomposer: Replace HwcDisplay::Stats with CompositionStats
The latter was extracted from the former, so only minor renaming is
needed.

Change-Id: Iea3228b802ddcd16f6840adbf242be3bd61fac60
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-29 14:13:04 -06:00
Drew Davenport
9de3f5cdd3 drm_hwcomposer: Clean up Backend interface
Backend::Validate function signature reflects the corresponding HWC2
function signature. The return value and arguments are redundant.

- Remove the return value, since Validate never fails and it wasn't used
  anyways.
- Remove the out params, since the same information can be (and is)
  determined by comparing the SfType and ValidatedType for each layer

Change-Id: I659f7e0b03f183c38ca0a6996c0546eb263e7b99
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-17 15:07:00 +00:00
Drew Davenport
571eb6af58 drm_hwcomposer: Check cursor layer compatibility
With the cursor layer's LayerData already populated before entering the
Backend, the Backend can check whether the cursor layer is compatible
with the drm cursor plane before attempting the composition.

Change-Id: I2725f411913b5f998b9549bfc0537d0d9886a569
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-07 16:24:37 -06:00