Commit b19a54b6 authored by Gil Dekel's avatar Gil Dekel Committed by Chromium LUCI CQ

ozone/drm: Skip Copying (or Clearing) Buffers when Testing Modeset

This CL modifies GetModesetBuffer() to skip the copying or clearing of a
freshly acquired buffer when we mode test, since it will not be used in
the next page flip.

This reduced the average traced duration of GetModesetBuffer() from
1.8ms (min:0.008ms to max:5.36ms) to 0.006ms (min:0.004ms to
max:0.029ms). This is a significant reduction since GetModesetBuffer()
is called num_of_displays x num_of_mode_tests times per display
configuration.

The average traced duration of a single TestModeset() was reduced from
8.9ms (min:5.04ms to max:16.9ms) to 0.059ms (min:0.04ms to max:0.199ms).

Tracing was collected on a Drallion, with two 4K 13.3" monitors
connected via MST and running 1,000 consecutive TestModeset().

Test: Trace on a Drallion
Change-Id: I0673f421dab597d45ab8e5666e17b2612bbca55a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2590393Reviewed-by: default avatarMark Yacoub <markyacoub@google.com>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Gil Dekel <gildekel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837263}
parent 2c42629a
......@@ -287,7 +287,7 @@ bool ScreenManager::TestAndSetPreferredModifiers(
DrmOverlayPlane primary_plane = GetModesetBuffer(
controller, gfx::Rect(params.origin, ModeSize(*params.mode)),
modifiers);
modifiers, /*is_testing=*/true);
if (!primary_plane.buffer) {
return false;
}
......@@ -342,7 +342,7 @@ bool ScreenManager::TestAndSetLinearModifier(
if (params.mode) {
DrmOverlayPlane primary_plane = GetModesetBuffer(
controller, gfx::Rect(params.origin, ModeSize(*params.mode)),
modifiers);
modifiers, /*is_testing=*/true);
if (!primary_plane.buffer)
return false;
......@@ -407,7 +407,7 @@ base::flat_map<int64_t, bool> ScreenManager::Modeset(
DrmOverlayPlane primary_plane = GetModesetBuffer(
controller, gfx::Rect(params.origin, ModeSize(*params.mode)),
modifiers);
modifiers, /*is_testing=*/false);
if (primary_plane.buffer) {
SetDisplayControllerForEnableAndGetProps(
&commit_request, params.drm, params.crtc, params.connector,
......@@ -647,8 +647,8 @@ void ScreenManager::UpdateControllerToWindowMapping() {
controller->GetSupportedModifiers(fourcc_format);
DrmOverlayPlane primary_plane = GetModesetBuffer(
controller,
gfx::Rect(controller->origin(), controller->GetModeSize()),
modifiers);
gfx::Rect(controller->origin(), controller->GetModeSize()), modifiers,
/*is_testing=*/false);
DCHECK(primary_plane.buffer);
CommitRequest commit_request;
......@@ -662,7 +662,8 @@ void ScreenManager::UpdateControllerToWindowMapping() {
DrmOverlayPlane ScreenManager::GetModesetBuffer(
HardwareDisplayController* controller,
const gfx::Rect& bounds,
const std::vector<uint64_t>& modifiers) {
const std::vector<uint64_t>& modifiers,
bool is_testing) {
scoped_refptr<DrmDevice> drm = controller->GetDrmDevice();
uint32_t fourcc_format = ui::GetFourCCFormatForOpaqueFramebuffer(
display::DisplaySnapshot::PrimaryFormat());
......@@ -696,13 +697,15 @@ DrmOverlayPlane ScreenManager::GetModesetBuffer(
return DrmOverlayPlane::Error();
}
sk_sp<SkSurface> surface = buffer->GetSurface();
if (!surface) {
VLOG(2) << "Can't get a SkSurface from the modeset gbm buffer.";
} else if (!FillModesetBuffer(drm, controller, surface.get(), modifiers)) {
// If we fail to fill the modeset buffer, clear it black to avoid displaying
// an uninitialized framebuffer.
surface->getCanvas()->clear(SK_ColorBLACK);
if (!is_testing) {
sk_sp<SkSurface> surface = buffer->GetSurface();
if (!surface) {
VLOG(2) << "Can't get a SkSurface from the modeset gbm buffer.";
} else if (!FillModesetBuffer(drm, controller, surface.get(), modifiers)) {
// If we fail to fill the modeset buffer, clear it black to avoid
// displaying an uninitialized framebuffer.
surface->getCanvas()->clear(SK_ColorBLACK);
}
}
return DrmOverlayPlane(framebuffer, nullptr);
}
......
......@@ -167,7 +167,8 @@ class ScreenManager {
DrmOverlayPlane GetModesetBuffer(HardwareDisplayController* controller,
const gfx::Rect& bounds,
const std::vector<uint64_t>& modifiers);
const std::vector<uint64_t>& modifiers,
bool is_testing);
// Gets props for modesetting the |controller| using |origin| and |mode|.
void GetModesetControllerProps(CommitRequest* commit_request,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment