From 4e69784010d271c0fce0927442e4f8e66ffe645b Mon Sep 17 00:00:00 2001 From: Alexandru Marc Date: Thu, 14 Nov 2024 09:12:50 +0200 Subject: [PATCH] Backed out 2 changesets (bug 1924184) for causing reftest failures @ color_quads.html. CLOSED TREE Backed out changeset cbe1b21f1d03 (bug 1924184) Backed out changeset ecd6e8cb110c (bug 1924184) --- dom/canvas/WebGLContextDraw.cpp | 3 --- dom/canvas/WebGLContextVertices.cpp | 8 +++++-- gfx/gl/GLContext.h | 4 ---- gfx/gl/ScopedGLHelpers.cpp | 35 +++++++++++++++++++---------- gfx/gl/ScopedGLHelpers.h | 20 ++++++++--------- 5 files changed, 39 insertions(+), 31 deletions(-) diff --git a/dom/canvas/WebGLContextDraw.cpp b/dom/canvas/WebGLContextDraw.cpp index 9efa6d594124..b61b5aeee2fa 100644 --- a/dom/canvas/WebGLContextDraw.cpp +++ b/dom/canvas/WebGLContextDraw.cpp @@ -1190,9 +1190,6 @@ bool WebGLContext::DoFakeVertexAttrib0( } gl->fEnableVertexAttribArray(0); - if (gl->HasVertexAttribDivisor()) { - gl->fVertexAttribDivisor(0, 0); - } if (!mFakeVertexAttrib0BufferObject) { gl->fGenBuffers(1, &mFakeVertexAttrib0BufferObject); diff --git a/dom/canvas/WebGLContextVertices.cpp b/dom/canvas/WebGLContextVertices.cpp index 2d27dcfcb4e1..cd2fbc51b2db 100644 --- a/dom/canvas/WebGLContextVertices.cpp +++ b/dom/canvas/WebGLContextVertices.cpp @@ -90,9 +90,10 @@ void WebGLContext::EnableVertexAttribArray(GLuint index) { if (!ValidateAttribIndex(*this, index)) return; + gl->fEnableVertexAttribArray(index); + MOZ_ASSERT(mBoundVertexArray); mBoundVertexArray->SetAttribIsArray(index, true); - mBoundVertexArray->DoVertexAttrib(index); } void WebGLContext::DisableVertexAttribArray(GLuint index) { @@ -101,9 +102,12 @@ void WebGLContext::DisableVertexAttribArray(GLuint index) { if (!ValidateAttribIndex(*this, index)) return; + if (index || !gl->IsCompatibilityProfile()) { + gl->fDisableVertexAttribArray(index); + } + MOZ_ASSERT(mBoundVertexArray); mBoundVertexArray->SetAttribIsArray(index, false); - mBoundVertexArray->DoVertexAttrib(index); } Maybe WebGLContext::GetVertexAttrib(GLuint index, GLenum pname) { diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index 8162b114c88d..45c75e8b6ecf 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -297,10 +297,6 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr { bool HasPBOState() const { return (!IsGLES() || Version() >= 300); } - bool HasVertexAttribDivisor() const { - return !!mSymbols.fVertexAttribDivisor; - } - /** * If this context is double-buffered, returns TRUE. */ diff --git a/gfx/gl/ScopedGLHelpers.cpp b/gfx/gl/ScopedGLHelpers.cpp index 0bc1683bc72d..d654cae16393 100644 --- a/gfx/gl/ScopedGLHelpers.cpp +++ b/gfx/gl/ScopedGLHelpers.cpp @@ -271,13 +271,35 @@ ScopedVertexAttribPointer::ScopedVertexAttribPointer( GLContext* aGL, GLuint index, GLint size, GLenum type, realGLboolean normalized, GLsizei stride, GLuint buffer, const GLvoid* pointer) - : mGL(aGL) { + : mGL(aGL), + mAttribEnabled(0), + mAttribSize(0), + mAttribStride(0), + mAttribType(0), + mAttribNormalized(0), + mAttribBufferBinding(0), + mAttribPointer(nullptr), + mBoundBuffer(0) { WrapImpl(index); mGL->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, buffer); mGL->fVertexAttribPointer(index, size, type, normalized, stride, pointer); mGL->fEnableVertexAttribArray(index); } +ScopedVertexAttribPointer::ScopedVertexAttribPointer(GLContext* aGL, + GLuint index) + : mGL(aGL), + mAttribEnabled(0), + mAttribSize(0), + mAttribStride(0), + mAttribType(0), + mAttribNormalized(0), + mAttribBufferBinding(0), + mAttribPointer(nullptr), + mBoundBuffer(0) { + WrapImpl(index); +} + void ScopedVertexAttribPointer::WrapImpl(GLuint index) { mAttribIndex = index; @@ -296,17 +318,9 @@ void ScopedVertexAttribPointer::WrapImpl(GLuint index) { * or alternatively in the internal vertex array state * for a buffer object. */ - // TODO: This should really be using VAOs when available. mGL->fGetVertexAttribiv(mAttribIndex, LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED, &mAttribEnabled); - - if (mGL->HasVertexAttribDivisor()) { - mGL->fGetVertexAttribiv(mAttribIndex, LOCAL_GL_VERTEX_ATTRIB_ARRAY_DIVISOR, - reinterpret_cast(&mAttribDivisor)); - mGL->fVertexAttribDivisor(mAttribIndex, 0); - } - mGL->fGetVertexAttribiv(mAttribIndex, LOCAL_GL_VERTEX_ATTRIB_ARRAY_SIZE, &mAttribSize); mGL->fGetVertexAttribiv(mAttribIndex, LOCAL_GL_VERTEX_ATTRIB_ARRAY_STRIDE, @@ -331,9 +345,6 @@ ScopedVertexAttribPointer::~ScopedVertexAttribPointer() { mGL->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mAttribBufferBinding); mGL->fVertexAttribPointer(mAttribIndex, mAttribSize, mAttribType, mAttribNormalized, mAttribStride, mAttribPointer); - if (mGL->HasVertexAttribDivisor()) { - mGL->fVertexAttribDivisor(mAttribIndex, mAttribDivisor); - } if (mAttribEnabled) mGL->fEnableVertexAttribArray(mAttribIndex); else diff --git a/gfx/gl/ScopedGLHelpers.h b/gfx/gl/ScopedGLHelpers.h index b52a9495cf24..6e3b9867bc48 100644 --- a/gfx/gl/ScopedGLHelpers.h +++ b/gfx/gl/ScopedGLHelpers.h @@ -186,22 +186,22 @@ struct ScopedScissorRect final { struct ScopedVertexAttribPointer final { private: GLContext* const mGL; - GLuint mAttribIndex = 0; - GLint mAttribEnabled = 0; - GLuint mAttribDivisor = 0; - GLint mAttribSize = 0; - GLint mAttribStride = 0; - GLint mAttribType = 0; - GLint mAttribNormalized = 0; - GLint mAttribBufferBinding = 0; - void* mAttribPointer = nullptr; - GLuint mBoundBuffer = 0; + GLuint mAttribIndex; + GLint mAttribEnabled; + GLint mAttribSize; + GLint mAttribStride; + GLint mAttribType; + GLint mAttribNormalized; + GLint mAttribBufferBinding; + void* mAttribPointer; + GLuint mBoundBuffer; public: ScopedVertexAttribPointer(GLContext* aGL, GLuint index, GLint size, GLenum type, realGLboolean normalized, GLsizei stride, GLuint buffer, const GLvoid* pointer); + explicit ScopedVertexAttribPointer(GLContext* aGL, GLuint index); ~ScopedVertexAttribPointer(); private: