зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 8dd927ca1cd1 (bug 1268638)
--HG-- extra : rebase_source : 8909933919f95877e7d61269955770c4532209db
This commit is contained in:
Родитель
253be4a67d
Коммит
db11a4525e
|
@ -435,15 +435,12 @@ WebGLContext::GetHeight() const
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
IsFeatureInBlacklist(const nsCOMPtr<nsIGfxInfo>& gfxInfo, int32_t feature,
|
IsFeatureInBlacklist(const nsCOMPtr<nsIGfxInfo>& gfxInfo, int32_t feature, nsACString* const out_failureId)
|
||||||
nsCString* const out_blacklistId)
|
|
||||||
{
|
{
|
||||||
int32_t status;
|
int32_t status;
|
||||||
if (!NS_SUCCEEDED(gfxUtils::ThreadSafeGetFeatureStatus(gfxInfo, feature,
|
if (!NS_SUCCEEDED(gfxUtils::ThreadSafeGetFeatureStatus(gfxInfo, feature,
|
||||||
*out_blacklistId, &status)))
|
*out_failureId, &status)))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
return status != nsIGfxInfo::FEATURE_STATUS_OK;
|
return status != nsIGfxInfo::FEATURE_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
@ -566,15 +563,15 @@ BaseCaps(const WebGLContextOptions& options, WebGLContext* webgl)
|
||||||
|
|
||||||
// Done with baseCaps construction.
|
// Done with baseCaps construction.
|
||||||
|
|
||||||
if (!gfxPrefs::WebGLForceMSAA()) {
|
bool forceAllowAA = gfxPrefs::WebGLForceMSAA();
|
||||||
const nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
||||||
|
nsCString discardFailureId;
|
||||||
nsCString blocklistId;
|
if (!forceAllowAA &&
|
||||||
if (IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_MSAA, &blocklistId)) {
|
IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_MSAA, &discardFailureId))
|
||||||
webgl->GenerateWarning("Disallowing antialiased backbuffers due"
|
{
|
||||||
" to blacklisting.");
|
webgl->GenerateWarning("Disallowing antialiased backbuffers due"
|
||||||
baseCaps.antialias = false;
|
" to blacklisting.");
|
||||||
}
|
baseCaps.antialias = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseCaps;
|
return baseCaps;
|
||||||
|
@ -584,7 +581,8 @@ BaseCaps(const WebGLContextOptions& options, WebGLContext* webgl)
|
||||||
|
|
||||||
static already_AddRefed<gl::GLContext>
|
static already_AddRefed<gl::GLContext>
|
||||||
CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||||
WebGLContext* webgl, std::vector<FailureReason>* const out_failReasons)
|
WebGLContext* webgl, nsACString* const out_failReason,
|
||||||
|
nsACString* const out_failureId)
|
||||||
{
|
{
|
||||||
const gfx::IntSize dummySize(16, 16);
|
const gfx::IntSize dummySize(16, 16);
|
||||||
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
|
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
|
||||||
|
@ -594,8 +592,13 @@ CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gl) {
|
if (!gl) {
|
||||||
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_EGL_INIT",
|
if (out_failReason->Length()) {
|
||||||
"Error during EGL OpenGL init." });
|
out_failReason->AppendLiteral("\n");
|
||||||
|
}
|
||||||
|
out_failReason->AppendLiteral("Error during EGL OpenGL init.");
|
||||||
|
if (out_failureId->IsEmpty()) {
|
||||||
|
*out_failureId = "FEATURE_FAILURE_WEBGL_EGL_INIT";
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,7 +607,8 @@ CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||||
|
|
||||||
static already_AddRefed<GLContext>
|
static already_AddRefed<GLContext>
|
||||||
CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||||
WebGLContext* webgl, std::vector<FailureReason>* const out_failReasons)
|
WebGLContext* webgl, nsACString* const out_failReason,
|
||||||
|
nsACString* const out_failureId)
|
||||||
{
|
{
|
||||||
const gfx::IntSize dummySize(16, 16);
|
const gfx::IntSize dummySize(16, 16);
|
||||||
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
|
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
|
||||||
|
@ -614,8 +618,13 @@ CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gl) {
|
if (!gl) {
|
||||||
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_ANGLE_INIT",
|
if (out_failReason->Length()) {
|
||||||
"Error during ANGLE OpenGL init." });
|
out_failReason->AppendLiteral("\n");
|
||||||
|
}
|
||||||
|
out_failReason->AppendLiteral("Error during ANGLE OpenGL init.");
|
||||||
|
if (out_failureId->IsEmpty()) {
|
||||||
|
*out_failureId = "FEATURE_FAILURE_WEBGL_ANGLE_INIT";
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,9 +633,22 @@ CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||||
|
|
||||||
static already_AddRefed<gl::GLContext>
|
static already_AddRefed<gl::GLContext>
|
||||||
CreateGLWithDefault(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
CreateGLWithDefault(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||||
WebGLContext* webgl,
|
WebGLContext* webgl, nsACString* const out_failReason,
|
||||||
std::vector<FailureReason>* const out_failReasons)
|
nsACString* const out_failureId)
|
||||||
{
|
{
|
||||||
|
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
||||||
|
|
||||||
|
if (!(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE) &&
|
||||||
|
IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_OPENGL, out_failureId))
|
||||||
|
{
|
||||||
|
if (out_failReason->Length()) {
|
||||||
|
out_failReason->AppendASCII("\n");
|
||||||
|
}
|
||||||
|
out_failReason->AppendASCII("Refused to create native OpenGL context because of"
|
||||||
|
" blacklisting.");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
const gfx::IntSize dummySize(16, 16);
|
const gfx::IntSize dummySize(16, 16);
|
||||||
RefPtr<GLContext> gl = gl::GLContextProvider::CreateOffscreen(dummySize, caps,
|
RefPtr<GLContext> gl = gl::GLContextProvider::CreateOffscreen(dummySize, caps,
|
||||||
flags, out_failureId);
|
flags, out_failureId);
|
||||||
|
@ -636,8 +658,13 @@ CreateGLWithDefault(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gl) {
|
if (!gl) {
|
||||||
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_DEFAULT_INIT",
|
if (out_failReason->Length()) {
|
||||||
"Error during native OpenGL init." });
|
out_failReason->AppendASCII("\n");
|
||||||
|
}
|
||||||
|
out_failReason->AppendASCII("Error during native OpenGL init.");
|
||||||
|
if (out_failureId->IsEmpty()) {
|
||||||
|
*out_failureId = "FEATURE_FAILURE_WEBGL_DEFAULT_INIT";
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,7 +677,8 @@ bool
|
||||||
WebGLContext::CreateAndInitGLWith(FnCreateGL_T fnCreateGL,
|
WebGLContext::CreateAndInitGLWith(FnCreateGL_T fnCreateGL,
|
||||||
const gl::SurfaceCaps& baseCaps,
|
const gl::SurfaceCaps& baseCaps,
|
||||||
gl::CreateContextFlags flags,
|
gl::CreateContextFlags flags,
|
||||||
std::vector<FailureReason>* const out_failReasons)
|
nsACString* const out_failReason,
|
||||||
|
nsACString* const out_failureId)
|
||||||
{
|
{
|
||||||
std::queue<gl::SurfaceCaps> fallbackCaps;
|
std::queue<gl::SurfaceCaps> fallbackCaps;
|
||||||
PopulateCapFallbackQueue(baseCaps, &fallbackCaps);
|
PopulateCapFallbackQueue(baseCaps, &fallbackCaps);
|
||||||
|
@ -658,8 +686,9 @@ WebGLContext::CreateAndInitGLWith(FnCreateGL_T fnCreateGL,
|
||||||
MOZ_RELEASE_ASSERT(!gl, "GFX: Already have a context.");
|
MOZ_RELEASE_ASSERT(!gl, "GFX: Already have a context.");
|
||||||
gl = nullptr;
|
gl = nullptr;
|
||||||
while (!fallbackCaps.empty()) {
|
while (!fallbackCaps.empty()) {
|
||||||
const gl::SurfaceCaps& caps = fallbackCaps.front();
|
gl::SurfaceCaps& caps = fallbackCaps.front();
|
||||||
gl = fnCreateGL(caps, flags, this, out_failReasons);
|
|
||||||
|
gl = fnCreateGL(caps, flags, this, out_failReason, out_failureId);
|
||||||
if (gl)
|
if (gl)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -668,11 +697,9 @@ WebGLContext::CreateAndInitGLWith(FnCreateGL_T fnCreateGL,
|
||||||
if (!gl)
|
if (!gl)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FailureReason reason;
|
if (!InitAndValidateGL(out_failReason, out_failureId)) {
|
||||||
if (!InitAndValidateGL(&reason.info, &reason.key)) {
|
|
||||||
// The fail reason here should be specific enough for now.
|
// The fail reason here should be specific enough for now.
|
||||||
gl = nullptr;
|
gl = nullptr;
|
||||||
out_failReasons->push_back(reason);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,30 +707,16 @@ WebGLContext::CreateAndInitGLWith(FnCreateGL_T fnCreateGL,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WebGLContext::CreateAndInitGL(bool forceEnabled,
|
WebGLContext::CreateAndInitGL(bool forceEnabled, nsACString* const out_failReason, nsACString* const out_failureId)
|
||||||
std::vector<FailureReason>* const out_failReasons)
|
|
||||||
{
|
{
|
||||||
bool blacklistOpenGL = false;
|
const bool useEGL = PR_GetEnv("MOZ_WEBGL_PREFER_EGL");
|
||||||
if (!forceEnabled) {
|
|
||||||
const nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
|
||||||
|
|
||||||
FailureReason reason;
|
bool useANGLE = false;
|
||||||
if (IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_OPENGL,
|
#ifdef XP_WIN
|
||||||
&reason.key))
|
const bool disableANGLE = (gfxPrefs::WebGLDisableANGLE() ||
|
||||||
{
|
PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL"));
|
||||||
blacklistOpenGL = true;
|
useANGLE = !disableANGLE;
|
||||||
|
#endif
|
||||||
reason.info = "Refused to create native OpenGL context because of blacklist"
|
|
||||||
" entry: ";
|
|
||||||
reason.info.Append(blacklistId);
|
|
||||||
|
|
||||||
out_failReasons->push_back(reason);
|
|
||||||
|
|
||||||
GenerateWarning(text.BeginReading());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//////
|
|
||||||
|
|
||||||
gl::CreateContextFlags flags = gl::CreateContextFlags::NO_VALIDATION;
|
gl::CreateContextFlags flags = gl::CreateContextFlags::NO_VALIDATION;
|
||||||
|
|
||||||
|
@ -713,34 +726,13 @@ WebGLContext::CreateAndInitGL(bool forceEnabled,
|
||||||
|
|
||||||
const gl::SurfaceCaps baseCaps = BaseCaps(mOptions, this);
|
const gl::SurfaceCaps baseCaps = BaseCaps(mOptions, this);
|
||||||
|
|
||||||
//////
|
if (useEGL)
|
||||||
|
return CreateAndInitGLWith(CreateGLWithEGL, baseCaps, flags, out_failReason, out_failureId);
|
||||||
if (!blacklistOpenGL) {
|
|
||||||
const bool useEGL = PR_GetEnv("MOZ_WEBGL_FORCE_EGL");
|
|
||||||
|
|
||||||
if (useEGL)
|
|
||||||
return CreateAndInitGLWith(CreateGLWithEGL, baseCaps, flags, out_failReasons);
|
|
||||||
|
|
||||||
if (CreateAndInitGLWith(CreateGLWithNative, baseCaps, flags, out_failReasons))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////
|
|
||||||
|
|
||||||
bool useANGLE = false;
|
|
||||||
#ifdef XP_WIN
|
|
||||||
const bool disableANGLE = (gfxPrefs::WebGLDisableANGLE() ||
|
|
||||||
PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL"));
|
|
||||||
useANGLE = !disableANGLE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (useANGLE)
|
if (useANGLE)
|
||||||
return CreateAndInitGLWith(CreateGLWithANGLE, baseCaps, flags, out_failReasons);
|
return CreateAndInitGLWith(CreateGLWithANGLE, baseCaps, flags, out_failReason, out_failureId);
|
||||||
|
|
||||||
//////
|
return CreateAndInitGLWith(CreateGLWithDefault, baseCaps, flags, out_failReason, out_failureId);
|
||||||
|
|
||||||
out_failReasons->push_back(nsLiteralCString("Exhausted GL driver options."));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback for resizes:
|
// Fallback for resizes:
|
||||||
|
@ -938,15 +930,12 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
|
||||||
ScopedGfxFeatureReporter reporter("WebGL", forceEnabled);
|
ScopedGfxFeatureReporter reporter("WebGL", forceEnabled);
|
||||||
|
|
||||||
MOZ_ASSERT(!gl);
|
MOZ_ASSERT(!gl);
|
||||||
std::vector<FailureReason> failReasons;
|
nsCString failReason;
|
||||||
if (!CreateAndInitGL(forceEnabled, &failReasons)) {
|
nsCString failureId;
|
||||||
nsCString text("WebGL creation failed: ");
|
if (!CreateAndInitGL(forceEnabled, &failReason, &failureId)) {
|
||||||
for (const auto& cur : failReasons) {
|
Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_FAILURE_ID, failureId);
|
||||||
Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_FAILURE_ID, cur.key);
|
const nsPrintfCString text("WebGL creation failed: %s",
|
||||||
|
failReason.BeginReading());
|
||||||
text.AppendASCII("\n* ");
|
|
||||||
text.Append(cur.info);
|
|
||||||
}
|
|
||||||
ThrowEvent_WebGLContextCreationError(text);
|
ThrowEvent_WebGLContextCreationError(text);
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1204,24 +1204,19 @@ public:
|
||||||
protected:
|
protected:
|
||||||
bool InitWebGL2(nsACString* const out_failReason, nsACString* const out_failureId);
|
bool InitWebGL2(nsACString* const out_failReason, nsACString* const out_failureId);
|
||||||
|
|
||||||
struct FailureReason {
|
bool CreateAndInitGL(bool forceEnabled, nsACString* const out_failReason, nsACString* const out_failureId);
|
||||||
nsCString key; // For reporting.
|
|
||||||
nsCString info;
|
|
||||||
};
|
|
||||||
bool CreateAndInitGL(bool forceEnabled,
|
|
||||||
std::vector<FailureReason>* const out_failReasons);
|
|
||||||
|
|
||||||
bool ResizeBackbuffer(uint32_t width, uint32_t height);
|
bool ResizeBackbuffer(uint32_t width, uint32_t height);
|
||||||
|
|
||||||
typedef already_AddRefed<gl::GLContext> FnCreateGL_T(const gl::SurfaceCaps& caps,
|
typedef already_AddRefed<gl::GLContext> FnCreateGL_T(const gl::SurfaceCaps& caps,
|
||||||
gl::CreateContextFlags flags,
|
gl::CreateContextFlags flags,
|
||||||
WebGLContext* webgl,
|
WebGLContext* webgl,
|
||||||
std::vector<FailureReason>* const out_failReasons);
|
nsACString* const out_failReason,
|
||||||
|
nsACString* const out_failureId);
|
||||||
|
|
||||||
bool CreateAndInitGLWith(FnCreateGL_T fnCreateGL, const gl::SurfaceCaps& baseCaps,
|
bool CreateAndInitGLWith(FnCreateGL_T fnCreateGL, const gl::SurfaceCaps& baseCaps,
|
||||||
gl::CreateContextFlags flags,
|
gl::CreateContextFlags flags,
|
||||||
std::vector<FailureReason>* const out_failReasons);
|
nsACString* const out_failReason,
|
||||||
|
nsACString* const out_failureId);
|
||||||
void ThrowEvent_WebGLContextCreationError(const nsACString& text);
|
void ThrowEvent_WebGLContextCreationError(const nsACString& text);
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
Загрузка…
Ссылка в новой задаче