Source/WebCore/ChangeLog

 12021-09-08 Kimmo Kinnunen <kkinnunen@apple.com>
 2
 3 webgl/2.0.y/conformance2/vertex_arrays/vertex-array-object.html fails
 4 https://bugs.webkit.org/show_bug.cgi?id=223360
 5 <rdar://problem/75774546>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 Deleting a buffer will remove the buffer from currently active
 10 vertex array buffer bindings. This worked.
 11 Drawing with a vertex array object that has enabled indexes
 12 but missing buffers for those indexes should fail. This
 13 WebGL specific constraint is not checked by ANGLE. Add this check to
 14 WebCore.
 15
 16 Fixed tests:
 17 webgl/1.0.x/conformance/extensions/oes-vertex-array-object.html
 18 webgl/2.0.y/conformance2/vertex_arrays/vertex-array-object.html
 19
 20 * html/canvas/WebGL2RenderingContext.cpp:
 21 (WebCore::WebGL2RenderingContext::initializeVertexArrayObjects):
 22 (WebCore::WebGL2RenderingContext::drawRangeElements):
 23 * html/canvas/WebGLRenderingContext.cpp:
 24 (WebCore::WebGLRenderingContext::initializeVertexArrayObjects):
 25 * html/canvas/WebGLRenderingContextBase.cpp:
 26 (WebCore::WebGLRenderingContextBase::disableVertexAttribArray):
 27 (WebCore::WebGLRenderingContextBase::validateVertexArrayObject):
 28 (WebCore::WebGLRenderingContextBase::drawArrays):
 29 (WebCore::WebGLRenderingContextBase::drawElements):
 30 (WebCore::WebGLRenderingContextBase::enableVertexAttribArray):
 31 (WebCore::WebGLRenderingContextBase::vertexAttribPointer):
 32 (WebCore::WebGLRenderingContextBase::initVertexAttrib0):
 33 (WebCore::WebGLRenderingContextBase::drawArraysInstanced):
 34 (WebCore::WebGLRenderingContextBase::drawElementsInstanced):
 35 * html/canvas/WebGLRenderingContextBase.h:
 36 * html/canvas/WebGLVertexArrayObjectBase.cpp:
 37 (WebCore::WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase):
 38 (WebCore::WebGLVertexArrayObjectBase::setVertexAttribEnabled):
 39 (WebCore::WebGLVertexArrayObjectBase::setVertexAttribState):
 40 (WebCore::WebGLVertexArrayObjectBase::unbindBuffer):
 41 (WebCore::WebGLVertexArrayObjectBase::updateVertexAttrib0):
 42 (WebCore::WebGLVertexArrayObjectBase::areAllEnabledAttribBuffersBound):
 43 * html/canvas/WebGLVertexArrayObjectBase.h:
 44 (WebCore::WebGLVertexArrayObjectBase::getVertexAttribState):
 45 Make VertexAttribState& a const so that we can maintain confidence
 46 that the cached value of "all enabled attrib buffers are bound"
 47 is maintained, e.g. that the callers cannot modify enabled or bound
 48 buffer status.
 49
1502021-09-08 Alan Bujtas <zalan@apple.com>
251
352 [LFC][IFC] Add support for inline box ink overflow

Source/WebCore/html/canvas/WebGL2RenderingContext.cpp

@@long long WebGL2RenderingContext::getInt64Parameter(GCGLenum pname)
223223
224224void WebGL2RenderingContext::initializeVertexArrayObjects()
225225{
 226#if !USE(ANGLE)
 227 if (!isGLES2Compliant())
 228 initVertexAttrib0();
 229#endif
226230 m_defaultVertexArrayObject = WebGLVertexArrayObject::create(*this, WebGLVertexArrayObject::Type::Default);
227231 addContextObject(*m_defaultVertexArrayObject);
228232#if USE(OPENGL_ES)

@@void WebGL2RenderingContext::initializeVertexArrayObjects()
230234#else
231235 bindVertexArray(nullptr); // The default VAO was removed in OpenGL 3.3 but not from WebGL 2; bind the default for WebGL to use.
232236#endif
233 #if !USE(ANGLE)
234  if (!isGLES2Compliant())
235  initVertexAttrib0();
236 #endif
 237
237238}
238239
239240void WebGL2RenderingContext::initializeShaderExtensions()

