Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 39e7258f6a9bf84fd5a45dfe06aec476ec2e3106
https://github.com/WebKit/WebKit/commit/39e7258f6a9bf84fd5a45dfe06aec476ec2e3106
Author: Kimmo Kinnunen <[email protected]>
Date: 2026-09-30 (Wed, 30 Sep 2026)
Changed paths:
A LayoutTests/webgl/context-restore-default-framebuffer-expected.txt
A LayoutTests/webgl/context-restore-default-framebuffer.html
A
LayoutTests/webgl/default-framebuffer-resize-clears-despite-state-expected.txt
A LayoutTests/webgl/default-framebuffer-resize-clears-despite-state.html
A
LayoutTests/webgl/lose-context-on-default-framebuffer-allocation-failure-expected.txt
A
LayoutTests/webgl/lose-context-on-default-framebuffer-allocation-failure.html
A LayoutTests/webgl/webgl2-default-framebuffer-read-buffer-none-expected.txt
A LayoutTests/webgl/webgl2-default-framebuffer-read-buffer-none.html
M Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp
M Source/WebCore/Modules/webxr/WebXRWebGLSwapchain.cpp
M Source/WebCore/html/canvas/WebGL2RenderingContext.cpp
M Source/WebCore/html/canvas/WebGL2RenderingContext.h
M Source/WebCore/html/canvas/WebGLDefaultFramebuffer.cpp
M Source/WebCore/html/canvas/WebGLDefaultFramebuffer.h
M Source/WebCore/html/canvas/WebGLDrawBuffers.cpp
M Source/WebCore/html/canvas/WebGLFramebuffer.cpp
M Source/WebCore/html/canvas/WebGLFramebuffer.h
M Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
M Source/WebCore/html/canvas/WebGLRenderingContextBase.h
M Source/WebCore/html/canvas/WebGLUtilities.cpp
M Source/WebCore/html/canvas/WebGLUtilities.h
M Source/WebCore/platform/graphics/GCGLExtension.h
M Source/WebCore/platform/graphics/GraphicsContextGLAttributes.h
M Source/WebCore/platform/graphics/GraphicsContextGLEnums.h
M Source/WebCore/platform/graphics/angle/ANGLEUtilities.cpp
M Source/WebCore/platform/graphics/angle/ANGLEUtilities.h
M Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp
M Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h
M Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm
M Source/WebCore/platform/graphics/egl/GraphicsContextGLEGL.cpp
M Source/WebCore/platform/graphics/egl/GraphicsContextGLEGL.h
M Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.cpp
M Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.h
M Source/WebCore/testing/Internals.cpp
M Source/WebCore/testing/Internals.h
M Source/WebCore/testing/Internals.idl
M Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp
M Source/WebKit/Shared/WebGL.serialization.in
M Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm
M Tools/TestWebKitAPI/Tests/WebCore/glib/GraphicsContextGLEGL.cpp
Log Message:
-----------
WebGL: Move MSAA and preserveDrawingBuffer handling to WebGLRenderingContext
level
https://bugs.webkit.org/show_bug.cgi?id=317913
rdar://180707384
Reviewed by Dan Glastonbury.
Before, the GraphicsContextGL simulated FBO 0 would handle MSAA,
preserveDrawingBuffer and the compositing result buffer. When a command
like readPixels would be called, the GraphicsContextGL would resolve
MSAA to the compositing result buffer and read the compositing result
FBO.
Implement this logic in WebGLDefaultFramebuffer instead. This simplifies
the GPUP side implementations of read operations.
Change preserveDrawingBuffer backing store to be a render buffer instead
of a texture, so that initializing it does not need to worry about
pixel unpack buffers.
GraphicsContextGL now implicitly handles only the compositing buffer,
currently hardcoded as WCP FBO 0.
This is work towards reducing the amount of implicit state tracking in
GraphicsContextGL, as well as simplifying the numerous places for state
tracing.
Track the default framebuffer READ_BUFFER in the WebGL context, since it
is per framebuffer object state and the default framebuffer is now a real
framebuffer object. Reads of the default framebuffer are validated in
validateDefaultFramebufferRead() and fail with INVALID_OPERATION when the
read buffer is NONE, instead of relying on the driver to fail the
redirected read. Internal reads, such as the ones backing toDataURL() and
captureStream(), are not application visible and so are unaffected by the
application read buffer: resolveColorIntoResult() scopes it, and
readRenderingResults() reads through a scratch framebuffer.
Destroy the default framebuffer explicitly in destroyDefaultFramebuffer(),
called before the GraphicsContextGL is replaced or released. The GL object
names are meaningful only in the instance that created them, so the
destructor cannot delete them: on context restore the new default
framebuffer is created before the old one is destroyed.
Use enableExtension() rather than supportsExtension() when selecting the
depth/stencil renderbuffer format. supportsExtension() is also true for
extensions that are requestable but not enabled, in which case the format
enum would not be accepted.
A WebGL 2 context now reports getContextAttributes().stencil as false when
packed depth/stencil is unavailable, instead of reporting the requested
value.
* LayoutTests/webgl/context-restore-default-framebuffer-expected.txt: Added.
* LayoutTests/webgl/context-restore-default-framebuffer.html: Added.
* LayoutTests/webgl/webgl2-default-framebuffer-read-buffer-none-expected.txt:
Added.
* LayoutTests/webgl/webgl2-default-framebuffer-read-buffer-none.html: Added.
* Source/WebCore/Modules/webxr/WebXRWebGLSwapchain.cpp:
(WebCore::WebXRWebGLTextureArraySwapchain::blitToSharedImage):
(WebCore::WebXRWebGLCubeSwapchain::blitToSharedImage):
* Source/WebCore/html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::readBuffer):
(WebCore::WebGL2RenderingContext::copyTexSubImage3D):
(WebCore::WebGL2RenderingContext::isDefaultFramebufferBoundForRead const):
(WebCore::WebGL2RenderingContext::rebindFramebuffers):
(WebCore::WebGL2RenderingContext::getParameter):
(WebCore::WebGL2RenderingContext::readPixels):
* Source/WebCore/html/canvas/WebGL2RenderingContext.h:
* Source/WebCore/html/canvas/WebGLDefaultFramebuffer.cpp:
(WebCore::WebGLDefaultFramebuffer::create):
(WebCore::WebGLDefaultFramebuffer::WebGLDefaultFramebuffer):
(WebCore::WebGLDefaultFramebuffer::destroy):
(WebCore::WebGLDefaultFramebuffer::~WebGLDefaultFramebuffer):
(WebCore::WebGLDefaultFramebuffer::resolveColorIntoResult):
(WebCore::WebGLDefaultFramebuffer::prepareForReadWhenBound):
(WebCore::WebGLDefaultFramebuffer::reshape):
(WebCore::WebGLDefaultFramebuffer::markAllBuffersDirty):
(WebCore::WebGLDefaultFramebuffer::size const): Deleted.
* Source/WebCore/html/canvas/WebGLDefaultFramebuffer.h:
(WebCore::WebGLDefaultFramebuffer::object const):
(WebCore::WebGLDefaultFramebuffer::hasStencil const):
(WebCore::WebGLDefaultFramebuffer::hasDepth const):
(WebCore::WebGLDefaultFramebuffer::size const):
* Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::resolveGraphicsContextGLAttributes):
(WebCore::WebGLRenderingContextBase::initializeNewContext):
(WebCore::WebGLRenderingContextBase::initializeContextState):
(WebCore::WebGLRenderingContextBase::initializeDefaultObjects):
(WebCore::WebGLRenderingContextBase::destroyDefaultFramebuffer):
(WebCore::WebGLRenderingContextBase::destroyGraphicsContextGL):
(WebCore::WebGLRenderingContextBase::surfaceBufferToNativeImage):
(WebCore::WebGLRenderingContextBase::drawingBufferToPixelBuffer):
(WebCore::WebGLRenderingContextBase::surfaceBufferToVideoFrame):
(WebCore::WebGLRenderingContextBase::didUpdateCanvasSizeProperties):
(WebCore::WebGLRenderingContextBase::copyTexSubImage2D):
(WebCore::WebGLRenderingContextBase::deleteFramebuffer):
(WebCore::WebGLRenderingContextBase::disable):
(WebCore::WebGLRenderingContextBase::enable):
(WebCore::WebGLRenderingContextBase::readPixels):
(WebCore::WebGLRenderingContextBase::copyTexImage2D):
(WebCore::WebGLRenderingContextBase::prepareDefaultFramebufferForReadIfBound):
(WebCore::WebGLRenderingContextBase::validateDefaultFramebufferRead):
(WebCore::WebGLRenderingContextBase::rebindFramebuffers):
(WebCore::WebGLRenderingContextBase::setBackReadBuffer):
(WebCore::WebGLRenderingContextBase::prepareForDisplay):
* Source/WebCore/html/canvas/WebGLRenderingContextBase.h:
(WebCore::WebGLRenderingContextBase::isDefaultFramebufferBoundForRead const):
* Source/WebCore/html/canvas/WebGLUtilities.cpp:
* Source/WebCore/html/canvas/WebGLUtilities.h:
(WebCore::ScopedEnableBackbufferRead::ScopedEnableBackbufferRead):
(WebCore::ScopedEnableBackbufferRead::~ScopedEnableBackbufferRead):
(WebCore::ScopedDisableDither::ScopedDisableDither):
(WebCore::ScopedDisableDither::~ScopedDisableDither):
(WebCore::ScopedWebGLRestoreFramebuffer::ScopedWebGLRestoreFramebuffer):
(WebCore::ScopedWebGLRestoreFramebuffer::~ScopedWebGLRestoreFramebuffer):
(WebCore::ScopedClearColorAndMask::ScopedClearColorAndMask):
(WebCore::ScopedClearColorAndMask::~ScopedClearColorAndMask):
(WebCore::ScopedClearDepthAndMask::ScopedClearDepthAndMask):
(WebCore::ScopedClearDepthAndMask::~ScopedClearDepthAndMask):
(WebCore::ScopedClearStencilAndMask::ScopedClearStencilAndMask):
(WebCore::ScopedClearStencilAndMask::~ScopedClearStencilAndMask):
* Source/WebCore/platform/graphics/GCGLExtension.h:
* Source/WebCore/platform/graphics/GraphicsContextGLAttributes.h:
* Source/WebCore/platform/graphics/angle/ANGLEUtilities.cpp:
(WebCore::ScopedScratchReadFramebufferBinding::ScopedScratchReadFramebufferBinding):
* Source/WebCore/platform/graphics/angle/ANGLEUtilities.h:
* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::initialize):
(WebCore::GraphicsContextGLANGLE::readPixelsBufferObject):
(WebCore::GraphicsContextGLANGLE::readPixelsImpl):
(WebCore::GraphicsContextGLANGLE::prepareTexture):
(WebCore::GraphicsContextGLANGLE::readRenderingResults):
(WebCore::GraphicsContextGLANGLE::reshape):
(WebCore::GraphicsContextGLANGLE::bindFramebuffer):
(WebCore::GraphicsContextGLANGLE::copyTexImage2D):
(WebCore::GraphicsContextGLANGLE::copyTexSubImage2D):
(WebCore::GraphicsContextGLANGLE::deleteFramebuffer):
(WebCore::GraphicsContextGLANGLE::copyTexSubImage3D):
(WebCore::GraphicsContextGLANGLE::validateAttributes): Deleted.
(WebCore::GraphicsContextGLANGLE::reshapeFBOs): Deleted.
(WebCore::GraphicsContextGLANGLE::attachDepthAndStencilBufferIfNeeded): Deleted.
(WebCore::GraphicsContextGLANGLE::resolveMultisamplingIfNecessary): Deleted.
* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h:
* Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
(WebCore::GraphicsContextGLANGLE::~GraphicsContextGLANGLE):
* Source/WebCore/platform/graphics/egl/GraphicsContextGLEGL.cpp:
(WebCore::GraphicsContextGLANGLE::~GraphicsContextGLANGLE):
(WebCore::GraphicsContextGLEGL::readCompositedResults):
(WebCore::GraphicsContextGLEGL::surfaceBufferToVideoFrame):
(WebCore::GraphicsContextGLEGL::swapCompositorTexture):
(WebCore::GraphicsContextGLEGL::reshapeDrawingBuffer):
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::workQueueInitialize):
* Source/WebKit/Shared/WebGL.serialization.in:
* Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm:
(TestWebKitAPI::WebCore::AnyContextAttributeTest::isWebGL2 const):
(TestWebKitAPI::WebCore::AnyContextAttributeTest::alphaMode const):
(TestWebKitAPI::WebCore::AnyContextAttributeTest::attributes):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest, ClearBufferIncorrectSizes)):
(TestWebKitAPI::TEST_F(GraphicsContextGLCocoaTest,
DestroyWithoutMakingCurrent)):
(TestWebKitAPI::TEST_P):
(TestWebKitAPI::anyContextAttributeTestName):
(TestWebKitAPI::WebCore::AnyContextAttributeTest::antialias const): Deleted.
(TestWebKitAPI::WebCore::AnyContextAttributeTest::preserveDrawingBuffer const):
Deleted.
* Tools/TestWebKitAPI/Tests/WebCore/glib/GraphicsContextGLEGL.cpp:
(TestWebKitAPI::WebCore::AnyContextAttributeTest::isWebGL2 const):
(TestWebKitAPI::WebCore::AnyContextAttributeTest::attributes):
(TestWebKitAPI::TEST_F(GraphicsContextGLEGLTest, ClearBufferIncorrectSizes)):
(TestWebKitAPI::TEST_F(GraphicsContextGLEGLTest, DestroyWithoutMakingCurrent)):
(TestWebKitAPI::WebCore::AnyContextAttributeTest::antialias const): Deleted.
(TestWebKitAPI::WebCore::AnyContextAttributeTest::preserveDrawingBuffer const):
Deleted.
Canonical link: https://commits.webkit.org/322356@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications