Taken from https://aur.archlinux.org/cgit/aur.git/tree/vdpau-support.patch?h=chromium-vaapi Index: dev/media/gpu/vaapi/vaapi_video_decode_accelerator.cc =================================================================== --- dev.orig/media/gpu/vaapi/vaapi_video_decode_accelerator.cc +++ dev/media/gpu/vaapi/vaapi_video_decode_accelerator.cc @@ -711,7 +711,8 @@ void VaapiVideoDecodeAccelerator::Assign // implementation we get from |vaapi_picture_factory_| requires the video // processing pipeline for downloading the decoded frame from the internal // surface, we need to create a |vpp_vaapi_wrapper_|. - if (requires_vpp && buffer_allocation_mode_ != BufferAllocationMode::kNone) { + if (requires_vpp && buffer_allocation_mode_ != BufferAllocationMode::kNone && + buffer_allocation_mode_ != BufferAllocationMode::kWrapVdpau) { if (!vpp_vaapi_wrapper_) { vpp_vaapi_wrapper_ = VaapiWrapper::Create( VaapiWrapper::kVideoProcess, VAProfileNone, @@ -1226,6 +1227,12 @@ VaapiVideoDecodeAccelerator::DecideBuffe return BufferAllocationMode::kReduced; return BufferAllocationMode::kSuperReduced; #else + // NVIDIA blobs use VDPAU + if (VaapiWrapper::GetImplementationType() == VAImplementation::kNVIDIAVDPAU) { + 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) @@ -1236,7 +1243,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: dev/media/gpu/vaapi/vaapi_video_decode_accelerator.h =================================================================== --- dev.orig/media/gpu/vaapi/vaapi_video_decode_accelerator.h +++ dev/media/gpu/vaapi/vaapi_video_decode_accelerator.h @@ -217,6 +217,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: dev/media/gpu/vaapi/vaapi_wrapper.cc =================================================================== --- dev.orig/media/gpu/vaapi/vaapi_wrapper.cc +++ dev/media/gpu/vaapi/vaapi_wrapper.cc @@ -240,6 +240,9 @@ media::VAImplementation VendorStringToIm } else if (base::StartsWith(va_vendor_string, "Intel iHD driver", base::CompareCase::SENSITIVE)) { return media::VAImplementation::kIntelIHD; + } else if (base::StartsWith(va_vendor_string, "Splitted-Desktop Systems VDPAU", + base::CompareCase::SENSITIVE)) { + return media::VAImplementation::kNVIDIAVDPAU; } return media::VAImplementation::kOther; } @@ -1977,6 +1980,11 @@ VaapiWrapper::ExportVASurfaceAsNativePix return nullptr; } + if (GetImplementationType() == VAImplementation::kNVIDIAVDPAU) { + LOG(ERROR) << "Disabled due to potential breakage."; + return nullptr; + } + VADRMPRIMESurfaceDescriptor descriptor; { base::AutoLock auto_lock(*va_lock_); @@ -2680,32 +2688,43 @@ bool VaapiWrapper::CreateSurfaces(unsign DCHECK(va_surfaces->empty()); va_surfaces->resize(num_surfaces); + VASurfaceAttrib attribute{}; - attribute.type = VASurfaceAttribUsageHint; - attribute.flags = VA_SURFACE_ATTRIB_SETTABLE; - attribute.value.type = VAGenericValueTypeInteger; - switch (usage_hint) { - case SurfaceUsageHint::kVideoDecoder: - attribute.value.value.i = VA_SURFACE_ATTRIB_USAGE_HINT_DECODER; - break; - case SurfaceUsageHint::kVideoEncoder: - attribute.value.value.i = VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER; - break; - case SurfaceUsageHint::kVideoProcessWrite: - attribute.value.value.i = VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE; - break; - case SurfaceUsageHint::kGeneric: - attribute.value.value.i = VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC; - break; + if (GetImplementationType() != VAImplementation::kNVIDIAVDPAU) { + // Nvidia's VAAPI-VDPAU driver doesn't support this attribute + attribute.type = VASurfaceAttribUsageHint; + attribute.flags = VA_SURFACE_ATTRIB_SETTABLE; + attribute.value.type = VAGenericValueTypeInteger; + switch (usage_hint) { + case SurfaceUsageHint::kVideoDecoder: + attribute.value.value.i = VA_SURFACE_ATTRIB_USAGE_HINT_DECODER; + break; + case SurfaceUsageHint::kVideoEncoder: + attribute.value.value.i = VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER; + break; + case SurfaceUsageHint::kVideoProcessWrite: + attribute.value.value.i = VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE; + break; + case SurfaceUsageHint::kGeneric: + attribute.value.value.i = VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC; + break; + } } VAStatus va_res; { base::AutoLock auto_lock(*va_lock_); - va_res = vaCreateSurfaces( - va_display_, va_format, base::checked_cast(size.width()), - base::checked_cast(size.height()), va_surfaces->data(), - num_surfaces, &attribute, 1u); + if (GetImplementationType() == VAImplementation::kNVIDIAVDPAU) { + va_res = vaCreateSurfaces( + va_display_, va_format, base::checked_cast(size.width()), + base::checked_cast(size.height()), va_surfaces->data(), + num_surfaces, NULL, 0); + } else { + va_res = vaCreateSurfaces( + va_display_, va_format, base::checked_cast(size.width()), + base::checked_cast(size.height()), va_surfaces->data(), + num_surfaces, &attribute, 1u); + } } VA_LOG_ON_ERROR(va_res, VaapiFunctions::kVACreateSurfaces_Allocating); return va_res == VA_STATUS_SUCCESS; Index: dev/media/gpu/vaapi/vaapi_wrapper.h =================================================================== --- dev.orig/media/gpu/vaapi/vaapi_wrapper.h +++ dev/media/gpu/vaapi/vaapi_wrapper.h @@ -92,6 +92,7 @@ enum class VAImplementation { kIntelIHD, kOther, kInvalid, + kNVIDIAVDPAU, }; // This class handles VA-API calls and ensures proper locking of VA-API calls