diff options
Diffstat (limited to 'chromium/content/browser/gpu')
20 files changed, 480 insertions, 203 deletions
diff --git a/chromium/content/browser/gpu/DEPS b/chromium/content/browser/gpu/DEPS index e1056a3cef6..a20e9f7a611 100644 --- a/chromium/content/browser/gpu/DEPS +++ b/chromium/content/browser/gpu/DEPS @@ -1,4 +1,5 @@ include_rules = [ + "+components/metal_util", "+components/ui_devtools/buildflags.h", ] diff --git a/chromium/content/browser/gpu/browser_gpu_channel_host_factory.cc b/chromium/content/browser/gpu/browser_gpu_channel_host_factory.cc index 8b33ed7860e..24eb8b83b7e 100644 --- a/chromium/content/browser/gpu/browser_gpu_channel_host_factory.cc +++ b/chromium/content/browser/gpu/browser_gpu_channel_host_factory.cc @@ -12,7 +12,6 @@ #include "base/location.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" -#include "base/task/post_task.h" #include "base/threading/thread_restrictions.h" #include "base/threading/thread_task_runner_handle.h" #include "base/timer/timer.h" @@ -44,6 +43,7 @@ #if defined(USE_X11) #include "content/browser/gpu/gpu_memory_buffer_manager_singleton_x11.h" // nogncheck +#include "ui/base/ui_base_features.h" #endif namespace content { @@ -54,15 +54,29 @@ namespace { void TimedOut() { LOG(FATAL) << "Timed out waiting for GPU channel."; } + +void DumpGpuStackOnIO() { + GpuProcessHost* host = + GpuProcessHost::Get(GPU_PROCESS_KIND_SANDBOXED, /*force_create=*/false); + if (host) { + host->DumpProcessStack(); + } + GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&TimedOut)); +} + +void TimerFired() { + GetIOThreadTaskRunner({})->PostTask(FROM_HERE, + base::BindOnce(&DumpGpuStackOnIO)); +} #endif // OS_ANDROID GpuMemoryBufferManagerSingleton* CreateGpuMemoryBufferManagerSingleton( int gpu_client_id) { #if defined(USE_X11) - return new GpuMemoryBufferManagerSingletonX11(gpu_client_id); -#else - return new GpuMemoryBufferManagerSingleton(gpu_client_id); + if (!features::IsUsingOzonePlatform()) + return new GpuMemoryBufferManagerSingletonX11(gpu_client_id); #endif + return new GpuMemoryBufferManagerSingleton(gpu_client_id); } } // namespace @@ -116,8 +130,8 @@ BrowserGpuChannelHostFactory::EstablishRequest::Create( scoped_refptr<EstablishRequest> establish_request = new EstablishRequest(gpu_client_id, gpu_client_tracing_id); // PostTask outside the constructor to ensure at least one reference exists. - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce( &BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO, establish_request)); @@ -180,8 +194,8 @@ void BrowserGpuChannelHostFactory::EstablishRequest::OnEstablishedOnIO( base::BindOnce( &BrowserGpuChannelHostFactory::EstablishRequest::RestartTimeout, this)); - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce( &BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO, this)); @@ -290,8 +304,8 @@ BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory() base::FilePath cache_dir = GetContentClient()->browser()->GetShaderDiskCacheDirectory(); if (!cache_dir.empty()) { - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce( &BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO, gpu_client_id_, cache_dir)); @@ -304,8 +318,8 @@ BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory() base::FilePath gr_cache_dir = GetContentClient()->browser()->GetGrShaderDiskCacheDirectory(); if (!gr_cache_dir.empty()) { - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce( &BrowserGpuChannelHostFactory::InitializeGrShaderDiskCacheOnIO, gr_cache_dir)); @@ -437,7 +451,7 @@ void BrowserGpuChannelHostFactory::RestartTimeout() { #endif timeout_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kGpuChannelTimeoutInSeconds), - base::BindOnce(&TimedOut)); + base::BindOnce(&TimerFired)); #endif // OS_ANDROID } diff --git a/chromium/content/browser/gpu/ca_transaction_gpu_coordinator.cc b/chromium/content/browser/gpu/ca_transaction_gpu_coordinator.cc index e8f21b5ae58..881c669dede 100644 --- a/chromium/content/browser/gpu/ca_transaction_gpu_coordinator.cc +++ b/chromium/content/browser/gpu/ca_transaction_gpu_coordinator.cc @@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/cancelable_callback.h" -#include "base/task/post_task.h" #include "content/browser/gpu/gpu_process_host.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -64,8 +63,8 @@ void CATransactionGPUCoordinator::RemovePostCommitObserverOnUIThread() { void CATransactionGPUCoordinator::OnActivateForTransaction() { DCHECK_CURRENTLY_ON(BrowserThread::UI); - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&CATransactionGPUCoordinator::OnActivateForTransactionOnIO, this)); } @@ -78,8 +77,8 @@ void CATransactionGPUCoordinator::OnEnterPostCommit() { // (and removed from the list of post-commit observers) soon after. pending_commit_count_++; - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&CATransactionGPUCoordinator::OnEnterPostCommitOnIO, this)); } diff --git a/chromium/content/browser/gpu/chromeos/video_capture_dependencies.cc b/chromium/content/browser/gpu/chromeos/video_capture_dependencies.cc index d98be022de4..b59b44b9d34 100644 --- a/chromium/content/browser/gpu/chromeos/video_capture_dependencies.cc +++ b/chromium/content/browser/gpu/chromeos/video_capture_dependencies.cc @@ -5,7 +5,6 @@ #include "content/browser/gpu/chromeos/video_capture_dependencies.h" #include "base/bind.h" -#include "base/task/post_task.h" #include "content/browser/gpu/gpu_process_host.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -17,8 +16,8 @@ void VideoCaptureDependencies::CreateJpegDecodeAccelerator( mojo::PendingReceiver<chromeos_camera::mojom::MjpegDecodeAccelerator> accelerator) { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&VideoCaptureDependencies::CreateJpegDecodeAccelerator, std::move(accelerator))); return; @@ -39,8 +38,8 @@ void VideoCaptureDependencies::CreateJpegEncodeAccelerator( mojo::PendingReceiver<chromeos_camera::mojom::JpegEncodeAccelerator> accelerator) { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&VideoCaptureDependencies::CreateJpegEncodeAccelerator, std::move(accelerator))); return; diff --git a/chromium/content/browser/gpu/compositor_util.cc b/chromium/content/browser/gpu/compositor_util.cc index 6e6de4c433a..4cdcc399628 100644 --- a/chromium/content/browser/gpu/compositor_util.cc +++ b/chromium/content/browser/gpu/compositor_util.cc @@ -37,6 +37,7 @@ #include "gpu/ipc/host/gpu_memory_buffer_support.h" #include "gpu/vulkan/buildflags.h" #include "media/media_buildflags.h" +#include "third_party/blink/public/common/switches.h" #include "ui/gl/gl_switches.h" namespace content { @@ -411,22 +412,22 @@ bool IsZeroCopyUploadEnabled() { const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); #if defined(OS_MACOSX) - return !command_line.HasSwitch(switches::kDisableZeroCopy); + return !command_line.HasSwitch(blink::switches::kDisableZeroCopy); #else - return command_line.HasSwitch(switches::kEnableZeroCopy); + return command_line.HasSwitch(blink::switches::kEnableZeroCopy); #endif } bool IsPartialRasterEnabled() { const auto& command_line = *base::CommandLine::ForCurrentProcess(); - return !command_line.HasSwitch(switches::kDisablePartialRaster); + return !command_line.HasSwitch(blink::switches::kDisablePartialRaster); } bool IsGpuMemoryBufferCompositorResourcesEnabled() { const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); if (command_line.HasSwitch( - switches::kEnableGpuMemoryBufferCompositorResources)) { + blink::switches::kEnableGpuMemoryBufferCompositorResources)) { return true; } if (command_line.HasSwitch( @@ -445,7 +446,8 @@ int GpuRasterizationMSAASampleCount() { const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); - if (!command_line.HasSwitch(switches::kGpuRasterizationMSAASampleCount)) + if (!command_line.HasSwitch( + blink::switches::kGpuRasterizationMSAASampleCount)) #if defined(OS_ANDROID) return 4; #else @@ -453,14 +455,14 @@ int GpuRasterizationMSAASampleCount() { return -1; #endif std::string string_value = command_line.GetSwitchValueASCII( - switches::kGpuRasterizationMSAASampleCount); + blink::switches::kGpuRasterizationMSAASampleCount); int msaa_sample_count = 0; if (base::StringToInt(string_value, &msaa_sample_count) && msaa_sample_count >= kMinMSAASampleCount) { return msaa_sample_count; } else { DLOG(WARNING) << "Failed to parse switch " - << switches::kGpuRasterizationMSAASampleCount << ": " + << blink::switches::kGpuRasterizationMSAASampleCount << ": " << string_value; return 0; } diff --git a/chromium/content/browser/gpu/gpu_data_manager_impl.cc b/chromium/content/browser/gpu/gpu_data_manager_impl.cc index 80fd68b4b86..f266f1b45a4 100644 --- a/chromium/content/browser/gpu/gpu_data_manager_impl.cc +++ b/chromium/content/browser/gpu/gpu_data_manager_impl.cc @@ -4,13 +4,54 @@ #include "content/browser/gpu/gpu_data_manager_impl.h" +#include "base/no_destructor.h" #include "content/browser/gpu/gpu_data_manager_impl_private.h" +#include "content/public/browser/browser_thread.h" #include "gpu/ipc/common/memory_stats.h" +#include "mojo/public/cpp/bindings/receiver_set.h" namespace content { namespace { + bool g_initialized = false; + +// Implementation of the Blink GpuDataManager interface to forward requests from +// a renderer to the GpuDataManagerImpl. +class GpuDataManagerReceiver : public blink::mojom::GpuDataManager { + public: + GpuDataManagerReceiver() = default; + GpuDataManagerReceiver(const GpuDataManagerReceiver&) = delete; + GpuDataManagerReceiver& operator=(const GpuDataManagerReceiver&) = delete; + ~GpuDataManagerReceiver() override = default; + + void Bind(mojo::PendingReceiver<blink::mojom::GpuDataManager> receiver) { + receivers_.Add(this, std::move(receiver)); + } + + // blink::mojom::GpuDataManager: + void Are3DAPIsBlockedForUrl( + const GURL& url, + Are3DAPIsBlockedForUrlCallback callback) override { + auto* manager = GpuDataManagerImpl::GetInstance(); + if (!manager) { + std::move(callback).Run(false); + return; + } + + std::move(callback).Run( + manager->Are3DAPIsBlocked(url, THREE_D_API_TYPE_WEBGL)); + } + + private: + mojo::ReceiverSet<blink::mojom::GpuDataManager> receivers_; +}; + +GpuDataManagerReceiver& GetGpuDataManagerReceiver() { + static base::NoDestructor<GpuDataManagerReceiver> receiver; + return *receiver.get(); +} + } // namespace // static @@ -128,10 +169,14 @@ void GpuDataManagerImpl::UpdateDxDiagNode( private_->UpdateDxDiagNode(dx_diagnostics); } -void GpuDataManagerImpl::UpdateDx12VulkanInfo( - const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info) { +void GpuDataManagerImpl::UpdateDx12Info(uint32_t d3d12_feature_level) { base::AutoLock auto_lock(lock_); - private_->UpdateDx12VulkanInfo(dx12_vulkan_version_info); + private_->UpdateDx12Info(d3d12_feature_level); +} + +void GpuDataManagerImpl::UpdateVulkanInfo(uint32_t vulkan_version) { + base::AutoLock auto_lock(lock_); + private_->UpdateVulkanInfo(vulkan_version); } void GpuDataManagerImpl::UpdateDevicePerfInfo( @@ -145,20 +190,34 @@ void GpuDataManagerImpl::UpdateOverlayInfo( base::AutoLock auto_lock(lock_); private_->UpdateOverlayInfo(overlay_info); } +void GpuDataManagerImpl::UpdateHDRStatus(bool hdr_enabled) { + base::AutoLock auto_lock(lock_); + private_->UpdateHDRStatus(hdr_enabled); +} void GpuDataManagerImpl::UpdateDxDiagNodeRequestStatus(bool request_continues) { base::AutoLock auto_lock(lock_); private_->UpdateDxDiagNodeRequestStatus(request_continues); } -void GpuDataManagerImpl::UpdateDx12VulkanRequestStatus(bool request_continues) { +void GpuDataManagerImpl::UpdateDx12RequestStatus(bool request_continues) { base::AutoLock auto_lock(lock_); - private_->UpdateDx12VulkanRequestStatus(request_continues); + private_->UpdateDx12RequestStatus(request_continues); } -bool GpuDataManagerImpl::Dx12VulkanRequested() const { +void GpuDataManagerImpl::UpdateVulkanRequestStatus(bool request_continues) { base::AutoLock auto_lock(lock_); - return private_->Dx12VulkanRequested(); + private_->UpdateVulkanRequestStatus(request_continues); +} + +bool GpuDataManagerImpl::Dx12Requested() const { + base::AutoLock auto_lock(lock_); + return private_->Dx12Requested(); +} + +bool GpuDataManagerImpl::VulkanRequested() const { + base::AutoLock auto_lock(lock_); + return private_->VulkanRequested(); } void GpuDataManagerImpl::OnBrowserThreadsStarted() { @@ -254,12 +313,9 @@ void GpuDataManagerImpl::BlockDomainFrom3DAPIs(const GURL& url, } bool GpuDataManagerImpl::Are3DAPIsBlocked(const GURL& top_origin_url, - int render_process_id, - int render_frame_id, ThreeDAPIType requester) { base::AutoLock auto_lock(lock_); - return private_->Are3DAPIsBlocked(top_origin_url, render_process_id, - render_frame_id, requester); + return private_->Are3DAPIsBlocked(top_origin_url, requester); } void GpuDataManagerImpl::UnblockDomainFrom3DAPIs(const GURL& url) { @@ -308,6 +364,15 @@ void GpuDataManagerImpl::OnDisplayRemoved(const display::Display& old_display) { private_->OnDisplayRemoved(old_display); } +// static +void GpuDataManagerImpl::BindReceiver( + mojo::PendingReceiver<blink::mojom::GpuDataManager> receiver) { + // This is intentionally always bound on the IO thread to ensure a low-latency + // response to sync IPCs. + DCHECK_CURRENTLY_ON(BrowserThread::IO); + GetGpuDataManagerReceiver().Bind(std::move(receiver)); +} + GpuDataManagerImpl::GpuDataManagerImpl() : private_(std::make_unique<GpuDataManagerImplPrivate>(this)) { g_initialized = true; diff --git a/chromium/content/browser/gpu/gpu_data_manager_impl.h b/chromium/content/browser/gpu/gpu_data_manager_impl.h index ce8f9551f1b..b1cb1060511 100644 --- a/chromium/content/browser/gpu/gpu_data_manager_impl.h +++ b/chromium/content/browser/gpu/gpu_data_manager_impl.h @@ -12,7 +12,6 @@ #include <string> #include "base/compiler_specific.h" -#include "base/logging.h" #include "base/macros.h" #include "base/no_destructor.h" #include "base/process/kill.h" @@ -30,6 +29,8 @@ #include "gpu/config/gpu_feature_info.h" #include "gpu/config/gpu_info.h" #include "gpu/config/gpu_mode.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" +#include "third_party/blink/public/mojom/gpu/gpu.mojom.h" #include "ui/display/display_observer.h" class GURL; @@ -83,13 +84,16 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager, const base::Optional<gpu::GPUInfo>& gpu_info_for_hardware_gpu); #if defined(OS_WIN) void UpdateDxDiagNode(const gpu::DxDiagNode& dx_diagnostics); - void UpdateDx12VulkanInfo( - const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info); + void UpdateDx12Info(uint32_t d3d12_feature_level); + void UpdateVulkanInfo(uint32_t vulkan_version); void UpdateDevicePerfInfo(const gpu::DevicePerfInfo& device_perf_info); void UpdateOverlayInfo(const gpu::OverlayInfo& overlay_info); + void UpdateHDRStatus(bool hdr_enabled); void UpdateDxDiagNodeRequestStatus(bool request_continues); - void UpdateDx12VulkanRequestStatus(bool request_continues); - bool Dx12VulkanRequested() const; + void UpdateDx12RequestStatus(bool request_continues); + void UpdateVulkanRequestStatus(bool request_continues); + bool Dx12Requested() const; + bool VulkanRequested() const; // Called from BrowserMainLoop::BrowserThreadsStarted(). void OnBrowserThreadsStarted(); void TerminateInfoCollectionGpuProcess(); @@ -141,8 +145,6 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager, // or a full URL to a page. void BlockDomainFrom3DAPIs(const GURL& url, gpu::DomainGuilt guilt); bool Are3DAPIsBlocked(const GURL& top_origin_url, - int render_process_id, - int render_frame_id, ThreeDAPIType requester); void UnblockDomainFrom3DAPIs(const GURL& url); @@ -174,6 +176,10 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager, void OnDisplayAdded(const display::Display& new_display) override; void OnDisplayRemoved(const display::Display& old_display) override; + // Binds a new Mojo receiver to handle requests from a renderer. + static void BindReceiver( + mojo::PendingReceiver<blink::mojom::GpuDataManager> receiver); + private: friend class GpuDataManagerImplPrivate; friend class GpuDataManagerImplPrivateTest; diff --git a/chromium/content/browser/gpu/gpu_data_manager_impl_private.cc b/chromium/content/browser/gpu/gpu_data_manager_impl_private.cc index e4ebd7fcd4a..e88f18d51f0 100644 --- a/chromium/content/browser/gpu/gpu_data_manager_impl_private.cc +++ b/chromium/content/browser/gpu/gpu_data_manager_impl_private.cc @@ -30,7 +30,6 @@ #include "base/rand_util.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" -#include "base/task/post_task.h" #include "base/trace_event/trace_event.h" #include "base/version.h" #include "build/build_config.h" @@ -74,6 +73,10 @@ #include "ui/gl/gpu_preference.h" #include "ui/gl/gpu_switching_manager.h" +#if defined(USE_OZONE) || defined(USE_X11) +#include "ui/base/ui_base_features.h" +#endif + #if defined(OS_ANDROID) #include "base/android/application_status_listener.h" #endif @@ -86,6 +89,7 @@ #if defined(OS_WIN) #include "base/base_paths_win.h" #include "base/win/windows_version.h" +#include "ui/display/win/screen_win.h" #endif // OS_WIN namespace content { @@ -373,8 +377,8 @@ enum BlockStatusHistogram { void OnVideoMemoryUsageStats( GpuDataManager::VideoMemoryUsageStatsCallback callback, const gpu::VideoMemoryUsageStats& stats) { - base::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(std::move(callback), stats)); + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), stats)); } void RequestVideoMemoryUsageStats( @@ -405,9 +409,8 @@ bool ALLOW_UNUSED_TYPE VulkanAllowed() { // be used for other purposes, such as WebGPU. const base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); - gpu::GrContextType gr_context_type = gpu::gles2::ParseGrContextType(); gpu::VulkanImplementationName use_vulkan = - gpu::gles2::ParseVulkanImplementationName(command_line, gr_context_type); + gpu::gles2::ParseVulkanImplementationName(command_line); return use_vulkan != gpu::VulkanImplementationName::kNone; #else return false; @@ -451,6 +454,45 @@ void CollectExtraDevicePerfInfo(const gpu::GPUInfo& gpu_info, device_perf_info->software_rendering = true; } } + +// Provides a bridge whereby display::win::ScreenWin can ask the GPU process +// about the HDR status of the system. +class HDRProxy { + public: + static void Initialize() { + display::win::ScreenWin::SetRequestHDRStatusCallback( + base::BindRepeating(&HDRProxy::RequestHDRStatus)); + } + + static void RequestHDRStatus() { + // The request must be sent to the GPU process from the IO thread. + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&HDRProxy::RequestOnIOThread)); + } + + static void GotResultOnIOThread(bool hdr_enabled) { + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&HDRProxy::GotResult, hdr_enabled)); + } + + private: + static void RequestOnIOThread() { + auto* gpu_process_host = + GpuProcessHost::Get(GPU_PROCESS_KIND_SANDBOXED, false); + if (gpu_process_host) { + auto* gpu_service = gpu_process_host->gpu_host()->gpu_service(); + gpu_service->RequestHDRStatus( + base::BindOnce(&HDRProxy::GotResultOnIOThread)); + } else { + bool hdr_enabled = false; + GotResultOnIOThread(hdr_enabled); + } + } + static void GotResult(bool hdr_enabled) { + display::win::ScreenWin::SetHDREnabled(hdr_enabled); + } +}; + #endif // OS_WIN } // anonymous namespace @@ -610,8 +652,11 @@ void GpuDataManagerImplPrivate::RequestDxdiagDx12VulkanGpuInfoIfNeeded( RequestDxDiagNodeData(); } - if (request & kGpuInfoRequestDx12Vulkan) - RequestGpuSupportedRuntimeVersion(delayed); + if (request & kGpuInfoRequestDx12) + RequestGpuSupportedDx12Version(delayed); + + if (request & kGpuInfoRequestVulkan) + RequestGpuSupportedVulkanVersion(delayed); } void GpuDataManagerImplPrivate::RequestDxDiagNodeData() { @@ -650,12 +695,11 @@ void GpuDataManagerImplPrivate::RequestDxDiagNodeData() { })); }); - base::PostTask(FROM_HERE, {BrowserThread::IO}, std::move(task)); + GetIOThreadTaskRunner({})->PostTask(FROM_HERE, std::move(task)); #endif } -void GpuDataManagerImplPrivate::RequestGpuSupportedRuntimeVersion( - bool delayed) { +void GpuDataManagerImplPrivate::RequestGpuSupportedDx12Version(bool delayed) { #if defined(OS_WIN) base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::TimeDelta delta; @@ -667,14 +711,14 @@ void GpuDataManagerImplPrivate::RequestGpuSupportedRuntimeVersion( base::OnceClosure task = base::BindOnce( [](base::TimeDelta delta) { GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); - if (manager->Dx12VulkanRequested()) + if (manager->Dx12Requested()) return; base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (command_line->HasSwitch( switches::kDisableGpuProcessForDX12VulkanInfoCollection)) { - manager->UpdateDx12VulkanRequestStatus(false); + manager->UpdateDx12RequestStatus(false); return; } @@ -687,26 +731,26 @@ void GpuDataManagerImplPrivate::RequestGpuSupportedRuntimeVersion( const gpu::GPUInfo::GPUDevice gpu = manager->GetGPUInfo().gpu; if ((gpu.vendor_id == 0xffff && gpu.device_id == 0xffff) || (!delta.is_zero() && gpu.vendor_id == 0 && gpu.device_id == 0)) { - manager->UpdateDx12VulkanRequestStatus(false); + manager->UpdateDx12RequestStatus(false); return; } GpuProcessHost* host = GpuProcessHost::Get( GPU_PROCESS_KIND_INFO_COLLECTION, true /* force_create */); if (!host) { - manager->UpdateDx12VulkanRequestStatus(false); + manager->UpdateDx12RequestStatus(false); return; } - manager->UpdateDx12VulkanRequestStatus(true); + manager->UpdateDx12RequestStatus(true); host->info_collection_gpu_service() - ->GetGpuSupportedRuntimeVersionAndDevicePerfInfo(base::BindOnce( - [](const gpu::Dx12VulkanVersionInfo& dx12_vulkan_info, - const gpu::DevicePerfInfo& device_perf_info) { + ->GetGpuSupportedDx12VersionAndDevicePerfInfo( + base::BindOnce([](uint32_t d3d12_feature_level, + const gpu::DevicePerfInfo& device_perf_info) { GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); - manager->UpdateDx12VulkanInfo(dx12_vulkan_info); - // UpdateDx12VulkanInfo() needs to be called before + manager->UpdateDx12Info(d3d12_feature_level); + // UpdateDx1Info() needs to be called before // UpdateDevicePerfInfo() because only the latter calls // NotifyGpuInfoUpdate(). manager->UpdateDevicePerfInfo(device_perf_info); @@ -715,7 +759,64 @@ void GpuDataManagerImplPrivate::RequestGpuSupportedRuntimeVersion( }, delta); - base::PostDelayedTask(FROM_HERE, {BrowserThread::IO}, std::move(task), delta); + GetIOThreadTaskRunner({})->PostDelayedTask(FROM_HERE, std::move(task), delta); +#endif +} + +void GpuDataManagerImplPrivate::RequestGpuSupportedVulkanVersion(bool delayed) { +#if defined(OS_WIN) + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + base::TimeDelta delta; + if (delayed && + !command_line->HasSwitch(switches::kNoDelayForDX12VulkanInfoCollection)) { + delta = base::TimeDelta::FromSeconds(120); + } + + base::OnceClosure task = base::BindOnce( + [](base::TimeDelta delta) { + GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); + if (manager->VulkanRequested()) + return; + + base::CommandLine* command_line = + base::CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch( + switches::kDisableGpuProcessForDX12VulkanInfoCollection)) { + manager->UpdateVulkanRequestStatus(false); + return; + } + + // No info collection for software GL implementation (id == 0xffff) or + // abnormal situation (id == 0). There are a few crash reports on + // exit_or_terminate_process() during process teardown. The GPU ID + // should be available by the time this task starts to run. In the case + // of no delay, which is for testing only, don't check the GPU ID + // because the ID is not available yet. + const gpu::GPUInfo::GPUDevice gpu = manager->GetGPUInfo().gpu; + if ((gpu.vendor_id == 0xffff && gpu.device_id == 0xffff) || + (!delta.is_zero() && gpu.vendor_id == 0 && gpu.device_id == 0)) { + manager->UpdateVulkanRequestStatus(false); + return; + } + + GpuProcessHost* host = GpuProcessHost::Get( + GPU_PROCESS_KIND_INFO_COLLECTION, true /* force_create */); + if (!host) { + manager->UpdateVulkanRequestStatus(false); + return; + } + + manager->UpdateVulkanRequestStatus(true); + host->info_collection_gpu_service()->GetGpuSupportedVulkanVersionInfo( + base::BindOnce([](uint32_t vulkan_version) { + GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); + manager->UpdateVulkanInfo(vulkan_version); + manager->TerminateInfoCollectionGpuProcess(); + })); + }, + delta); + + GetIOThreadTaskRunner({})->PostDelayedTask(FROM_HERE, std::move(task), delta); #endif } @@ -732,8 +833,9 @@ bool GpuDataManagerImplPrivate::IsDx12VulkanVersionAvailable() const { // This function returns the status of availability to the tests based on // whether gpu info has been requested or not. - return gpu_info_dx12_vulkan_valid_ || !gpu_info_dx12_vulkan_requested_ || - gpu_info_dx12_vulkan_request_failed_; + return (gpu_info_dx12_valid_ && gpu_info_vulkan_valid_) || + (!gpu_info_dx12_requested_ || !gpu_info_vulkan_requested_) || + (gpu_info_dx12_request_failed_ || gpu_info_vulkan_request_failed_); #else return true; #endif @@ -800,8 +902,8 @@ void GpuDataManagerImplPrivate::UpdateGpuInfo( // the new GPU process again, and may overwrite the DX12, Vulkan, DxDiagNode // info we already collected. This is to make sure it doesn't happen. gpu::DxDiagNode dx_diagnostics = gpu_info_.dx_diagnostics; - gpu::Dx12VulkanVersionInfo dx12_vulkan_version_info = - gpu_info_.dx12_vulkan_version_info; + uint32_t d3d12_feature_level = gpu_info_.d3d12_feature_level; + uint32_t vulkan_version = gpu_info_.vulkan_version; #endif gpu_info_ = gpu_info; UMA_HISTOGRAM_CUSTOM_TIMES("GPU.GPUInitializationTime.V2", @@ -812,8 +914,11 @@ void GpuDataManagerImplPrivate::UpdateGpuInfo( if (!dx_diagnostics.IsEmpty()) { gpu_info_.dx_diagnostics = dx_diagnostics; } - if (!dx12_vulkan_version_info.IsEmpty()) { - gpu_info_.dx12_vulkan_version_info = dx12_vulkan_version_info; + if (d3d12_feature_level != 0) { + gpu_info_.d3d12_feature_level = d3d12_feature_level; + } + if (vulkan_version != 0) { + gpu_info_.vulkan_version = vulkan_version; } #endif // OS_WIN @@ -838,15 +943,20 @@ void GpuDataManagerImplPrivate::UpdateDxDiagNode( NotifyGpuInfoUpdate(); } -void GpuDataManagerImplPrivate::UpdateDx12VulkanInfo( - const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info) { - gpu_info_.dx12_vulkan_version_info = dx12_vulkan_version_info; - gpu_info_dx12_vulkan_valid_ = true; - // No need to call NotifyGpuInfoUpdate() because UpdateDx12VulkanInfo() is +void GpuDataManagerImplPrivate::UpdateDx12Info(uint32_t d3d12_feature_level) { + gpu_info_.d3d12_feature_level = d3d12_feature_level; + gpu_info_dx12_valid_ = true; + // No need to call NotifyGpuInfoUpdate() because UpdateDx12Info() is // always called together with UpdateDevicePerfInfo, which calls // NotifyGpuInfoUpdate(). } +void GpuDataManagerImplPrivate::UpdateVulkanInfo(uint32_t vulkan_version) { + gpu_info_.vulkan_version = vulkan_version; + gpu_info_vulkan_valid_ = true; + NotifyGpuInfoUpdate(); +} + void GpuDataManagerImplPrivate::UpdateDevicePerfInfo( const gpu::DevicePerfInfo& device_perf_info) { gpu::DevicePerfInfo mutable_device_perf_info = device_perf_info; @@ -864,6 +974,12 @@ void GpuDataManagerImplPrivate::UpdateOverlayInfo( NotifyGpuInfoUpdate(); } +void GpuDataManagerImplPrivate::UpdateHDRStatus(bool hdr_enabled) { + // This is running on the IO thread; + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + HDRProxy::GotResultOnIOThread(hdr_enabled); +} + void GpuDataManagerImplPrivate::UpdateDxDiagNodeRequestStatus( bool request_continues) { gpu_info_dx_diag_request_failed_ = !request_continues; @@ -872,31 +988,52 @@ void GpuDataManagerImplPrivate::UpdateDxDiagNodeRequestStatus( NotifyGpuInfoUpdate(); } -void GpuDataManagerImplPrivate::UpdateDx12VulkanRequestStatus( +void GpuDataManagerImplPrivate::UpdateDx12RequestStatus( bool request_continues) { - gpu_info_dx12_vulkan_requested_ = true; - gpu_info_dx12_vulkan_request_failed_ = !request_continues; + gpu_info_dx12_requested_ = true; + gpu_info_dx12_request_failed_ = !request_continues; - if (gpu_info_dx12_vulkan_request_failed_) { + if (gpu_info_dx12_request_failed_) { gpu::DevicePerfInfo device_perf_info; gpu::CollectDevicePerfInfo(&device_perf_info, /*in_browser_process=*/true); UpdateDevicePerfInfo(device_perf_info); } } -bool GpuDataManagerImplPrivate::Dx12VulkanRequested() const { - return gpu_info_dx12_vulkan_requested_; +void GpuDataManagerImplPrivate::UpdateVulkanRequestStatus( + bool request_continues) { + gpu_info_vulkan_requested_ = true; + gpu_info_vulkan_request_failed_ = !request_continues; +} + +bool GpuDataManagerImplPrivate::Dx12Requested() const { + return gpu_info_dx12_requested_; +} + +bool GpuDataManagerImplPrivate::VulkanRequested() const { + return gpu_info_vulkan_requested_; } void GpuDataManagerImplPrivate::OnBrowserThreadsStarted() { - // Launch the info collection GPU process to collect DX12 and Vulkan support - // information. Not to affect Chrome startup, this is done in a delayed mode, - // i.e., 120 seconds after Chrome startup. - RequestDxdiagDx12VulkanGpuInfoIfNeeded(kGpuInfoRequestDx12Vulkan, - /*delayed=*/true); + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kNoDelayForDX12VulkanInfoCollection)) { + // This is for the info collection test of the gpu integration tests. + RequestDxdiagDx12VulkanGpuInfoIfNeeded(kGpuInfoRequestDx12Vulkan, + /*delayed=*/false); + } else { + // Launch the info collection GPU process to collect DX12 support + // information for UMA at the start of the browser. + // Not to affect Chrome startup, this is done in a delayed mode, i.e., 120 + // seconds after Chrome startup. + RequestDxdiagDx12VulkanGpuInfoIfNeeded(kGpuInfoRequestDx12, + /*delayed=*/true); + } // Observer for display change. if (display::Screen::GetScreen()) display::Screen::GetScreen()->AddObserver(owner_); + + // Initialization for HDR status update. + HDRProxy::Initialize(); } void GpuDataManagerImplPrivate::TerminateInfoCollectionGpuProcess() { @@ -905,12 +1042,15 @@ void GpuDataManagerImplPrivate::TerminateInfoCollectionGpuProcess() { if (gpu_info_dx_diag_requested_ && !gpu_info_dx_diag_request_failed_ && gpu_info_.dx_diagnostics.IsEmpty()) return; - // gpu_info_dx12_vulkan_valid_ is always updated before device_perf_info - if (gpu_info_dx12_vulkan_requested_ && - !gpu_info_dx12_vulkan_request_failed_ && + // gpu_info_dx12_valid_ is always updated before device_perf_info + if (gpu_info_dx12_requested_ && !gpu_info_dx12_request_failed_ && !gpu::GetDevicePerfInfo().has_value()) return; + if (gpu_info_vulkan_requested_ && !gpu_info_vulkan_request_failed_ && + !gpu_info_vulkan_valid_) + return; + // GpuProcessHost::Get() calls GpuDataManagerImpl functions and causes a // re-entry of lock. base::AutoUnlock unlock(owner_->lock_); @@ -1055,12 +1195,16 @@ void GpuDataManagerImplPrivate::UpdateGpuPreferences( GpuMemoryBufferManagerSingleton::GetInstance()) { // On X11, we do not know GpuMemoryBuffer configuration support until // receiving the initial GPUInfo. -#if !defined(USE_X11) - gpu_preferences->disable_biplanar_gpu_memory_buffers_for_video_frames = - !gpu_memory_buffer_manager->IsNativeGpuMemoryBufferConfiguration( - gfx::BufferFormat::YUV_420_BIPLANAR, - gfx::BufferUsage::GPU_READ_CPU_READ_WRITE); + bool should_update = true; +#if defined(USE_X11) + should_update = features::IsUsingOzonePlatform(); #endif + if (should_update) { + gpu_preferences->disable_biplanar_gpu_memory_buffers_for_video_frames = + !gpu_memory_buffer_manager->IsNativeGpuMemoryBufferConfiguration( + gfx::BufferFormat::YUV_420_BIPLANAR, + gfx::BufferUsage::GPU_READ_CPU_READ_WRITE); + } } gpu_preferences->gpu_program_cache_size = @@ -1089,9 +1233,11 @@ void GpuDataManagerImplPrivate::UpdateGpuPreferences( #endif #if defined(USE_OZONE) - gpu_preferences->message_pump_type = ui::OzonePlatform::GetInstance() - ->GetPlatformProperties() - .message_pump_type_for_gpu; + if (features::IsUsingOzonePlatform()) { + gpu_preferences->message_pump_type = ui::OzonePlatform::GetInstance() + ->GetPlatformProperties() + .message_pump_type_for_gpu; + } #endif #if defined(OS_MACOSX) @@ -1300,8 +1446,6 @@ void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIs(const GURL& url, } bool GpuDataManagerImplPrivate::Are3DAPIsBlocked(const GURL& top_origin_url, - int render_process_id, - int render_frame_id, ThreeDAPIType requester) { return Are3DAPIsBlockedAtTime(top_origin_url, base::Time::Now()) != DomainBlockStatus::kNotBlocked; diff --git a/chromium/content/browser/gpu/gpu_data_manager_impl_private.h b/chromium/content/browser/gpu/gpu_data_manager_impl_private.h index 37c11fa98c3..563472dcafa 100644 --- a/chromium/content/browser/gpu/gpu_data_manager_impl_private.h +++ b/chromium/content/browser/gpu/gpu_data_manager_impl_private.h @@ -62,14 +62,17 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate { const base::Optional<gpu::GPUInfo>& optional_gpu_info_for_hardware_gpu); #if defined(OS_WIN) void UpdateDxDiagNode(const gpu::DxDiagNode& dx_diagnostics); - void UpdateDx12VulkanInfo( - const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info); + void UpdateDx12Info(uint32_t d3d12_feature_level); + void UpdateVulkanInfo(uint32_t vulkan_version); void UpdateDevicePerfInfo(const gpu::DevicePerfInfo& device_perf_info); void UpdateOverlayInfo(const gpu::OverlayInfo& overlay_info); - void UpdateDx12VulkanRequestStatus(bool request_continues); + void UpdateHDRStatus(bool hdr_enabled); void UpdateDxDiagNodeRequestStatus(bool request_continues); - bool Dx12VulkanRequested() const; + void UpdateDx12RequestStatus(bool request_continues); + void UpdateVulkanRequestStatus(bool request_continues); + bool Dx12Requested() const; + bool VulkanRequested() const; void OnBrowserThreadsStarted(); void TerminateInfoCollectionGpuProcess(); #endif @@ -104,8 +107,6 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate { void BlockDomainFrom3DAPIs(const GURL& url, gpu::DomainGuilt guilt); bool Are3DAPIsBlocked(const GURL& top_origin_url, - int render_process_id, - int render_frame_id, ThreeDAPIType requester); void DisableDomainBlockingFor3DAPIsForTesting(); @@ -194,7 +195,8 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate { void NotifyGpuInfoUpdate(); void RequestDxDiagNodeData(); - void RequestGpuSupportedRuntimeVersion(bool delayed); + void RequestGpuSupportedDx12Version(bool delayed); + void RequestGpuSupportedVulkanVersion(bool delayed); void RecordCompositingMode(); @@ -206,9 +208,12 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate { #if defined(OS_WIN) bool gpu_info_dx_diag_requested_ = false; bool gpu_info_dx_diag_request_failed_ = false; - bool gpu_info_dx12_vulkan_valid_ = false; - bool gpu_info_dx12_vulkan_requested_ = false; - bool gpu_info_dx12_vulkan_request_failed_ = false; + bool gpu_info_dx12_valid_ = false; + bool gpu_info_dx12_requested_ = false; + bool gpu_info_dx12_request_failed_ = false; + bool gpu_info_vulkan_valid_ = false; + bool gpu_info_vulkan_requested_ = false; + bool gpu_info_vulkan_request_failed_ = false; #endif // What we would have gotten if we haven't fallen back to SwiftShader or diff --git a/chromium/content/browser/gpu/gpu_data_manager_testing_autogen.cc b/chromium/content/browser/gpu/gpu_data_manager_testing_autogen.cc index 742589f9f2f..7d2a264c142 100644 --- a/chromium/content/browser/gpu/gpu_data_manager_testing_autogen.cc +++ b/chromium/content/browser/gpu/gpu_data_manager_testing_autogen.cc @@ -33,8 +33,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = { GpuControlList::kVersionSchemaCommon, nullptr, nullptr}, // os_version 0x00, // vendor_id - 0, // DeviceIDs size - nullptr, // DeviceIDs + 0, // Devices size + nullptr, // Devices GpuControlList::kMultiGpuCategoryNone, // multi_gpu_category GpuControlList::kMultiGpuStyleNone, // multi_gpu_style nullptr, // driver info @@ -67,8 +67,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = { GpuControlList::kVersionSchemaCommon, nullptr, nullptr}, // os_version 0x00, // vendor_id - 0, // DeviceIDs size - nullptr, // DeviceIDs + 0, // Devices size + nullptr, // Devices GpuControlList::kMultiGpuCategoryNone, // multi_gpu_category GpuControlList::kMultiGpuStyleNone, // multi_gpu_style nullptr, // driver info @@ -101,8 +101,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = { GpuControlList::kVersionSchemaCommon, nullptr, nullptr}, // os_version 0x00, // vendor_id - 0, // DeviceIDs size - nullptr, // DeviceIDs + 0, // Devices size + nullptr, // Devices GpuControlList::kMultiGpuCategoryNone, // multi_gpu_category GpuControlList::kMultiGpuStyleNone, // multi_gpu_style nullptr, // driver info @@ -135,8 +135,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = { GpuControlList::kVersionSchemaCommon, nullptr, nullptr}, // os_version 0x00, // vendor_id - 0, // DeviceIDs size - nullptr, // DeviceIDs + 0, // Devices size + nullptr, // Devices GpuControlList::kMultiGpuCategoryNone, // multi_gpu_category GpuControlList::kMultiGpuStyleNone, // multi_gpu_style nullptr, // driver info @@ -169,8 +169,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = { GpuControlList::kVersionSchemaCommon, nullptr, nullptr}, // os_version 0x00, // vendor_id - 0, // DeviceIDs size - nullptr, // DeviceIDs + 0, // Devices size + nullptr, // Devices GpuControlList::kMultiGpuCategoryNone, // multi_gpu_category GpuControlList::kMultiGpuStyleNone, // multi_gpu_style nullptr, // driver info @@ -203,8 +203,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = { GpuControlList::kVersionSchemaCommon, nullptr, nullptr}, // os_version 0x00, // vendor_id - 0, // DeviceIDs size - nullptr, // DeviceIDs + 0, // Devices size + nullptr, // Devices GpuControlList::kMultiGpuCategoryNone, // multi_gpu_category GpuControlList::kMultiGpuStyleNone, // multi_gpu_style nullptr, // driver info @@ -237,8 +237,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = { GpuControlList::kVersionSchemaCommon, nullptr, nullptr}, // os_version 0x8086, // vendor_id - 0, // DeviceIDs size - nullptr, // DeviceIDs + 0, // Devices size + nullptr, // Devices GpuControlList::kMultiGpuCategoryActive, // multi_gpu_category GpuControlList::kMultiGpuStyleNone, // multi_gpu_style nullptr, // driver info diff --git a/chromium/content/browser/gpu/gpu_data_manager_testing_exceptions_autogen.h b/chromium/content/browser/gpu/gpu_data_manager_testing_exceptions_autogen.h index d879bd64bcc..5fc8fbbbf38 100644 --- a/chromium/content/browser/gpu/gpu_data_manager_testing_exceptions_autogen.h +++ b/chromium/content/browser/gpu/gpu_data_manager_testing_exceptions_autogen.h @@ -18,8 +18,8 @@ const GpuControlList::Conditions kExceptionsForEntry5[1] = { {GpuControlList::kUnknown, GpuControlList::kVersionStyleNumerical, GpuControlList::kVersionSchemaCommon, nullptr, nullptr}, // os_version 0x00, // vendor_id - 0, // DeviceIDs size - nullptr, // DeviceIDs + 0, // Devices size + nullptr, // Devices GpuControlList::kMultiGpuCategoryNone, // multi_gpu_category GpuControlList::kMultiGpuStyleNone, // multi_gpu_style nullptr, // driver info diff --git a/chromium/content/browser/gpu/gpu_internals_ui.cc b/chromium/content/browser/gpu/gpu_internals_ui.cc index 86ffbc43120..3a61d1573d3 100644 --- a/chromium/content/browser/gpu/gpu_internals_ui.cc +++ b/chromium/content/browser/gpu/gpu_internals_ui.cc @@ -47,6 +47,7 @@ #include "gpu/config/gpu_util.h" #include "gpu/ipc/common/gpu_memory_buffer_support.h" #include "gpu/ipc/host/gpu_memory_buffer_support.h" +#include "services/network/public/mojom/content_security_policy.mojom.h" #include "skia/ext/skia_commit_hash.h" #include "third_party/angle/src/common/version.h" #include "third_party/skia/include/core/SkMilestone.h" @@ -62,6 +63,7 @@ #endif #if defined(USE_X11) +#include "ui/base/ui_base_features.h" #include "ui/base/x/x11_util.h" // nogncheck #include "ui/gfx/x/x11_atom_cache.h" // nogncheck #endif @@ -71,7 +73,8 @@ namespace { WebUIDataSource* CreateGpuHTMLSource() { WebUIDataSource* source = WebUIDataSource::Create(kChromeUIGpuHost); - source->OverrideContentSecurityPolicyScriptSrc( + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::ScriptSrc, "script-src chrome://resources 'self' 'unsafe-eval';"); source->UseStringsJs(); @@ -136,6 +139,9 @@ std::string GPUDeviceToString(const gpu::GPUInfo::GPUDevice& gpu) { rt += base::StringPrintf(", SUBSYS=0x%08x, REV=%u", gpu.sub_sys_id, gpu.revision); } + + rt += base::StringPrintf(", LUID={%ld,%lu}", gpu.luid.HighPart, + gpu.luid.LowPart); #endif if (gpu.active) rt += " *ACTIVE*"; @@ -189,6 +195,14 @@ std::unique_ptr<base::ListValue> BasicGpuInfoAsListValue( basic_info->Append(NewDescriptionValuePair( "NV12 overlay support", gpu::OverlaySupportToString(gpu_info.overlay_info.nv12_overlay_support))); + basic_info->Append(NewDescriptionValuePair( + "BGRA8 overlay support", + gpu::OverlaySupportToString( + gpu_info.overlay_info.bgra8_overlay_support))); + basic_info->Append(NewDescriptionValuePair( + "RGB10A2 overlay support", + gpu::OverlaySupportToString( + gpu_info.overlay_info.rgb10a2_overlay_support))); std::vector<gfx::PhysicalDisplaySize> display_sizes = gfx::GetPhysicalSizeForDisplays(); @@ -207,13 +221,11 @@ std::unique_ptr<base::ListValue> BasicGpuInfoAsListValue( basic_info->Append(NewDescriptionValuePair( "Driver D3D12 feature level", - gpu::D3DFeatureLevelToString( - gpu_info.dx12_vulkan_version_info.d3d12_feature_level))); + gpu::D3DFeatureLevelToString(gpu_info.d3d12_feature_level))); basic_info->Append(NewDescriptionValuePair( "Driver Vulkan API version", - gpu::VulkanVersionToString( - gpu_info.dx12_vulkan_version_info.vulkan_version))); + gpu::VulkanVersionToString(gpu_info.vulkan_version))); #endif basic_info->Append( @@ -251,25 +263,29 @@ std::unique_ptr<base::ListValue> BasicGpuInfoAsListValue( basic_info->Append(NewDescriptionValuePair("Window system binding extensions", gpu_info.gl_ws_extensions)); #if defined(USE_X11) - basic_info->Append( - NewDescriptionValuePair("Window manager", ui::GuessWindowManagerName())); - { - std::unique_ptr<base::Environment> env(base::Environment::Create()); - std::string value; - const char kXDGCurrentDesktop[] = "XDG_CURRENT_DESKTOP"; - if (env->GetVar(kXDGCurrentDesktop, &value)) - basic_info->Append(NewDescriptionValuePair(kXDGCurrentDesktop, value)); - const char kGDMSession[] = "GDMSESSION"; - if (env->GetVar(kGDMSession, &value)) - basic_info->Append(NewDescriptionValuePair(kGDMSession, value)); + // TODO(https://crbug.com/1097007): capture window manager name on Ozone. + if (!features::IsUsingOzonePlatform()) { + basic_info->Append(NewDescriptionValuePair("Window manager", + ui::GuessWindowManagerName())); + { + std::unique_ptr<base::Environment> env(base::Environment::Create()); + std::string value; + const char kXDGCurrentDesktop[] = "XDG_CURRENT_DESKTOP"; + if (env->GetVar(kXDGCurrentDesktop, &value)) + basic_info->Append(NewDescriptionValuePair(kXDGCurrentDesktop, value)); + const char kGDMSession[] = "GDMSESSION"; + if (env->GetVar(kGDMSession, &value)) + basic_info->Append(NewDescriptionValuePair(kGDMSession, value)); + basic_info->Append(NewDescriptionValuePair( + "Compositing manager", + ui::IsCompositingManagerPresent() ? "Yes" : "No")); + } basic_info->Append(NewDescriptionValuePair( - "Compositing manager", - ui::IsCompositingManagerPresent() ? "Yes" : "No")); + "System visual ID", + base::NumberToString(gpu_extra_info.system_visual))); + basic_info->Append(NewDescriptionValuePair( + "RGBA visual ID", base::NumberToString(gpu_extra_info.rgba_visual))); } - basic_info->Append(NewDescriptionValuePair( - "System visual ID", base::NumberToString(gpu_extra_info.system_visual))); - basic_info->Append(NewDescriptionValuePair( - "RGBA visual ID", base::NumberToString(gpu_extra_info.rgba_visual))); #endif std::string direct_rendering_version; if (gpu_info.direct_rendering_version == "1") { @@ -361,13 +377,18 @@ std::unique_ptr<base::ListValue> GpuMemoryBufferInfo( gpu::GpuMemoryBufferSupport gpu_memory_buffer_support; + gpu::GpuMemoryBufferConfigurationSet native_config; #if defined(USE_X11) - const auto& native_configurations = - gpu_extra_info.gpu_memory_buffer_support_x11; -#else - const auto native_configurations = - gpu::GetNativeGpuMemoryBufferConfigurations(&gpu_memory_buffer_support); + if (features::IsUsingOzonePlatform()) { + for (const auto& config : gpu_extra_info.gpu_memory_buffer_support_x11) { + native_config.emplace(config); + } + } #endif + if (native_config.empty()) { + native_config = + gpu::GetNativeGpuMemoryBufferConfigurations(&gpu_memory_buffer_support); + } for (size_t format = 0; format < static_cast<size_t>(gfx::BufferFormat::LAST) + 1; format++) { std::string native_usage_support; @@ -375,7 +396,7 @@ std::unique_ptr<base::ListValue> GpuMemoryBufferInfo( usage < static_cast<size_t>(gfx::BufferUsage::LAST) + 1; usage++) { gfx::BufferUsageAndFormat element{static_cast<gfx::BufferUsage>(usage), static_cast<gfx::BufferFormat>(format)}; - if (base::Contains(native_configurations, element)) { + if (base::Contains(native_config, element)) { native_usage_support = base::StringPrintf( "%s%s %s", native_usage_support.c_str(), native_usage_support.empty() ? "" : ",", diff --git a/chromium/content/browser/gpu/gpu_ipc_browsertests.cc b/chromium/content/browser/gpu/gpu_ipc_browsertests.cc index 670a9f5c9f6..e25560436b4 100644 --- a/chromium/content/browser/gpu/gpu_ipc_browsertests.cc +++ b/chromium/content/browser/gpu/gpu_ipc_browsertests.cc @@ -4,7 +4,6 @@ #include "base/command_line.h" #include "base/run_loop.h" -#include "base/task/post_task.h" #include "build/build_config.h" #include "components/viz/common/gpu/context_provider.h" #include "content/browser/browser_main_loop.h" @@ -319,8 +318,8 @@ IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, CreateTransferBuffer) { // channel on the IO thread, which then notifies the main thread about the // error state. base::RunLoop wait_for_io_run_loop; - base::CreateSingleThreadTaskRunner({BrowserThread::IO}) - ->PostTask(FROM_HERE, wait_for_io_run_loop.QuitClosure()); + GetIOThreadTaskRunner({})->PostTask(FROM_HERE, + wait_for_io_run_loop.QuitClosure()); // Waits for the IO thread to run. wait_for_io_run_loop.Run(); diff --git a/chromium/content/browser/gpu/gpu_memory_buffer_manager_singleton.cc b/chromium/content/browser/gpu/gpu_memory_buffer_manager_singleton.cc index dcbcb823254..1a3d4510a1a 100644 --- a/chromium/content/browser/gpu/gpu_memory_buffer_manager_singleton.cc +++ b/chromium/content/browser/gpu/gpu_memory_buffer_manager_singleton.cc @@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/check_op.h" -#include "base/task/post_task.h" #include "components/viz/host/gpu_host_impl.h" #include "content/browser/gpu/gpu_process_host.h" #include "content/public/browser/browser_task_traits.h" @@ -35,7 +34,7 @@ GpuMemoryBufferManagerSingleton::GpuMemoryBufferManagerSingleton(int client_id) base::BindRepeating(&content::GetGpuService), client_id, std::make_unique<gpu::GpuMemoryBufferSupport>(), - base::CreateSingleThreadTaskRunner({BrowserThread::IO})) { + GetIOThreadTaskRunner({})) { DCHECK(!g_gpu_memory_buffer_manager); g_gpu_memory_buffer_manager = this; } diff --git a/chromium/content/browser/gpu/gpu_process_host.cc b/chromium/content/browser/gpu/gpu_process_host.cc index d39f52a896c..9f9d3422ad1 100644 --- a/chromium/content/browser/gpu/gpu_process_host.cc +++ b/chromium/content/browser/gpu/gpu_process_host.cc @@ -26,7 +26,6 @@ #include "base/numerics/ranges.h" #include "base/stl_util.h" #include "base/strings/utf_string_conversions.h" -#include "base/task/post_task.h" #include "base/threading/thread.h" #include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" @@ -56,6 +55,7 @@ #include "content/public/common/content_switches.h" #include "content/public/common/result_codes.h" #include "content/public/common/sandboxed_process_launcher_delegate.h" +#include "content/public/common/zygote/zygote_buildflags.h" #include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/config/gpu_driver_bug_list.h" #include "gpu/config/gpu_driver_bug_workaround_type.h" @@ -97,11 +97,16 @@ #include "ui/gfx/x/x11_switches.h" // nogncheck #endif +#if BUILDFLAG(USE_ZYGOTE_HANDLE) +#include "content/common/zygote/zygote_handle_impl_linux.h" +#endif + #if defined(OS_MACOSX) || defined(OS_ANDROID) #include "gpu/ipc/common/gpu_surface_tracker.h" #endif #if defined(OS_MACOSX) +#include "components/metal_util/switches.h" #include "content/browser/gpu/ca_transaction_gpu_coordinator.h" #endif @@ -252,10 +257,12 @@ static const char* const kSwitchNames[] = { switches::kUseGpuInTests, switches::kV, switches::kVModule, + switches::kUseAdapterLuid, #if defined(OS_MACOSX) service_manager::switches::kEnableSandboxLogging, switches::kDisableAVFoundationOverlays, switches::kDisableMacOverlays, + switches::kDisableMetalTestShaders, switches::kDisableRemoteCoreAnimation, switches::kShowMacOverlayBorders, switches::kUseHighGPUThreadPriorityForPerfTests, @@ -275,6 +282,7 @@ static const char* const kSwitchNames[] = { switches::kForceVideoOverlays, #if defined(OS_ANDROID) switches::kEnableReachedCodeProfiler, + switches::kReachedCodeSamplingIntervalUs, #endif }; @@ -305,9 +313,11 @@ void OnGpuProcessHostDestroyedOnUI(int host_id, const std::string& message) { GpuDataManagerImpl::GetInstance()->AddLogMessage(logging::LOG_ERROR, "GpuProcessHost", message); #if defined(USE_OZONE) - ui::OzonePlatform::GetInstance() - ->GetGpuPlatformSupportHost() - ->OnChannelDestroyed(host_id); + if (features::IsUsingOzonePlatform()) { + ui::OzonePlatform::GetInstance() + ->GetGpuPlatformSupportHost() + ->OnChannelDestroyed(host_id); + } #endif } @@ -418,13 +428,13 @@ class GpuSandboxedProcessLauncherDelegate #endif // OS_WIN #if BUILDFLAG(USE_ZYGOTE_HANDLE) - service_manager::ZygoteHandle GetZygote() override { + ZygoteHandle GetZygote() override { if (service_manager::IsUnsandboxedSandboxType(GetSandboxType())) return nullptr; // The GPU process needs a specialized sandbox, so fork from the unsandboxed // zygote and then apply the actual sandboxes in the forked process. - return service_manager::GetUnsandboxedZygote(); + return GetUnsandboxedZygote(); } #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) @@ -479,8 +489,8 @@ void BindDiscardableMemoryReceiverOnUI( mojo::PendingReceiver< discardable_memory::mojom::DiscardableSharedMemoryManager> receiver) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce( &BindDiscardableMemoryReceiverOnIO, std::move(receiver), discardable_memory::DiscardableSharedMemoryManager::Get())); @@ -558,8 +568,8 @@ GpuProcessHost* GpuProcessHost::Get(GpuProcessKind kind, bool force_create) { // static void GpuProcessHost::GetHasGpuProcess(base::OnceCallback<void(bool)> callback) { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&GpuProcessHost::GetHasGpuProcess, std::move(callback))); return; } @@ -582,8 +592,8 @@ void GpuProcessHost::CallOnIO( #if !defined(OS_WIN) DCHECK_NE(kind, GPU_PROCESS_KIND_INFO_COLLECTION); #endif - base::PostTask(FROM_HERE, {BrowserThread::IO}, - base::BindOnce(&RunCallbackOnIO, kind, force_create, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&RunCallbackOnIO, kind, force_create, std::move(callback))); } @@ -681,9 +691,9 @@ GpuProcessHost::GpuProcessHost(int host_id, GpuProcessKind kind) if (!in_process_ && kind != GPU_PROCESS_KIND_INFO_COLLECTION && base::FeatureList::IsEnabled( features::kForwardMemoryPressureEventsToGpuProcess)) { - memory_pressure_listener_ = - std::make_unique<base::MemoryPressureListener>(base::BindRepeating( - &GpuProcessHost::OnMemoryPressure, base::Unretained(this))); + memory_pressure_listener_ = std::make_unique<base::MemoryPressureListener>( + FROM_HERE, base::BindRepeating(&GpuProcessHost::OnMemoryPressure, + base::Unretained(this))); } #endif @@ -799,8 +809,8 @@ GpuProcessHost::~GpuProcessHost() { NOTREACHED(); break; } - base::PostTask( - FROM_HERE, {BrowserThread::UI}, + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&OnGpuProcessHostDestroyedOnUI, host_id_, message)); } @@ -856,8 +866,7 @@ bool GpuProcessHost::Init() { params.product = GetContentClient()->browser()->GetProduct(); params.deadline_to_synchronize_surfaces = switches::GetDeadlineToSynchronizeSurfaces(); - params.main_thread_task_runner = - base::CreateSingleThreadTaskRunner({BrowserThread::UI}); + params.main_thread_task_runner = GetUIThreadTaskRunner({}); params.info_collection_gpu_process = kind_ == GPU_PROCESS_KIND_INFO_COLLECTION; gpu_host_ = std::make_unique<viz::GpuHostImpl>( @@ -1021,6 +1030,10 @@ void GpuProcessHost::DidUpdateOverlayInfo( const gpu::OverlayInfo& overlay_info) { GpuDataManagerImpl::GetInstance()->UpdateOverlayInfo(overlay_info); } + +void GpuProcessHost::DidUpdateHDRStatus(bool hdr_enabled) { + GpuDataManagerImpl::GetInstance()->UpdateHDRStatus(hdr_enabled); +} #endif void GpuProcessHost::BlockDomainFrom3DAPIs(const GURL& url, @@ -1038,10 +1051,11 @@ void GpuProcessHost::DisableGpuCompositing() { #else // TODO(crbug.com/819474): The switch from GPU to software compositing should // be handled here instead of by ImageTransportFactory. - base::PostTask(FROM_HERE, {BrowserThread::UI}, base::BindOnce([]() { - if (auto* factory = ImageTransportFactory::GetInstance()) - factory->DisableGpuCompositing(); - })); + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce([]() { + if (auto* factory = ImageTransportFactory::GetInstance()) + factory->DisableGpuCompositing(); + })); #endif } @@ -1058,8 +1072,8 @@ void GpuProcessHost::RecordLogMessage(int32_t severity, void GpuProcessHost::BindDiscardableMemoryReceiver( mojo::PendingReceiver< discardable_memory::mojom::DiscardableSharedMemoryManager> receiver) { - base::PostTask( - FROM_HERE, {BrowserThread::UI}, + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&BindDiscardableMemoryReceiverOnUI, std::move(receiver))); } @@ -1067,6 +1081,7 @@ GpuProcessKind GpuProcessHost::kind() { return kind_; } +// Atomically shut down the GPU process with a normal termination status. void GpuProcessHost::ForceShutdown() { // This is only called on the IO thread so no race against the constructor // for another GpuProcessHost. @@ -1076,6 +1091,14 @@ void GpuProcessHost::ForceShutdown() { process_->ForceShutdown(); } +void GpuProcessHost::DumpProcessStack() { +#if defined(OS_ANDROID) + if (in_process_) + return; + process_->DumpProcessStack(); +#endif +} + void GpuProcessHost::RunService(mojo::GenericPendingReceiver receiver) { process_->child_process()->BindServiceInterface(std::move(receiver)); } diff --git a/chromium/content/browser/gpu/gpu_process_host.h b/chromium/content/browser/gpu/gpu_process_host.h index 3471ec0da41..b2aef2c770f 100644 --- a/chromium/content/browser/gpu/gpu_process_host.h +++ b/chromium/content/browser/gpu/gpu_process_host.h @@ -104,6 +104,10 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, // Forcefully terminates the GPU process. void ForceShutdown(); + // Dumps the stack of the child process without crashing it. + // Only implemented on Android. + void DumpProcessStack(); + // Asks the GPU process to run a service instance corresponding to the // specific interface receiver type carried by |receiver|. void RunService(mojo::GenericPendingReceiver receiver); @@ -161,6 +165,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, void MaybeShutdownGpuProcess() override; #if defined(OS_WIN) void DidUpdateOverlayInfo(const gpu::OverlayInfo& overlay_info) override; + void DidUpdateHDRStatus(bool hdr_enabled) override; #endif void BlockDomainFrom3DAPIs(const GURL& url, gpu::DomainGuilt guilt) override; void DisableGpuCompositing() override; diff --git a/chromium/content/browser/gpu/gpu_process_host_receiver_bindings.cc b/chromium/content/browser/gpu/gpu_process_host_receiver_bindings.cc index ebfb7c0a488..224dc97539b 100644 --- a/chromium/content/browser/gpu/gpu_process_host_receiver_bindings.cc +++ b/chromium/content/browser/gpu/gpu_process_host_receiver_bindings.cc @@ -6,7 +6,6 @@ #include "content/browser/gpu/gpu_process_host.h" -#include "base/task/post_task.h" #include "build/build_config.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -38,8 +37,8 @@ void GpuProcessHost::BindHostReceiver( mojo::GenericPendingReceiver generic_receiver) { #if defined(OS_ANDROID) if (auto r = generic_receiver.As<media::mojom::AndroidOverlayProvider>()) { - base::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&BindAndroidOverlayProvider, std::move(r))); + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&BindAndroidOverlayProvider, std::move(r))); return; } #endif diff --git a/chromium/content/browser/gpu/in_process_gpu_thread_browsertests.cc b/chromium/content/browser/gpu/in_process_gpu_thread_browsertests.cc index 6f5d597561d..fe502914b61 100644 --- a/chromium/content/browser/gpu/in_process_gpu_thread_browsertests.cc +++ b/chromium/content/browser/gpu/in_process_gpu_thread_browsertests.cc @@ -5,7 +5,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/run_loop.h" -#include "base/task/post_task.h" #include "content/browser/browser_main_loop.h" #include "content/browser/gpu/gpu_process_host.h" #include "content/gpu/in_process_gpu_thread.h" @@ -34,9 +33,8 @@ void CreateGpuProcessHost() { void WaitUntilGpuProcessHostIsCreated() { base::RunLoop run_loop; - base::PostTaskAndReply(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&CreateGpuProcessHost), - run_loop.QuitClosure()); + content::GetIOThreadTaskRunner({})->PostTaskAndReply( + FROM_HERE, base::BindOnce(&CreateGpuProcessHost), run_loop.QuitClosure()); run_loop.Run(); } diff --git a/chromium/content/browser/gpu/peak_gpu_memory_tracker_impl_browsertest.cc b/chromium/content/browser/gpu/peak_gpu_memory_tracker_impl_browsertest.cc index ff12f92adb2..3ae1eae938b 100644 --- a/chromium/content/browser/gpu/peak_gpu_memory_tracker_impl_browsertest.cc +++ b/chromium/content/browser/gpu/peak_gpu_memory_tracker_impl_browsertest.cc @@ -9,7 +9,6 @@ #include "base/clang_profiling_buildflags.h" #include "base/location.h" #include "base/run_loop.h" -#include "base/task/post_task.h" #include "base/test/metrics/histogram_tester.h" #include "build/build_config.h" #include "components/viz/test/gpu_host_impl_test_api.h" @@ -136,8 +135,8 @@ class TestGpuService : public viz::mojom::GpuService { // task has ran. void PostTaskToIOThreadAndWait(base::OnceClosure task) { base::RunLoop run_loop; - base::PostTaskAndReply(FROM_HERE, {content::BrowserThread::IO}, - std::move(task), run_loop.QuitClosure()); + content::GetIOThreadTaskRunner({})->PostTaskAndReply( + FROM_HERE, std::move(task), run_loop.QuitClosure()); run_loop.Run(); } diff --git a/chromium/content/browser/gpu/viz_devtools_connector.cc b/chromium/content/browser/gpu/viz_devtools_connector.cc index b3da62dff7c..e184ddbc413 100644 --- a/chromium/content/browser/gpu/viz_devtools_connector.cc +++ b/chromium/content/browser/gpu/viz_devtools_connector.cc @@ -5,7 +5,6 @@ #include "content/browser/gpu/viz_devtools_connector.h" #include "base/bind.h" -#include "base/task/post_task.h" #include "components/ui_devtools/devtools_server.h" #include "components/viz/common/switches.h" #include "content/browser/gpu/gpu_process_host.h" @@ -25,8 +24,8 @@ void OnSocketCreated(base::OnceCallback<void(int, int)> callback, int port = 0; if (local_addr) port = local_addr->port(); - base::PostTask(FROM_HERE, {BrowserThread::IO}, - base::BindOnce(std::move(callback), result, port)); + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), result, port)); } void CreateSocketOnUiThread( @@ -55,8 +54,8 @@ void VizDevToolsConnector::ConnectVizDevTools() { switches::kEnableVizDevTools, kVizDevToolsDefaultPort); // Jump to the UI thread to get the network context, create the socket, then // jump back to the IO thread to complete the callback. - base::PostTask( - FROM_HERE, {BrowserThread::UI}, + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce( &CreateSocketOnUiThread, server_socket.InitWithNewPipeAndPassReceiver(), port, |