зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1696071 - Add support for DMABuf to the blocklist. r=rmader
Differential Revision: https://phabricator.services.mozilla.com/D107019
This commit is contained in:
Родитель
8ebccdd08d
Коммит
86da16f9a5
|
@ -36,6 +36,7 @@ namespace gfx {
|
|||
_(OMTP, Feature, "Off Main Thread Painting") \
|
||||
_(WEBGPU, Feature, "WebGPU") \
|
||||
_(X11_EGL, Feature, "X11 EGL") \
|
||||
_(DMABUF, Feature, "DMABUF") \
|
||||
/* Add new entries above this comment */
|
||||
|
||||
enum class Feature : uint32_t {
|
||||
|
|
|
@ -75,7 +75,8 @@ class gfxVarReceiver;
|
|||
_(UseAHardwareBufferContent, bool, false) \
|
||||
_(UseAHardwareBufferSharedSurface, bool, false) \
|
||||
_(UseEGL, bool, false) \
|
||||
_(DrmRenderDevice, nsCString, nsCString())
|
||||
_(DrmRenderDevice, nsCString, nsCString()) \
|
||||
_(UseDMABuf, bool, false)
|
||||
|
||||
/* Add new entries above this line. */
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
# include <gdk/gdkwayland.h>
|
||||
# include "mozilla/widget/nsWaylandDisplay.h"
|
||||
# include "mozilla/widget/DMABufLibWrapper.h"
|
||||
# include "mozilla/StaticPrefs_media.h"
|
||||
# include "mozilla/StaticPrefs_widget.h"
|
||||
#endif
|
||||
|
||||
#define GDK_PIXMAP_SIZE_MAX 32767
|
||||
|
@ -106,14 +106,13 @@ gfxPlatformGtk::gfxPlatformGtk() {
|
|||
#endif
|
||||
|
||||
InitX11EGLConfig();
|
||||
|
||||
if (IsWaylandDisplay() || gfxConfig::IsEnabled(Feature::X11_EGL)) {
|
||||
gfxVars::SetUseEGL(true);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGfxInfo> gfxInfo = components::GfxInfo::Service();
|
||||
nsAutoCString drmRenderDevice;
|
||||
gfxInfo->GetDrmRenderDevice(drmRenderDevice);
|
||||
gfxVars::SetDrmRenderDevice(drmRenderDevice);
|
||||
InitDmabufConfig();
|
||||
if (gfxConfig::IsEnabled(Feature::DMABUF)) {
|
||||
gfxVars::SetUseDMABuf(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +120,7 @@ gfxPlatformGtk::gfxPlatformGtk() {
|
|||
|
||||
#ifdef MOZ_WAYLAND
|
||||
mUseWebGLDmabufBackend =
|
||||
gfxVars::UseEGL() && GetDMABufDevice()->IsDMABufWebGLEnabled();
|
||||
gfxVars::UseDMABuf() && GetDMABufDevice()->IsDMABufWebGLEnabled();
|
||||
#endif
|
||||
|
||||
gPlatformFTLibrary = Factory::NewFTLibrary();
|
||||
|
@ -180,6 +179,49 @@ void gfxPlatformGtk::InitX11EGLConfig() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void gfxPlatformGtk::InitDmabufConfig() {
|
||||
FeatureState& feature = gfxConfig::GetFeature(Feature::DMABUF);
|
||||
#ifdef MOZ_WAYLAND
|
||||
feature.EnableByDefault();
|
||||
|
||||
if (StaticPrefs::widget_dmabuf_force_enabled_AtStartup()) {
|
||||
feature.UserForceEnable("Force enabled by pref");
|
||||
}
|
||||
|
||||
nsCString failureId;
|
||||
int32_t status;
|
||||
nsCOMPtr<nsIGfxInfo> gfxInfo = components::GfxInfo::Service();
|
||||
if (NS_FAILED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DMABUF, failureId,
|
||||
&status))) {
|
||||
feature.Disable(FeatureStatus::BlockedNoGfxInfo, "gfxInfo is broken",
|
||||
"FEATURE_FAILURE_NO_GFX_INFO"_ns);
|
||||
} else if (status != nsIGfxInfo::FEATURE_STATUS_OK) {
|
||||
feature.Disable(FeatureStatus::Blocklisted, "Blocklisted by gfxInfo",
|
||||
failureId);
|
||||
}
|
||||
|
||||
if (!gfxVars::UseEGL()) {
|
||||
feature.ForceDisable(FeatureStatus::Unavailable, "Requires EGL",
|
||||
"FEATURE_FAILURE_REQUIRES_EGL"_ns);
|
||||
}
|
||||
|
||||
if (feature.IsEnabled()) {
|
||||
nsAutoCString drmRenderDevice;
|
||||
gfxInfo->GetDrmRenderDevice(drmRenderDevice);
|
||||
gfxVars::SetDrmRenderDevice(drmRenderDevice);
|
||||
|
||||
if (!GetDMABufDevice()->Configure(failureId)) {
|
||||
feature.ForceDisable(FeatureStatus::Failed, "Failed to configure",
|
||||
failureId);
|
||||
}
|
||||
}
|
||||
#else
|
||||
feature.DisableByDefault(FeatureStatus::Unavailable,
|
||||
"Wayland support missing",
|
||||
"FEATURE_FAILURE_NO_WAYLAND"_ns);
|
||||
#endif
|
||||
}
|
||||
|
||||
void gfxPlatformGtk::FlushContentDrawing() {
|
||||
if (gfxVars::UseXRender()) {
|
||||
XFlush(DefaultXDisplay());
|
||||
|
|
|
@ -93,6 +93,7 @@ class gfxPlatformGtk final : public gfxPlatform {
|
|||
|
||||
protected:
|
||||
void InitX11EGLConfig();
|
||||
void InitDmabufConfig();
|
||||
void InitPlatformGPUProcessPrefs() override;
|
||||
bool CheckVariationFontSupport() override;
|
||||
|
||||
|
|
|
@ -10823,6 +10823,12 @@
|
|||
mirror: always
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
# Whether to override the DMABuf blocklist.
|
||||
- name: widget.dmabuf.force-enabled
|
||||
type: bool
|
||||
value: false
|
||||
mirror: once
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
# Keep those pref hidden on non-nightly builds to avoid people accidentally
|
||||
# turning it on.
|
||||
|
|
|
@ -234,6 +234,9 @@ static const char* GetPrefNameForFeature(int32_t aFeature) {
|
|||
case nsIGfxInfo::FEATURE_X11_EGL:
|
||||
name = BLOCKLIST_PREF_BRANCH "x11.egl";
|
||||
break;
|
||||
case nsIGfxInfo::FEATURE_DMABUF:
|
||||
name = BLOCKLIST_PREF_BRANCH "dmabuf";
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unexpected nsIGfxInfo feature?!");
|
||||
break;
|
||||
|
@ -432,6 +435,8 @@ static int32_t BlocklistFeatureToGfxFeature(const nsAString& aFeature) {
|
|||
return nsIGfxInfo::FEATURE_WEBRENDER_SOFTWARE;
|
||||
else if (aFeature.EqualsLiteral("X11_EGL"))
|
||||
return nsIGfxInfo::FEATURE_X11_EGL;
|
||||
else if (aFeature.EqualsLiteral("DMABUF"))
|
||||
return nsIGfxInfo::FEATURE_DMABUF;
|
||||
|
||||
// If we don't recognize the feature, it may be new, and something
|
||||
// this version doesn't understand. So, nothing to do. This is
|
||||
|
@ -1294,6 +1299,7 @@ void GfxInfoBase::EvaluateDownloadedBlocklist(
|
|||
nsIGfxInfo::FEATURE_GL_SWIZZLE,
|
||||
nsIGfxInfo::FEATURE_ALLOW_WEBGL_OUT_OF_PROCESS,
|
||||
nsIGfxInfo::FEATURE_X11_EGL,
|
||||
nsIGfxInfo::FEATURE_DMABUF,
|
||||
0};
|
||||
|
||||
// For every feature we know about, we evaluate whether this blocklist has a
|
||||
|
|
|
@ -168,7 +168,8 @@ nsDMABufDevice::nsDMABufDevice()
|
|||
: mXRGBFormat({true, false, GBM_FORMAT_XRGB8888, nullptr, 0}),
|
||||
mARGBFormat({true, true, GBM_FORMAT_ARGB8888, nullptr, 0}),
|
||||
mGbmDevice(nullptr),
|
||||
mGbmFd(-1) {
|
||||
mGbmFd(-1),
|
||||
mInitialized(false) {
|
||||
if (GdkIsWaylandDisplay()) {
|
||||
wl_display* display = WaylandDisplayGetWLDisplay();
|
||||
mRegistry = (void*)wl_display_get_registry(display);
|
||||
|
@ -185,9 +186,12 @@ nsDMABufDevice::~nsDMABufDevice() {
|
|||
}
|
||||
}
|
||||
|
||||
bool nsDMABufDevice::Configure() {
|
||||
bool nsDMABufDevice::Configure(nsACString& aFailureId) {
|
||||
LOGDMABUF(("nsDMABufDevice::Configure()"));
|
||||
|
||||
MOZ_ASSERT(!mInitialized);
|
||||
mInitialized = true;
|
||||
|
||||
bool isDMABufUsed = (
|
||||
#ifdef NIGHTLY_BUILD
|
||||
StaticPrefs::widget_dmabuf_textures_enabled() ||
|
||||
|
@ -199,11 +203,13 @@ bool nsDMABufDevice::Configure() {
|
|||
if (!isDMABufUsed) {
|
||||
// Disabled by user, just quit.
|
||||
LOGDMABUF(("IsDMABufEnabled(): Disabled by preferences."));
|
||||
aFailureId = "FEATURE_FAILURE_NO_PREFS_ENABLED";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!nsGbmLib::IsAvailable()) {
|
||||
LOGDMABUF(("nsGbmLib is not available!"));
|
||||
aFailureId = "FEATURE_FAILURE_NO_LIBGBM";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -212,6 +218,7 @@ bool nsDMABufDevice::Configure() {
|
|||
drm_render_node.Assign(gfx::gfxVars::DrmRenderDevice());
|
||||
if (drm_render_node.IsEmpty()) {
|
||||
LOGDMABUF(("Failed: We're missing DRM render device!\n"));
|
||||
aFailureId = "FEATURE_FAILURE_NO_DRM_RENDER_NODE";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -219,6 +226,7 @@ bool nsDMABufDevice::Configure() {
|
|||
mGbmFd = open(drm_render_node.get(), O_RDWR);
|
||||
if (mGbmFd < 0) {
|
||||
LOGDMABUF(("Failed to open drm render node %s\n", drm_render_node.get()));
|
||||
aFailureId = "FEATURE_FAILURE_BAD_DRM_RENDER_NODE";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -226,6 +234,7 @@ bool nsDMABufDevice::Configure() {
|
|||
if (!mGbmDevice) {
|
||||
LOGDMABUF(
|
||||
("Failed to create drm render device %s\n", drm_render_node.get()));
|
||||
aFailureId = "FEATURE_FAILURE_NO_DRM_RENDER_DEVICE";
|
||||
close(mGbmFd);
|
||||
mGbmFd = -1;
|
||||
return false;
|
||||
|
@ -236,13 +245,17 @@ bool nsDMABufDevice::Configure() {
|
|||
}
|
||||
|
||||
bool nsDMABufDevice::IsDMABufEnabled() {
|
||||
static bool isDMABufEnabled = Configure();
|
||||
return isDMABufEnabled;
|
||||
if (!mInitialized) {
|
||||
MOZ_ASSERT(!XRE_IsParentProcess());
|
||||
nsCString failureId;
|
||||
return Configure(failureId);
|
||||
}
|
||||
return !!mGbmDevice;
|
||||
}
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
bool nsDMABufDevice::IsDMABufTexturesEnabled() {
|
||||
return gfx::gfxVars::UseEGL() && IsDMABufEnabled() &&
|
||||
return gfx::gfxVars::UseDMABuf() && IsDMABufEnabled() &&
|
||||
StaticPrefs::widget_dmabuf_textures_enabled();
|
||||
}
|
||||
#else
|
||||
|
@ -257,7 +270,7 @@ bool nsDMABufDevice::IsDMABufVAAPIEnabled() {
|
|||
StaticPrefs::media_ffmpeg_vaapi_enabled(),
|
||||
gfx::gfxVars::CanUseHardwareVideoDecoding(), !XRE_IsRDDProcess()));
|
||||
return StaticPrefs::media_ffmpeg_vaapi_enabled() && !XRE_IsRDDProcess() &&
|
||||
gfx::gfxVars::UseEGL() && IsDMABufEnabled() &&
|
||||
gfx::gfxVars::UseDMABuf() && IsDMABufEnabled() &&
|
||||
gfx::gfxVars::CanUseHardwareVideoDecoding();
|
||||
}
|
||||
bool nsDMABufDevice::IsDMABufWebGLEnabled() {
|
||||
|
@ -266,7 +279,7 @@ bool nsDMABufDevice::IsDMABufWebGLEnabled() {
|
|||
"widget_dmabuf_webgl_enabled %d\n",
|
||||
gfx::gfxVars::UseEGL(), IsDMABufEnabled(),
|
||||
StaticPrefs::widget_dmabuf_webgl_enabled()));
|
||||
return gfx::gfxVars::UseEGL() && IsDMABufEnabled() &&
|
||||
return gfx::gfxVars::UseDMABuf() && IsDMABufEnabled() &&
|
||||
StaticPrefs::widget_dmabuf_webgl_enabled();
|
||||
}
|
||||
|
||||
|
|
|
@ -150,10 +150,10 @@ class nsDMABufDevice {
|
|||
void ResetFormatsModifiers();
|
||||
void AddFormatModifier(bool aHasAlpha, int aFormat, uint32_t mModifierHi,
|
||||
uint32_t mModifierLo);
|
||||
bool Configure(nsACString& aFailureId);
|
||||
|
||||
private:
|
||||
bool IsDMABufEnabled();
|
||||
bool Configure();
|
||||
|
||||
void* mRegistry;
|
||||
|
||||
|
@ -162,6 +162,7 @@ class nsDMABufDevice {
|
|||
|
||||
gbm_device* mGbmDevice;
|
||||
int mGbmFd;
|
||||
bool mInitialized;
|
||||
};
|
||||
|
||||
nsDMABufDevice* GetDMABufDevice();
|
||||
|
|
|
@ -175,8 +175,10 @@ interface nsIGfxInfo : nsISupports
|
|||
const long FEATURE_WEBRENDER_OPTIMIZED_SHADERS = 33;
|
||||
/* Whether we prefer EGL over GLX with X11, starting in 88. */
|
||||
const long FEATURE_X11_EGL = 34;
|
||||
/* Whether DMABUF is supported, starting in 88. */
|
||||
const long FEATURE_DMABUF = 35;
|
||||
/* the maximum feature value. */
|
||||
const long FEATURE_MAX_VALUE = FEATURE_X11_EGL;
|
||||
const long FEATURE_MAX_VALUE = FEATURE_DMABUF;
|
||||
|
||||
/*
|
||||
* A set of return values from GetFeatureStatus
|
||||
|
|
Загрузка…
Ссылка в новой задаче