[webkit-changes] [WebKit/WebKit] 99889a: Support long-lived images of WebGL backbuffers
Kimmo Kinnunen
noreply at github.com
Fri Jan 17 05:35:01 PST 2025
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 99889a50c5762026c26d6665c88dc28d7c5ee991
https://github.com/WebKit/WebKit/commit/99889a50c5762026c26d6665c88dc28d7c5ee991
Author: Kimmo Kinnunen <kkinnunen at apple.com>
Date: 2025-01-17 (Fri, 17 Jan 2025)
Changed paths:
M Source/WebCore/PlatformMac.cmake
M Source/WebCore/SaferCPPExpectations/UncountedLambdaCapturesCheckerExpectations
M Source/WebCore/SourcesCocoa.txt
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp
M Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h
M Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h
M Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm
A Source/WebCore/platform/graphics/cocoa/IOSurfaceDrawingBuffer.cpp
A Source/WebCore/platform/graphics/cocoa/IOSurfaceDrawingBuffer.h
M Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp
A Tools/TestWebKitAPI/GraphicsTestUtilities.cpp
A Tools/TestWebKitAPI/GraphicsTestUtilities.h
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
M Tools/TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp
M Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm
M Tools/TestWebKitAPI/WebCoreTestUtilities.h
Log Message:
-----------
Support long-lived images of WebGL backbuffers
https://bugs.webkit.org/show_bug.cgi?id=285834
rdar://142803884
Reviewed by Dan Glastonbury.
Add the ability to hold on to WebGL drawing and display buffer images
long term.
Construct the buffers out of held CGIOSurfaceContexts. When the IOSurface
is being modified, notify the CGIOSurfaceContext. This will migrate
the possible CGImage reference to malloc-backed memory.
Write to the backbuffer is detected by notifying about the write for
any GraphicsContextGL function that might modify the default
framebuffer.
This will be used to solve the deadlock case where the WebGL image is
drawn to a ImageBuffer (for example for 2D context interop)
synchronously across threads. The long term image can be snapshot and
held without needing to guarantee the end-of-use. Thus the image
creation can be done in RemoteGraphicsContextGL timeline and the image
use will be posted in RemoteRenderingBackend timeline. This part of
the work will be made in the subsequent commits.
* Source/WebCore/PlatformMac.cmake:
* Source/WebCore/SourcesCocoa.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::resolveMultisamplingIfNecessary):
(WebCore::GraphicsContextGLANGLE::prepareTexture):
(WebCore::GraphicsContextGLANGLE::clear):
(WebCore::GraphicsContextGLANGLE::drawArrays):
(WebCore::GraphicsContextGLANGLE::drawElements):
(WebCore::GraphicsContextGLANGLE::drawArraysInstanced):
(WebCore::GraphicsContextGLANGLE::drawElementsInstanced):
(WebCore::GraphicsContextGLANGLE::invalidateFramebuffer):
(WebCore::GraphicsContextGLANGLE::invalidateSubFramebuffer):
(WebCore::GraphicsContextGLANGLE::drawRangeElements):
(WebCore::GraphicsContextGLANGLE::drawBuffers):
(WebCore::GraphicsContextGLANGLE::clearBufferiv):
(WebCore::GraphicsContextGLANGLE::clearBufferuiv):
(WebCore::GraphicsContextGLANGLE::clearBufferfv):
(WebCore::GraphicsContextGLANGLE::multiDrawArraysInstancedANGLE):
(WebCore::GraphicsContextGLANGLE::multiDrawElementsANGLE):
(WebCore::GraphicsContextGLANGLE::multiDrawElementsInstancedANGLE):
(WebCore::GraphicsContextGLANGLE::drawArraysInstancedBaseInstanceANGLE):
(WebCore::GraphicsContextGLANGLE::drawElementsInstancedBaseVertexBaseInstanceANGLE):
(WebCore::GraphicsContextGLANGLE::multiDrawArraysInstancedBaseInstanceANGLE):
(WebCore::GraphicsContextGLANGLE::multiDrawElementsInstancedBaseVertexBaseInstanceANGLE):
(WebCore::GraphicsContextGLANGLE::drawSurfaceBufferToImageBuffer):
(WebCore::GraphicsContextGLANGLE::bufferAsNativeImage):
(WebCore::GraphicsContextGLANGLE::prepareForDrawingBufferWriteIfBound):
(WebCore::GraphicsContextGLANGLE::prepareForDrawingBufferWrite):
(WebCore::GraphicsContextGLANGLE::withBufferAsNativeImage): Deleted.
* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h:
* Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h:
(WebCore::IOSurfacePbuffer::pbuffer const):
(WebCore::IOSurfacePbuffer::IOSurfacePbuffer):
(WebCore::IOSurfacePbuffer::operator=):
* Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
(WebCore::GraphicsContextGLCocoa::displayBufferSurface):
(WebCore::GraphicsContextGLCocoa::drawingBuffer):
(WebCore::GraphicsContextGLCocoa::displayBuffer):
(WebCore::GraphicsContextGLCocoa::surfaceBuffer):
(WebCore::GraphicsContextGLCocoa::bindNextDrawingBuffer):
(WebCore::GraphicsContextGLCocoa::freeDrawingBuffers):
(WebCore::GraphicsContextGLCocoa::readCompositedResults):
(WebCore::GraphicsContextGLCocoa::surfaceBufferToVideoFrame):
(WebCore::GraphicsContextGLCocoa::bufferAsNativeImage):
(WebCore::GraphicsContextGLCocoa::prepareForDrawingBufferWrite):
(WebCore::GraphicsContextGLCocoa::withBufferAsNativeImage): Deleted.
* Source/WebCore/platform/graphics/cocoa/IOSurfaceDrawingBuffer.cpp: Added.
(WebCore::IOSurfaceDrawingBuffer::copyNativeImage const):
(WebCore::IOSurfaceDrawingBuffer::forceCopy):
* Source/WebCore/platform/graphics/cocoa/IOSurfaceDrawingBuffer.h: Added.
(WebCore::IOSurfaceDrawingBuffer::operator bool const):
(WebCore::IOSurfaceDrawingBuffer::surface const):
(WebCore::IOSurfaceDrawingBuffer::IOSurfaceDrawingBuffer):
(WebCore::IOSurfaceDrawingBuffer::operator=):
(WebCore::IOSurfaceDrawingBuffer::prepareForWrite):
(WebCore::IOSurfaceDrawingBuffer::isInUse const):
(WebCore::IOSurfaceDrawingBuffer::size const):
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::drawSurfaceBufferToImageBuffer):
* Tools/TestWebKitAPI/GraphicsTestUtilities.cpp: Added.
(TestWebKitAPI::imageBufferPixelIs):
(TestWebKitAPI::imagePixelIs):
* Tools/TestWebKitAPI/GraphicsTestUtilities.h: Copied from Tools/TestWebKitAPI/WebCoreTestUtilities.h.
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp:
(TestWebKitAPI::hasTestPattern):
(TestWebKitAPI::TEST(ImageBufferTests, ImageBufferSubPixelDrawing)):
(TestWebKitAPI::TEST(ImageBufferTests, DISABLED_DrawImageBufferDoesNotReferenceExtraMemory)):
(TestWebKitAPI::imageBufferPixelIs): Deleted.
* Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm:
(TestWebKitAPI::WebCore::TestedGraphicsContextGLCocoa::create):
(TestWebKitAPI::WebCore::TestedGraphicsContextGLCocoa::TestedGraphicsContextGLCocoa):
(TestWebKitAPI::WebCore::AnyContextAttributeTest::attributes):
(TestWebKitAPI::WebCore::AnyContextAttributeTest::createTestContext):
(TestWebKitAPI::changeContextContents):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest, MultipleGPUsDifferentPowerPreferenceMetal)):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest, MultipleGPUsExplicitLowPowerDeviceMetal)):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest, MultipleGPUsExplicitHighPerformanceDeviceMetal)):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest, MultipleGPUsDifferentGPUIDsMetal)):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest, ClearBufferIncorrectSizes)):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest, DestroyWithoutMakingCurrent)):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest, TwoLinks)):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest, BufferAsImageNoDrawingBufferReturnsNullptr)):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest, BufferAsImageAfterReshape)):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest, CopyImageAndMutateDrawingBuffer)):
(TestWebKitAPI::TEST_P):
* Tools/TestWebKitAPI/WebCoreTestUtilities.h:
(WebCore::operator<<):
Canonical link: https://commits.webkit.org/289054@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list