Skip to content
Permalink
Browse files
[WebGL] Skip vertexAttrib0 simulation when using ANGLE
https://bugs.webkit.org/show_bug.cgi?id=209416
<rdar://problem/60765734>

Reviewed by Antoine Quint.

Source/WebCore:

When using ANGLE as a backend, we do not need to simulate a
missing vertexAttrib0 at the WebGL layer, since ANGLE will
handle it for us.

This causes a couple of tests to begin passing (they were marked as
failures). It also allows us to re-land r258025, which was rolled
out in r258226.

* html/canvas/WebGL2RenderingContext.cpp: Wrap any code that does vertexAttrib0
simulation in a !USE(ANGLE).
(WebCore::WebGL2RenderingContext::initializeVertexArrayObjects):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::initializeVertexArrayObjects):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::~WebGLRenderingContextBase):
(WebCore::WebGLRenderingContextBase::disableVertexAttribArray):
(WebCore::WebGLRenderingContextBase::validateDrawArrays):
(WebCore::WebGLRenderingContextBase::validateDrawElements):
(WebCore::WebGLRenderingContextBase::drawArrays):
(WebCore::WebGLRenderingContextBase::drawElements):
(WebCore::WebGLRenderingContextBase::getActiveUniform):
(WebCore::WebGLRenderingContextBase::getVertexAttrib):
(WebCore::WebGLRenderingContextBase::vertexAttribfImpl):
(WebCore::WebGLRenderingContextBase::vertexAttribfvImpl):
* html/canvas/WebGLRenderingContextBase.h:
* html/canvas/WebGLVertexArrayObjectBase.cpp:
(WebCore::WebGLVertexArrayObjectBase::unbindBuffer):

LayoutTests:

Remove the console logging that is no longer output when using ANGLE.
Remove failing expectations for some tests.

* fast/canvas/webgl/index-validation-with-subsequent-draws-expected.txt:
* fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays-expected.txt:
* platform/mac/TestExpectations:

Canonical link: https://commits.webkit.org/222371@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258875 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
grorg committed Mar 23, 2020
1 parent 27d501c commit 41d0081c070f874ce7d6c8a9b2b3c76b3c214eb4
@@ -1,3 +1,18 @@
2020-03-23 Dean Jackson <dino@apple.com>

[WebGL] Skip vertexAttrib0 simulation when using ANGLE
https://bugs.webkit.org/show_bug.cgi?id=209416
<rdar://problem/60765734>

Reviewed by Antoine Quint.

Remove the console logging that is no longer output when using ANGLE.
Remove failing expectations for some tests.

* fast/canvas/webgl/index-validation-with-subsequent-draws-expected.txt:
* fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays-expected.txt:
* platform/mac/TestExpectations:

2020-03-23 Darin Adler <darin@apple.com>

Change TextIterator::rangeLength to not require a live range
@@ -1,3 +1 @@
CONSOLE MESSAGE: line 50: WebGL: INVALID_OPERATION: drawElements: unable to simulate vertexAttrib0 array
CONSOLE MESSAGE: line 56: WebGL: INVALID_OPERATION: drawElements: unable to simulate vertexAttrib0 array

@@ -1,2 +1 @@
CONSOLE MESSAGE: line 30: WebGL: INVALID_OPERATION: drawArrays: attempt to access outside the bounds of the simulated vertexAttrib0 array

