forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gpu: Plumb GPU vsync from IDXGIOutput to display compositor
Implement a GpuVSyncBeginFrameSource that uses OutputSurface to provide vsync updates. GLOutputSurface implements this by plumbing vsync requests and updates through InProcessCommandBuffer and GLSurface. The vsync updates are posted directly on the display compositor thread to guard against GPU main thread contention and to minimize latency. DirectCompositionSurfaceWin implements support for vsync updates based on DirectCompositionGpuVSync feature flag. Testing shows markedly better alignment of begin frames with GPU vsync than using timer based begin frames in ETW profiles and vastly improved regularity of frame deltas on vsynctester.com. Change-Id: Iaca86b3f15a6cccace168b9ac6b62a6f38c67542 Bug: 953970 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1558583 Reviewed-by: kylechar <kylechar@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Antoine Labour <piman@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org> Cr-Commit-Position: refs/heads/master@{#658281}
- Loading branch information
Showing
34 changed files
with
487 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef COMPONENTS_VIZ_COMMON_GPU_GPU_VSYNC_CALLBACK_H_ | ||
#define COMPONENTS_VIZ_COMMON_GPU_GPU_VSYNC_CALLBACK_H_ | ||
|
||
#include "base/callback.h" | ||
#include "base/time/time.h" | ||
|
||
namespace viz { | ||
|
||
using GpuVSyncCallback = | ||
base::RepeatingCallback<void(base::TimeTicks vsync_time, | ||
base::TimeDelta vsync_interval)>; | ||
|
||
} // namespace viz | ||
|
||
#endif // COMPONENTS_VIZ_COMMON_GPU_GPU_VSYNC_CALLBACK_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
components/viz/service/frame_sinks/gpu_vsync_begin_frame_source.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "components/viz/service/frame_sinks/gpu_vsync_begin_frame_source.h" | ||
|
||
#include "base/bind.h" | ||
#include "components/viz/service/display/output_surface.h" | ||
|
||
namespace viz { | ||
|
||
GpuVSyncBeginFrameSource::GpuVSyncBeginFrameSource( | ||
uint32_t restart_id, | ||
OutputSurface* output_surface) | ||
: ExternalBeginFrameSource(this, restart_id), | ||
output_surface_(output_surface) { | ||
DCHECK(output_surface->capabilities().supports_gpu_vsync); | ||
output_surface->SetGpuVSyncCallback(base::BindRepeating( | ||
&GpuVSyncBeginFrameSource::OnGpuVSync, base::Unretained(this))); | ||
} | ||
|
||
GpuVSyncBeginFrameSource::~GpuVSyncBeginFrameSource() = default; | ||
|
||
void GpuVSyncBeginFrameSource::OnGpuVSync(base::TimeTicks vsync_time, | ||
base::TimeDelta vsync_interval) { | ||
ExternalBeginFrameSource::OnBeginFrame(BeginFrameArgs::Create( | ||
BEGINFRAME_FROM_HERE, source_id(), next_begin_frame_sequence_number_++, | ||
vsync_time, vsync_time + vsync_interval, vsync_interval, | ||
BeginFrameArgs::NORMAL)); | ||
} | ||
|
||
void GpuVSyncBeginFrameSource::OnNeedsBeginFrames(bool needs_begin_frames) { | ||
output_surface_->SetGpuVSyncEnabled(needs_begin_frames); | ||
} | ||
|
||
} // namespace viz |
41 changes: 41 additions & 0 deletions
41
components/viz/service/frame_sinks/gpu_vsync_begin_frame_source.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef COMPONENTS_VIZ_SERVICE_FRAME_SINKS_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ | ||
#define COMPONENTS_VIZ_SERVICE_FRAME_SINKS_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ | ||
|
||
#include "base/macros.h" | ||
#include "components/viz/common/frame_sinks/begin_frame_source.h" | ||
#include "components/viz/service/viz_service_export.h" | ||
|
||
namespace viz { | ||
|
||
class OutputSurface; | ||
|
||
// Receives begin frames via OutputSurface::SetGpuVSyncCallback(). Output | ||
// surface must have |supports_gpu_vsync| capability. This class is not thread | ||
// safe so the callbacks must be received on the original thread. The BFS is | ||
// guaranteed to outlive the OutputSurface. | ||
class VIZ_SERVICE_EXPORT GpuVSyncBeginFrameSource | ||
: public ExternalBeginFrameSource, | ||
public ExternalBeginFrameSourceClient { | ||
public: | ||
GpuVSyncBeginFrameSource(uint32_t restart_id, OutputSurface* output_surface); | ||
~GpuVSyncBeginFrameSource() override; | ||
|
||
// ExternalBeginFrameSourceClient implementation. | ||
void OnNeedsBeginFrames(bool needs_begin_frames) override; | ||
|
||
private: | ||
void OnGpuVSync(base::TimeTicks vsync_time, base::TimeDelta vsync_interval); | ||
|
||
OutputSurface* const output_surface_; | ||
uint64_t next_begin_frame_sequence_number_ = 1; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(GpuVSyncBeginFrameSource); | ||
}; | ||
|
||
} // namespace viz | ||
|
||
#endif // COMPONENTS_VIZ_SERVICE_FRAME_SINKS_GPU_VSYNC_BEGIN_FRAME_SOURCE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
include_rules = [ | ||
"+components/viz/common/features.h", | ||
"+components/viz/common/display/update_vsync_parameters_callback.h", | ||
"+components/viz/common/gpu/gpu_vsync_callback.h", | ||
"+components/viz/common/resources/resource_format.h", | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.