Skip to content

Commit

Permalink
[WebGPU] GPUBuffer should not destroy the underlying buffer from its …
Browse files Browse the repository at this point in the history
…destructor

https://bugs.webkit.org/show_bug.cgi?id=273606
<radar://127408015>

Reviewed by Dan Glastonbury.

The first and last line of the dtor were useless but the destroy
call should have not existed, since the buffer may still be used in the GPU
process after it is GC'ed from the JS layer.

Observed in a flaky fashion from https://webgpu.github.io/webgpu-samples/?sample=deferredRendering
where some command buffers were failing, occassionally.

* Source/WebCore/Modules/WebGPU/GPUBuffer.cpp:
(WebCore::GPUBuffer::~GPUBuffer): Deleted.

Canonical link: https://commits.webkit.org/278412@main
  • Loading branch information
mwyrzykowski committed May 6, 2024
1 parent 23a4062 commit 0a9423a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions Source/WebCore/Modules/WebGPU/GPUBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@

namespace WebCore {

GPUBuffer::~GPUBuffer()
{
m_bufferSize = 0;
m_backing->destroy();
m_arrayBuffers.clear();
}
GPUBuffer::~GPUBuffer() = default;

GPUBuffer::GPUBuffer(Ref<WebGPU::Buffer>&& backing, size_t bufferSize, GPUBufferUsageFlags usage, bool mappedAtCreation, GPUDevice& device)
: m_backing(WTFMove(backing))
Expand Down
2 changes: 1 addition & 1 deletion Source/WebGPU/WebGPU/Pipeline.mm
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ bool validateBindGroup(BindGroup& bindGroup)

auto bufferSize = bufferBinding->minBindingSize;
if (bufferSize && buffer->get()) {
if (!buffer->get()->isDestroyed() && buffer->get()->buffer().length < bufferSize)
if (buffer->get()->buffer().length < bufferSize)
return false;
}
}
Expand Down

0 comments on commit 0a9423a

Please sign in to comment.