diff options
| author | jmadill <jmadill@chromium.org> | 2015-03-18 15:45:22 -0700 | 
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2015-03-18 22:45:58 +0000 | 
| commit | 29fda863e960afecd39be697b54506877264a30f (patch) | |
| tree | 2b7af6b24dcf2436b1204a8976fac7838a314046 | |
| parent | f4a0d6b3eb666ef634d719e4d5ddc0dee3bb0d12 (diff) | |
| download | chromium_src-29fda863e960afecd39be697b54506877264a30f.zip chromium_src-29fda863e960afecd39be697b54506877264a30f.tar.gz chromium_src-29fda863e960afecd39be697b54506877264a30f.tar.bz2 | |
Add ANGLE Platform implementation.
*re-re-land with SwiftShader fix*
*re-land with fix to components_browsertests*
This logic allows us to record traces and histograms easily within
ANGLE's code. It also gives a flexible design that we can extend
with further methods later, without breaking compilation. The
design is based on blink::Platform.
Also add two new histogram descriptions to histograms.xml, and
move the GPU Process metrics init to before InitializeOneOff, so
ANGLE can record histograms during Renderer initialization.
BUG=436191
TBR=jam@chromium.org, asvitkine@chromium.org, piman@chromium.org, maruel@chromium.org, kbr@chromium.org
Review URL: https://codereview.chromium.org/1007513006
Cr-Commit-Position: refs/heads/master@{#321225}
| -rw-r--r-- | ash/ash_unittests.isolate | 1 | ||||
| -rw-r--r-- | cc/cc_unittests.isolate | 1 | ||||
| -rw-r--r-- | chrome/sync_integration_tests.isolate | 1 | ||||
| -rw-r--r-- | chrome/unit_tests.isolate | 1 | ||||
| -rw-r--r-- | components/components_browsertests.isolate | 9 | ||||
| -rw-r--r-- | components/components_unittests.isolate | 1 | ||||
| -rw-r--r-- | content/content_browsertests.isolate | 1 | ||||
| -rw-r--r-- | content/content_gpu.gypi | 5 | ||||
| -rw-r--r-- | content/content_unittests.isolate | 1 | ||||
| -rw-r--r-- | content/gpu/gpu_main.cc | 19 | ||||
| -rw-r--r-- | extensions/extensions_browsertests.isolate | 1 | ||||
| -rw-r--r-- | gpu/gpu_unittests.isolate | 1 | ||||
| -rw-r--r-- | tools/metrics/histograms/histograms.xml | 40 | ||||
| -rw-r--r-- | ui/gl/BUILD.gn | 2 | ||||
| -rw-r--r-- | ui/gl/DEPS | 6 | ||||
| -rw-r--r-- | ui/gl/angle_platform_impl.cc | 50 | ||||
| -rw-r--r-- | ui/gl/angle_platform_impl.h | 39 | ||||
| -rw-r--r-- | ui/gl/gl.gyp | 2 | ||||
| -rw-r--r-- | ui/gl/gl_implementation_win.cc | 32 | 
19 files changed, 193 insertions, 20 deletions
| diff --git a/ash/ash_unittests.isolate b/ash/ash_unittests.isolate index 319dfc7..40e3e79 100644 --- a/ash/ash_unittests.isolate +++ b/ash/ash_unittests.isolate @@ -64,5 +64,6 @@    ],    'includes': [      '../base/base.isolate', +    '../third_party/angle/angle.isolate',    ],  } diff --git a/cc/cc_unittests.isolate b/cc/cc_unittests.isolate index dc6c449..7c359d0 100644 --- a/cc/cc_unittests.isolate +++ b/cc/cc_unittests.isolate @@ -84,5 +84,6 @@    ],    'includes': [      '../base/base.isolate', +    '../third_party/angle/angle.isolate',    ],  } diff --git a/chrome/sync_integration_tests.isolate b/chrome/sync_integration_tests.isolate index abecb56..06741e3 100644 --- a/chrome/sync_integration_tests.isolate +++ b/chrome/sync_integration_tests.isolate @@ -108,5 +108,6 @@    'includes': [      '../base/base.isolate',      '../gin/v8.isolate', +    '../third_party/angle/angle.isolate',    ],  } diff --git a/chrome/unit_tests.isolate b/chrome/unit_tests.isolate index 715e1fe..33821eb 100644 --- a/chrome/unit_tests.isolate +++ b/chrome/unit_tests.isolate @@ -157,5 +157,6 @@    'includes': [      '../base/base.isolate',      '../gin/v8.isolate', +    '../third_party/angle/angle.isolate',    ],  } diff --git a/components/components_browsertests.isolate b/components/components_browsertests.isolate index c18c7cf..f384f85f 100644 --- a/components/components_browsertests.isolate +++ b/components/components_browsertests.isolate @@ -2,10 +2,6 @@  # Use of this source code is governed by a BSD-style license that can be  # found in the LICENSE file.  { -  'includes': [ -    '../base/base.isolate', -    '../gin/v8.isolate', -  ],    'conditions': [      ['use_x11==0', {        'variables': { @@ -74,4 +70,9 @@        },      }],    ], +  'includes': [ +    '../base/base.isolate', +    '../gin/v8.isolate', +    '../third_party/angle/angle.isolate', +  ],  } diff --git a/components/components_unittests.isolate b/components/components_unittests.isolate index e240ea7..ed969e0 100644 --- a/components/components_unittests.isolate +++ b/components/components_unittests.isolate @@ -94,5 +94,6 @@    ],    'includes': [      '../base/base.isolate', +    '../third_party/angle/angle.isolate',    ],  } diff --git a/content/content_browsertests.isolate b/content/content_browsertests.isolate index 84379d6..aa24c23 100644 --- a/content/content_browsertests.isolate +++ b/content/content_browsertests.isolate @@ -141,5 +141,6 @@    'includes': [      '../base/base.isolate',      '../gin/v8.isolate', +    '../third_party/angle/angle.isolate',    ],  } diff --git a/content/content_gpu.gypi b/content/content_gpu.gypi index af0c47f..1c2121d 100644 --- a/content/content_gpu.gypi +++ b/content/content_gpu.gypi @@ -26,13 +26,10 @@      ['OS=="win"', {        'include_dirs': [          '<(DEPTH)/third_party/khronos', +        # ANGLE libs picked up from ui/gl          '<(angle_path)/src',          '<(DEPTH)/third_party/wtl/include',        ], -      'dependencies': [ -        '<(angle_path)/src/angle.gyp:libEGL', -        '<(angle_path)/src/angle.gyp:libGLESv2', -      ],        'link_settings': {          'libraries': [            '-lsetupapi.lib', diff --git a/content/content_unittests.isolate b/content/content_unittests.isolate index f61a3e1..07ac6e7 100644 --- a/content/content_unittests.isolate +++ b/content/content_unittests.isolate @@ -109,5 +109,6 @@    'includes': [      '../base/base.isolate',      '../gin/v8.isolate', +    '../third_party/angle/angle.isolate',    ],  } diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc index b34d42f..76a6020 100644 --- a/content/gpu/gpu_main.cc +++ b/content/gpu/gpu_main.cc @@ -12,6 +12,7 @@  #include "base/lazy_instance.h"  #include "base/message_loop/message_loop.h"  #include "base/metrics/histogram.h" +#include "base/metrics/statistics_recorder.h"  #include "base/rand_util.h"  #include "base/strings/string_number_conversions.h"  #include "base/strings/stringprintf.h" @@ -214,14 +215,14 @@ int GpuMain(const MainFunctionParams& parameters) {      watchdog_thread->StartWithOptions(options);    } +  // Initializes StatisticsRecorder which tracks UMA histograms. +  base::StatisticsRecorder::Initialize(); +    gpu::GPUInfo gpu_info;    // Get vendor_id, device_id, driver_version from browser process through    // commandline switches.    GetGpuInfoFromCommandLine(gpu_info, command_line); -  base::TimeDelta collect_context_time; -  base::TimeDelta initialize_one_off_time; -    // Warm up resources that don't need access to GPUInfo.    if (WarmUpSandbox(command_line)) {  #if defined(OS_LINUX) @@ -293,15 +294,18 @@ int GpuMain(const MainFunctionParams& parameters) {  #endif  // !defined(OS_CHROMEOS)  #endif  // defined(OS_LINUX)  #endif  // !defined(OS_MACOSX) -      collect_context_time = +      base::TimeDelta collect_context_time =            base::TimeTicks::Now() - before_collect_context_graphics_info; +      UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", +                          collect_context_time);      } else {  // gl_initialized        VLOG(1) << "gfx::GLSurface::InitializeOneOff failed";        dead_on_arrival = true;      } -    initialize_one_off_time = +    base::TimeDelta initialize_one_off_time =          base::TimeTicks::Now() - before_initialize_one_off; +    UMA_HISTOGRAM_TIMES("GPU.InitializeOneOffTime", initialize_one_off_time);      if (enable_watchdog && delayed_watchdog_enable) {        watchdog_thread = new GpuWatchdogThread(kGpuTimeout); @@ -342,11 +346,6 @@ int GpuMain(const MainFunctionParams& parameters) {    GpuProcess gpu_process; -  // These UMA must be stored after GpuProcess is constructed as it -  // initializes StatisticsRecorder which tracks the histograms. -  UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", collect_context_time); -  UMA_HISTOGRAM_TIMES("GPU.InitializeOneOffTime", initialize_one_off_time); -    GpuChildThread* child_thread = new GpuChildThread(watchdog_thread.get(),                                                      dead_on_arrival,                                                      gpu_info, diff --git a/extensions/extensions_browsertests.isolate b/extensions/extensions_browsertests.isolate index d939336..301e919 100644 --- a/extensions/extensions_browsertests.isolate +++ b/extensions/extensions_browsertests.isolate @@ -80,5 +80,6 @@    'includes': [      '../base/base.isolate',      '../gin/v8.isolate', +    '../third_party/angle/angle.isolate',    ],  } diff --git a/gpu/gpu_unittests.isolate b/gpu/gpu_unittests.isolate index b12c5cb..7ad1b79 100644 --- a/gpu/gpu_unittests.isolate +++ b/gpu/gpu_unittests.isolate @@ -59,5 +59,6 @@    ],    'includes': [      '../base/base.isolate', +    '../third_party/angle/angle.isolate',    ],  } diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index e8bb06f..12e49de 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -10931,6 +10931,22 @@ Therefore, the affected-histogram name has to have at least one dot in it.    </summary>  </histogram> +<histogram name="GPU.ANGLE.D3D11InitializeResult" enum="D3D11InitializeResult"> +  <owner>jmadill@chromium.org</owner> +  <summary> +    The result from initializing a D3D11 device in ANGLE. Can be success, or one +    of several error codes which indicate different reasons for failing. +  </summary> +</histogram> + +<histogram name="GPU.ANGLE.D3D9InitializeResult" enum="D3D9InitializeResult"> +  <owner>jmadill@chromium.org</owner> +  <summary> +    The result from initializing a D3D9 device in ANGLE. Can be success, or one +    of several error codes which indicate different reasons for failing. +  </summary> +</histogram> +  <histogram name="GPU.CollectContextGraphicsInfo" units="microseconds">    <owner>vangelis@chromium.org</owner>    <summary> @@ -10952,7 +10968,8 @@ Therefore, the affected-histogram name has to have at least one dot in it.    <owner>jmadill@chromium.org</owner>    <summary>      ANGLE's currently active D3D shader model version. Logged once every startup -    of the GPU process, on Windows only. +    of the GPU process, on Windows only. Note that Shader Models 2 and 3 map to +    D3D9 with ANGLE, and 4+ map to D3D11 ANGLE.    </summary>  </histogram> @@ -46192,6 +46209,27 @@ Therefore, the affected-histogram name has to have at least one dot in it.    <int value="2" label="Has enough SCTs"/>  </enum> +<enum name="D3D11InitializeResult" type="int"> +  <int value="0" label="Success"/> +  <int value="1" label="Error initializing compiler"/> +  <int value="2" label="Missing DLL dependency"/> +  <int value="3" label="D3D11CreateDevice returned E_INVALIDARG"/> +  <int value="4" label="D3D11CreateDevice returned other error"/> +  <int value="5" label="DXGI version not supported"/> +  <int value="6" label="Other initialization error"/> +</enum> + +<enum name="D3D9InitializeResult" type="int"> +  <int value="0" label="Success"/> +  <int value="1" label="Error initializing compiler"/> +  <int value="2" label="Missing DLL dependency"/> +  <int value="3" label="Error creating device"/> +  <int value="4" label="Shader version not supported"/> +  <int value="5" label="StretchRect from textures not supported"/> +  <int value="6" label="Device lost of out-of-memory error"/> +  <int value="7" label="Other initialization error"/> +</enum> +  <enum name="DailyEventIntervalType" type="int">    <int value="0" label="First Run"/>    <int value="1" label="Day Elapsed"/> diff --git a/ui/gl/BUILD.gn b/ui/gl/BUILD.gn index 12a44cc..ae1132e 100644 --- a/ui/gl/BUILD.gn +++ b/ui/gl/BUILD.gn @@ -183,6 +183,8 @@ component("gl") {    }    if (is_win) {      sources += [ +      "angle_platform_impl.cc", +      "angle_platform_impl.h",        "gl_bindings_autogen_wgl.cc",        "gl_bindings_autogen_wgl.h",        "gl_context_wgl.cc", @@ -12,5 +12,9 @@ specific_include_rules = {  # get access to desktop OpenGL.    "gl_surface_osmesa.cc": [      "+third_party/mesa/src/include/GL/osmesa.h", -  ] +  ], +# Allow us to include ANGLE's base platform implementation. +  "angle_platform_impl.h": [ +    "+third_party/angle/include/platform/Platform.h", +  ],  } diff --git a/ui/gl/angle_platform_impl.cc b/ui/gl/angle_platform_impl.cc new file mode 100644 index 0000000..2ce12b8 --- /dev/null +++ b/ui/gl/angle_platform_impl.cc @@ -0,0 +1,50 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/gl/angle_platform_impl.h" + +#include "base/metrics/histogram.h" +#include "base/metrics/sparse_histogram.h" + +namespace gfx { + +ANGLEPlatformImpl::ANGLEPlatformImpl() { +} + +ANGLEPlatformImpl::~ANGLEPlatformImpl() { +} + +void ANGLEPlatformImpl::histogramCustomCounts(const char* name, +                                              int sample, +                                              int min, +                                              int max, +                                              int bucket_count) { +  // Copied from histogram macro, but without the static variable caching +  // the histogram because name is dynamic. +  base::HistogramBase* counter = base::Histogram::FactoryGet( +      name, min, max, bucket_count, +      base::HistogramBase::kUmaTargetedHistogramFlag); +  DCHECK_EQ(name, counter->histogram_name()); +  counter->Add(sample); +} + +void ANGLEPlatformImpl::histogramEnumeration(const char* name, +                                             int sample, +                                             int boundary_value) { +  // Copied from histogram macro, but without the static variable caching +  // the histogram because name is dynamic. +  base::HistogramBase* counter = base::LinearHistogram::FactoryGet( +      name, 1, boundary_value, boundary_value + 1, +      base::HistogramBase::kUmaTargetedHistogramFlag); +  DCHECK_EQ(name, counter->histogram_name()); +  counter->Add(sample); +} + +void ANGLEPlatformImpl::histogramSparse(const char* name, int sample) { +  // For sparse histograms, we can use the macro, as it does not incorporate a +  // static. +  UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample); +} + +}  // namespace gfx diff --git a/ui/gl/angle_platform_impl.h b/ui/gl/angle_platform_impl.h new file mode 100644 index 0000000..2d12f60 --- /dev/null +++ b/ui/gl/angle_platform_impl.h @@ -0,0 +1,39 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_GL_ANGLE_PLATFORM_IMPL_H_ +#define UI_GL_ANGLE_PLATFORM_IMPL_H_ + +// Implements the ANGLE platform interface, for functionality like +// histograms and trace profiling. + +#include "base/macros.h" +#include "third_party/angle/include/platform/Platform.h" + +namespace gfx { + +// Derives the base ANGLE platform and provides implementations +class ANGLEPlatformImpl : public angle::Platform { + public: +  ANGLEPlatformImpl(); +  ~ANGLEPlatformImpl() override; + +  // angle::Platform: +  void histogramCustomCounts(const char* name, +                             int sample, +                             int min, +                             int max, +                             int bucket_count) override; +  void histogramEnumeration(const char* name, +                            int sample, +                            int boundary_value) override; +  void histogramSparse(const char* name, int sample) override; + + private: +  DISALLOW_COPY_AND_ASSIGN(ANGLEPlatformImpl); +}; + +}  // namespace gfx + +#endif  // UI_GL_ANGLE_PLATFORM_IMPL_H_ diff --git a/ui/gl/gl.gyp b/ui/gl/gl.gyp index 05381078..d11014b 100644 --- a/ui/gl/gl.gyp +++ b/ui/gl/gl.gyp @@ -186,6 +186,8 @@          }],          ['OS=="win"', {            'sources': [ +            'angle_platform_impl.cc', +            'angle_platform_impl.h',              'gl_bindings_autogen_wgl.cc',              'gl_bindings_autogen_wgl.h',              'gl_context_wgl.cc', diff --git a/ui/gl/gl_implementation_win.cc b/ui/gl/gl_implementation_win.cc index 477f5a5..49ffa89 100644 --- a/ui/gl/gl_implementation_win.cc +++ b/ui/gl/gl_implementation_win.cc @@ -9,6 +9,7 @@  #include "base/bind.h"  #include "base/command_line.h"  #include "base/files/file_path.h" +#include "base/lazy_instance.h"  #include "base/logging.h"  #include "base/native_library.h"  #include "base/path_service.h" @@ -16,6 +17,8 @@  #include "base/threading/thread_restrictions.h"  #include "base/trace_event/trace_event.h"  #include "base/win/windows_version.h" +// TODO(jmadill): Apply to all platforms eventually +#include "ui/gl/angle_platform_impl.h"  #include "ui/gl/gl_bindings.h"  #include "ui/gl/gl_context_stub_with_extensions.h"  #include "ui/gl/gl_egl_api_implementation.h" @@ -97,6 +100,12 @@ typedef void (__stdcall *SetTraceFunctionPointersFunc)(      GetCategoryEnabledFlagFunc get_category_enabled_flag,      AddTraceEventFunc add_trace_event_func); +// TODO(jmadill): Apply to all platforms eventually +base::LazyInstance<ANGLEPlatformImpl> g_angle_platform_impl = +    LAZY_INSTANCE_INITIALIZER; + +ANGLEPlatformShutdownFunc g_angle_platform_shutdown = nullptr; +  }  // namespace  void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { @@ -204,6 +213,7 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {  #endif        if (!using_swift_shader) { +        // TODO(jmadill): remove when platform impl supports tracing          SetTraceFunctionPointersFunc set_trace_function_pointers =              reinterpret_cast<SetTraceFunctionPointersFunc>(                  base::GetFunctionPointerFromNativeLibrary( @@ -212,6 +222,23 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {            set_trace_function_pointers(&AngleGetTraceCategoryEnabledFlag,                                        &AngleAddTraceEvent);          } + +        // Init ANGLE platform here, before we call GetPlatformDisplay(). +        // TODO(jmadill): Apply to all platforms eventually +        ANGLEPlatformInitializeFunc angle_platform_init = +            reinterpret_cast<ANGLEPlatformInitializeFunc>( +                base::GetFunctionPointerFromNativeLibrary( +                    gles_library, +                    "ANGLEPlatformInitialize")); +        if (angle_platform_init) { +          angle_platform_init(&g_angle_platform_impl.Get()); + +          g_angle_platform_shutdown = +              reinterpret_cast<ANGLEPlatformShutdownFunc>( +                  base::GetFunctionPointerFromNativeLibrary( +                      gles_library, +                      "ANGLEPlatformShutdown")); +        }        }        GLGetProcAddressProc get_proc_address = @@ -348,6 +375,11 @@ void InitializeDebugGLBindings() {  }  void ClearGLBindings() { +  // TODO(jmadill): Apply to all platforms eventually +  if (g_angle_platform_shutdown) { +    g_angle_platform_shutdown(); +  } +    ClearGLBindingsEGL();    ClearGLBindingsGL();    ClearGLBindingsOSMESA(); | 
