Bug 1831038 Add FEATURE_H264_HW_DECODE / FEATURE_AV1_HW_DECODE to track HW decode state on Linux r=alwu

- Add H264_HW_DECODE / AV1_HW_DECODE features to track H264/AV1 decoding state on Linux.
- Add UseH264HwDecode / UseAV1HwDecode gfx variables to route decode state to RDD process.
- Init H264_HW_DECODE / AV1_HW_DECODE features on Linux only and skip all HW decoding features init if VA-API is not supported.

Differential Revision: https://phabricator.services.mozilla.com/D177021
This commit is contained in:
stransky 2023-05-11 09:58:21 +00:00
parent 924c311c4b
commit c1968f2af4
5 changed files with 41 additions and 6 deletions

View file

@ -48,8 +48,10 @@ namespace gfx {
_(REUSE_DECODER_DEVICE, Feature, "Reuse decoder device") \
_(BACKDROP_FILTER, Feature, "Backdrop filter") \
_(CANVAS_RENDERER_THREAD, Feature, "canvas renderer thread") \
_(ACCELERATED_CANVAS2D, Feature, "Accelerated Canvas2D")
/* Add new entries above this comment */
_(ACCELERATED_CANVAS2D, Feature, "Accelerated Canvas2D") \
_(H264_HW_DECODE, Feature, "H.264 hardware decoding") \
_(AV1_HW_DECODE, Feature, "AV1 hardware decoding") \
/* Add new entries above this comment */
enum class Feature : uint32_t {
#define MAKE_ENUM(name, type, desc) name,

View file

@ -88,6 +88,8 @@ class gfxVarReceiver;
_(AllowWebGPU, bool, false) \
_(UseVP8HwDecode, bool, false) \
_(UseVP9HwDecode, bool, false) \
_(UseAV1HwDecode, bool, false) \
_(UseH264HwDecode, bool, false) \
_(HwDecodedVideoZeroCopy, bool, false) \
_(UseDMABufSurfaceExport, bool, true) \
_(ReuseDecoderDevice, bool, false) \

View file

@ -2856,10 +2856,12 @@ void gfxPlatform::InitHardwareVideoConfig() {
return;
}
// We don't use selective VP8/9 decode control on Linux.
if (kIsWayland || kIsX11) {
#ifdef MOZ_WIDGET_GTK
// We don't want to expose codec info if whole HW decoding is disabled.
if (!sLayersSupportsHardwareVideoDecoding) {
return;
}
#endif
nsCString message;
nsCString failureId;
@ -2871,7 +2873,6 @@ void gfxPlatform::InitHardwareVideoConfig() {
failureId)) {
featureVP8.Disable(FeatureStatus::Blocklisted, message.get(), failureId);
}
gfxVars::SetUseVP8HwDecode(featureVP8.IsEnabled());
FeatureState& featureVP9 = gfxConfig::GetFeature(Feature::VP9_HW_DECODE);
@ -2881,8 +2882,28 @@ void gfxPlatform::InitHardwareVideoConfig() {
failureId)) {
featureVP9.Disable(FeatureStatus::Blocklisted, message.get(), failureId);
}
gfxVars::SetUseVP9HwDecode(featureVP9.IsEnabled());
// H264_HW_DECODE/AV1_HW_DECODE is used on Linux only right now.
#ifdef MOZ_WIDGET_GTK
FeatureState& featureH264 = gfxConfig::GetFeature(Feature::H264_HW_DECODE);
featureH264.EnableByDefault();
if (!IsGfxInfoStatusOkay(nsIGfxInfo::FEATURE_H264_HW_DECODE, &message,
failureId)) {
featureH264.Disable(FeatureStatus::Blocklisted, message.get(), failureId);
}
gfxVars::SetUseH264HwDecode(featureH264.IsEnabled());
FeatureState& featureAV1 = gfxConfig::GetFeature(Feature::AV1_HW_DECODE);
featureAV1.EnableByDefault();
if (!IsGfxInfoStatusOkay(nsIGfxInfo::FEATURE_AV1_HW_DECODE, &message,
failureId)) {
featureAV1.Disable(FeatureStatus::Blocklisted, message.get(), failureId);
}
gfxVars::SetUseAV1HwDecode(featureAV1.IsEnabled());
#endif
}
void gfxPlatform::InitWebGLConfig() {

View file

@ -260,6 +260,12 @@ static const char* GetPrefNameForFeature(int32_t aFeature) {
case nsIGfxInfo::FEATURE_ACCELERATED_CANVAS2D:
name = BLOCKLIST_PREF_BRANCH "accelerated-canvas2d";
break;
case nsIGfxInfo::FEATURE_H264_HW_DECODE:
name = BLOCKLIST_PREF_BRANCH "h264.hw-decode";
break;
case nsIGfxInfo::FEATURE_AV1_HW_DECODE:
name = BLOCKLIST_PREF_BRANCH "av1.hw-decode";
break;
default:
MOZ_ASSERT_UNREACHABLE("Unexpected nsIGfxInfo feature?!");
break;

View file

@ -181,6 +181,10 @@ interface nsIGfxInfo : nsISupports
const long FEATURE_BACKDROP_FILTER = 42;
/* Whether to use Accelerated Canvas2D, starting in 110. */
const long FEATURE_ACCELERATED_CANVAS2D = 43;
/* Whether hardware H264 decoding is supported, starting in 114; not for downloadable blocking. */
const long FEATURE_H264_HW_DECODE = 44;
/* Whether hardware AV1 decoding is supported, starting in 114; not for downloadable blocking. */
const long FEATURE_AV1_HW_DECODE = 45;
/* the maximum feature value. */
const long FEATURE_MAX_VALUE = FEATURE_ACCELERATED_CANVAS2D;