File chromium-vaapi-fix.patch of Package chromium.openSUSE_Leap_15.1_Update

description: fix vaapi with vdpau
author: Maxim Baz
origin: chromium-vaapi patches from Arch linux

Index: chromium-84.0.4147.68/media/gpu/vaapi/vaapi_video_decode_accelerator.cc
===================================================================
--- chromium-84.0.4147.68.orig/media/gpu/vaapi/vaapi_video_decode_accelerator.cc
+++ chromium-84.0.4147.68/media/gpu/vaapi/vaapi_video_decode_accelerator.cc
@@ -677,6 +677,7 @@ void VaapiVideoDecodeAccelerator::Assign
   // |vpp_vaapi_wrapper_| for VaapiPicture to DownloadFromSurface() the VA's
   // internal decoded frame.
   if (buffer_allocation_mode_ != BufferAllocationMode::kNone &&
+      buffer_allocation_mode_ != BufferAllocationMode::kWrapVdpau &&
       !vpp_vaapi_wrapper_) {
     vpp_vaapi_wrapper_ = VaapiWrapper::Create(
         VaapiWrapper::kVideoProcess, VAProfileNone,
@@ -708,7 +709,8 @@ void VaapiVideoDecodeAccelerator::Assign
             : gfx::Size();
 
     std::unique_ptr<VaapiPicture> picture = vaapi_picture_factory_->Create(
-        (buffer_allocation_mode_ == BufferAllocationMode::kNone)
+        ((buffer_allocation_mode_ == BufferAllocationMode::kNone) ||
+         (buffer_allocation_mode_ == BufferAllocationMode::kWrapVdpau))
             ? vaapi_wrapper_
             : vpp_vaapi_wrapper_,
         make_context_current_cb_, bind_image_cb_, buffer, size_to_bind);
@@ -1164,6 +1166,14 @@ VaapiVideoDecodeAccelerator::GetSupporte
 
 VaapiVideoDecodeAccelerator::BufferAllocationMode
 VaapiVideoDecodeAccelerator::DecideBufferAllocationMode() {
+  // NVIDIA blobs use VDPAU
+  if (base::StartsWith(VaapiWrapper::GetVendorString(),
+              "Splitted-Desktop Systems VDPAU",
+              base::CompareCase::SENSITIVE)) {
+    LOG(INFO) << "VA-API driver on VDPAU backend";
+    return BufferAllocationMode::kWrapVdpau;
+  }
+
   // TODO(crbug.com/912295): Enable a better BufferAllocationMode for IMPORT
   // |output_mode_| as well.
   if (output_mode_ == VideoDecodeAccelerator::Config::OutputMode::IMPORT)
@@ -1174,7 +1184,7 @@ VaapiVideoDecodeAccelerator::DecideBuffe
   // associated format reconciliation copy, avoiding all internal buffer
   // allocations.
   // TODO(crbug.com/911754): Enable for VP9 Profile 2.
-  if (IsGeminiLakeOrLater() &&
+  if (false && IsGeminiLakeOrLater() &&
       (profile_ == VP9PROFILE_PROFILE0 || profile_ == VP8PROFILE_ANY ||
        (profile_ >= H264PROFILE_MIN && profile_ <= H264PROFILE_MAX))) {
     // Add one to the reference frames for the one being currently egressed, and
Index: chromium-84.0.4147.68/media/gpu/vaapi/vaapi_video_decode_accelerator.h
===================================================================
--- chromium-84.0.4147.68.orig/media/gpu/vaapi/vaapi_video_decode_accelerator.h
+++ chromium-84.0.4147.68/media/gpu/vaapi/vaapi_video_decode_accelerator.h
@@ -210,6 +210,7 @@ class MEDIA_GPU_EXPORT VaapiVideoDecodeA
     // Using |client_|s provided PictureBuffers and as many internally
     // allocated.
     kNormal,
+    kWrapVdpau,
   };
 
   // Decides the concrete buffer allocation mode, depending on the hardware
Index: chromium-84.0.4147.68/media/gpu/vaapi/vaapi_wrapper.cc
===================================================================
--- chromium-84.0.4147.68.orig/media/gpu/vaapi/vaapi_wrapper.cc
+++ chromium-84.0.4147.68/media/gpu/vaapi/vaapi_wrapper.cc
@@ -1227,6 +1227,11 @@ VAImplementation VaapiWrapper::GetImplem
 }
 
 // static
+const std::string& VaapiWrapper::GetVendorString() {
+  return VADisplayState::Get()->va_vendor_string();
+}
+
+// static
 scoped_refptr<VaapiWrapper> VaapiWrapper::Create(
     CodecMode mode,
     VAProfile va_profile,
Index: chromium-84.0.4147.68/media/gpu/vaapi/vaapi_wrapper.h
===================================================================
--- chromium-84.0.4147.68.orig/media/gpu/vaapi/vaapi_wrapper.h
+++ chromium-84.0.4147.68/media/gpu/vaapi/vaapi_wrapper.h
@@ -121,6 +121,9 @@ class MEDIA_GPU_EXPORT VaapiWrapper
   // Returns the type of the underlying VA-API implementation.
   static VAImplementation GetImplementationType();
 
+  // Returns the VAAPI vendor string (obtained using vaQueryVendorString()).
+  static const std::string& GetVendorString();
+
   // Return an instance of VaapiWrapper initialized for |va_profile| and
   // |mode|. |report_error_to_uma_cb| will be called independently from
   // reporting errors to clients via method return values.
openSUSE Build Service is sponsored by