@@void WebGL2RenderingContext::drawRangeElements(GCGLenum mode, GCGLuint start, GC
17951796{
17961797 if (isContextLostOrPending())
17971798 return;
1798 
 1799 if (!validateVertexArrayObject("drawRangeElements"))
 1800 return;
17991801 m_context->drawRangeElements(mode, start, end, count, type, offset);
18001802}
18011803

Source/WebCore/html/canvas/WebGLRenderingContext.cpp

@@WebGLRenderingContext::WebGLRenderingContext(CanvasBase& canvas, Ref<GraphicsCon
124124
125125void WebGLRenderingContext::initializeVertexArrayObjects()
126126{
127  m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(*this, WebGLVertexArrayObjectOES::Type::Default);
128  addContextObject(*m_defaultVertexArrayObject);
129  m_boundVertexArrayObject = m_defaultVertexArrayObject;
130127#if !USE(ANGLE)
131128 if (!isGLES2Compliant())
132129 initVertexAttrib0();
133130#endif
 131 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(*this, WebGLVertexArrayObjectOES::Type::Default);
 132 addContextObject(*m_defaultVertexArrayObject);
 133 m_boundVertexArrayObject = m_defaultVertexArrayObject;
134134}
135135
136136WebGLExtension* WebGLRenderingContext::getExtension(const String& name)

Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

@@void WebGLRenderingContextBase::disableVertexAttribArray(GCGLuint index)
23382338 synthesizeGLError(GraphicsContextGL::INVALID_VALUE, "disableVertexAttribArray", "index out of range");
23392339 return;
23402340 }
2341 
2342  WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
2343  state.enabled = false;
2344 
 2341 m_boundVertexArrayObject->setVertexAttribEnabled(index, false);
23452342#if !USE(ANGLE)
23462343 if (index > 0 || isGLES2Compliant())
23472344#endif

@@bool WebGLRenderingContextBase::validateNPOTTextureLevel(GCGLsizei width, GCGLsi
23602357}
23612358#endif
23622359
 2360bool WebGLRenderingContextBase::validateVertexArrayObject(const char* functionName)
 2361{
 2362 if (!m_boundVertexArrayObject->areAllEnabledAttribBuffersBound()) {
 2363 synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, functionName, "no buffer is bound to enabled attribute");
 2364 return false;
 2365 }
 2366 return true;
 2367}
 2368
23632369bool WebGLRenderingContextBase::validateElementArraySize(GCGLsizei count, GCGLenum type, GCGLintptr offset)
23642370{
23652371 RefPtr<WebGLBuffer> elementArrayBuffer = m_boundVertexArrayObject->getElementArrayBuffer();

@@void WebGLRenderingContextBase::drawArrays(GCGLenum mode, GCGLint first, GCGLsiz
27012707 if (!validateDrawArrays("drawArrays", mode, first, count, 0))
27022708 return;
27032709#endif
 2710 if (!validateVertexArrayObject("drawArrays"))
 2711 return;
27042712
27052713 if (m_currentProgram && InspectorInstrumentation::isWebGLProgramDisabled(*this, *m_currentProgram))
27062714 return;

@@void WebGLRenderingContextBase::drawElements(GCGLenum mode, GCGLsizei count, GCG
27642772 if (!validateDrawElements("drawElements", mode, count, type, offset, numElements, 0))
27652773 return;
27662774#endif
 2775 if (!validateVertexArrayObject("drawElements"))
 2776 return;
27672777
27682778 if (m_currentProgram && InspectorInstrumentation::isWebGLProgramDisabled(*this, *m_currentProgram))
27692779 return;

@@void WebGLRenderingContextBase::enableVertexAttribArray(GCGLuint index)
28322842 synthesizeGLError(GraphicsContextGL::INVALID_VALUE, "enableVertexAttribArray", "index out of range");
28332843 return;
28342844 }
2835 
2836  WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
2837  state.enabled = true;
2838 
 2845 m_boundVertexArrayObject->setVertexAttribEnabled(index, true);
28392846 m_context->enableVertexAttribArray(index);
28402847}
28412848

@@void WebGLRenderingContextBase::vertexAttribPointer(GCGLuint index, GCGLint size
63356342 return;
63366343 }
63376344 GCGLsizei bytesPerElement = size * typeSize;
6338 
63396345 m_boundVertexArrayObject->setVertexAttribState(locker, index, bytesPerElement, size, type, normalized, stride, static_cast<GCGLintptr>(offset), false, m_boundArrayBuffer.get());
63406346 m_context->vertexAttribPointer(index, size, type, normalized, stride, static_cast<GCGLintptr>(offset));
63416347}

