Commit ad1de109 authored by Eric Seckler's avatar Eric Seckler Committed by Commit Bot

viz: Add support for headless + full-pipe mode flags.

Use SoftwareOutputDevice for headless and pass on the full-pipeline flag to the
viz process and its DisplayScheduler.

Bug: 786067
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: Ief3a80777cf339b435724410f45ae64686c4beff
Reviewed-on: https://chromium-review.googlesource.com/960862
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543369}
parent d94f7320
...@@ -65,7 +65,9 @@ namespace viz { ...@@ -65,7 +65,9 @@ namespace viz {
GpuDisplayProvider::GpuDisplayProvider( GpuDisplayProvider::GpuDisplayProvider(
uint32_t restart_id, uint32_t restart_id,
scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service,
gpu::GpuChannelManager* gpu_channel_manager) gpu::GpuChannelManager* gpu_channel_manager,
bool headless,
bool wait_for_all_pipeline_stages_before_draw)
: restart_id_(restart_id), : restart_id_(restart_id),
gpu_service_(std::move(gpu_service)), gpu_service_(std::move(gpu_service)),
gpu_channel_manager_delegate_(gpu_channel_manager->delegate()), gpu_channel_manager_delegate_(gpu_channel_manager->delegate()),
...@@ -73,7 +75,10 @@ GpuDisplayProvider::GpuDisplayProvider( ...@@ -73,7 +75,10 @@ GpuDisplayProvider::GpuDisplayProvider(
std::make_unique<InProcessGpuMemoryBufferManager>( std::make_unique<InProcessGpuMemoryBufferManager>(
gpu_channel_manager)), gpu_channel_manager)),
image_factory_(GetImageFactory(gpu_channel_manager)), image_factory_(GetImageFactory(gpu_channel_manager)),
task_runner_(base::ThreadTaskRunnerHandle::Get()) { task_runner_(base::ThreadTaskRunnerHandle::Get()),
headless_(headless),
wait_for_all_pipeline_stages_before_draw_(
wait_for_all_pipeline_stages_before_draw) {
DCHECK_NE(restart_id_, BeginFrameSource::kNotRestartableId); DCHECK_NE(restart_id_, BeginFrameSource::kNotRestartableId);
} }
...@@ -153,7 +158,8 @@ std::unique_ptr<Display> GpuDisplayProvider::CreateDisplay( ...@@ -153,7 +158,8 @@ std::unique_ptr<Display> GpuDisplayProvider::CreateDisplay(
DCHECK_GT(max_frames_pending, 0); DCHECK_GT(max_frames_pending, 0);
auto scheduler = std::make_unique<DisplayScheduler>( auto scheduler = std::make_unique<DisplayScheduler>(
display_begin_frame_source, task_runner_.get(), max_frames_pending); display_begin_frame_source, task_runner_.get(), max_frames_pending,
wait_for_all_pipeline_stages_before_draw_);
// The ownership of the BeginFrameSource is transferred to the caller. // The ownership of the BeginFrameSource is transferred to the caller.
*out_begin_frame_source = std::move(synthetic_begin_frame_source); *out_begin_frame_source = std::move(synthetic_begin_frame_source);
...@@ -166,6 +172,9 @@ std::unique_ptr<Display> GpuDisplayProvider::CreateDisplay( ...@@ -166,6 +172,9 @@ std::unique_ptr<Display> GpuDisplayProvider::CreateDisplay(
std::unique_ptr<SoftwareOutputDevice> std::unique_ptr<SoftwareOutputDevice>
GpuDisplayProvider::CreateSoftwareOutputDeviceForPlatform( GpuDisplayProvider::CreateSoftwareOutputDeviceForPlatform(
gpu::SurfaceHandle surface_handle) { gpu::SurfaceHandle surface_handle) {
if (headless_)
return std::make_unique<SoftwareOutputDevice>();
#if defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) #if defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW)
gfx::AcceleratedWidget widget = surface_handle; gfx::AcceleratedWidget widget = surface_handle;
#endif #endif
......
...@@ -36,7 +36,9 @@ class VIZ_SERVICE_EXPORT GpuDisplayProvider : public DisplayProvider { ...@@ -36,7 +36,9 @@ class VIZ_SERVICE_EXPORT GpuDisplayProvider : public DisplayProvider {
GpuDisplayProvider( GpuDisplayProvider(
uint32_t restart_id, uint32_t restart_id,
scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service, scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service,
gpu::GpuChannelManager* gpu_channel_manager); gpu::GpuChannelManager* gpu_channel_manager,
bool headless,
bool wait_for_all_pipeline_stages_before_draw);
~GpuDisplayProvider() override; ~GpuDisplayProvider() override;
// DisplayProvider implementation. // DisplayProvider implementation.
...@@ -66,6 +68,9 @@ class VIZ_SERVICE_EXPORT GpuDisplayProvider : public DisplayProvider { ...@@ -66,6 +68,9 @@ class VIZ_SERVICE_EXPORT GpuDisplayProvider : public DisplayProvider {
scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
const bool headless_;
const bool wait_for_all_pipeline_stages_before_draw_;
DISALLOW_COPY_AND_ASSIGN(GpuDisplayProvider); DISALLOW_COPY_AND_ASSIGN(GpuDisplayProvider);
}; };
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
include_rules = [ include_rules = [
"+components/discardable_memory/client", "+components/discardable_memory/client",
"+components/viz/common/switches.h",
"+components/viz/service", "+components/viz/service",
"+gpu/command_buffer", "+gpu/command_buffer",
"+gpu/config", "+gpu/config",
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/viz/common/switches.h"
#include "components/viz/service/display_embedder/gpu_display_provider.h" #include "components/viz/service/display_embedder/gpu_display_provider.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h" #include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "components/viz/service/gl/gpu_service_impl.h" #include "components/viz/service/gl/gpu_service_impl.h"
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
#include "services/metrics/public/cpp/mojo_ukm_recorder.h" #include "services/metrics/public/cpp/mojo_ukm_recorder.h"
#include "services/metrics/public/mojom/constants.mojom.h" #include "services/metrics/public/mojom/constants.mojom.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
#include "ui/gfx/switches.h"
#if defined(OS_CHROMEOS) && BUILDFLAG(USE_VAAPI) #if defined(OS_CHROMEOS) && BUILDFLAG(USE_VAAPI)
#include "media/gpu/vaapi/vaapi_wrapper.h" #include "media/gpu/vaapi/vaapi_wrapper.h"
...@@ -274,9 +276,13 @@ void VizMainImpl::CreateFrameSinkManagerOnCompositorThread( ...@@ -274,9 +276,13 @@ void VizMainImpl::CreateFrameSinkManagerOnCompositorThread(
mojom::FrameSinkManagerParamsPtr params) { mojom::FrameSinkManagerParamsPtr params) {
DCHECK(!frame_sink_manager_); DCHECK(!frame_sink_manager_);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
display_provider_ = std::make_unique<GpuDisplayProvider>( display_provider_ = std::make_unique<GpuDisplayProvider>(
params->restart_id, gpu_command_service_, params->restart_id, gpu_command_service_,
gpu_service_->gpu_channel_manager()); gpu_service_->gpu_channel_manager(),
command_line->HasSwitch(switches::kHeadless),
command_line->HasSwitch(switches::kRunAllCompositorStagesBeforeDraw));
mojom::FrameSinkManagerClientPtr client( mojom::FrameSinkManagerClientPtr client(
std::move(params->frame_sink_manager_client)); std::move(params->frame_sink_manager_client));
......
...@@ -148,6 +148,7 @@ static const char* const kSwitchNames[] = { ...@@ -148,6 +148,7 @@ static const char* const kSwitchNames[] = {
switches::kEnableLowEndDeviceMode, switches::kEnableLowEndDeviceMode,
switches::kDisableLowEndDeviceMode, switches::kDisableLowEndDeviceMode,
switches::kNoSandbox, switches::kNoSandbox,
switches::kRunAllCompositorStagesBeforeDraw,
switches::kTestGLLib, switches::kTestGLLib,
switches::kTraceConfigFile, switches::kTraceConfigFile,
switches::kTraceStartup, switches::kTraceStartup,
......
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