зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1268638 - Use FailureReason struct. - r=jrmuizel
MozReview-Commit-ID: 4jxtXlToNZS
This commit is contained in:
Родитель
cd59689cf5
Коммит
1ceea00332
|
@ -97,7 +97,7 @@ static const gl::GLFeature kRequiredFeatures[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WebGLContext::InitWebGL2(nsACString* const out_failReason, nsACString* const out_failureId)
|
WebGLContext::InitWebGL2(FailureReason* const out_failReason)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(IsWebGL2(), "WebGLContext is not a WebGL 2 context!");
|
MOZ_ASSERT(IsWebGL2(), "WebGLContext is not a WebGL 2 context!");
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ WebGLContext::InitWebGL2(nsACString* const out_failReason, nsACString* const out
|
||||||
{
|
{
|
||||||
// On desktop, we fake occlusion_query_boolean with occlusion_query if
|
// On desktop, we fake occlusion_query_boolean with occlusion_query if
|
||||||
// necessary. (See WebGL2ContextQueries.cpp)
|
// necessary. (See WebGL2ContextQueries.cpp)
|
||||||
*out_failureId = "FEATURE_FAILURE_WEBGL2_OCCL";
|
*out_failReason = FailureReason("FEATURE_FAILURE_WEBGL2_OCCL",
|
||||||
out_failReason->AssignASCII("WebGL 2 requires occlusion query support.");
|
"WebGL 2 requires occlusion query support.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,11 +136,10 @@ WebGLContext::InitWebGL2(nsACString* const out_failReason, nsACString* const out
|
||||||
exts.Append(gl::GLContext::GetFeatureName(*itr));
|
exts.Append(gl::GLContext::GetFeatureName(*itr));
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_failureId = "FEATURE_FAILURE_WEBGL2_FEATURE";
|
|
||||||
const nsPrintfCString reason("WebGL 2 requires support for the following"
|
const nsPrintfCString reason("WebGL 2 requires support for the following"
|
||||||
" features: %s",
|
" features: %s",
|
||||||
exts.BeginReading());
|
exts.BeginReading());
|
||||||
out_failReason->Assign(reason);
|
*out_failReason = FailureReason("FEATURE_FAILURE_WEBGL2_OCCL", reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -587,7 +587,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,
|
||||||
|
std::vector<WebGLContext::FailureReason>* const out_failReasons)
|
||||||
{
|
{
|
||||||
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,
|
||||||
|
@ -597,8 +598,10 @@ CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gl) {
|
if (!gl) {
|
||||||
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_EGL_INIT",
|
out_failReasons->push_back(WebGLContext::FailureReason(
|
||||||
"Error during EGL OpenGL init." });
|
"FEATURE_FAILURE_WEBGL_EGL_INIT",
|
||||||
|
"Error during EGL OpenGL init."
|
||||||
|
));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,7 +610,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,
|
||||||
|
std::vector<WebGLContext::FailureReason>* const out_failReasons)
|
||||||
{
|
{
|
||||||
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,
|
||||||
|
@ -617,8 +621,10 @@ CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gl) {
|
if (!gl) {
|
||||||
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_ANGLE_INIT",
|
out_failReasons->push_back(WebGLContext::FailureReason(
|
||||||
"Error during ANGLE OpenGL init." });
|
"FEATURE_FAILURE_WEBGL_ANGLE_INIT",
|
||||||
|
"Error during ANGLE OpenGL init."
|
||||||
|
));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,7 +634,7 @@ 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,
|
||||||
std::vector<FailureReason>* const out_failReasons)
|
std::vector<WebGLContext::FailureReason>* const out_failReasons)
|
||||||
{
|
{
|
||||||
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,
|
||||||
|
@ -639,8 +645,10 @@ CreateGLWithDefault(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gl) {
|
if (!gl) {
|
||||||
out_failReasons->push_back({ "FEATURE_FAILURE_WEBGL_DEFAULT_INIT",
|
out_failReasons->push_back(WebGLContext::FailureReason(
|
||||||
"Error during native OpenGL init." });
|
"FEATURE_FAILURE_WEBGL_DEFAULT_INIT",
|
||||||
|
"Error during native OpenGL init."
|
||||||
|
));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,7 +680,7 @@ WebGLContext::CreateAndInitGLWith(FnCreateGL_T fnCreateGL,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FailureReason reason;
|
FailureReason reason;
|
||||||
if (!InitAndValidateGL(&reason.info, &reason.key)) {
|
if (!InitAndValidateGL(&reason)) {
|
||||||
// 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);
|
out_failReasons->push_back(reason);
|
||||||
|
@ -698,11 +706,11 @@ WebGLContext::CreateAndInitGL(bool forceEnabled,
|
||||||
|
|
||||||
reason.info = "Refused to create native OpenGL context because of blacklist"
|
reason.info = "Refused to create native OpenGL context because of blacklist"
|
||||||
" entry: ";
|
" entry: ";
|
||||||
reason.info.Append(blacklistId);
|
reason.info.Append(reason.key);
|
||||||
|
|
||||||
out_failReasons->push_back(reason);
|
out_failReasons->push_back(reason);
|
||||||
|
|
||||||
GenerateWarning(text.BeginReading());
|
GenerateWarning(reason.info.BeginReading());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,7 +758,8 @@ WebGLContext::CreateAndInitGL(bool forceEnabled,
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
|
||||||
out_failReasons->push_back(nsLiteralCString("Exhausted GL driver options."));
|
out_failReasons->push_back(FailureReason("FEATURE_FAILURE_WEBGL_EXHAUSTED_DRIVERS",
|
||||||
|
"Exhausted GL driver options."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1198,13 +1198,21 @@ protected:
|
||||||
public:
|
public:
|
||||||
virtual bool IsWebGL2() const = 0;
|
virtual bool IsWebGL2() const = 0;
|
||||||
|
|
||||||
protected:
|
|
||||||
bool InitWebGL2(nsACString* const out_failReason, nsACString* const out_failureId);
|
|
||||||
|
|
||||||
struct FailureReason {
|
struct FailureReason {
|
||||||
nsCString key; // For reporting.
|
nsCString key; // For reporting.
|
||||||
nsCString info;
|
nsCString info;
|
||||||
|
|
||||||
|
FailureReason() { }
|
||||||
|
|
||||||
|
template<typename A, typename B>
|
||||||
|
FailureReason(const A& _key, const B& _info)
|
||||||
|
: key(nsCString(_key))
|
||||||
|
, info(nsCString(_info))
|
||||||
|
{ }
|
||||||
};
|
};
|
||||||
|
protected:
|
||||||
|
bool InitWebGL2(FailureReason* const out_failReason);
|
||||||
|
|
||||||
bool CreateAndInitGL(bool forceEnabled,
|
bool CreateAndInitGL(bool forceEnabled,
|
||||||
std::vector<FailureReason>* const out_failReasons);
|
std::vector<FailureReason>* const out_failReasons);
|
||||||
|
|
||||||
|
@ -1223,7 +1231,8 @@ protected:
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Validation functions (implemented in WebGLContextValidate.cpp)
|
// Validation functions (implemented in WebGLContextValidate.cpp)
|
||||||
bool InitAndValidateGL(nsACString* const out_failReason, nsACString* const out_failureId);
|
bool InitAndValidateGL(FailureReason* const out_failReason);
|
||||||
|
|
||||||
bool ValidateBlendEquationEnum(GLenum cap, const char* info);
|
bool ValidateBlendEquationEnum(GLenum cap, const char* info);
|
||||||
bool ValidateBlendFuncDstEnum(GLenum mode, const char* info);
|
bool ValidateBlendFuncDstEnum(GLenum mode, const char* info);
|
||||||
bool ValidateBlendFuncSrcEnum(GLenum mode, const char* info);
|
bool ValidateBlendFuncSrcEnum(GLenum mode, const char* info);
|
||||||
|
|
|
@ -648,7 +648,7 @@ FloorPOT(int32_t x)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* const out_failureId)
|
WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
|
||||||
{
|
{
|
||||||
MOZ_RELEASE_ASSERT(gl, "GFX: GL not initialized");
|
MOZ_RELEASE_ASSERT(gl, "GFX: GL not initialized");
|
||||||
|
|
||||||
|
@ -657,18 +657,17 @@ WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* co
|
||||||
// formats back into the authority.
|
// formats back into the authority.
|
||||||
mFormatUsage = CreateFormatUsage(gl);
|
mFormatUsage = CreateFormatUsage(gl);
|
||||||
if (!mFormatUsage) {
|
if (!mFormatUsage) {
|
||||||
*out_failureId = "FEATURE_FAILURE_WEBGL_FORMAT";
|
*out_failReason = { "FEATURE_FAILURE_WEBGL_FORMAT",
|
||||||
out_failReason->AssignLiteral("Failed to create mFormatUsage.");
|
"Failed to create mFormatUsage." };
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum error = gl->fGetError();
|
GLenum error = gl->fGetError();
|
||||||
if (error != LOCAL_GL_NO_ERROR) {
|
if (error != LOCAL_GL_NO_ERROR) {
|
||||||
*out_failureId = "FEATURE_FAILURE_WEBGL_GLERR_1";
|
|
||||||
const nsPrintfCString reason("GL error 0x%x occurred during OpenGL context"
|
const nsPrintfCString reason("GL error 0x%x occurred during OpenGL context"
|
||||||
" initialization, before WebGL initialization!",
|
" initialization, before WebGL initialization!",
|
||||||
error);
|
error);
|
||||||
out_failReason->Assign(reason);
|
*out_failReason = { "FEATURE_FAILURE_WEBGL_GLERR_1", reason };
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,10 +756,9 @@ WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* co
|
||||||
gl->fGetIntegerv(LOCAL_GL_MAX_VERTEX_ATTRIBS, &mGLMaxVertexAttribs);
|
gl->fGetIntegerv(LOCAL_GL_MAX_VERTEX_ATTRIBS, &mGLMaxVertexAttribs);
|
||||||
|
|
||||||
if (mGLMaxVertexAttribs < 8) {
|
if (mGLMaxVertexAttribs < 8) {
|
||||||
*out_failureId = "FEATURE_FAILURE_WEBGL_V_ATRB";
|
|
||||||
const nsPrintfCString reason("GL_MAX_VERTEX_ATTRIBS: %d is < 8!",
|
const nsPrintfCString reason("GL_MAX_VERTEX_ATTRIBS: %d is < 8!",
|
||||||
mGLMaxVertexAttribs);
|
mGLMaxVertexAttribs);
|
||||||
out_failReason->Assign(reason);
|
*out_failReason = { "FEATURE_FAILURE_WEBGL_V_ATRB", reason };
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -773,10 +771,9 @@ WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* co
|
||||||
gl->fGetIntegerv(LOCAL_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &mGLMaxTextureUnits);
|
gl->fGetIntegerv(LOCAL_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &mGLMaxTextureUnits);
|
||||||
|
|
||||||
if (mGLMaxTextureUnits < 8) {
|
if (mGLMaxTextureUnits < 8) {
|
||||||
*out_failureId = "FEATURE_FAILURE_WEBGL_T_UNIT";
|
|
||||||
const nsPrintfCString reason("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: %d is < 8!",
|
const nsPrintfCString reason("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: %d is < 8!",
|
||||||
mGLMaxTextureUnits);
|
mGLMaxTextureUnits);
|
||||||
out_failReason->Assign(reason);
|
*out_failReason = { "FEATURE_FAILURE_WEBGL_T_UNIT", reason };
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -932,8 +929,8 @@ WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* co
|
||||||
|
|
||||||
// initialize shader translator
|
// initialize shader translator
|
||||||
if (!ShInitialize()) {
|
if (!ShInitialize()) {
|
||||||
*out_failureId = "FEATURE_FAILURE_WEBGL_GLSL";
|
*out_failReason = { "FEATURE_FAILURE_WEBGL_GLSL",
|
||||||
out_failReason->AssignLiteral("GLSL translator initialization failed!");
|
"GLSL translator initialization failed!" };
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,16 +944,15 @@ WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* co
|
||||||
// getError call will give the correct result.
|
// getError call will give the correct result.
|
||||||
error = gl->fGetError();
|
error = gl->fGetError();
|
||||||
if (error != LOCAL_GL_NO_ERROR) {
|
if (error != LOCAL_GL_NO_ERROR) {
|
||||||
*out_failureId = "FEATURE_FAILURE_WEBGL_GLERR_2";
|
|
||||||
const nsPrintfCString reason("GL error 0x%x occurred during WebGL context"
|
const nsPrintfCString reason("GL error 0x%x occurred during WebGL context"
|
||||||
" initialization!",
|
" initialization!",
|
||||||
error);
|
error);
|
||||||
out_failReason->Assign(reason);
|
*out_failReason = { "FEATURE_FAILURE_WEBGL_GLERR_2", reason };
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsWebGL2() &&
|
if (IsWebGL2() &&
|
||||||
!InitWebGL2(out_failReason, out_failureId))
|
!InitWebGL2(out_failReason))
|
||||||
{
|
{
|
||||||
// Todo: Bug 898404: Only allow WebGL2 on GL>=3.0 on desktop GL.
|
// Todo: Bug 898404: Only allow WebGL2 on GL>=3.0 on desktop GL.
|
||||||
return false;
|
return false;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче