diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-15 22:31:26 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-15 22:31:26 +0000 |
commit | 41579aea1ddb436acb6491e4b79ea564d86b55a0 (patch) | |
tree | 42829d8ed9773096be51647be7f73e32b7ba0247 /chrome/gpu | |
parent | b7ba5b5e11aaa87de7601daf1ab5443fe41a6f3c (diff) | |
download | chromium_src-41579aea1ddb436acb6491e4b79ea564d86b55a0.zip chromium_src-41579aea1ddb436acb6491e4b79ea564d86b55a0.tar.gz chromium_src-41579aea1ddb436acb6491e4b79ea564d86b55a0.tar.bz2 |
Collect DirectX diagnostic information asynchronously.
Collecting this can take a couple of seconds. I put the code onto a worker thread. The about:gpuinfo handler polls for it until it is available, initially displaying only the subset of informtation that can be retreived quickly.
This makes the startup time for accelerated compositing, WebGL, etc significantly lower on Windows. None of the other platforms have this issue.
TEST=go to about:gpuinfo, try
BUG=59711
Review URL: http://codereview.chromium.org/4860001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66184 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu')
-rw-r--r-- | chrome/gpu/gpu_info_collector_linux.cc | 3 | ||||
-rw-r--r-- | chrome/gpu/gpu_info_collector_mac.mm | 2 | ||||
-rw-r--r-- | chrome/gpu/gpu_info_collector_win.cc | 13 | ||||
-rw-r--r-- | chrome/gpu/gpu_thread.cc | 40 | ||||
-rw-r--r-- | chrome/gpu/gpu_thread.h | 5 |
5 files changed, 57 insertions, 6 deletions
diff --git a/chrome/gpu/gpu_info_collector_linux.cc b/chrome/gpu/gpu_info_collector_linux.cc index 2a4db9a..fd48c83 100644 --- a/chrome/gpu/gpu_info_collector_linux.cc +++ b/chrome/gpu/gpu_info_collector_linux.cc @@ -12,6 +12,9 @@ bool CollectGraphicsInfo(GPUInfo* gpu_info) { // on this platform in the future. // bool can_lose_context = // gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; + + gpu_info->SetProgress(GPUInfo::kComplete); + return true; } diff --git a/chrome/gpu/gpu_info_collector_mac.mm b/chrome/gpu/gpu_info_collector_mac.mm index 02c12b0..9da958c 100644 --- a/chrome/gpu/gpu_info_collector_mac.mm +++ b/chrome/gpu/gpu_info_collector_mac.mm @@ -163,6 +163,8 @@ bool CollectGraphicsInfo(GPUInfo* gpu_info) { gl_version, false); + gpu_info->SetProgress(GPUInfo::kComplete); + return true; } diff --git a/chrome/gpu/gpu_info_collector_win.cc b/chrome/gpu/gpu_info_collector_win.cc index b5d30b4..f1ed1f8 100644 --- a/chrome/gpu/gpu_info_collector_win.cc +++ b/chrome/gpu/gpu_info_collector_win.cc @@ -37,13 +37,14 @@ bool CollectGraphicsInfo(GPUInfo* gpu_info) { if (FAILED(device->GetDirect3D(&d3d))) return false; - // Don't fail if DirectX diagnostics are not available. Just leave the tree - // empty. The other GPU info is still valuable. - DxDiagNode dx_diagnostics; - if (GetDxDiagnostics(&dx_diagnostics)) - gpu_info->SetDxDiagnostics(dx_diagnostics); + if (!CollectGraphicsInfoD3D(d3d, gpu_info)) + return false; + + // DirectX diagnostics are collected asynchronously because it takes a + // couple of seconds. Do not mark as complete until that is done. + gpu_info->SetProgress(GPUInfo::kPartial); - return CollectGraphicsInfoD3D(d3d, gpu_info); + return true; } bool CollectGraphicsInfoD3D(IDirect3D9* d3d, GPUInfo* gpu_info) { diff --git a/chrome/gpu/gpu_thread.cc b/chrome/gpu/gpu_thread.cc index 9dc57d8..e278bec 100644 --- a/chrome/gpu/gpu_thread.cc +++ b/chrome/gpu/gpu_thread.cc @@ -9,6 +9,7 @@ #include "app/gfx/gl/gl_context.h" #include "base/command_line.h" +#include "base/worker_pool.h" #include "build/build_config.h" #include "chrome/common/child_process.h" #include "chrome/common/child_process_logging.h" @@ -16,6 +17,10 @@ #include "chrome/gpu/gpu_info_collector.h" #include "ipc/ipc_channel_handle.h" +#if defined(OS_WIN) +#include "app/win_util.h" +#endif + #if defined(TOOLKIT_USES_GTK) #include <gtk/gtk.h> #include "app/x11_util.h" @@ -44,6 +49,18 @@ void GpuThread::Init(const base::Time& process_start_time) { gpu_info_collector::CollectGraphicsInfo(&gpu_info_); child_process_logging::SetGpuInfo(gpu_info_); +#if defined(OS_WIN) + // Asynchronously collect the DirectX diagnostics because this can take a + // couple of seconds. + if (!WorkerPool::PostTask( + FROM_HERE, + NewRunnableFunction(&GpuThread::CollectDxDiagnostics, this), + true)) { + // Flag GPU info as complete if the DirectX diagnostics cannot be collected. + gpu_info_.SetProgress(GPUInfo::kComplete); + } +#endif + // Record initialization only after collecting the GPU info because that can // take a significant amount of time. gpu_info_.SetInitializationTime(base::Time::Now() - process_start_time); @@ -118,3 +135,26 @@ void GpuThread::OnHang() { for (;;) PlatformThread::Sleep(1000); } + +#if defined(OS_WIN) + +// Runs on a worker thread. The GpuThread never terminates voluntarily so it is +// safe to assume that its message loop is valid. +void GpuThread::CollectDxDiagnostics(GpuThread* thread) { + win_util::ScopedCOMInitializer com_initializer; + + DxDiagNode node; + gpu_info_collector::GetDxDiagnostics(&node); + + thread->message_loop()->PostTask( + FROM_HERE, + NewRunnableFunction(&GpuThread::SetDxDiagnostics, thread, node)); +} + +// Runs on the GPU thread. +void GpuThread::SetDxDiagnostics(GpuThread* thread, const DxDiagNode& node) { + thread->gpu_info_.SetDxDiagnostics(node); + thread->gpu_info_.SetProgress(GPUInfo::kComplete); +} + +#endif diff --git a/chrome/gpu/gpu_thread.h b/chrome/gpu/gpu_thread.h index 56d4b431..275fa12 100644 --- a/chrome/gpu/gpu_thread.h +++ b/chrome/gpu/gpu_thread.h @@ -38,6 +38,11 @@ class GpuThread : public ChildThread { void OnCrash(); void OnHang(); +#if defined(OS_WIN) + static void CollectDxDiagnostics(GpuThread* thread); + static void SetDxDiagnostics(GpuThread* thread, const DxDiagNode& node); +#endif + typedef base::hash_map<int, scoped_refptr<GpuChannel> > GpuChannelMap; GpuChannelMap gpu_channels_; |