Implement gpu info collector efl (chromium-efl)
authoramit.kumar8 <amit.kumar8@samsung.com>
Fri, 23 Jan 2015 09:26:10 +0000 (14:56 +0530)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
This is gpu_info_collector implementation for efl port.
As in Linux port, we use libpci to get the gpu information
and it does not work for Tizen.
So we need a separate implementation for getting the gpu
information in efl.
The gpu information is needed for disabling multisampling feature
bu adding entry in the gpu_driver_bug_list_json.cc

m34 patch:

Original Commit: e998dd80676ee33bcb5da645580ca24fb7339dc5
Original Author: das.kulajit <das.kulajit@samsung.com>
Reviewed by: Prashant Nevase, venu musham

Change-Id: I715e8a3b7da03d27b8396a799700a71c89d94988
Signed-off-by: amit.kumar8 <amit.kumar8@samsung.com>
tizen_src/impl/chromium-efl.gyp
tizen_src/impl/chromium-efl.gypi
tizen_src/impl/gpu/config/gpu_info_collector_efl.cc [new file with mode: 0644]

index f490874..24c9744 100644 (file)
           'content/common/gpu/gpu_memory_buffer_factory_efl.cc',
           'content/common/gpu/gpu_memory_buffer_factory_efl_pixmap.cc',
           'content/common/gpu/gpu_memory_buffer_factory_efl_pixmap.h',
+          'gpu/config/gpu_info_collector_efl.cc',
           'ui/gl/gl_image_efl_pixmap.cc',
           'ui/gl/gl_image_efl_pixmap.h',
           'ui/gl/efl_pixmap.cc',
index 36dd596..d5912f2 100644 (file)
            ['exclude', 'browser/device_sensors/data_fetcher_shared_memory_default.cc$'],
            ['exclude', 'browser/sound_effect.cc$'],
            ['exclude', 'battery_status_manager_linux\\.(h|cc)$'],
+           ['exclude', 'config/gpu_info_collector_linux\\.cc$'],
          ],
          'cflags_cc': [ '-std=gnu++0x', '-fpermissive' ],
       }, {
diff --git a/tizen_src/impl/gpu/config/gpu_info_collector_efl.cc b/tizen_src/impl/gpu/config/gpu_info_collector_efl.cc
new file mode 100644 (file)
index 0000000..55787bc
--- /dev/null
@@ -0,0 +1,135 @@
+// Copyright 2014 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/config/gpu_info_collector.h"
+
+#include "base/command_line.h"
+#include "base/debug/trace_event.h"
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_piece.h"
+#include "base/strings/string_split.h"
+#include "base/strings/string_util.h"
+#include "ui/gl/gl_implementation.h"
+#include "ui/gl/gl_context.h"
+#include "ui/gl/gl_surface.h"
+#include "ui/gl/gl_surface_egl.h"
+
+#if defined(TIZEN_MULTIMEDIA_SUPPORT)
+#include "content/common/gpu/media/gpu_video_encode_accelerator.h"
+#endif
+
+namespace {
+
+std::string GetDriverVersionFromString(const std::string& version_string) {
+  // Extract driver version from the second number in a string like:
+  // "OpenGL ES 2.0 V@6.0 AU@ (CL@2946718)"
+
+  // Exclude first "2.0".
+  size_t begin = version_string.find_first_of("0123456789");
+  if (begin == std::string::npos)
+    return "0";
+  size_t end = version_string.find_first_not_of("01234567890.", begin);
+
+  // Extract number of the form "%d.%d"
+  begin = version_string.find_first_of("0123456789", end);
+  if (begin == std::string::npos)
+    return "0";
+  end = version_string.find_first_not_of("01234567890.", begin);
+  std::string sub_string;
+  if (end != std::string::npos)
+    sub_string = version_string.substr(begin, end - begin);
+  else
+    sub_string = version_string.substr(begin);
+  std::vector<std::string> pieces;
+  base::SplitString(sub_string, '.', &pieces);
+  if (pieces.size() < 2)
+    return "0";
+  return pieces[0] + "." + pieces[1];
+}
+
+
+class ScopedRestoreNonOwnedEGLContext {
+ public:
+  ScopedRestoreNonOwnedEGLContext();
+  ~ScopedRestoreNonOwnedEGLContext();
+
+ private:
+  EGLContext context_;
+  EGLDisplay display_;
+  EGLSurface draw_surface_;
+  EGLSurface read_surface_;
+};
+
+ScopedRestoreNonOwnedEGLContext::ScopedRestoreNonOwnedEGLContext()
+  : context_(EGL_NO_CONTEXT),
+    display_(EGL_NO_DISPLAY),
+    draw_surface_(EGL_NO_SURFACE),
+    read_surface_(EGL_NO_SURFACE) {
+  // This should only used to restore a context that is not created or owned by
+  // Chromium native code, but created by Android system itself.
+  DCHECK(!gfx::GLContext::GetCurrent());
+
+  context_ = eglGetCurrentContext();
+  display_ = eglGetCurrentDisplay();
+  draw_surface_ = eglGetCurrentSurface(EGL_DRAW);
+  read_surface_ = eglGetCurrentSurface(EGL_READ);
+}
+
+ScopedRestoreNonOwnedEGLContext::~ScopedRestoreNonOwnedEGLContext() {
+  if (context_ == EGL_NO_CONTEXT || display_ == EGL_NO_DISPLAY ||
+      draw_surface_ == EGL_NO_SURFACE || read_surface_ == EGL_NO_SURFACE)
+    return;
+
+  if (!eglMakeCurrent(display_, draw_surface_, read_surface_, context_))
+    LOG(WARNING) << "Failed to restore EGL context";
+}
+
+}
+
+namespace gpu {
+
+CollectInfoResult CollectContextGraphicsInfo(GPUInfo* gpu_info) {
+  return CollectBasicGraphicsInfo(gpu_info);
+}
+
+CollectInfoResult CollectGpuID(uint32* vendor_id, uint32* device_id) {
+  DCHECK(vendor_id && device_id);
+  *vendor_id = 0;
+  *device_id = 0;
+  return kCollectInfoNonFatalFailure;
+}
+
+CollectInfoResult CollectBasicGraphicsInfo(GPUInfo* gpu_info) {
+  DCHECK(gpu_info);
+  gpu_info->can_lose_context = false;
+
+  // Create a short-lived context on the UI thread to collect the GL strings.
+  // Make sure we restore the existing context if there is one.
+  ScopedRestoreNonOwnedEGLContext restore_context;
+  CollectInfoResult result = CollectGraphicsInfoGL(gpu_info);
+  gpu_info->basic_info_state = result;
+  gpu_info->context_info_state = result;
+#if defined(TIZEN_MULTIMEDIA_SUPPORT)
+  gpu_info->video_encode_accelerator_supported_profiles =
+      content::GpuVideoEncodeAccelerator::GetSupportedProfiles();
+#endif
+  return result;
+}
+
+CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) {
+  DCHECK(gpu_info);
+  gpu_info->driver_version = GetDriverVersionFromString(
+      gpu_info->gl_version);
+  gpu_info->gpu.vendor_string = gpu_info->gl_vendor;
+  gpu_info->gpu.device_string = gpu_info->gl_renderer;
+  return kCollectInfoSuccess;
+}
+
+void MergeGPUInfo(GPUInfo* basic_gpu_info,
+                  const GPUInfo& context_gpu_info) {
+  MergeGPUInfoGL(basic_gpu_info, context_gpu_info);
+}
+
+}  // namespace gpu