Commit 1cc323b0 authored by kylechar's avatar kylechar Committed by Chromium LUCI CQ

Add GpuVsync feature

Add a feature to control if GpuVsync is enabled or not, in addition to
the --disable-gpu-vsync flag. The feature is on by default so this
should be a no-op change. This is intended to be used in a finch trial
to see what the impact of disabling GPU vsync is after the feature
freeze is over.

Bug: 43611
Change-Id: I09715832b48e5ba9fe11e04404ed68fb441a5dfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2597637Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838656}
parent 72ae75b3
......@@ -8,14 +8,13 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/histogram_macros_local.h"
#include "build/build_config.h"
#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "ui/gfx/vsync_provider.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_switches.h"
#include "ui/gl/gl_features.h"
namespace gpu {
......@@ -28,10 +27,6 @@ int g_current_swap_generation_ = 0;
int g_num_swaps_in_current_swap_generation_ = 0;
int g_last_multi_window_swap_generation_ = 0;
bool HasSwitch(const char switch_constant[]) {
return base::CommandLine::ForCurrentProcess()->HasSwitch(switch_constant);
}
} // anonymous namespace
PassThroughImageTransportSurface::PassThroughImageTransportSurface(
......@@ -39,13 +34,12 @@ PassThroughImageTransportSurface::PassThroughImageTransportSurface(
gl::GLSurface* surface,
bool override_vsync_for_multi_window_swap)
: GLSurfaceAdapter(surface),
is_gpu_vsync_disabled_(HasSwitch(switches::kDisableGpuVsync)),
is_gpu_vsync_disabled_(!features::UseGpuVsync()),
is_multi_window_swap_vsync_override_enabled_(
override_vsync_for_multi_window_swap),
delegate_(delegate) {}
PassThroughImageTransportSurface::~PassThroughImageTransportSurface() {
}
PassThroughImageTransportSurface::~PassThroughImageTransportSurface() = default;
bool PassThroughImageTransportSurface::Initialize(gl::GLSurfaceFormat format) {
// The surface is assumed to have already been initialized.
......
......@@ -20,6 +20,7 @@
#include "ui/gl/dc_layer_tree.h"
#include "ui/gl/direct_composition_child_surface_win.h"
#include "ui/gl/gl_angle_util_win.h"
#include "ui/gl/gl_features.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_switches.h"
#include "ui/gl/gpu_switching_manager.h"
......@@ -652,8 +653,7 @@ bool DirectCompositionSurfaceWin::IsSwapChainTearingSupported() {
// static
bool DirectCompositionSurfaceWin::AllowTearing() {
// Swap chain tearing is used only if vsync is disabled explicitly.
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableGpuVsync) &&
return features::UseGpuVsync() &&
DirectCompositionSurfaceWin::IsSwapChainTearingSupported();
}
......
......@@ -4,9 +4,17 @@
#include "ui/gl/gl_features.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "build/chromeos_buildflags.h"
#include "ui/gl/gl_switches.h"
namespace features {
namespace {
const base::Feature kGpuVsync{"GpuVsync", base::FEATURE_ENABLED_BY_DEFAULT};
} // namespace
// Use the passthrough command decoder by default. This can be overridden with
// the --use-cmd-decoder=passthrough or --use-cmd-decoder=validating flags.
......@@ -24,4 +32,10 @@ const base::Feature kDefaultPassthroughCommandDecoder{
#endif
};
bool UseGpuVsync() {
return !base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableGpuVsync) &&
base::FeatureList::IsEnabled(kGpuVsync);
}
} // namespace features
......@@ -11,6 +11,9 @@
namespace features {
// Controls if GPU should synchronize presentation with vsync.
GL_EXPORT bool UseGpuVsync();
// All features in alphabetical order. The features should be documented
// alongside the definition of their values in the .cc file.
GL_EXPORT extern const base::Feature kDefaultPassthroughCommandDecoder;
......
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