зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1664905 - Use gfxVars instead of GfxInfo in WebGL code. r=mattwoodrow
GfxInfo generally wants to be main-thread, so WebGL (especially out-of-process) runs into problems sometimes. Also remove obsolete FEATURE_WEBGL_MSAA. Differential Revision: https://phabricator.services.mozilla.com/D91208
This commit is contained in:
Родитель
e3827b1882
Коммит
98e2fea926
|
@ -23,7 +23,6 @@
|
|||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/StaticPrefs_webgl.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIGfxInfo.h"
|
||||
#include "TexUnpackBlob.h"
|
||||
#include "WebGLMethodDispatcher.h"
|
||||
#include "WebGLChild.h"
|
||||
|
@ -577,6 +576,21 @@ bool ClientWebGLContext::CreateHostContext(const uvec2& requestedSize) {
|
|||
if (StaticPrefs::webgl_disable_fail_if_major_performance_caveat()) {
|
||||
options.failIfMajorPerformanceCaveat = false;
|
||||
}
|
||||
|
||||
if (options.failIfMajorPerformanceCaveat) {
|
||||
const auto backend = GetCompositorBackendType();
|
||||
bool isCompositorSlow = false;
|
||||
isCompositorSlow |= (backend == layers::LayersBackend::LAYERS_BASIC);
|
||||
isCompositorSlow |= (backend == layers::LayersBackend::LAYERS_WR &&
|
||||
gfx::gfxVars::UseSoftwareWebRender());
|
||||
|
||||
if (isCompositorSlow) {
|
||||
return Err(
|
||||
"failIfMajorPerformanceCaveat: Compositor is not"
|
||||
" hardware-accelerated.");
|
||||
}
|
||||
}
|
||||
|
||||
const bool resistFingerprinting = ShouldResistFingerprinting();
|
||||
|
||||
const auto& principal = GetCanvas()->NodePrincipal();
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "mozilla/dom/WebGLContextEvent.h"
|
||||
#include "mozilla/EnumeratedArrayCycleCollection.h"
|
||||
#include "mozilla/EnumeratedRange.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ProcessPriorityManager.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
|
@ -45,7 +46,6 @@
|
|||
#include "nsDisplayList.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsIGfxInfo.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "SharedSurfaceGL.h"
|
||||
|
@ -94,18 +94,6 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
static bool IsFeatureInBlacklist(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
|
||||
int32_t feature,
|
||||
nsCString* const out_blacklistId) {
|
||||
int32_t status;
|
||||
if (!NS_SUCCEEDED(gfxUtils::ThreadSafeGetFeatureStatus(
|
||||
gfxInfo, feature, *out_blacklistId, &status))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return status != nsIGfxInfo::FEATURE_STATUS_OK;
|
||||
}
|
||||
|
||||
WebGLContextOptions::WebGLContextOptions() {
|
||||
// Set default alpha state based on preference.
|
||||
alpha = !StaticPrefs::webgl_default_no_alpha();
|
||||
|
@ -158,20 +146,6 @@ WebGLContext::WebGLContext(HostWebGLContext& host,
|
|||
mRequestedSize(desc.size) {
|
||||
host.mContext = this;
|
||||
const FuncScope funcScope(*this, "<Create>");
|
||||
|
||||
if (mOptions.antialias && !StaticPrefs::webgl_msaa_force()) {
|
||||
const nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
||||
|
||||
nsCString blocklistId;
|
||||
if (IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_MSAA,
|
||||
&blocklistId)) {
|
||||
GenerateWarning(
|
||||
"getContext: Disallowing antialiased backbuffers due to "
|
||||
"blacklisting. (%s)",
|
||||
blocklistId.BeginReading());
|
||||
mOptions.antialias = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebGLContext::~WebGLContext() { DestroyResourcesAndContext(); }
|
||||
|
@ -267,37 +241,6 @@ void WebGLContext::OnMemoryPressure() {
|
|||
if (shouldLoseContext) LoseContext();
|
||||
}
|
||||
|
||||
//
|
||||
// nsICanvasRenderingContextInternal
|
||||
//
|
||||
|
||||
static bool HasAcceleratedLayers(const nsCOMPtr<nsIGfxInfo>& gfxInfo) {
|
||||
int32_t status;
|
||||
|
||||
nsCString discardFailureId;
|
||||
gfxUtils::ThreadSafeGetFeatureStatus(gfxInfo,
|
||||
nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS,
|
||||
discardFailureId, &status);
|
||||
if (status) return true;
|
||||
gfxUtils::ThreadSafeGetFeatureStatus(gfxInfo,
|
||||
nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS,
|
||||
discardFailureId, &status);
|
||||
if (status) return true;
|
||||
gfxUtils::ThreadSafeGetFeatureStatus(gfxInfo,
|
||||
nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS,
|
||||
discardFailureId, &status);
|
||||
if (status) return true;
|
||||
gfxUtils::ThreadSafeGetFeatureStatus(gfxInfo,
|
||||
nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
|
||||
discardFailureId, &status);
|
||||
if (status) return true;
|
||||
gfxUtils::ThreadSafeGetFeatureStatus(
|
||||
gfxInfo, nsIGfxInfo::FEATURE_OPENGL_LAYERS, discardFailureId, &status);
|
||||
if (status) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// --
|
||||
|
||||
bool WebGLContext::CreateAndInitGL(
|
||||
|
@ -316,15 +259,9 @@ bool WebGLContext::CreateAndInitGL(
|
|||
|
||||
// WebGL2 is separately blocked:
|
||||
if (IsWebGL2() && !forceEnabled) {
|
||||
const nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
||||
const auto feature = nsIGfxInfo::FEATURE_WEBGL2;
|
||||
|
||||
FailureReason reason;
|
||||
if (IsFeatureInBlacklist(gfxInfo, feature, &reason.key)) {
|
||||
reason.info =
|
||||
"Refused to create WebGL2 context because of blacklist"
|
||||
" entry: ";
|
||||
reason.info.Append(reason.key);
|
||||
if (!gfx::gfxVars::AllowWebgl2()) {
|
||||
reason.info = "AllowWebgl2:false restricts context creation on this system.";
|
||||
out_failReasons->push_back(reason);
|
||||
GenerateWarning("%s", reason.info.BeginReading());
|
||||
return false;
|
||||
|
@ -375,18 +312,9 @@ bool WebGLContext::CreateAndInitGL(
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
const nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
||||
nsString vendorID, deviceID;
|
||||
|
||||
// Avoid crash for Intel HD Graphics 3000 on OSX. (Bug 1413269)
|
||||
gfxInfo->GetAdapterVendorID(vendorID);
|
||||
gfxInfo->GetAdapterDeviceID(deviceID);
|
||||
if (vendorID.EqualsLiteral("0x8086") &&
|
||||
(deviceID.EqualsLiteral("0x0116") || deviceID.EqualsLiteral("0x0126"))) {
|
||||
if (!gfx::gfxVars::WebglAllowCoreProfile()) {
|
||||
flags |= gl::CreateContextFlags::REQUIRE_COMPAT_PROFILE;
|
||||
}
|
||||
#endif
|
||||
|
||||
// --
|
||||
|
||||
|
@ -408,15 +336,9 @@ bool WebGLContext::CreateAndInitGL(
|
|||
#endif
|
||||
|
||||
if (tryNativeGL && !forceEnabled) {
|
||||
const nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
||||
const auto feature = nsIGfxInfo::FEATURE_WEBGL_OPENGL;
|
||||
|
||||
FailureReason reason;
|
||||
if (IsFeatureInBlacklist(gfxInfo, feature, &reason.key)) {
|
||||
reason.info =
|
||||
"Refused to create native OpenGL context because of blacklist"
|
||||
" entry: ";
|
||||
reason.info.Append(reason.key);
|
||||
if (!gfx::gfxVars::WebglAllowWindowsNativeGl()) {
|
||||
reason.info = "WebglAllowWindowsNativeGl:false restricts context creation on this system.";
|
||||
|
||||
out_failReasons->push_back(reason);
|
||||
|
||||
|
@ -584,16 +506,6 @@ RefPtr<WebGLContext> WebGLContext::Create(HostWebGLContext& host,
|
|||
return Err("WebGL is currently disabled.");
|
||||
}
|
||||
|
||||
if (desc.options.failIfMajorPerformanceCaveat) {
|
||||
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
||||
if (!HasAcceleratedLayers(gfxInfo)) {
|
||||
failureId = "FEATURE_FAILURE_WEBGL_PERF_CAVEAT"_ns;
|
||||
return Err(
|
||||
"failIfMajorPerformanceCaveat: Compositor is not"
|
||||
" hardware-accelerated.");
|
||||
}
|
||||
}
|
||||
|
||||
// Alright, now let's start trying.
|
||||
|
||||
RefPtr<WebGLContext> webgl;
|
||||
|
|
|
@ -23,6 +23,7 @@ class gfxVarReceiver;
|
|||
// Generator for graphics vars.
|
||||
#define GFX_VARS_LIST(_) \
|
||||
/* C++ Name, Data Type, Default Value */ \
|
||||
_(AllowWebgl2, bool, true) \
|
||||
_(BrowserTabsRemoteAutostart, bool, false) \
|
||||
_(ContentBackend, BackendType, BackendType::NONE) \
|
||||
_(SoftwareBackend, BackendType, BackendType::NONE) \
|
||||
|
@ -49,6 +50,8 @@ class gfxVarReceiver;
|
|||
_(UseWebRenderOptimizedShaders, bool, false) \
|
||||
_(UseWebRenderMultithreading, bool, false) \
|
||||
_(UseWebRenderScissoredCacheClears, bool, true) \
|
||||
_(WebglAllowCoreProfile, bool, true) \
|
||||
_(WebglAllowWindowsNativeGl, bool, false) \
|
||||
_(WebRenderMaxPartialPresentRects, int32_t, 0) \
|
||||
_(WebRenderDebugFlags, int32_t, 0) \
|
||||
_(WebRenderBatchingLookback, int32_t, 10) \
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "mozilla/webrender/WebRenderAPI.h"
|
||||
#include "mozilla/webrender/webrender_ffi.h"
|
||||
#include "mozilla/layers/PaintThread.h"
|
||||
#include "mozilla/gfx/BuildConstants.h"
|
||||
#include "mozilla/gfx/gfxConfigManager.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/gfx/GPUProcessManager.h"
|
||||
|
@ -2549,6 +2550,28 @@ void gfxPlatform::InitAcceleration() {
|
|||
gfxVars::SetUseDoubleBufferingWithCompositor(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NS_SUCCEEDED(
|
||||
gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBGL2,
|
||||
discardFailureId, &status))) {
|
||||
gfxVars::SetAllowWebgl2(status == nsIGfxInfo::FEATURE_STATUS_OK);
|
||||
}
|
||||
if (NS_SUCCEEDED(
|
||||
gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBGL_OPENGL,
|
||||
discardFailureId, &status))) {
|
||||
gfxVars::SetWebglAllowWindowsNativeGl(status == nsIGfxInfo::FEATURE_STATUS_OK);
|
||||
}
|
||||
|
||||
if (kIsMacOS) {
|
||||
// Avoid crash for Intel HD Graphics 3000 on OSX. (Bug 1413269)
|
||||
nsString vendorID, deviceID;
|
||||
gfxInfo->GetAdapterVendorID(vendorID);
|
||||
gfxInfo->GetAdapterDeviceID(deviceID);
|
||||
if (vendorID.EqualsLiteral("0x8086") &&
|
||||
(deviceID.EqualsLiteral("0x0116") || deviceID.EqualsLiteral("0x0126"))) {
|
||||
gfxVars::SetWebglAllowCoreProfile(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Preferences::GetBool("media.hardware-video-decoding.enabled", false) &&
|
||||
|
|
|
@ -85,9 +85,6 @@ async function run_test() {
|
|||
);
|
||||
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
|
||||
|
||||
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_MSAA);
|
||||
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
|
||||
|
||||
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_ANGLE);
|
||||
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
|
||||
|
||||
|
|
|
@ -104,12 +104,6 @@ async function run_test() {
|
|||
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
|
||||
Assert.equal(failureId.value, "FEATURE_FAILURE_DL_BLOCKLIST_NO_ID");
|
||||
|
||||
status = gfxInfo.getFeatureStatus(
|
||||
Ci.nsIGfxInfo.FEATURE_WEBGL_MSAA,
|
||||
failureId
|
||||
);
|
||||
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
|
||||
|
||||
status = gfxInfo.getFeatureStatus(
|
||||
Ci.nsIGfxInfo.FEATURE_STAGEFRIGHT,
|
||||
failureId
|
||||
|
|
|
@ -163,9 +163,6 @@ static const char* GetPrefNameForFeature(int32_t aFeature) {
|
|||
case nsIGfxInfo::FEATURE_WEBGL_ANGLE:
|
||||
name = BLOCKLIST_PREF_BRANCH "webgl.angle";
|
||||
break;
|
||||
case nsIGfxInfo::FEATURE_WEBGL_MSAA:
|
||||
name = BLOCKLIST_PREF_BRANCH "webgl.msaa";
|
||||
break;
|
||||
case nsIGfxInfo::FEATURE_STAGEFRIGHT:
|
||||
name = BLOCKLIST_PREF_BRANCH "stagefright";
|
||||
break;
|
||||
|
@ -377,8 +374,6 @@ static int32_t BlocklistFeatureToGfxFeature(const nsAString& aFeature) {
|
|||
return nsIGfxInfo::FEATURE_WEBGL_OPENGL;
|
||||
else if (aFeature.EqualsLiteral("WEBGL_ANGLE"))
|
||||
return nsIGfxInfo::FEATURE_WEBGL_ANGLE;
|
||||
else if (aFeature.EqualsLiteral("WEBGL_MSAA"))
|
||||
return nsIGfxInfo::FEATURE_WEBGL_MSAA;
|
||||
else if (aFeature.EqualsLiteral("STAGEFRIGHT"))
|
||||
return nsIGfxInfo::FEATURE_STAGEFRIGHT;
|
||||
else if (aFeature.EqualsLiteral("WEBRTC_HW_ACCELERATION_ENCODE"))
|
||||
|
@ -1258,7 +1253,6 @@ void GfxInfoBase::EvaluateDownloadedBlocklist(
|
|||
nsIGfxInfo::FEATURE_WEBGL_ANGLE,
|
||||
nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_ENCODE,
|
||||
nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_DECODE,
|
||||
nsIGfxInfo::FEATURE_WEBGL_MSAA,
|
||||
nsIGfxInfo::FEATURE_STAGEFRIGHT,
|
||||
nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_H264,
|
||||
nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION,
|
||||
|
|
|
@ -117,8 +117,6 @@ interface nsIGfxInfo : nsISupports
|
|||
const long FEATURE_WEBGL_OPENGL = 6;
|
||||
/* Whether WebGL is supported via ANGLE (D3D9 -- does not check for the presence of ANGLE libs). */
|
||||
const long FEATURE_WEBGL_ANGLE = 7;
|
||||
/* Whether WebGL antialiasing is supported. */
|
||||
const long FEATURE_WEBGL_MSAA = 8;
|
||||
/* Whether Stagefright is supported, starting in 17. */
|
||||
const long FEATURE_STAGEFRIGHT = 9;
|
||||
/* Whether Webrtc Hardware H.264 acceleration is supported, starting in 71. */
|
||||
|
|
|
@ -139,8 +139,7 @@ nsresult GfxInfo::GetFeatureStatusImpl(
|
|||
// This early return is so we avoid potentially slow
|
||||
// GLStrings initialization on startup when we initialize GL layers.
|
||||
if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS ||
|
||||
aFeature == nsIGfxInfo::FEATURE_WEBGL_OPENGL ||
|
||||
aFeature == nsIGfxInfo::FEATURE_WEBGL_MSAA) {
|
||||
aFeature == nsIGfxInfo::FEATURE_WEBGL_OPENGL) {
|
||||
*aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче