Bug 1326367 - Fix FakeVertex0 and enable emulation for OSX+NV+Core profiles. - r=ethlin
MozReview-Commit-ID: IafpirHZroB
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -992,35 +992,36 @@ WebGLContext::ValidateBufferFetching(con
WebGLVertexAttrib0Status
WebGLContext::WhatDoesVertexAttrib0Need() const
{
MOZ_ASSERT(mCurrentProgram);
MOZ_ASSERT(mActiveProgramLinkInfo);
const auto& isAttribArray0Enabled = mBoundVertexArray->mAttribs[0].mEnabled;
- // work around Mac OSX crash, see bug 631420
+ bool legacyAttrib0 = gl->IsCompatibilityProfile();
#ifdef XP_MACOSX
- if (gl->WorkAroundDriverBugs() &&
- isAttribArray0Enabled &&
- !mBufferFetch_IsAttrib0Active)
- {
- return WebGLVertexAttrib0Status::EmulatedUninitializedArray;
+ if (gl->WorkAroundDriverBugs()) {
+ // Failures in conformance/attribs/gl-disabled-vertex-attrib.
+ // Even in Core profiles on NV. Sigh.
+ legacyAttrib0 |= (gl->Vendor() == gl::GLVendor::NVIDIA);
}
#endif
- if (MOZ_LIKELY(!gl->IsCompatibilityProfile() ||
- isAttribArray0Enabled))
- {
+ if (!legacyAttrib0)
+ return WebGLVertexAttrib0Status::Default;
+
+ if (isAttribArray0Enabled && mBufferFetch_IsAttrib0Active)
return WebGLVertexAttrib0Status::Default;
- }
- return mBufferFetch_IsAttrib0Active
- ? WebGLVertexAttrib0Status::EmulatedInitializedArray
- : WebGLVertexAttrib0Status::EmulatedUninitializedArray;
+ if (mBufferFetch_IsAttrib0Active)
+ return WebGLVertexAttrib0Status::EmulatedInitializedArray;
+
+ // Ensure that the legacy code has enough buffer.
+ return WebGLVertexAttrib0Status::EmulatedUninitializedArray;
}
bool
WebGLContext::DoFakeVertexAttrib0(const char* funcName, GLuint vertexCount)
{
if (!vertexCount) {
vertexCount = 1;
}
@@ -1033,16 +1034,18 @@ WebGLContext::DoFakeVertexAttrib0(const
GenerateWarning("Drawing without vertex attrib 0 array enabled forces the browser "
"to do expensive emulation work when running on desktop OpenGL "
"platforms, for example on Mac. It is preferable to always draw "
"with vertex attrib 0 array enabled, by using bindAttribLocation "
"to bind some always-used attribute to location 0.");
mAlreadyWarnedAboutFakeVertexAttrib0 = true;
}
+ gl->fEnableVertexAttribArray(0);
+
if (!mFakeVertexAttrib0BufferObject) {
gl->fGenBuffers(1, &mFakeVertexAttrib0BufferObject);
mFakeVertexAttrib0BufferObjectSize = 0;
}
gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mFakeVertexAttrib0BufferObject);
////
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -531,20 +531,16 @@ WebGLContext::InitAndValidateGL(FailureR
mCurrentProgram = nullptr;
mBoundDrawFramebuffer = nullptr;
mBoundReadFramebuffer = nullptr;
mBoundRenderbuffer = nullptr;
MakeContextCurrent();
- // For OpenGL compat. profiles, we always keep vertex attrib 0 array enabled.
- if (gl->IsCompatibilityProfile())
- gl->fEnableVertexAttribArray(0);
-
if (MinCapabilityMode())
mGLMaxVertexAttribs = MINVALUE_GL_MAX_VERTEX_ATTRIBS;
else
gl->GetUIntegerv(LOCAL_GL_MAX_VERTEX_ATTRIBS, &mGLMaxVertexAttribs);
if (mGLMaxVertexAttribs < 8) {
const nsPrintfCString reason("GL_MAX_VERTEX_ATTRIBS: %d is < 8!",
mGLMaxVertexAttribs);