Skip to content

ANGLE: Metal: TransformFeedbackTest.RenderOnceChangeXfbBufferRenderAgain fails validation#63322

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
kkinnunen-apple:angle-transformfeedback-resize-1
Apr 23, 2026
Merged

ANGLE: Metal: TransformFeedbackTest.RenderOnceChangeXfbBufferRenderAgain fails validation#63322
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
kkinnunen-apple:angle-transformfeedback-resize-1

Conversation

@kkinnunen-apple
Copy link
Copy Markdown
Contributor

@kkinnunen-apple kkinnunen-apple commented Apr 22, 2026

7e67d72

ANGLE: Metal: TransformFeedbackTest.RenderOnceChangeXfbBufferRenderAgain fails validation
https://bugs.webkit.org/show_bug.cgi?id=312988
rdar://175334405

Reviewed by Dan Glastonbury.

TransformFeedbackTest.RenderOnceChangeXfbBufferRenderAgain would draw
the second draw with too small transform feedback buffer.
This should generate INVALID_OPERATION, but didn't.

Implement the feature by invalidating the vertex capacity of the
transform feedback buffer when the buffer is updated. Recalculate
the capacity upon the draw call validation check.

WebGL does not use this feature, as updating the buffer is disallowed
by WebGL specification. However, the validation failure would make
running the ANGLEEnd2EndTests inconventient on Metal, as the tests
stop when the process crashes.

Enable TransformFeedback_unittest in WebKit build.

* Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj:
* Source/ThirdParty/ANGLE/src/libANGLE/Buffer.cpp:
(gl::Buffer::onStateChange):
(gl::Buffer::onContentsChange):
* Source/ThirdParty/ANGLE/src/libANGLE/Context.cpp:
(gl::Context::invalidateTransformFeedbackCapacities const):
* Source/ThirdParty/ANGLE/src/libANGLE/Context.h:
* Source/ThirdParty/ANGLE/src/libANGLE/TransformFeedback.cpp:
(gl::TransformFeedbackState::TransformFeedbackState):
(gl::TransformFeedback::begin):
(gl::TransformFeedback::end):
(gl::TransformFeedback::resume):
(gl::TransformFeedback::checkBufferSpaceForDraw):
(gl::TransformFeedback::checkBufferSpaceForDraw const): Deleted.
(gl::TransformFeedback::recomputeVertexCapacity): Deleted.
* Source/ThirdParty/ANGLE/src/libANGLE/TransformFeedback.h:
* Source/ThirdParty/ANGLE/src/libANGLE/validationES.cpp:
(gl::ValidateDrawArraysTransformFeedbackBufferSize):
* Source/ThirdParty/ANGLE/src/tests/gl_tests/TransformFeedbackTest.cpp:
* Source/ThirdParty/ANGLE/src/tests/gl_tests/VertexAttributeTest.cpp:

Canonical link: https://commits.webkit.org/311839@main

91ac6e8

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe loading 🛠 win ⏳ 🛠 ios-apple
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 loading 🧪 win-tests ⏳ 🛠 mac-apple
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 🧪 api-mac ✅ 🧪 api-wpe ⏳ 🛠 vision-apple
🧪 ios-wk2-wpt 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🧪 vision-wk2 🧪 mac-intel-wk2
✅ 🛠 tv
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@kkinnunen-apple kkinnunen-apple self-assigned this Apr 22, 2026
@kkinnunen-apple kkinnunen-apple added the ANGLE Bugs related to the ANGLE project label Apr 22, 2026
@kkinnunen-apple kkinnunen-apple force-pushed the angle-transformfeedback-resize-1 branch from ef7b4a3 to 78eafe7 Compare April 22, 2026 13:04
Copy link
Copy Markdown
Contributor

