Bug 1669381 - Replace GLLibraryEGL nsIGfxInfo use with gfxVars. r=mattwoodrow

+ Remove now-unused gfxUtils::ThreadSafeGetFeatureStatus.

Differential Revision: https://phabricator.services.mozilla.com/D92529
This commit is contained in:
Jeff Gilbert 2020-10-06 05:43:33 +00:00
Родитель 5752bb8db2
Коммит a426e3880b
7 изменённых файлов: 25 добавлений и 77 удалений

Просмотреть файл

@ -23,7 +23,9 @@ class gfxVarReceiver;
// Generator for graphics vars.
#define GFX_VARS_LIST(_) \
/* C++ Name, Data Type, Default Value */ \
_(AllowEglRbab, bool, true) \
_(AllowWebgl2, bool, true) \
_(AllowWebglAccelAngle, bool, true) \
_(AllowWebglOop, bool, true) \
_(BrowserTabsRemoteAutostart, bool, false) \
_(ContentBackend, BackendType, BackendType::NONE) \

Просмотреть файл

@ -695,12 +695,7 @@ RefPtr<GLContextEGL> GLContextEGL::CreateGLContext(
LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT);
robustness_attribs.push_back(LOCAL_EGL_LOSE_CONTEXT_ON_RESET_EXT);
// Don't enable robust buffer access on Adreno 630 devices.
// It causes the linking of some shaders to fail. See bug 1485441.
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
nsAutoString renderer;
gfxInfo->GetAdapterDeviceID(renderer);
if (renderer.Find("Adreno (TM) 630") == -1) {
if (gfxVars::AllowEglRbab()) {
rbab_attribs = robustness_attribs;
rbab_attribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT);
rbab_attribs.push_back(LOCAL_EGL_TRUE);

Просмотреть файл

@ -19,7 +19,6 @@
#include "mozilla/webrender/RenderThread.h"
#include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsIGfxInfo.h"
#include "nsPrintfCString.h"
#ifdef XP_WIN
# include "mozilla/gfx/DeviceManagerDx.h"
@ -208,26 +207,19 @@ std::shared_ptr<EglDisplay> GLLibraryEGL::CreateDisplay(
return ret;
}
static bool IsAccelAngleSupported(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
nsACString* const out_failureId) {
static bool IsAccelAngleSupported(nsACString* const out_failureId) {
if (wr::RenderThread::IsInRenderThread()) {
// We can only enter here with WebRender, so assert that this is a
// WebRender-enabled build.
return true;
}
int32_t angleSupport;
nsCString failureId;
gfxUtils::ThreadSafeGetFeatureStatus(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_ANGLE,
failureId, &angleSupport);
if (failureId.IsEmpty() && angleSupport != nsIGfxInfo::FEATURE_STATUS_OK) {
// This shouldn't happen, if we see this it's because we've missed
// some failure paths
failureId = "FEATURE_FAILURE_ACCL_ANGLE_NOT_OK"_ns;
if (!gfxVars::AllowWebglAccelAngle()) {
if (out_failureId->IsEmpty()) {
*out_failureId = "FEATURE_FAILURE_ACCL_ANGLE_NOT_OK"_ns;
}
return false;
}
if (out_failureId->IsEmpty()) {
*out_failureId = failureId;
}
return (angleSupport == nsIGfxInfo::FEATURE_STATUS_OK);
return true;
}
class AngleErrorReporting {
@ -718,14 +710,11 @@ std::shared_ptr<EglDisplay> GLLibraryEGL::DefaultDisplay(
std::shared_ptr<EglDisplay> GLLibraryEGL::CreateDisplay(
const bool forceAccel, nsACString* const out_failureId) {
const nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
std::shared_ptr<EglDisplay> ret;
if (IsExtensionSupported(EGLLibExtension::ANGLE_platform_angle_d3d)) {
nsCString accelAngleFailureId;
bool accelAngleSupport =
IsAccelAngleSupported(gfxInfo, &accelAngleFailureId);
bool accelAngleSupport = IsAccelAngleSupported(&accelAngleFailureId);
bool shouldTryAccel = forceAccel || accelAngleSupport;
bool shouldTryWARP = !forceAccel; // Only if ANGLE not supported or fails

Просмотреть файл

@ -33,11 +33,6 @@ extern "C" {
struct AHardwareBuffer;
}
class nsIGfxInfo;
template <typename T>
class nsCOMPtr;
namespace angle {
class Platform;
}

Просмотреть файл

@ -2560,6 +2560,10 @@ void gfxPlatform::InitAcceleration() {
gfxVars::SetWebglAllowWindowsNativeGl(status ==
nsIGfxInfo::FEATURE_STATUS_OK);
}
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBGL_ANGLE,
discardFailureId, &status))) {
gfxVars::SetAllowWebglAccelAngle(status == nsIGfxInfo::FEATURE_STATUS_OK);
}
if (kIsMacOS) {
// Avoid crash for Intel HD Graphics 3000 on OSX. (Bug 1413269)
@ -2592,6 +2596,16 @@ void gfxPlatform::InitAcceleration() {
gfxVars::SetAllowWebglOop(allowWebGLOop);
}
if (kIsAndroid) {
// Don't enable robust buffer access on Adreno 630 devices.
// It causes the linking of some shaders to fail. See bug 1485441.
nsAutoString renderer;
gfxInfo->GetAdapterDeviceID(renderer);
if (renderer.Find("Adreno (TM) 630") != -1) {
gfxVars::SetAllowEglRbab(false);
}
}
}
if (Preferences::GetBool("media.hardware-video-decoding.enabled", false) &&

Просмотреть файл

@ -1398,49 +1398,6 @@ class GetFeatureStatusWorkerRunnable final
nsresult mNSResult;
};
/* static */
nsresult gfxUtils::ThreadSafeGetFeatureStatus(
const nsCOMPtr<nsIGfxInfo>& gfxInfo, int32_t feature, nsACString& failureId,
int32_t* status) {
if (NS_IsMainThread()) {
return gfxInfo->GetFeatureStatus(feature, failureId, status);
}
// In a content process, we must call this on the main thread.
// In a composition process (parent or GPU), this needs to be called on the
// compositor thread.
bool isCompositionProcess = XRE_IsGPUProcess() || XRE_IsParentProcess();
MOZ_ASSERT(!isCompositionProcess || NS_IsInCompositorThread());
// Content-process non-main-thread case:
if (!isCompositionProcess) {
dom::WorkerPrivate* workerPrivate = dom::GetCurrentThreadWorkerPrivate();
RefPtr<GetFeatureStatusWorkerRunnable> runnable =
new GetFeatureStatusWorkerRunnable(workerPrivate, gfxInfo, feature,
failureId, status);
ErrorResult rv;
runnable->Dispatch(dom::WorkerStatus::Canceling, rv);
if (rv.Failed()) {
// XXXbz This is totally broken, since we're supposed to just abort
// everything up the callstack but the callers basically eat the
// exception. Ah, well.
return rv.StealNSResult();
}
return runnable->GetNSResult();
}
nsresult rv;
SynchronousTask task("GetFeatureStatusSync");
NS_DispatchToMainThread(NS_NewRunnableFunction("GetFeatureStatusMain", [&]() {
AutoCompleteTask complete(&task);
rv = gfxInfo->GetFeatureStatus(feature, failureId, status);
}));
task.Wait();
return rv;
}
#define GFX_SHADER_CHECK_BUILD_VERSION_PREF "gfx-shader-check.build-version"
#define GFX_SHADER_CHECK_DEVICE_ID_PREF "gfx-shader-check.device-id"
#define GFX_SHADER_CHECK_DRIVER_VERSION_PREF "gfx-shader-check.driver-version"

Просмотреть файл

@ -296,10 +296,6 @@ class gfxUtils {
const nsAString& aEncoderOptions,
nsIInputStream** outStream);
static nsresult ThreadSafeGetFeatureStatus(
const nsCOMPtr<nsIGfxInfo>& gfxInfo, int32_t feature,
nsACString& failureId, int32_t* status);
static void RemoveShaderCacheFromDiskIfNecessary();
/**