summaryrefslogtreecommitdiffstats
path: root/only-fall-back-to-the-i965-driver-if-we-re-on-iHD.patch
diff options
context:
space:
mode:
Diffstat (limited to 'only-fall-back-to-the-i965-driver-if-we-re-on-iHD.patch')
-rw-r--r--only-fall-back-to-the-i965-driver-if-we-re-on-iHD.patch139
1 files changed, 139 insertions, 0 deletions
diff --git a/only-fall-back-to-the-i965-driver-if-we-re-on-iHD.patch b/only-fall-back-to-the-i965-driver-if-we-re-on-iHD.patch
new file mode 100644
index 0000000..ed811bc
--- /dev/null
+++ b/only-fall-back-to-the-i965-driver-if-we-re-on-iHD.patch
@@ -0,0 +1,139 @@
+From fbd756ab55f9351165f923b0411c31dd71319c78 Mon Sep 17 00:00:00 2001
+From: Ted Meyer <tmathmeyer@chromium.org>
+Date: Wed, 16 Sep 2020 17:42:03 +0000
+Subject: [PATCH] Only fall back to the i965 driver if we're on iHD
+
+I got my hands on an old AMD laptop, and the gallium driver worked very
+well and was saving power even at 720p, so there's no reason to block
+that for now.
+
+Bug: 1116703
+Change-Id: Ib15bc2b93f33e99adad7569dd825e167b503a0ea
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2409967
+Commit-Queue: Ted Meyer <tmathmeyer@chromium.org>
+Reviewed-by: Andres Calderon Jaramillo <andrescj@chromium.org>
+Cr-Commit-Position: refs/heads/master@{#807550}
+---
+ media/gpu/vaapi/vaapi_wrapper.cc | 73 ++++++++++++++++++++------------
+ 1 file changed, 47 insertions(+), 26 deletions(-)
+
+diff --git a/media/gpu/vaapi/vaapi_wrapper.cc b/media/gpu/vaapi/vaapi_wrapper.cc
+index 2ad0b997e56..e30d1dfb73b 100644
+--- a/media/gpu/vaapi/vaapi_wrapper.cc
++++ b/media/gpu/vaapi/vaapi_wrapper.cc
+@@ -409,6 +409,8 @@ class VADisplayState {
+
+ // Implementation of Initialize() called only once.
+ bool InitializeOnce() EXCLUSIVE_LOCKS_REQUIRED(va_lock_);
++ bool InitializeVaDisplay_Locked() EXCLUSIVE_LOCKS_REQUIRED(va_lock_);
++ bool InitializeVaDriver_Locked() EXCLUSIVE_LOCKS_REQUIRED(va_lock_);
+
+ int refcount_ GUARDED_BY(va_lock_);
+
+@@ -472,11 +474,7 @@ bool VADisplayState::Initialize() {
+ return success;
+ }
+
+-bool VADisplayState::InitializeOnce() {
+- static_assert(
+- VA_MAJOR_VERSION >= 2 || (VA_MAJOR_VERSION == 1 && VA_MINOR_VERSION >= 1),
+- "Requires VA-API >= 1.1.0");
+-
++bool VADisplayState::InitializeVaDisplay_Locked() {
+ switch (gl::GetGLImplementation()) {
+ case gl::kGLImplementationEGLGLES2:
+ va_display_ = vaGetDisplayDRM(drm_fd_.get());
+@@ -519,25 +517,10 @@ bool VADisplayState::InitializeOnce() {
+ return false;
+ }
+
+- // Set VA logging level and driver name, unless already set.
+- constexpr char libva_log_level_env[] = "LIBVA_MESSAGING_LEVEL";
+- std::unique_ptr<base::Environment> env(base::Environment::Create());
+- if (!env->HasVar(libva_log_level_env))
+- env->SetVar(libva_log_level_env, "1");
+-
+-#if defined(USE_X11)
+- if (gl::GetGLImplementation() == gl::kGLImplementationEGLANGLE) {
+- DCHECK(!features::IsUsingOzonePlatform());
+- constexpr char libva_driver_impl_env[] = "LIBVA_DRIVER_NAME";
+- // TODO(crbug/1116703) The libva intel-media driver has a known segfault in
+- // vaPutSurface, so until this is fixed, fall back to the i965 driver. There
+- // is discussion of the issue here:
+- // https://github.com/intel/media-driver/issues/818
+- if (!env->HasVar(libva_driver_impl_env))
+- env->SetVar(libva_driver_impl_env, "i965");
+- }
+-#endif // USE_X11
++ return true;
++}
+
++bool VADisplayState::InitializeVaDriver_Locked() {
+ // The VAAPI version.
+ int major_version, minor_version;
+ VAStatus va_res = vaInitialize(va_display_, &major_version, &minor_version);
+@@ -545,9 +528,6 @@ bool VADisplayState::InitializeOnce() {
+ LOG(ERROR) << "vaInitialize failed: " << vaErrorStr(va_res);
+ return false;
+ }
+-
+- va_initialized_ = true;
+-
+ const std::string va_vendor_string = vaQueryVendorString(va_display_);
+ DLOG_IF(WARNING, va_vendor_string.empty())
+ << "Vendor string empty or error reading.";
+@@ -555,6 +535,8 @@ bool VADisplayState::InitializeOnce() {
+ << va_vendor_string;
+ implementation_type_ = VendorStringToImplementationType(va_vendor_string);
+
++ va_initialized_ = true;
++
+ // The VAAPI version is determined from what is loaded on the system by
+ // calling vaInitialize(). Since the libva is now ABI-compatible, relax the
+ // version check which helps in upgrading the libva, without breaking any
+@@ -571,6 +553,45 @@ bool VADisplayState::InitializeOnce() {
+ return true;
+ }
+
++bool VADisplayState::InitializeOnce() {
++ static_assert(
++ VA_MAJOR_VERSION >= 2 || (VA_MAJOR_VERSION == 1 && VA_MINOR_VERSION >= 1),
++ "Requires VA-API >= 1.1.0");
++
++ // Set VA logging level, unless already set.
++ constexpr char libva_log_level_env[] = "LIBVA_MESSAGING_LEVEL";
++ std::unique_ptr<base::Environment> env(base::Environment::Create());
++ if (!env->HasVar(libva_log_level_env))
++ env->SetVar(libva_log_level_env, "1");
++
++ if (!InitializeVaDisplay_Locked() || !InitializeVaDriver_Locked())
++ return false;
++
++#if defined(USE_X11)
++ if (gl::GetGLImplementation() == gl::kGLImplementationEGLANGLE &&
++ implementation_type_ == VAImplementation::kIntelIHD) {
++ DCHECK(!features::IsUsingOzonePlatform());
++ constexpr char libva_driver_impl_env[] = "LIBVA_DRIVER_NAME";
++ // TODO(crbug/1116703) The libva intel-media driver has a known segfault in
++ // vaPutSurface, so until this is fixed, fall back to the i965 driver. There
++ // is discussion of the issue here:
++ // https://github.com/intel/media-driver/issues/818
++ if (!env->HasVar(libva_driver_impl_env))
++ env->SetVar(libva_driver_impl_env, "i965");
++
++ // Re-initialize with the new driver.
++ va_display_ = nullptr;
++ va_initialized_ = false;
++ implementation_type_ = VAImplementation::kInvalid;
++
++ if (!InitializeVaDisplay_Locked() || !InitializeVaDriver_Locked())
++ return false;
++ }
++#endif // USE_X11
++
++ return true;
++}
++
+ VAStatus VADisplayState::Deinitialize() {
+ base::AutoLock auto_lock(va_lock_);
+ VAStatus va_res = VA_STATUS_SUCCESS;