@@ -118,6 +118,10 @@ webkit.org/b/189686 webgl/2.0.0/conformance/reading/read-pixels-test.html [ Slow
# Crashes
webkit.org/b/189686 webgl/2.0.0/conformance2/buffers/one-large-uniform-buffer.html [ Skip ]

# This test takes a long time to execute in the simulator, since it creates a huge (empty) buffer
# to draw lots of nothing.
webkit.org/b/209416 fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays.html [ Pass Timeout ]

imported/w3c/web-platform-tests/css/css-lists/content-property/marker-text-matches-georgian.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-lists/content-property/marker-text-matches-lower-greek.html [ Pass ]
imported/w3c/web-platform-tests/css/css-lists/list-and-writing-mode-001.html [ Failure ]
@@ -1978,9 +1978,6 @@ webkit.org/b/207726 imported/w3c/web-platform-tests/html/semantics/embedded-cont
webkit.org/b/207859 fast/images/slower-decoding-than-animation-image.html [ Pass Failure ]

webkit.org/b/207858 fast/canvas/webgl/program-test.html [ Failure ]
webkit.org/b/207858 fast/canvas/webgl/readPixels-float.html [ Failure ]
webkit.org/b/207858 fast/canvas/webgl/draw-elements-out-of-bounds-uint-index.html [ Failure ]
webkit.org/b/207858 fast/canvas/webgl/webgl2-texture-upload-enums.html [ Failure ]
webkit.org/b/207858 webgl/1.0.3/conformance/programs/program-test.html [ Failure ]

webkit.org/b/207971 css3/selectors3/xml/css3-modsel-d1.xml [ Pass Failure ]
@@ -1,3 +1,39 @@
2020-03-23 Dean Jackson <dino@apple.com>

[WebGL] Skip vertexAttrib0 simulation when using ANGLE
https://bugs.webkit.org/show_bug.cgi?id=209416
<rdar://problem/60765734>

Reviewed by Antoine Quint.

When using ANGLE as a backend, we do not need to simulate a
missing vertexAttrib0 at the WebGL layer, since ANGLE will
handle it for us.

This causes a couple of tests to begin passing (they were marked as
failures). It also allows us to re-land r258025, which was rolled
out in r258226.

* html/canvas/WebGL2RenderingContext.cpp: Wrap any code that does vertexAttrib0
simulation in a !USE(ANGLE).
(WebCore::WebGL2RenderingContext::initializeVertexArrayObjects):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::initializeVertexArrayObjects):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::~WebGLRenderingContextBase):
(WebCore::WebGLRenderingContextBase::disableVertexAttribArray):
(WebCore::WebGLRenderingContextBase::validateDrawArrays):
(WebCore::WebGLRenderingContextBase::validateDrawElements):
(WebCore::WebGLRenderingContextBase::drawArrays):
(WebCore::WebGLRenderingContextBase::drawElements):
(WebCore::WebGLRenderingContextBase::getActiveUniform):
(WebCore::WebGLRenderingContextBase::getVertexAttrib):
(WebCore::WebGLRenderingContextBase::vertexAttribfImpl):
(WebCore::WebGLRenderingContextBase::vertexAttribfvImpl):
* html/canvas/WebGLRenderingContextBase.h:
* html/canvas/WebGLVertexArrayObjectBase.cpp:
(WebCore::WebGLVertexArrayObjectBase::unbindBuffer):

2020-03-23 Darin Adler <darin@apple.com>

Change TextIterator::rangeLength to not require a live range
@@ -120,8 +120,10 @@ void WebGL2RenderingContext::initializeVertexArrayObjects()
#else
bindVertexArray(nullptr); // The default VAO was removed in OpenGL 3.3 but not from WebGL 2; bind the default for WebGL to use.
#endif
#if !USE(ANGLE)
if (!isGLES2Compliant())
initVertexAttrib0();
#endif
}

void WebGL2RenderingContext::initializeShaderExtensions()
@@ -107,8 +107,10 @@ void WebGLRenderingContext::initializeVertexArrayObjects()
m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(*this, WebGLVertexArrayObjectOES::Type::Default);
addContextObject(*m_defaultVertexArrayObject);
m_boundVertexArrayObject = m_defaultVertexArrayObject;
#if !USE(ANGLE)
if (!isGLES2Compliant())
initVertexAttrib0();
#endif
}

WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
@@ -858,7 +858,9 @@ WebGLRenderingContextBase::~WebGLRenderingContextBase()
m_boundArrayBuffer = nullptr;
m_defaultVertexArrayObject = nullptr;
m_boundVertexArrayObject = nullptr;
#if !USE(ANGLE)
m_vertexAttrib0Buffer = nullptr;
#endif
m_currentProgram = nullptr;
m_framebufferBinding = nullptr;
m_readFramebufferBinding = nullptr;
@@ -1962,7 +1964,9 @@ void WebGLRenderingContextBase::disableVertexAttribArray(GCGLuint index)
WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
state.enabled = false;

#if !USE(ANGLE)
if (index > 0 || isGLES2Compliant())
#endif
m_context->disableVertexAttribArray(index);
}

@@ -2176,10 +2180,12 @@ bool WebGLRenderingContextBase::validateDrawArrays(const char* functionName, GCG
synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, functionName, "attempt to access out of bounds arrays");
return false;
}
#if !USE(ANGLE)
if (!validateSimulatedVertexAttrib0(checkedSum.unsafeGet() - 1)) {
synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, functionName, "attempt to access outside the bounds of the simulated vertexAttrib0 array");
return false;
}
#endif

const char* reason = "framebuffer incomplete";
if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContextGL(), &reason)) {
@@ -2254,10 +2260,12 @@ bool WebGLRenderingContextBase::validateDrawElements(const char* functionName, G
}
}

#if !USE(ANGLE)
if (!validateSimulatedVertexAttrib0(numElements)) {
synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, functionName, "attempt to access outside the bounds of the simulated vertexAttrib0 array");
return false;
}
#endif

