diff options
Diffstat (limited to 'chromium/content/gpu')
-rw-r--r-- | chromium/content/gpu/BUILD.gn | 4 | ||||
-rw-r--r-- | chromium/content/gpu/browser_exposed_gpu_interfaces.cc | 4 | ||||
-rw-r--r-- | chromium/content/gpu/gpu_child_thread.cc | 6 | ||||
-rw-r--r-- | chromium/content/gpu/gpu_main.cc | 80 | ||||
-rw-r--r-- | chromium/content/gpu/gpu_sandbox_hook_linux.cc | 21 |
5 files changed, 78 insertions, 37 deletions
diff --git a/chromium/content/gpu/BUILD.gn b/chromium/content/gpu/BUILD.gn index 64ebb18c5f6..354cc7c3f38 100644 --- a/chromium/content/gpu/BUILD.gn +++ b/chromium/content/gpu/BUILD.gn @@ -96,10 +96,6 @@ target(link_target_type, "gpu_sources") { ] } - if (is_linux) { - deps += [ "//services/service_manager/zygote" ] - } - if (mojo_media_host == "gpu") { deps += [ "//media/mojo/services" ] } diff --git a/chromium/content/gpu/browser_exposed_gpu_interfaces.cc b/chromium/content/gpu/browser_exposed_gpu_interfaces.cc index c84d1fefedb..45a9935d45a 100644 --- a/chromium/content/gpu/browser_exposed_gpu_interfaces.cc +++ b/chromium/content/gpu/browser_exposed_gpu_interfaces.cc @@ -9,6 +9,7 @@ #include "mojo/public/cpp/bindings/binder_map.h" #if defined(USE_OZONE) +#include "ui/base/ui_base_features.h" #include "ui/ozone/public/ozone_platform.h" #endif @@ -22,7 +23,8 @@ void ExposeGpuInterfacesToBrowser(const gpu::GpuPreferences& gpu_preferences, } #if defined(USE_OZONE) - ui::OzonePlatform::GetInstance()->AddInterfaces(binders); + if (features::IsUsingOzonePlatform()) + ui::OzonePlatform::GetInstance()->AddInterfaces(binders); #endif } diff --git a/chromium/content/gpu/gpu_child_thread.cc b/chromium/content/gpu/gpu_child_thread.cc index 0ae0a633850..eb0485fc15d 100644 --- a/chromium/content/gpu/gpu_child_thread.cc +++ b/chromium/content/gpu/gpu_child_thread.cc @@ -134,9 +134,9 @@ void GpuChildThread::Init(const base::Time& process_start_time) { associated_registry->AddInterface(base::BindRepeating( &GpuChildThread::CreateVizMainService, base::Unretained(this))); - memory_pressure_listener_ = - std::make_unique<base::MemoryPressureListener>(base::BindRepeating( - &GpuChildThread::OnMemoryPressure, base::Unretained(this))); + memory_pressure_listener_ = std::make_unique<base::MemoryPressureListener>( + FROM_HERE, base::BindRepeating(&GpuChildThread::OnMemoryPressure, + base::Unretained(this))); } void GpuChildThread::CreateVizMainService( diff --git a/chromium/content/gpu/gpu_main.cc b/chromium/content/gpu/gpu_main.cc index 4ba4a150565..82f55455fe3 100644 --- a/chromium/content/gpu/gpu_main.cc +++ b/chromium/content/gpu/gpu_main.cc @@ -17,8 +17,8 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "base/system/sys_info.h" -#include "base/task/post_task.h" #include "base/task/single_thread_task_executor.h" +#include "base/task/thread_pool.h" #include "base/threading/platform_thread.h" #include "base/timer/hi_res_timer_manager.h" #include "base/trace_event/trace_event.h" @@ -48,6 +48,7 @@ #include "media/gpu/buildflags.h" #include "services/tracing/public/cpp/trace_startup.h" #include "third_party/angle/src/gpu_info_util/SystemInfo.h" +#include "ui/base/ui_base_features.h" #include "ui/events/platform/platform_event_source.h" #include "ui/gfx/switches.h" #include "ui/gl/gl_context.h" @@ -79,6 +80,7 @@ #if defined(USE_X11) #include "ui/base/x/x11_util.h" // nogncheck #include "ui/gfx/linux/gpu_memory_buffer_support_x11.h" // nogncheck +#include "ui/gfx/x/x11.h" // nogncheck #include "ui/gfx/x/x11_switches.h" // nogncheck #include "ui/gfx/x/x11_types.h" // nogncheck #endif @@ -87,7 +89,6 @@ #include "content/gpu/gpu_sandbox_hook_linux.h" #include "content/public/common/sandbox_init.h" #include "services/service_manager/sandbox/linux/sandbox_linux.h" -#include "services/service_manager/zygote/common/common_sandbox_support_linux.h" #endif #if defined(OS_MACOSX) @@ -180,9 +181,9 @@ class ContentSandboxHelper : public gpu::GpuSandboxHelper { }; #if defined(OS_MACOSX) -void TestShaderCallback(metal::TestShaderResult result, - const base::TimeDelta& method_time, - const base::TimeDelta& compile_time) { +void TestShaderCallback(metal::TestShaderComponent component, + metal::TestShaderResult result, + const base::TimeDelta& callback_time) { switch (result) { case metal::TestShaderResult::kNotAttempted: case metal::TestShaderResult::kFailed: @@ -194,8 +195,15 @@ void TestShaderCallback(metal::TestShaderResult result, case metal::TestShaderResult::kSucceeded: break; } - UMA_HISTOGRAM_MEDIUM_TIMES("Gpu.Metal.TestShaderMethodTime", method_time); - UMA_HISTOGRAM_MEDIUM_TIMES("Gpu.Metal.TestShaderCompileTime", compile_time); + switch (component) { + case metal::TestShaderComponent::kCompile: + UMA_HISTOGRAM_MEDIUM_TIMES("Gpu.Metal.TestShaderCompileTime", + callback_time); + break; + case metal::TestShaderComponent::kLink: + UMA_HISTOGRAM_MEDIUM_TIMES("Gpu.Metal.TestShaderLinkTime", callback_time); + break; + } } #endif @@ -266,22 +274,29 @@ int GpuMain(const MainFunctionParams& parameters) { main_thread_task_executor = std::make_unique<base::SingleThreadTaskExecutor>( base::MessagePumpType::DEFAULT); -#elif defined(USE_X11) - // We need a UI loop so that we can grab the Expose events. See GLSurfaceGLX - // and https://crbug.com/326995. - ui::SetDefaultX11ErrorHandlers(); - if (!gfx::GetXDisplay()) - return RESULT_CODE_GPU_DEAD_ON_ARRIVAL; - main_thread_task_executor = - std::make_unique<base::SingleThreadTaskExecutor>( - base::MessagePumpType::UI); - event_source = ui::PlatformEventSource::CreateDefault(); -#elif defined(USE_OZONE) +#elif defined(USE_X11) || defined(USE_OZONE) +#if defined(USE_X11) + if (!features::IsUsingOzonePlatform()) { + // We need a UI loop so that we can grab the Expose events. See + // GLSurfaceGLX and https://crbug.com/326995. + ui::SetDefaultX11ErrorHandlers(); + if (!gfx::GetXDisplay()) + return RESULT_CODE_GPU_DEAD_ON_ARRIVAL; + main_thread_task_executor = + std::make_unique<base::SingleThreadTaskExecutor>( + base::MessagePumpType::UI); + event_source = ui::PlatformEventSource::CreateDefault(); + } +#endif +#if defined(USE_OZONE) // The MessagePump type required depends on the Ozone platform selected at // runtime. - main_thread_task_executor = - std::make_unique<base::SingleThreadTaskExecutor>( - gpu_preferences.message_pump_type); + if (!main_thread_task_executor) { + main_thread_task_executor = + std::make_unique<base::SingleThreadTaskExecutor>( + gpu_preferences.message_pump_type); + } +#endif #elif defined(OS_LINUX) #error "Unsupported Linux platform." #elif defined(OS_MACOSX) @@ -320,10 +335,15 @@ int GpuMain(const MainFunctionParams& parameters) { gpu_init->set_sandbox_helper(&sandbox_helper); - // Since GPU initialization calls into skia, its important to initialize skia + // Since GPU initialization calls into skia, it's important to initialize skia // before it. InitializeSkia(); + // Create the ThreadPool before invoking |gpu_init| as it needs the ThreadPool + // (in angle::InitializePlatform()). Do not start it until after the sandbox + // is initialized however to avoid creating threads outside the sandbox. + base::ThreadPoolInstance::Create("GPU"); + // Gpu initialization may fail for various reasons, in which case we will need // to tear down this process. However, we can not do so safely until the IPC // channel is set up, because the detection of early return of a child process @@ -338,6 +358,9 @@ int GpuMain(const MainFunctionParams& parameters) { GetContentClient()->SetGpuInfo(gpu_init->gpu_info()); + // Start the ThreadPoolInstance now that the sandbox is initialized. + base::ThreadPoolInstance::Get()->StartWithDefaultParams(); + const base::ThreadPriority io_thread_priority = base::FeatureList::IsEnabled(features::kGpuUseDisplayThreadPriority) ? base::ThreadPriority::DISPLAY @@ -356,11 +379,14 @@ int GpuMain(const MainFunctionParams& parameters) { #if defined(USE_X11) // ui::GbmDevice() takes >50ms with amdgpu, so kick off // GpuMemoryBufferSupportX11 creation on another thread now. - base::PostTask( - FROM_HERE, base::BindOnce([]() { - SCOPED_UMA_HISTOGRAM_TIMER("Linux.X11.GbmSupportX11CreationTime"); - ui::GpuMemoryBufferSupportX11::GetInstance(); - })); + if (!features::IsUsingOzonePlatform() && + gpu_preferences.enable_native_gpu_memory_buffers) { + base::ThreadPool::PostTask( + FROM_HERE, base::BindOnce([]() { + SCOPED_UMA_HISTOGRAM_TIMER("Linux.X11.GbmSupportX11CreationTime"); + ui::GpuMemoryBufferSupportX11::GetInstance(); + })); + } #endif auto* client = GetContentClient()->gpu(); diff --git a/chromium/content/gpu/gpu_sandbox_hook_linux.cc b/chromium/content/gpu/gpu_sandbox_hook_linux.cc index 82736eebc20..1b8cd6396f3 100644 --- a/chromium/content/gpu/gpu_sandbox_hook_linux.cc +++ b/chromium/content/gpu/gpu_sandbox_hook_linux.cc @@ -16,6 +16,7 @@ #include "base/bind.h" #include "base/files/file_enumerator.h" #include "base/files/scoped_file.h" +#include "base/logging.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "build/buildflag.h" @@ -132,8 +133,16 @@ void AddV4L2GpuWhitelist( if (options.accelerated_video_encode_enabled) { // Device node for V4L2 video encode accelerator drivers. - static const char kDevVideoEncPath[] = "/dev/video-enc"; - permissions->push_back(BrokerFilePermission::ReadWrite(kDevVideoEncPath)); + // See comments above for why we don't use a FileEnumerator. + static constexpr size_t MAX_V4L2_ENCODERS = 5; + static const base::FilePath::CharType kVideoEncBase[] = "/dev/video-enc"; + permissions->push_back(BrokerFilePermission::ReadWrite(kVideoEncBase)); + for (size_t i = 0; i < MAX_V4L2_ENCODERS; i++) { + std::ostringstream encoderPath; + encoderPath << kVideoEncBase << i; + permissions->push_back( + BrokerFilePermission::ReadWrite(encoderPath.str())); + } } // Device node for V4L2 JPEG decode accelerator drivers. @@ -264,6 +273,14 @@ void AddChromecastArmGpuWhitelist( static const char kLdSoCache[] = "/etc/ld.so.cache"; permissions->push_back(BrokerFilePermission::ReadOnly(kLdSoCache)); + + base::FileEnumerator enumerator( + base::FilePath(FILE_PATH_LITERAL("/dev/dri/")), false /* recursive */, + base::FileEnumerator::FILES, FILE_PATH_LITERAL("renderD*")); + for (base::FilePath name = enumerator.Next(); !name.empty(); + name = enumerator.Next()) { + permissions->push_back(BrokerFilePermission::ReadWrite(name.value())); + } } void AddStandardGpuWhiteList(std::vector<BrokerFilePermission>* permissions) { |