@@void WebGLRenderingContextBase::vertexAttribfvImpl(const char* functionName, GCG
75337539#if !USE(ANGLE)
75347540void WebGLRenderingContextBase::initVertexAttrib0()
75357541{
7536  WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
7537 
75387542 m_vertexAttrib0Buffer = createBuffer();
75397543 m_context->bindBuffer(GraphicsContextGL::ARRAY_BUFFER, m_vertexAttrib0Buffer->object());
75407544 m_context->bufferData(GraphicsContextGL::ARRAY_BUFFER, 0, GraphicsContextGL::DYNAMIC_DRAW);
75417545 m_context->vertexAttribPointer(0, 4, GraphicsContextGL::FLOAT, false, 0, 0);
7542  state.bufferBinding = m_vertexAttrib0Buffer;
75437546 m_context->bindBuffer(GraphicsContextGL::ARRAY_BUFFER, 0);
75447547 m_context->enableVertexAttribArray(0);
75457548 m_vertexAttrib0BufferSize = 0;

@@void WebGLRenderingContextBase::drawArraysInstanced(GCGLenum mode, GCGLint first
79327935 if (!validateDrawArrays("drawArraysInstanced", mode, first, count, primcount))
79337936 return;
79347937#endif // !USE(ANGLE)
 7938 if (!validateVertexArrayObject("drawArraysInstanced"))
 7939 return;
79357940
79367941 clearIfComposited(ClearCallerDrawOrClear);
79377942

@@void WebGLRenderingContextBase::drawElementsInstanced(GCGLenum mode, GCGLsizei c
79717976 if (!validateDrawElements("drawElementsInstanced", mode, count, type, offset, numElements, primcount))
79727977 return;
79737978#endif // !USE(ANGLE)
 7979 if (!validateVertexArrayObject("drawElementsInstanced"))
 7980 return;
79747981
79757982 clearIfComposited(ClearCallerDrawOrClear);
79767983

Source/WebCore/html/canvas/WebGLRenderingContextBase.h

@@protected:
512512 bool validateDrawElements(const char* functionName, GCGLenum mode, GCGLsizei count, GCGLenum type, long long offset, unsigned& numElements, GCGLsizei primcount);
513513 bool validateNPOTTextureLevel(GCGLsizei width, GCGLsizei height, GCGLint level, const char* functionName);
514514#endif
 515 bool validateVertexArrayObject(const char* functionName);
515516
516517 // Adds a compressed texture format.
517518 void addCompressedTextureFormat(GCGLenum);

Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.cpp

@@WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase(WebGLRenderingContextBase
3939 , m_type(type)
4040{
4141 m_vertexAttribState.resize(context.getMaxVertexAttribs());
 42#if !USE(ANGLE)
 43 updateVertexAttrib0();
 44#endif
4245}
4346
4447void WebGLVertexArrayObjectBase::setElementArrayBuffer(const AbstractLocker& locker, WebGLBuffer* buffer)

@@void WebGLVertexArrayObjectBase::setElementArrayBuffer(const AbstractLocker& loc
5053 m_boundElementArrayBuffer = buffer;
5154
5255}
 56void WebGLVertexArrayObjectBase::setVertexAttribEnabled(int index, bool flag)
 57{
 58 auto& state = m_vertexAttribState[index];
 59 if (state.enabled == flag)
 60 return;
 61 state.enabled = flag;
 62 if (!state.validateBinding())
 63 m_allEnabledAttribBuffersBoundCache = false;
 64 else
 65 m_allEnabledAttribBuffersBoundCache.reset();
 66}
5367
5468void WebGLVertexArrayObjectBase::setVertexAttribState(const AbstractLocker& locker, GCGLuint index, GCGLsizei bytesPerElement, GCGLint size, GCGLenum type, GCGLboolean normalized, GCGLsizei stride, GCGLintptr offset, bool isInteger, WebGLBuffer* buffer)
5569{
56  GCGLsizei validatedStride = stride ? stride : bytesPerElement;
57 
5870 auto& state = m_vertexAttribState[index];
59 
 71 bool bindingWasValid = state.validateBinding();
6072 if (buffer)
6173 buffer->onAttached();
6274 if (state.bufferBinding)
6375 state.bufferBinding->onDetached(locker, context()->graphicsContextGL());
64 
6576 state.bufferBinding = buffer;
 77 if (!state.validateBinding())
 78 m_allEnabledAttribBuffersBoundCache = false;
 79 else if (!bindingWasValid)
 80 m_allEnabledAttribBuffersBoundCache.reset();
6681 state.bytesPerElement = bytesPerElement;
6782 state.size = size;
6883 state.type = type;
6984 state.normalized = normalized;
70  state.stride = validatedStride;
 85 state.stride = stride ? stride : bytesPerElement;
7186 state.originalStride = stride;
7287 state.offset = offset;
7388 state.isInteger = isInteger;

@@void WebGLVertexArrayObjectBase::unbindBuffer(const AbstractLocker& locker, WebG
8095 m_boundElementArrayBuffer = nullptr;
8196 }
8297
83  for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
84  auto& state = m_vertexAttribState[i];
 98 for (auto& state : m_vertexAttribState) {
8599 if (state.bufferBinding == &buffer) {
86100 buffer.onDetached(locker, context()->graphicsContextGL());
87 
 101 state.bufferBinding = nullptr;
 102 if (!state.validateBinding())
 103 m_allEnabledAttribBuffersBoundCache = false;
 104 }
 105 }
88106#if !USE(ANGLE)
89  if (!i && !context()->isGLES2Compliant()) {
90  state.bufferBinding = context()->m_vertexAttrib0Buffer;
91  state.bufferBinding->onAttached();
92  state.bytesPerElement = 0;
93  state.size = 4;
94  state.type = GraphicsContextGL::FLOAT;
95  state.normalized = false;
96  state.stride = 16;
97  state.originalStride = 0;
98  state.offset = 0;
99  } else
 107 updateVertexAttrib0();
100108#endif
101  state.bufferBinding = nullptr;
102  }
 109}
 110
 111#if !USE(ANGLE)
 112void WebGLVertexArrayObjectBase::updateVertexAttrib0()
 113{
 114 auto& state = m_vertexAttribState[0];
 115 if (!state.bufferBinding && !context()->isGLES2Compliant()) {
 116 state.bufferBinding = context()->m_vertexAttrib0Buffer;
 117 state.bufferBinding->onAttached();
 118 state.bytesPerElement = 0;
 119 state.size = 4;
 120 state.type = GraphicsContextGL::FLOAT;
 121 state.normalized = false;
 122 state.stride = 16;
 123 state.originalStride = 0;
 124 state.offset = 0;
 125 m_allEnabledAttribBuffersBoundCache.reset();
103126 }
104127}
 128#endif
105129
106130void WebGLVertexArrayObjectBase::setVertexAttribDivisor(GCGLuint index, GCGLuint divisor)
107131{

@@void WebGLVertexArrayObjectBase::addMembersToOpaqueRoots(const AbstractLocker&,
115139 visitor.addOpaqueRoot(state.bufferBinding.get());
116140}
117141
 142bool WebGLVertexArrayObjectBase::areAllEnabledAttribBuffersBound()
 143{
 144 if (!m_allEnabledAttribBuffersBoundCache) {
 145 m_allEnabledAttribBuffersBoundCache = [&] {
 146 for (auto const& state : m_vertexAttribState) {
 147 if (!state.validateBinding())
 148 return false;
 149 }
 150 return true;
 151 }();
 152 }
 153 return *m_allEnabledAttribBuffersBoundCache;
 154}
 155
118156}
119157
120158#endif // ENABLE(WEBGL)

Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.h

3030#include "GraphicsContextGL.h"
3131#include "WebGLBuffer.h"
3232#include "WebGLContextObject.h"
 33#include <optional>
3334
3435namespace JSC {
3536class AbstractSlotVisitor;

@@public:
7172 WebGLBuffer* getElementArrayBuffer() const { return m_boundElementArrayBuffer.get(); }
7273 void setElementArrayBuffer(const WTF::AbstractLocker&, WebGLBuffer*);
7374
74  VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribState[index]; }
 75 void setVertexAttribEnabled(int index, bool flag);
 76 const VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribState[index]; }
7577 void setVertexAttribState(const WTF::AbstractLocker&, GCGLuint, GCGLsizei, GCGLint, GCGLenum, GCGLboolean, GCGLsizei, GCGLintptr, bool, WebGLBuffer*);
7678 void unbindBuffer(const WTF::AbstractLocker&, WebGLBuffer&);
7779

@@public:
7981
8082 void addMembersToOpaqueRoots(const WTF::AbstractLocker&, JSC::AbstractSlotVisitor&);
8183
 84 bool areAllEnabledAttribBuffersBound();
8285protected:
8386 WebGLVertexArrayObjectBase(WebGLRenderingContextBase&, Type);
8487 void deleteObjectImpl(const WTF::AbstractLocker&, GraphicsContextGL*, PlatformGLObject) override = 0;
 88#if !USE(ANGLE)
 89 void updateVertexAttrib0();
 90#endif
8591
8692 Type m_type;
8793 bool m_hasEverBeenBound { false };
8894 RefPtr<WebGLBuffer> m_boundElementArrayBuffer;
8995 Vector<VertexAttribState> m_vertexAttribState;
 96 std::optional<bool> m_allEnabledAttribBuffersBoundCache;
9097};
9198
9299} // namespace WebCore

LayoutTests/ChangeLog

 12021-09-08 Kimmo Kinnunen <kkinnunen@apple.com>
 2
 3 webgl/2.0.y/conformance2/vertex_arrays/vertex-array-object.html fails
 4 https://bugs.webkit.org/show_bug.cgi?id=223360
 5 <rdar://problem/75774546>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 Test webgl/2.0.y/conformance2/vertex_arrays/vertex-array-object.html explicitly
 10 until 2.0.y suite is run by default. Same for 1.0.x.
 11
 12 * TestExpectations:
 13 * fast/canvas/webgl/drawElements-empty-vertex-data-expected.txt:
 14 * fast/canvas/webgl/vertexAttribPointer-with-bad-offset-expected.txt:
 15 Add console logs for the added errors.
 16 * platform/ios/TestExpectations:
 17 * platform/mac/TestExpectations:
 18 For consistency, remove all skips for vertex-array-object tests.
 19 They should now work.
 20
1212021-09-08 Martin Robinson <mrobinson@webkit.org>
222
323 [css-position-sticky] Sticky constraints are calculated incorrectly when scrolling container has padding and borders

LayoutTests/TestExpectations

@@webgl/2.0.y/conformance/glsl/bugs/character-set.html [ Pass ]
36893689webgl/2.0.y/conformance/textures/misc/texture-corner-case-videos.html [ Pass ]
36903690webgl/2.0.y/conformance/glsl/misc/fragcolor-fragdata-invariant.html [ Pass ]
36913691webgl/2.0.y/conformance2/context/constants-and-properties-2.html [ Pass ]
 3692webgl/2.0.y/conformance2/vertex_arrays/vertex-array-object.html [ Pass ]
 3693webgl/1.0.x/conformance/extensions/oes-vertex-array-object.html [ Pass ]
36923694
36933695# WebGL 1.0.3 and 2.0.0 tests where behavior is obsolete and WebKit contains implementation
36943696# and tests for the new behavior. Should be removed once 1.0.3 and 2.0.0 are retired.

LayoutTests/fast/canvas/webgl/drawElements-empty-vertex-data-expected.txt

 1CONSOLE MESSAGE: WebGL: INVALID_OPERATION: drawElements: no buffer is bound to enabled attribute
12PASS: Unable to draw with invalid vertexAttribArray0

LayoutTests/fast/canvas/webgl/vertexAttribPointer-with-bad-offset-expected.txt

11CONSOLE MESSAGE: WebGL: INVALID_VALUE: vertexAttribPointer: bad offset
 2CONSOLE MESSAGE: WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
23PASS: vertexAttribPointer should have an error.
34

LayoutTests/fast/canvas/webgl/webgl-drawarrays-crash-2-expected.txt

 1CONSOLE MESSAGE: WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
12PASS. You didn't crash.
23

LayoutTests/platform/ios/TestExpectations

@@webkit.org/b/207858 webgl/webgl-border.html [ Pass Failure ImageOnlyFailure ]
32013201webkit.org/b/207858 webgl/webgl-box-shadow.html [ Pass Failure ImageOnlyFailure ]
32023202webkit.org/b/207858 fast/canvas/webgl/uninitialized-test.html [ Pass Failure ]
32033203webkit.org/b/207858 fast/canvas/webgl/oes-texture-float-linear.html [ Pass Failure ]
3204 webkit.org/b/207858 fast/canvas/webgl/oes-vertex-array-object.html [ Pass Failure ]
32053204webkit.org/b/207858 fast/canvas/webgl/tex-image-and-sub-image-2d-with-video.html [ Pass Failure ]
32063205webkit.org/b/207858 webgl/1.0.3/conformance/context/context-lost-restored.html [ Pass Failure ]
32073206webkit.org/b/207858 webgl/1.0.3/conformance/glsl/misc/shader-struct-scope.html [ Pass Failure ]

LayoutTests/platform/mac/TestExpectations

@@webgl/1.0.3/conformance/more/functions [ Skip ]
404404# Sending the mouse down event to the scrollbar starts a nested run loop which causes a hang.
405405fast/events/mousedown-in-subframe-scrollbar.html [ Skip ]
406406
407 webkit.org/b/96828 fast/canvas/webgl/oes-vertex-array-object.html [ Skip ]
408 webkit.org/b/96828 webgl/1.0.3/conformance/extensions/oes-vertex-array-object.html [ Skip ]
409 
410407http/tests/misc/willCacheResponse-delegate-callback.html [ Failure ]
411408http/tests/xmlhttprequest/basic-auth-nopassword.html [ Failure ]
412409