@djg djg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@@ -107,6 +108,7 @@ class TransformFeedback final : public RefCountObject<TransformFeedbackID>, publ
// Returns true if the buffer is bound to any of the indexed binding points in this transform
// feedback.
bool isBufferBound(BufferID bufferID) const;
void invalidateVertexCapacity() { mState.mVertexCapacity = 0; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: mVertexCapacity = 0 is doing double duty as both "needs recompute" and "legitimately zero capacity" (e.g. null program executable). When capacity is genuinely zero, checkBufferSpaceForDraw will re-enter recomputeVertexCapacity on every draw. Not a correctness issue since the result is the same, but a dedicated bool mVertexCapacityDirty or a negative sentinel like -1 would make the intent unambiguous and avoid the redundant recompute.

Copy link
Copy Markdown
Contributor Author

@kkinnunen-apple kkinnunen-apple Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're of course right. The idea was that recomputation doesn't matter, as drawing with 0 capacity is never sensical.
I don't want to use -1, as there have been enough issues with such a value being mistakenly used.
I wrapped it in std::optional.

I also moved the code from the free method to the compute function, as the method wasn't used anywhere else and the calling function was not doing any other significant work.

I also enabled the unit tests and removed a workaround from the code that addressed a unitest thing that is not an issue anymore.

I'll land with these changes and let you review post-landing. I can adjust if there's something incorrect.

@kkinnunen-apple kkinnunen-apple force-pushed the angle-transformfeedback-resize-1 branch from 78eafe7 to 7dfa05d Compare April 23, 2026 07:19
@kkinnunen-apple kkinnunen-apple force-pushed the angle-transformfeedback-resize-1 branch from 7dfa05d to 9f169d3 Compare April 23, 2026 07:26
@kkinnunen-apple kkinnunen-apple force-pushed the angle-transformfeedback-resize-1 branch from 9f169d3 to 10dd337 Compare April 23, 2026 07:29
@kkinnunen-apple kkinnunen-apple force-pushed the angle-transformfeedback-resize-1 branch from 10dd337 to 91ac6e8 Compare April 23, 2026 08:37
@kkinnunen-apple kkinnunen-apple added the merge-queue Applied to send a pull request to merge-queue label Apr 23, 2026
…ain fails validation

https://bugs.webkit.org/show_bug.cgi?id=312988
rdar://175334405

Reviewed by Dan Glastonbury.

TransformFeedbackTest.RenderOnceChangeXfbBufferRenderAgain would draw
the second draw with too small transform feedback buffer.
This should generate INVALID_OPERATION, but didn't.

Implement the feature by invalidating the vertex capacity of the
transform feedback buffer when the buffer is updated. Recalculate
the capacity upon the draw call validation check.

WebGL does not use this feature, as updating the buffer is disallowed
by WebGL specification. However, the validation failure would make
running the ANGLEEnd2EndTests inconventient on Metal, as the tests
stop when the process crashes.

Enable TransformFeedback_unittest in WebKit build.

* Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj:
* Source/ThirdParty/ANGLE/src/libANGLE/Buffer.cpp:
(gl::Buffer::onStateChange):
(gl::Buffer::onContentsChange):
* Source/ThirdParty/ANGLE/src/libANGLE/Context.cpp:
(gl::Context::invalidateTransformFeedbackCapacities const):
* Source/ThirdParty/ANGLE/src/libANGLE/Context.h:
* Source/ThirdParty/ANGLE/src/libANGLE/TransformFeedback.cpp:
(gl::TransformFeedbackState::TransformFeedbackState):
(gl::TransformFeedback::begin):
(gl::TransformFeedback::end):
(gl::TransformFeedback::resume):
(gl::TransformFeedback::checkBufferSpaceForDraw):
(gl::TransformFeedback::checkBufferSpaceForDraw const): Deleted.
(gl::TransformFeedback::recomputeVertexCapacity): Deleted.
* Source/ThirdParty/ANGLE/src/libANGLE/TransformFeedback.h:
* Source/ThirdParty/ANGLE/src/libANGLE/validationES.cpp:
(gl::ValidateDrawArraysTransformFeedbackBufferSize):
* Source/ThirdParty/ANGLE/src/tests/gl_tests/TransformFeedbackTest.cpp:
* Source/ThirdParty/ANGLE/src/tests/gl_tests/VertexAttributeTest.cpp:

Canonical link: https://commits.webkit.org/311839@main
@webkit-commit-queue webkit-commit-queue force-pushed the angle-transformfeedback-resize-1 branch from 91ac6e8 to 7e67d72 Compare April 23, 2026 09:59
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 311839@main (7e67d72): https://commits.webkit.org/311839@main

Reviewed commits have been landed. Closing PR #63322 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 7e67d72 into WebKit:main Apr 23, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ANGLE Bugs related to the ANGLE project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants