New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GPU Process] Cache Gradient as a rendering resource #11252
[GPU Process] Cache Gradient as a rendering resource #11252
Conversation
EWS run on previous version of this PR (hash 2b39fb0) |
2b39fb0
to
dac1862
Compare
EWS run on previous version of this PR (hash dac1862) |
dac1862
to
9f44c23
Compare
EWS run on previous version of this PR (hash 9f44c23) |
9f44c23
to
78a0467
Compare
EWS run on current version of this PR (hash 78a0467) |
bool hasValidRenderingResourceIdentifier() const | ||
{ | ||
return m_renderingResourceIdentifier.has_value(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When do we create resources without a valid RenderingResourceIdentifier
? Is it that we don't provide an identifier for gradients that are cheap to send across or something? If so, instead of doing it based on whether the identifier is valid, is it something the encode/decode functions can decide by inspecting the gradient? Then we can continue to have valid identifiers always.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When trying to cache all gradients, I noticed MotionMark CanvasLines regressed significantly. The reason for this is CanvasLines creates a gradient every time a line is drawn https://github.com/WebKit/WebKit/blob/main/PerformanceTests/MotionMark/tests/master/resources/canvas-tests.js#L238. So caching this gradient was not beneficial at all since each gradient is just used only once. This contrary to SVG gradients which lives as long as the SVG object lives. So only SVG gradients will have valid RenderingResourceIdentifier
.
https://bugs.webkit.org/show_bug.cgi?id=253599 rdar://106447608 Reviewed by Cameron McCormack. Sending the gradient data to GPUProcess every time it is used forces creating the platform gradient. To avoid creating the platform gradient, we are going to cache Gradient as a rendering resource in GPUProcess. So the object (and its platform gradient) will stay alive in GPUProcess as long as the WebProcess gradient is alive. * Source/WebCore/platform/graphics/DecomposedGlyphs.cpp: (WebCore::DecomposedGlyphs::create): (): Deleted. * Source/WebCore/platform/graphics/DecomposedGlyphs.h: * Source/WebCore/platform/graphics/Gradient.cpp: (WebCore::Gradient::create): (WebCore::Gradient::Gradient): (WebCore::operator<<): * Source/WebCore/platform/graphics/Gradient.h: (WebCore::Gradient::create): (WebCore::Gradient::colorInterpolationMethod const): (WebCore::Gradient::spreadMethod const): (WebCore::Gradient::stops const): * Source/WebCore/platform/graphics/GraphicsContextState.h: (WebCore::GraphicsContextState::fillBrush): (WebCore::GraphicsContextState::strokeBrush): * Source/WebCore/platform/graphics/NativeImage.h: * Source/WebCore/platform/graphics/RenderingResource.h: (WebCore::RenderingResource::~RenderingResource): (WebCore::RenderingResource::hasValidRenderingResourceIdentifier const): (WebCore::RenderingResource::renderingResourceIdentifier const): (WebCore::RenderingResource::addObserver): (WebCore::RenderingResource::removeObserver): (WebCore::RenderingResource::RenderingResource): * Source/WebCore/platform/graphics/SourceBrush.cpp: (WebCore::SourceBrush::gradientSpaceTransform const): (WebCore::SourceBrush::gradient const): (WebCore::SourceBrush::gradientIdentifier const): (WebCore::SourceBrush::setGradient): * Source/WebCore/platform/graphics/SourceBrush.h: (WebCore::SourceBrush::setGradient): (WebCore::operator==): (WebCore::SourceBrush::Brush::LogicalGradient::encode const): (WebCore::SourceBrush::Brush::LogicalGradient::decode): * Source/WebCore/platform/graphics/displaylists/DisplayList.h: (WebCore::DisplayList::DisplayList::cacheDecomposedGlyphs): (WebCore::DisplayList::DisplayList::cacheGradient): * Source/WebCore/platform/graphics/displaylists/DisplayListItems.h: (WebCore::DisplayList::SetState::state): * Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp: (WebCore::DisplayList::Recorder::appendStateChangeItem): * Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h: * Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp: (WebCore::DisplayList::RecorderImpl::recordResourceUse): * Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h: * Source/WebCore/platform/graphics/displaylists/DisplayListResourceHeap.h: (WebCore::DisplayList::LocalResourceHeap::add): * Source/WebCore/rendering/svg/RenderSVGResourceLinearGradient.cpp: (WebCore::RenderSVGResourceLinearGradient::buildGradient const): * Source/WebCore/rendering/svg/RenderSVGResourceRadialGradient.cpp: (WebCore::RenderSVGResourceRadialGradient::buildGradient const): * Source/WebKit/GPUProcess/graphics/QualifiedResourceHeap.h: (WebKit::QualifiedResourceHeap::add): (WebKit::QualifiedResourceHeap::getGradient const): (WebKit::QualifiedResourceHeap::removeGradient): (WebKit::QualifiedResourceHeap::releaseAllResources): (WebKit::QualifiedResourceHeap::checkInvariants const): * Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp: (WebKit::RemoteDisplayListRecorder::setState): * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp: (WebKit::RemoteRenderingBackend::cacheGradient): (WebKit::RemoteRenderingBackend::cacheGradientWithQualifiedIdentifier): * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h: * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in: * Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp: (WebKit::RemoteResourceCache::cacheGradient): (WebKit::RemoteResourceCache::cachedGradient const): (WebKit::RemoteResourceCache::releaseRenderingResource): * Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h: * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: * Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp: (WebKit::RemoteDisplayListRecorderProxy::recordResourceUse): * Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h: * Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp: (WebKit::RemoteRenderingBackendProxy::cacheGradient): * Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h: * Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp: (WebKit::RemoteResourceCacheProxy::~RemoteResourceCacheProxy): (WebKit::RemoteResourceCacheProxy::clear): (WebKit::RemoteResourceCacheProxy::recordGradientUse): (WebKit::RemoteResourceCacheProxy::releaseRenderingResource): (WebKit::RemoteResourceCacheProxy::clearGradientMap): (WebKit::RemoteResourceCacheProxy::remoteResourceCacheWasDestroyed): (WebKit::RemoteResourceCacheProxy::releaseMemory): * Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h: Canonical link: https://commits.webkit.org/262185@main
78a0467
to
676af9d
Compare
Committed 262185@main (676af9d): https://commits.webkit.org/262185@main Reviewed commits have been landed. Closing PR #11252 and removing active labels. |
Thiis broke linux clang builds...
Would it be possible to simplify the |
If it is a So why do think this structure is not simplified and seems ambiguous? I could not understand from the lines above which line in the code causes this error. Can you please include more lines from the compilation output? |
That's the beauty of it, thanks to unified builds, the error message is almost useless. What I shared is what's reported by the tooling, I don't have more details... @zdobersek mentioned in-place constructors might help |
I think there is a build option to disable local unified builds. @JonWBedard might know more about this option. |
Fixed in #12177. |
676af9d
78a0467