[webkit-changes] [WebKit/WebKit] 291555: [WebGPU] GPURenderPassEncoder.setBindGroup() shows...

mwyrzykowski noreply at github.com
Tue Mar 18 12:22:39 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 29155572a7c4547529fc876564975662d36d15be
      https://github.com/WebKit/WebKit/commit/29155572a7c4547529fc876564975662d36d15be
  Author: Mike Wyrzykowski <mwyrzykowski at apple.com>
  Date:   2025-03-18 (Tue, 18 Mar 2025)

  Changed paths:
    M Source/WebGPU/WebGPU/Buffer.h
    M Source/WebGPU/WebGPU/Buffer.mm
    M Source/WebGPU/WebGPU/CommandEncoder.h
    M Source/WebGPU/WebGPU/CommandEncoder.mm
    M Source/WebGPU/WebGPU/ComputePassEncoder.mm
    M Source/WebGPU/WebGPU/Device.h
    M Source/WebGPU/WebGPU/Device.mm
    M Source/WebGPU/WebGPU/ExternalTexture.h
    M Source/WebGPU/WebGPU/ExternalTexture.mm
    M Source/WebGPU/WebGPU/HardwareCapabilities.h
    M Source/WebGPU/WebGPU/HardwareCapabilities.mm
    M Source/WebGPU/WebGPU/QuerySet.h
    M Source/WebGPU/WebGPU/QuerySet.mm
    M Source/WebGPU/WebGPU/Queue.h
    M Source/WebGPU/WebGPU/Queue.mm
    M Source/WebGPU/WebGPU/RenderBundleEncoder.mm
    M Source/WebGPU/WebGPU/RenderPassEncoder.h
    M Source/WebGPU/WebGPU/RenderPassEncoder.mm
    M Source/WebGPU/WebGPU/Texture.h
    M Source/WebGPU/WebGPU/Texture.mm
    M Source/WebGPU/WebGPU/TextureView.h
    M Source/WebGPU/WebGPU/TextureView.mm

  Log Message:
  -----------
  [WebGPU] GPURenderPassEncoder.setBindGroup() shows up in CPU trace samples as significant
https://bugs.webkit.org/show_bug.cgi?id=289433
rdar://146605221

Reviewed by Tadeu Zagallo.

CPU profile showed significant time in setBindGroup calls

* Source/WebGPU/WebGPU/Buffer.h:
* Source/WebGPU/WebGPU/Buffer.mm:
(WebGPU::Device::safeCreateBuffer const):
(WebGPU::Buffer::incrementBufferMapCount):
(WebGPU::Buffer::decrementBufferMapCount):
(WebGPU::Buffer::setCommandEncoder const):
(WebGPU::Buffer::destroy):
Creating the WeakPtr was showing up significantly in traces,
we can avoid this by storing identifiers and then performing
lookups in the rare cases it is needed.

* Source/WebGPU/WebGPU/CommandEncoder.h:
* Source/WebGPU/WebGPU/CommandEncoder.mm:
(WebGPU::Device::createCommandEncoder):
(WebGPU::CommandEncoder::CommandEncoder):
(WebGPU::CommandEncoder::~CommandEncoder):
(WebGPU::CommandEncoder::encoderIsCurrent const):
(WebGPU::CommandEncoder::computeSize):
(WebGPU::CommandEncoder::trackEncoder):
Adapt new container.

(WebGPU::CommandEncoder::useResidencySet):
Allow for residency sets on devices which support them.

* Source/WebGPU/WebGPU/ComputePassEncoder.mm:
(WebGPU::addTextureToActiveResources):
(WebGPU::addResourceToActiveResources):
(WebGPU::ComputePassEncoder::executePreDispatchCommands):
Track textures and buffers seperately as buffers consume less resources.

* Source/WebGPU/WebGPU/Device.h:
(WebGPU::Device::isShaderValidationEnabled const):
(WebGPU::Device::commandEncoderFromIdentifier const):
(WebGPU::Device::commandEncoderFromIdentifier):
(WebGPU::Device::removeCommandEncoder):
(WebGPU::Device::supportsResidencySets):
* Source/WebGPU/WebGPU/Device.mm:
(WebGPU::Device::Device):
(WebGPU::Device::newBufferWithBytes const):
(WebGPU::Device::newBufferWithBytesNoCopy const):
Skip memory attributions for buffers of short lifetime, the attribution
cost is significant and the GPU process already needs headroom available
to allocate the memory initially.

* Source/WebGPU/WebGPU/ExternalTexture.h:
* Source/WebGPU/WebGPU/ExternalTexture.mm:
(WebGPU::ExternalTexture::destroy):
(WebGPU::ExternalTexture::openCommandEncoderCount const):
Use adopted helper functions.

* Source/WebGPU/WebGPU/HardwareCapabilities.h:
* Source/WebGPU/WebGPU/HardwareCapabilities.mm:
(WebGPU::baseCapabilities):
(WebGPU::apple6):
(WebGPU::apple7):
(WebGPU::mergeBaseCapabilities):
Apple6 and later support residency sets.

* Source/WebGPU/WebGPU/QuerySet.h:
* Source/WebGPU/WebGPU/QuerySet.mm:
(WebGPU::QuerySet::destroy):
Use new container.

* Source/WebGPU/WebGPU/Queue.h:
* Source/WebGPU/WebGPU/Queue.mm:
(WebGPU::span):
(WebGPU::Queue::newTemporaryBufferWithBytes):
(WebGPU::Queue::writeBuffer):
(WebGPU::Queue::writeTexture):
Sub-allocate small writeBuffer calls from a single buffer.

* Source/WebGPU/WebGPU/RenderBundleEncoder.mm:
(WebGPU::RenderBundleEncoder::addResource):
* Source/WebGPU/WebGPU/RenderPassEncoder.h:
* Source/WebGPU/WebGPU/RenderPassEncoder.mm:
(WebGPU::RenderPassEncoder::addTextureToActiveResources):
(WebGPU::RenderPassEncoder::addResourceToActiveResources):
(WebGPU::RenderPassEncoder::executePreDrawCommands):
(WebGPU::RenderPassEncoder::executeBundles):
(WebGPU::RenderPassEncoder::setBindGroup):
(WebGPU::RenderPassEncoder::setIndexBuffer):
(WebGPU::RenderPassEncoder::setVertexBuffer):
Use lighter weight mechanism for tracking resources.

* Source/WebGPU/WebGPU/Texture.h:
* Source/WebGPU/WebGPU/Texture.mm:
(WebGPU::Texture::waitForCommandBufferCompletion):
(WebGPU::Texture::destroy):
* Source/WebGPU/WebGPU/TextureView.h:
* Source/WebGPU/WebGPU/TextureView.mm:
(WebGPU::TextureView::destroy):
Adapt new container.

Canonical link: https://commits.webkit.org/292320@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