const char* reason = "framebuffer incomplete";
if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContextGL(), &reason)) {
@@ -2278,6 +2286,7 @@ void WebGLRenderingContextBase::drawArrays(GCGLenum mode, GCGLint first, GCGLsiz

clearIfComposited();

#if !USE(ANGLE)
bool vertexAttrib0Simulated = false;
if (!isGLES2Compliant()) {
auto simulateVertexAttrib0Status = simulateVertexAttrib0(first + count - 1);
@@ -2288,6 +2297,7 @@ void WebGLRenderingContextBase::drawArrays(GCGLenum mode, GCGLint first, GCGLsiz
}
vertexAttrib0Simulated = simulateVertexAttrib0Status.value();
}
#endif
bool usesFallbackTexture = false;
if (!isGLES2NPOTStrict())
usesFallbackTexture = checkTextureCompleteness("drawArrays", true);
@@ -2298,8 +2308,10 @@ void WebGLRenderingContextBase::drawArrays(GCGLenum mode, GCGLint first, GCGLsiz
m_context->drawArrays(mode, first, count);
}

#if !USE(ANGLE)
if (!isGLES2Compliant() && vertexAttrib0Simulated)
restoreStatesAfterVertexAttrib0Simulation();
#endif
if (usesFallbackTexture)
checkTextureCompleteness("drawArrays", false);
markContextChangedAndNotifyCanvasObserver();
@@ -2336,13 +2348,15 @@ void WebGLRenderingContextBase::drawElements(GCGLenum mode, GCGLsizei count, GCG
if (!isGLES2Compliant()) {
if (!numElements)
validateIndexArrayPrecise(count, type, static_cast<GCGLintptr>(offset), numElements);
#if !USE(ANGLE)
auto simulateVertexAttrib0Status = simulateVertexAttrib0(numElements);
if (!simulateVertexAttrib0Status) {
// We were unable to simulate the attribute buffer.
synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "drawElements", "unable to simulate vertexAttrib0 array");
return;
}
vertexAttrib0Simulated = simulateVertexAttrib0Status.value();
#endif
}

bool usesFallbackTexture = false;
@@ -2360,8 +2374,12 @@ void WebGLRenderingContextBase::drawElements(GCGLenum mode, GCGLsizei count, GCG
m_context->drawElements(mode, count, type, static_cast<GCGLintptr>(offset));
}

#if !USE(ANGLE)
if (!isGLES2Compliant() && vertexAttrib0Simulated)
restoreStatesAfterVertexAttrib0Simulation();
#else
UNUSED_VARIABLE(vertexAttrib0Simulated);
#endif
if (usesFallbackTexture)
checkTextureCompleteness("drawElements", false);
markContextChangedAndNotifyCanvasObserver();
@@ -2547,6 +2565,7 @@ RefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveUniform(WebGLProgram
GraphicsContextGL::ActiveInfo info;
if (!m_context->getActiveUniform(objectOrZero(program), index, info))
return nullptr;
// FIXME: Do we still need this for the ANGLE backend?
if (!isGLES2Compliant())
if (info.size > 1 && !info.name.endsWith("[0]"))
info.name.append("[0]");
@@ -3049,10 +3068,12 @@ WebGLAny WebGLRenderingContextBase::getVertexAttrib(GCGLuint index, GCGLenum pna

switch (pname) {
case GraphicsContextGL::VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
#if !USE(ANGLE)
if ((!isGLES2Compliant() && !index && m_boundVertexArrayObject->getVertexAttribState(0).bufferBinding == m_vertexAttrib0Buffer)
|| !state.bufferBinding
|| !state.bufferBinding->object())
return nullptr;
#endif
return state.bufferBinding;
case GraphicsContextGL::VERTEX_ATTRIB_ARRAY_ENABLED:
return state.enabled;
@@ -6109,8 +6130,11 @@ void WebGLRenderingContextBase::vertexAttribfImpl(const char* functionName, GCGL
synthesizeGLError(GraphicsContextGL::INVALID_VALUE, functionName, "index out of range");
return;
}
#if !USE(ANGLE)
// In GL, we skip setting vertexAttrib0 values.
if (index || isGLES2Compliant()) {
if (index || isGLES2Compliant())
#endif
{
switch (expectedSize) {
case 1:
m_context->vertexAttrib1f(index, v0);
@@ -6153,8 +6177,11 @@ void WebGLRenderingContextBase::vertexAttribfvImpl(const char* functionName, GCG
synthesizeGLError(GraphicsContextGL::INVALID_VALUE, functionName, "index out of range");
return;
}
#if !USE(ANGLE)
// In GL, we skip setting vertexAttrib0 values.
if (index || isGLES2Compliant()) {
if (index || isGLES2Compliant())
#endif
{
switch (expectedSize) {
case 1:
m_context->vertexAttrib1fv(index, data);
@@ -6176,6 +6203,7 @@ void WebGLRenderingContextBase::vertexAttribfvImpl(const char* functionName, GCG
attribValue.value[ii] = data[ii];
}

#if !USE(ANGLE)
void WebGLRenderingContextBase::initVertexAttrib0()
{
WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
@@ -6288,6 +6316,7 @@ void WebGLRenderingContextBase::restoreStatesAfterVertexAttrib0Simulation()
}
m_context->bindBuffer(GraphicsContextGL::ARRAY_BUFFER, objectOrZero(m_boundArrayBuffer.get()));
}
#endif

void WebGLRenderingContextBase::dispatchContextLostEvent()
{
@@ -6558,6 +6587,7 @@ void WebGLRenderingContextBase::drawArraysInstanced(GCGLenum mode, GCGLint first

clearIfComposited();

#if !USE(ANGLE)
bool vertexAttrib0Simulated = false;
if (!isGLES2Compliant()) {
auto simulateVertexAttrib0Status = simulateVertexAttrib0(first + count - 1);
@@ -6568,13 +6598,16 @@ void WebGLRenderingContextBase::drawArraysInstanced(GCGLenum mode, GCGLint first
}
vertexAttrib0Simulated = simulateVertexAttrib0Status.value();
}
#endif
if (!isGLES2NPOTStrict())
checkTextureCompleteness("drawArraysInstanced", true);

m_context->drawArraysInstanced(mode, first, count, primcount);

#if !USE(ANGLE)
if (!isGLES2Compliant() && vertexAttrib0Simulated)
restoreStatesAfterVertexAttrib0Simulation();
#endif
if (!isGLES2NPOTStrict())
checkTextureCompleteness("drawArraysInstanced", false);
markContextChangedAndNotifyCanvasObserver();
@@ -6597,13 +6630,15 @@ void WebGLRenderingContextBase::drawElementsInstanced(GCGLenum mode, GCGLsizei c
if (!isGLES2Compliant()) {
if (!numElements)
validateIndexArrayPrecise(count, type, static_cast<GCGLintptr>(offset), numElements);
#if !USE(ANGLE)
auto simulateVertexAttrib0Status = simulateVertexAttrib0(numElements);
if (!simulateVertexAttrib0Status) {
// We were unable to simulate the attribute buffer.
synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "drawArraysInstanced", "unable to simulate vertexAttrib0 array");
return;
}
vertexAttrib0Simulated = simulateVertexAttrib0Status.value();
#endif
}
if (!isGLES2NPOTStrict())
checkTextureCompleteness("drawElementsInstanced", true);
@@ -6615,8 +6650,12 @@ void WebGLRenderingContextBase::drawElementsInstanced(GCGLenum mode, GCGLsizei c

m_context->drawElementsInstanced(mode, count, type, static_cast<GCGLintptr>(offset), primcount);

#if !USE(ANGLE)
if (!isGLES2Compliant() && vertexAttrib0Simulated)
restoreStatesAfterVertexAttrib0Simulation();
#else
UNUSED_VARIABLE(vertexAttrib0Simulated);
#endif
if (!isGLES2NPOTStrict())
checkTextureCompleteness("drawElementsInstanced", false);
markContextChangedAndNotifyCanvasObserver();
@@ -512,11 +512,13 @@ class WebGLRenderingContextBase : public GraphicsContextGLOpenGL::Client, public
};
Vector<VertexAttribValue> m_vertexAttribValue;
unsigned m_maxVertexAttribs;
#if !USE(ANGLE)
RefPtr<WebGLBuffer> m_vertexAttrib0Buffer;
long m_vertexAttrib0BufferSize { 0 };
GCGLfloat m_vertexAttrib0BufferValue[4];
bool m_forceAttrib0BufferRefill { true };
bool m_vertexAttrib0UsedBefore { false };
#endif

RefPtr<WebGLProgram> m_currentProgram;
RefPtr<WebGLFramebuffer> m_framebufferBinding;
@@ -820,11 +822,13 @@ class WebGLRenderingContextBase : public GraphicsContextGLOpenGL::Client, public

bool validateAndCacheBufferBinding(const char* functionName, GCGLenum target, WebGLBuffer*);

#if !USE(ANGLE)
// Helpers for simulating vertexAttrib0.
void initVertexAttrib0();
Optional<bool> simulateVertexAttrib0(GCGLuint numVertex);
bool validateSimulatedVertexAttrib0(GCGLuint numVertex);
void restoreStatesAfterVertexAttrib0Simulation();
#endif

// Wrapper for GraphicsContextGLOpenGL::synthesizeGLError that sends a message to the JavaScript console.
enum ConsoleDisplayPreference { DisplayInConsole, DontDisplayInConsole };
@@ -82,6 +82,7 @@ void WebGLVertexArrayObjectBase::unbindBuffer(WebGLBuffer& buffer)
if (state.bufferBinding == &buffer) {
buffer.onDetached(context()->graphicsContextGL());

#if !USE(ANGLE)
if (!i && !context()->isGLES2Compliant()) {
state.bufferBinding = context()->m_vertexAttrib0Buffer;
state.bufferBinding->onAttached();
@@ -93,6 +94,7 @@ void WebGLVertexArrayObjectBase::unbindBuffer(WebGLBuffer& buffer)
state.originalStride = 0;
state.offset = 0;
} else
#endif
state.bufferBinding = nullptr;
}
}

0 comments on commit 41d0081

Please sign in to comment.